
var flag = 0;

$(function() {
	$("#fld_search").mousedown(function() {
		var t = setTimeout("hideSearch()",3000);
		
		$("#cntr_header_search").bind("mouseenter",function() {
			clearTimeout(t);
		}).bind("mouseleave",function() {
			hideSearch();
		}).slideDown();
	});
	
	$(".link_poll_close").click(function() {
		$("#cntr_home_poll_close,#poll_view_results,#cntr_home_poll_select,#cntr_home_poll_results,#cntr_poll_view_results").hide();
		$("#cntr_home_poll").slideUp();
		return false;
	});
	
	$("#lnk_poll_select").click(function() {
		$("#cntr_home_poll_notice").slideUp(function(){$("#cntr_home_poll_area").slideDown(function(){$("#cntr_home_poll_close,#cntr_poll_view_results,#cntr_home_poll_select").fadeIn();});});
		return false;
	});
	
	$("#cntr_poll_view_results").click(function() {
		$("#cntr_home_poll_select,#cntr_poll_view_results").fadeOut(function(){$("#cntr_home_poll_results").fadeIn();});
		return false;
	});
		
});

function hideSearch() {
	$("#cntr_header_search").slideUp();
}


// MENU LEFT
$(function(){
	$("#lnk_arrow_leftmenu1_recipes").bind("mouseenter",function(){
		flag=1;
	});
	$("#menu_left_recipes li").bind("mouseenter",function(){
		if($(this).children("ul").children("li").children("ul").length != 0) {
			$(this).children("ul, div").css({display:"block"});
			var io = $(this).offset();
			var iw = $(this).width();
			var sw = $(this).children("ul").width();
			var sh = $(this).children("ul").height();
			if(jQuery.browser.version.charAt(0) == "6" && jQuery.browser.msie) {
				var col = $(this).children("ul").children("li").children("ul");
				var sum=0;
				for(i=0; i < col.length;i++){
					sum += parseInt($(col[i]).width());}
				$(this).children("ul").css({top:-22,left:176,width:sum+iw})
					if ((flag==0)&&(i>1)){
						sh=sh/i;
						sh=sh+45;
						}
				$(this).children("div").css({top:-19,left:170,width:sum+62,height:sh})
			}
				 else
				 {
					$(this).children("ul").css({top:-22,left:176})
					$(this).children("div").css({top:-19,left:170,width:sw-15,height:sh})
				}
		}
	}).bind("mouseleave",function() {
		if($(this).children("ul").children("li").children("ul").length != 0) {
			$(this).children("ul, div").css({display:"none"});
			//flag=0;
		}
	});
});


//Right drop down menu

var t;
function menu_right2fn(parameterflag){
		if (parameterflag=='0')
		{
			$("#menu_right1").css({backgroundPosition:"top left"});
			$("#menu_right2").children(".real").css({backgroundPosition:"top left"});
			$("#menu_right3").children(".real").css({backgroundPosition:"top left"});
			$("dd:visible").slideUp("slow");
			$("#menu_right2").parent().next().slideDown("slow");
			$("#menu_right2").children(".real").css({backgroundPosition:"bottom left"});
		}
	}	


function timedMsgright2(timesfn2)
{
	timerRunning= true;
	t=setTimeout("menu_right2fn('0');",400)
}

	$(document).ready(function(){
		$("#menu_right1").css({backgroundPosition:"bottom left"});
		$("dd:not(:first)").hide();
		var flag1=1;
		var flag2=0;
		var flag3=0;		
			$("#menu_right1").bind("mouseenter",function(){
				if (flag1!=1 )
				{
					clearTimeout(t);
					$("#menu_right1").css({backgroundPosition:"top left"});
					$("#menu_right2").children(".real").css({backgroundPosition:"top left"});
					$("#menu_right3").children(".real").css({backgroundPosition:"top left"});
					$("dd:visible").slideUp("slow");
					$(this).parent().next().slideDown("slow");
					$(this).css({backgroundPosition:"bottom left"});
				}		
			}).bind("mouseleave",function(){
					flag1=1;
					flag2=0;
					flag3=0;
			});
			
			
			$("#menu_right2").bind("mouseenter",function(){
				if (flag2!=1 )
				{
					timedMsgright2();
				}		
			}).bind("mouseleave",function(){
					flag1=0;
					flag2=1;
					flag3=0;
			});
			
			$("#menu_right3").bind("mouseenter",function(){
				if (flag3!=1)
				{
					clearTimeout(t);
					$("#menu_right1").css({backgroundPosition:"top left"});
					$("#menu_right2").children(".real").css({backgroundPosition:"top left"});
					$("#menu_right3").children(".real").css({backgroundPosition:"top left"});
					$("dd:visible").slideUp("slow");
					$(this).parent().next().slideDown("slow");
					$(this).children(".real").css({backgroundPosition:"bottom left"});	

				}		
			}).bind("mouseleave",function(){
					flag1=0;
					flag2=0;				
					flag3=1;
			});			
			
	
		
		/*$("dt a").bind("mouseover",function() {
			
			//if($(this) != $("dd:visible")) {
//}
			//return false;				
			})*/
											
	});
	
	
	/*$(document).ready(function(){
		$("dd:not(:first)").hide();
		$("dt a").click(function(){
			$("dd:visible").slideUp("slow");
			$(this).parent().next().slideDown("slow");
			return false;
		});
	});*/
	

