$(document).ready(function(){
	 //Add class "hover" to menu items when the cursor is over them, necessary for IE6
	$('.sf-menu li').mouseover(function(){
		$(this).addClass('hover');
	}).mouseout(function(){
		$(this).removeClass('hover');
	});
	// Add class "parent" to menu items with submenus
	$('.sf-menu li ul').parent().addClass('parent');
	// Add class "menu" to ul's in sf-menu
	$('.sf-menu a.active-parent').next().addClass('active-menu');
	// Add class "submenu" to ul's that are children of menus in sf-menu
	$('.sf-menu ul ul').addClass('sub-child-menu');
	// Add class "last" to each of the last list items
	$('.sf-menu ul li:last-child').each(function(){
		$(this).addClass('last');
	});
	// Apply hover class so menus work in IE 6
	$('ul.sf-menu').superfish({ 
		delay:       700,                            // one second delay on mouseout 
		pathLevels:    2,
		speed:       'fast',                          // faster animation speed 
		autoArrows:  false,                           // disable generation of arrow mark-up 
		dropShadows: false                            // disable drop shadows 
	}); 
	// Add star graphic to left menu
	$('.side_navigation .sf-menu li.parent').append('<span><img src="/images/global/subnav_star.png" class="has_subnav"/></span>');
	// Add Floor
	$('div.column.left.side').append('<div id="floor-level"></div>');
	
	// Attach class to location image
	$('.location_hours img:first').addClass('location-image');
	// Take the page name from the URL and add it as a class to body
	var url = window.location.pathname;
	function stripSlashes(str)
	{
		return str.replace(/\//g, '');
	}
	$('body').addClass(stripSlashes(url));
	// Add Frilly Bits only to the main site and not the reservations page.
	$('body').not('body.hospitality').append('<div id="top_vines"></div><div id="floor-container"><div id="main_floor"></div><div id="floor-mandala"></div><div id="left_flower"></div><div id="right_flower"></div></div><div id="vines"><div id="left_vines"></div><div id="right_vines"></div></div>');
	// Fix png transparency for IE6
	//$('.search, ul.navi, div.eye, .sf-menu li.parent span, .callout, #floor-container, .content_footer, #quotes, .post, .gallery .thumb_list a, .right .crystal_ball, .right .events').pngFix();
	// Add class to even comments for striping effect
	$('#comments div:even').addClass('even');
	// Add preloader to gallery launch
	//var gallery_button = $("#main_content table");
	//alert(gallery_button.length);
	/* $(".button[href*='galleries']").click(function() {
		alert("CLICK");
		//$('#full_screen').append('<div id="loading-graphic"><h2>The gallery is loading&hellip;</h2><p><img src="/images/global/ajax-loader.gif"/></p></div>');
	}); */
	$(".content a[href*='galleries']").click(function() {
		$('#full_screen').append('<div id="loading-graphic"><h2>The gallery is loading&hellip;</h2><p><img src="/images/global/ajax-loader.gif"/></p></div>');
	});
	// Run Functions
	$("#tabs").tabs();
	docHeight = $(document).height(); // get height of document
	frillyBits();
	checkSize();
	// Debug Zone
});

// This positions and sizes the floor and vines
function frillyBits() {
	var floorOffset = $('#floor-level').offset(); // Measure where the floor is
	var vineOffset = $('#floor-container').offset(); // Store the measurement
	// This tests whether the floor is higher on the page than we want
	if(floorOffset.top > 800) {
		var currentSize = $(document).height(); // Find the document height
		$('#floor-container').css( {"top":(floorOffset.top + 20) + "px"} ); // Move frilly bits 20px below floor level
		$('#vines').height(currentSize - floorOffset.top - 100 ).css( {"top":floorOffset.top + "px"} ); // Set height and position of vines
	// The floor is too high on the page so we manually set the vines where we want them
	}else{
	//	jQuery.noConflict();
		var currentSize = $(document).height(); // Find the document height
		$('#floor-container').css( {"top":800 + "px"} ); // Move frilly bits 800 pixels from top
		var vineOffset = $('#floor-container').offset(); // Store the measurement
		$('#vines').height(currentSize - vineOffset.top - 100 ).css( {"top":vineOffset.top + "px"} ); // Set height and position of vines
	}
};

function checkSize() {
  var currentSize = $(document).height();
 
  // Compare sizes & run jQueryFunction() if different
  if (currentSize != docHeight) {
    frillyBits();
    docHeight = currentSize;
  }
 
  timer(); // Check size again after 1 second
}

function timer() {
  var myTimer = setTimeout('checkSize()', 500); // Check size every 1/2 second
}


