// for the menu part
function menuShow(){ 
  $(this).next().show();
}	
function menuHide(){
   if(!$(this).hasClass("menuOn")) {
     $(this).next().hide();
   }
   
}


$(document).ready(function () {
					  
  $("#globalNav li ul, #globalNav li ul li ul").hide();
  
  $("#globalNav > li > h3").hoverIntent({	
				sensitivity: 5,
				interval: 100, 
				over: menuShow, 
				timeout: 250, 
				out: menuHide
	});
  $("#globalNav li ul li a").hover(
	    function(){
			$(this).next().show();
		},
		function(){
			$(this).next().hide();
		}
	  );


  $("#globalNav li ul").hover(
	    function(){
		  $(this).prev().addClass("menuOn");		  
		  $(this).show();
		},
		function(){
  		  $(this).prev().removeClass("menuOn");
		  $(this).hide();
		}
	  );
  $("#globalNav li ul li ul").hover(
	    function(){ 
  		  $(this).parent().addClass("submenuOn");	
		},
		function(){
 		  $(this).parent().removeClass("submenuOn");	  		   
		}
	  );
  
  /*highlight the current section*/
  var bodyClass = $("body").attr("class");
  var section = bodyClass.split(" ");

  $("#subNav li").each(function(){
     var liID = this.id;
    if(liID == section[1]) {

        $(this).addClass("active");
	}
	
 });

	/* highlight the current page*/
   $('#leftNav a').each(function(){
		var location = window.location;
		var href=location.href;
		if (this.href.toLowerCase() == href.toLowerCase()) {
			$(this).addClass('active'); 
			$(this).parent().addClass('active');
			if($(this).parent().parent().parent().parent().hasClass("arrow")) { $(this).parent().parent().parent().addClass('open'); }
			return false
		};
	});
   
  $("#leftNav li ul").hide();
  $("#leftNav li").each(function(){
	 if($(this).hasClass("active")) {							 
		$(this).children().show();
	 }
  });
  $("#leftNav li ul li").each(function(){
	 if($(this).hasClass("active")) {							 
		$(this).parent().show();
	 }
  });
  
  
  var blockheight = $("#adv .block-1").height();
  if(blockheight>=240) { $("#adv").css({'height' : blockheight}); }
  var blockweight = $("#adv").width();
  if(blockweight==720) { $("#adv").css({'background-position' : '-90px top'}) }; 
  
  var advwidth = $("#adv").width();
  if(advwidth<900) { $("#adv #blockNote").hide(); }
  if(advwidth>=900) { $("#adv .block-2 .block form").css("paddingLeft", "30px"); }  
  
  
  /*給中獎頁面和車主大聲公用*/
  $("#awards li .awardList, #thought li .thoughtList").hide();
  
  $("#awards li .close, #thought li .close").hide();  
  
     $("#awards .open, #thought li .open").click(function () {
	  $(this).hide();											
      $(this).next().toggle();										
      $(this).next().next().toggle();
    });
	 
     $("#awards .close, #thought li .close").click(function () {
	  $(this).hide();											 
      $(this).prev().toggle();	
      $(this).next().toggle();
    });

  $("#thought li:eq(0) .thoughtList, #thought li:eq(0) .close").show();
  $("#thought li:eq(0) .open").hide();  



   $("small a").attr({style: ""});





});

