/* WYC menu behavior */

$(document).ready(function() {
	menu_top = "26px";

	// 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");
					
					// for the 3 drop down menus, only reposition the image after the menu is gone
					switch (pid) {
						case "experience":
							p.find("a:not(.active_menu)").css({
								backgroundPosition:"-185px 0"
							});
						break;
						case "new-homes":
							p.find("a:not(.active_menu)").css({
								backgroundPosition:"-370px 0"
							});
						break;
						case "thelocation":
							p.find("a:not(.active_menu)").css({
								backgroundPosition:"-555px 0"
							});
						break;						
					}
				}
			);
		}
	);
	
	// dropdown menu item hover
	$('.sub_menu li').bind("mouseenter mouseleave", 
		function(e){
			$(this).toggleClass("sfHover");
		}
	);

	// reposition bg img for home menu button
	$('#home').hover(
		function(){
			$(this).find("a:not(.active_menu)").css({
				backgroundPosition:"0 -27px"
			});
    	},
		function() {
			$(this).find("a:not(.active_menu)").css({
				backgroundPosition:"0 0"
			});
		}
	);
	
	// reposition bg img for experience menu button
	$('#experience').hover(
		function(){
			$(this).find("a:not(.active_menu)").css({
				backgroundPosition:"-185px -27px"
			});
		},
		function() {
		}
	);
	
	// reposition bg img for new-homes menu button
	$('#new-homes').hover(
		function(){
			$(this).find("a:not(.active_menu)").css({
				backgroundPosition:"-370px -27px"
			});
		},
		function() {
		}
	);
	
	// reposition bg img for thelocation menu button
	$('#thelocation').hover(
		function(){
			$(this).find("a:not(.active_menu)").css({
				backgroundPosition:"-555px -27px"
			});
		},
		function() {
		}
	);
	
	// reposition bg img for contact menu button
	$('#contact').hover(
		function(){
			$(this).find("a:not(.active_menu)").css({
				backgroundPosition:"-740px -27px"
			});
		},
		function() {
			$(this).find("a:not(.active_menu)").css({
				backgroundPosition:"-740px 0"
			});
		}
	);
					  

});
