
search_block_status = "shown";


function toggleHmSrchImg(siteID) {
	var currentImg = $('#search_block_image').attr("src");
	if(currentImg.substring(currentImg.length - 8) == "plus.gif") {
		$('#search_block_image').attr("src","/content/" + siteID + "/images/minus.gif");
	} else {
		$('#search_block_image').attr("src","/content/" + siteID + "/images/plus.gif");
	}
	if(search_block_status == "shown") {
		$('#inventory_search_block_form').animate({ height:"hide" }, { queue:true, duration:500 });
		search_block_status = "hidden";
	} else {
		$('#inventory_search_block_form').animate({ height:"show" }, { queue:true, duration:500 });
		search_block_status = "shown";
	}
	return false;
}

// search left-side nav for correct active link for residence detail pages
function activateMenuItems() {
	
	//quick delivery
	if (location.href.search(/new-homes\/inventory\//) > -1 ) {
		$("#content_left a[href='/new-homes/search/quick-delivery']").addClass("active");
	} else if (location.href.search(/new-homes\/grand-villas\//) > -1) {
		$("#content_left a[href='/new-homes/search/home-type/grand-villas']").addClass("active");
	

	} else if (location.href.search(/new-homes\/villas\//) > -1) {
		$("#content_left a[href='/new-homes/search/home-type/villas']").addClass("active");
	} else if (location.href.search(/new-homes\/search\/quick-delivery\//) > -1) {
		$("#content_left a[href='/new-homes/search/quick-delivery']").addClass("active");
	}

	return false;	
}

function trackPage(uri) {
	if (typeof(pageTracker) != "undefined") {
		pageTracker._trackPageview(uri);
	}
}


$(document).ready(function() {
						   
	
	$('#menu .sub_menu').fadeTo(1, 0.85);
	
	menu_top = "22px";

	// menu display
	$('#experience,#new-homes,#thelocation').hover(
		function() {
			$(this).find('.sub_menu').css({
				top: menu_top,
				display:"none"
			}).show();
		},
		function() {
			$(this).find('.sub_menu').fadeOut('fast',  // fade out menu 
				function() {
					// only after the fade to do move the menu off screen
					$(this).css({
						top: "-999em"
					});
					
					var p = $(this).parent();
					var pid = p.attr("id");
	
				}
			);
		}
	);
	
	// dropdown menu item hover
	$('#menu .sub_menu a').hover(
		function() {
			$(this).addClass("sfHover");
		},
		function() { 
			$(this).removeClass("sfHover");
		}
	);
	
	
	$('body').pngFix();

	// textbox input hinting where title attribute is present
	$('input:text').hint();
	
	// setup correct active menu
	activateMenuItems();


});
