var topIndex = {}; 



topIndex.isIndexPage = false;
topIndex.timeoutHandler = 0;

topIndex.navHover = function(){
	$("#indexNavUl > li ").hover(
	   function(){
		   $(this).siblings().children("div").children("span").removeClass("slideback");
		   if($(this).children("div").children("span").hasClass("fixback")){
			   return;
		   }
		   $(this).children("div").children("span").addClass("slideback");
	   },
		 function(){
		   if($(this).children("div").children("span").hasClass("fixback")){
			   return;
		   }
		   $(this).children("div").children("span").removeClass("slideback");
	   }
	);
};
topIndex.navClick = function(){
	$("#indexNavUl > li").click(
	 function(){
		  var href =  $(this).children("div").attr("name");
		  if(href){
			  window.location.href = href;
		  }
	   }
	);
};
topIndex.cooperatorShowFun = function(){
	 $("#leftCooperatorListUL > li").hover(
    	     function(){
    	    	$(this).children("div").show();	    	
    	     },
    	     function(){
    	    	 $(this).children("div").hide(); 
    	     }
     );
};

topIndex.cooperatorDlHoverFun = function(){
	$("dl[class = 'feizul'] > dd").hover(
	    function(){$(this).addClass("j_hover");},
	    function(){$(this).removeClass("j_hover");}
	);
};

topIndex.cooperatorNavHideFun = function(){	
	if(topIndex.isIndexPage){
		return;
	}
	$("#drawerNavDiv").hide();
};

topIndex.cooperatorNavShowFun = function(){	
	$("#drawerNavDiv").show();
};

topIndex.cooperatorNavHover = function(){
	$("#coopNavDrawerId").hover(
			function(){
			  window.clearTimeout(topIndex.timeoutHandler);
			  topIndex.cooperatorNavShowFun();
			},
			function(){topIndex.timeoutHandler = window.setTimeout(topIndex.cooperatorNavHideFun,300);}
	);
};

topIndex.hightLightFun = function(){
	  var showJson = topIndexJsp.highLightNavigatorLi();
	  var showLiId = "";
	  if(showJson.isIndex == 'true'){
		  showLiId = "indexLi";
	  } else if(showJson.isMall == 'true'){
		  showLiId="cooperatorNavLi";
	  }else if(showJson.isPlacard == 'true'){
		  showLiId = "placardLi";
	  }else if(showJson.isVirtualMoney == 'true'){
		  showLiId = 'virtualMoneyLi';
	  }else if(showJson.isHelper == 'true'){
		  showLiId = 'helperLi';
	  }else if(showJson.isCrazysale == 'true'){
		  showLiId = 'crazysaleLi';
	  }else if(showJson.isTaobao == 'true'){
		  showLiId = 'taobaoLi';
	  }
	  $("#indexNavUl>li[id='"+showLiId+"']").children("div:first").children("span:first").addClass("fixback");
};

topIndex.drawerNavHoverFun = function(){
	$("#drawerNavDiv").hover(
			function(){ window.clearTimeout(topIndex.timeoutHandler);  },
			topIndex.cooperatorNavHideFun
	);	    
};

topIndex.orderPromotionMsgValidatorFun = function(){
	 if($("#emId_a").attr("value")=="请输入Email地址"){
	      alert("请输入Email地址");
	      return false;
	     }     
		 if(checkEmail($("#emId_a").attr("value"))) {
			return true; 
		 }
		 alert("Email地址格式不对");
		 return false;
};

topIndex.orderPromotionMsgHintFun = function(obj,isShow){
	if(isShow){
		  var id = obj.id;
		  if($("#"+id).attr("value")==""){
	      	$("#"+id).attr("value","请输入Email地址");
	      	$("#"+id).attr("style","color:#CCCCCC");
	      }
	}else{
       var id = obj.id;
       if($("#"+id).attr("value")=="请输入Email地址"){
			$("#"+id).attr("value","");
			$("#"+id).attr("style","color:#3F3F3F;text-align:left;");
        }
	}
	
};

topIndex.orderPromotionBind = function(){
	$("#orderPromotionForm").bind("submit",topIndex.orderPromotionMsgValidatorFun);
	$("#emId_a").click(function(){topIndex.orderPromotionMsgHintFun(this,false)});
	$("#emId_a").bind("blur",function(){topIndex.orderPromotionMsgHintFun(this,true)});
};

topIndex.topshowsubscribe = function(){
	$("#secondRightScrollArrowhead3").hover(
	function(){
		$("#second3").attr("style","display:");
		$("#yye2_id").attr("class","yye2");
	})
}
topIndex.tophiddensubscribe = function(){
	$("#secondRightScrollArrowhead3").mouseout(
	function(){
		$("#second3").attr("style","display:none");
		$("#yye2_id").attr("class","yye3");
	})
	//$("#second3").attr("class","yye2");
}

$(document).ready(function(){
	try{
	topIndex.navHover();
	topIndex.navClick();
	topIndex.cooperatorShowFun();	
	topIndex.cooperatorNavHover();
	topIndex.drawerNavHoverFun();	
	topIndex.hightLightFun();	
	topIndex.cooperatorDlHoverFun();
	topIndex.orderPromotionBind();
	//topIndex.cooperatorNavHideFun();
	topIndex.topshowsubscribe();
	topIndex.tophiddensubscribe();
	}catch(e){}
});