$(document).ready(function(){

   $(".leftMenu").each(function(){
   		//var menuID_newID = $(this).attr("menuID");
   		var menuID_newID = $("#lMenuID").val();
   		var cookNameNew = $.cookie("menuID_"+menuID_newID);
   		$(".hiddenSubMenu[divMid="+cookNameNew+"]").show();
   		/*
   		var menuID_newID = $(this).attr("menuID");
   		var cookNameNew = $.cookie("menuID_"+menuID_newID);
   		if(cookNameNew == null || cookNameNew == "")
   		{

   		}
   		else
   		{
   			$(".hiddenSubMenu[divMid="+cookNameNew+"]").show();
        }
        */
   });


   $(".leftMenu").click(function(){
   	   var menuID = $(this).attr("menuID");
   	   var test = $(".hiddenSubMenu[divMid="+menuID+"]:hidden").length;

   	   var linkToPage = $(this).attr("href");
   	   linkToPage = linkToPage+"&menuID="+menuID;

   	   $(".leftMenu").each(function(){   	   	  $(".hiddenSubMenu").slideUp("fast");
   	   });

   	   if(test == 0)
   	   {
   	   	    $(".hiddenSubMenu[divMid="+menuID+"]").slideUp("fast");

   	   	    JsHttpRequest.query(
		    "skin/php/delCookie.php",
		    {
                  "menuID": menuID
		    },
		    function (result,errors)
		    {
				if (result)
				{
					var ok = result.ok;

					if(ok == 'ok')
					{
                        location.replace(linkToPage);
					}
					else
					{

					}
				}
				else
				{

				}
			 },
			 true
		   )
   	   }
   	   else
   	   {
   	   	    $(".hiddenSubMenu[divMid="+menuID+"]").slideDown("fast");

   	   	    JsHttpRequest.query(
		    "skin/php/setCookie.php",
		    {
                  "menuID": menuID
		    },
		    function (result,errors)
		    {
				if (result)
				{
					var ok = result.ok;

					if(ok == 'ok')
					{
                        location.replace(linkToPage);
					}
					else
					{

					}
				}
				else
				{

				}
			 },
			 true
		   )
   	   }

   	   return false;
   });

   /*OLD ONE*/
   /*   $(".leftMenu").toggle(function(){        var menuID = $(this).attr("menuID");
        $(".hiddenSubMenu[divMid="+menuID+"]").slideDown("fast");

       // $(this).parent().css("background-image","url(images/menuClickBg.gif)");
       // $(this).css("color","#000000");
       // $(this).addClass("leftMenuClicked");
       // $(this).css("padding-left","5px");

   		return false;
   },
   function(){        var menuID = $(this).attr("menuID");
        $(".hiddenSubMenu[divMid="+menuID+"]").slideUp("fast");

        //$(this).parent().css("background-image","none");
        //$(this).css("color","#E59017");
        //$(this).css("padding-left","0px");
        //$(this).removeClass("leftMenuClicked");

   		return false;
   });
   */
   /*END*/

  /*HOVER LEFT MENU NEW*/
  $(".leftMenuClassDiv").hover(function(){
  	//$(this).stop().animate({width:"197px",height:"39px"}, 400);  	$(this).css("background-image","url(images/img/hoverLeftMenu.gif)");
  	//$(this).css("background-repeat","repeat-y");
  	//$(this).children().children().css("font-size","14px");
  	//$(this).children().css("padding-top","18px");
  },
  function(){
  	 //$(this).stop().animate({width:"197px",height:"21px"}, 400);     $(this).css("background-image","url(images/img/bgLeftMenu.gif)");
     //$(this).css("background-repeat","no-repeat");
     //$(this).children().children().css("font-size","13px");
     //$(this).children().css("padding-top","1px");
  });

  $(".leftMenuClassDivAc").hover(function(){
  	//$(this).stop().animate({width:"197px",height:"39px"}, 400);
  	$(this).css("background-image","url(images/img/bgLeftMenu.gif)");
  	//$(this).css("background-repeat","repeat-y");
  	//$(this).children().children().css("font-size","14px");
  	//$(this).children().css("padding-top","18px");
  },
  function(){
  	// $(this).stop().animate({width:"197px",height:"21px"}, 400);
     $(this).css("background-image","url(images/img/hoverLeftMenu.gif)");
    // $(this).css("background-repeat","no-repeat");
    // $(this).children().children().css("font-size","13px");
    // $(this).children().css("padding-top","1px");
  });

  $(".leftMenuClassDiv").click(function(){  	 $(this).children().children().trigger("click");
  });

  $(".leftMenuClassDivAc").click(function(){
  	 $(this).children().children().trigger("click");
  });
  /*END*/

  /*BOTTOM HOVER LOGOS*/
   $(".logosBot").hover(function(){
      var hPic = $(this).attr("hPic");
      $(this).attr("src",hPic);
  },
  function(){
  	  var nPic = $(this).attr("nPic");
  	  $(this).attr("src",nPic);
  });
/*
  $(".logosBot1").hover(function(){
      $(this).children().children().stop().animate({width:"150px",height:"80px"}, 400);
  },
  function(){
  	  var thisW = $(this).children().children().attr("thisW");
  	  var thisH = $(this).children().children().attr("thisH");
      $(this).children().children().stop().animate({width: thisW+"px",height: thisH+"px"}, 400);
  });

  $(".logosBot2").hover(function(){
      $(this).children().children().stop().animate({width:"190px",height:"54px"}, 400);
  },
  function(){
  	  var thisW = $(this).children().children().attr("thisW");
  	  var thisH = $(this).children().children().attr("thisH");
      $(this).children().children().stop().animate({width: thisW+"px",height: thisH+"px"}, 400);
  });

  $(".logosBot3").hover(function(){
      $(this).children().children().stop().animate({width:"204px",height:"70px"}, 400);
  },
  function(){
  	  var thisW = $(this).children().children().attr("thisW");
  	  var thisH = $(this).children().children().attr("thisH");
      $(this).children().children().stop().animate({width: thisW+"px",height: thisH+"px"}, 400);
  });

  $(".logosBot4").hover(function(){
      $(this).children().children().stop().animate({width:"150px",height:"80px"}, 400);
  },
  function(){
  	  var thisW = $(this).children().children().attr("thisW");
  	  var thisH = $(this).children().children().attr("thisH");
      $(this).children().children().stop().animate({width: thisW+"px",height: thisH+"px"}, 400);
  });

  $(".logosBot5").hover(function(){
      $(this).children().children().stop().animate({width:"210px",height:"70px"}, 400);
  },
  function(){
  	  var thisW = $(this).children().children().attr("thisW");
  	  var thisH = $(this).children().children().attr("thisH");
      $(this).children().children().stop().animate({width: thisW+"px",height: thisH+"px"}, 400);
  });
*/

  /*END*/

  /*TOP LOGO HOVER*/
  $(".smallDivLogo").hover(function(){
    var hPic = $(this).attr("hPic");

	//$(this).stop().animate({width: "269px",height: "89px"}, 400).attr("src",hPic);

	//$(".divLogo").css("left","45px");
	//$(".divLogo").css("top","-13px");
  },
  function(){    var nPic = $(this).attr("nPic");

	//$(this).stop().animate({width: "259px",height: "86px"}, 400).attr("src",nPic);

	//$(".divLogo").css("left","57px");
	//$(".divLogo").css("top","-11px");
  });
  /*END*/
});