var NowMenu="";
var SelectMenu="";
var TopSite="http://www.ikbao.com";

try{
   document.getElementById("NQGuide").onclick=function(){showNQGuide()};
   document.getElementById("topsearch").onclick=function(){indexsearch()};
   document.getElementById("searchtype").onchange=function(){changesearchtype()};
   document.getElementById("getshopinfo").onfocus=function(){indexsearchfocusblur(1);};
   document.getElementById("getshopinfo").onblur=function(){indexsearchfocusblur(0);};
   
   document.getElementById("menut").onmouseover=function(){ShowMenus(NowMenu,1)};
   document.getElementById("menut").onmouseout=function(){ShowMenus(NowMenu,0)};
   document.getElementById("menus").onmouseover=function(){ShowMenus(NowMenu,1)};
   document.getElementById("menus").onmouseout=function(){ShowMenus(NowMenu,0)};
   
   document.getElementById("SearchNav").onmouseover=function(){ShowMenus("",-2)};
   document.getElementById("OutTop").onmouseover=function(){ShowMenus("",-2)};
   document.getElementById("USInfo").onmouseover=function(){ShowMenus("",-2)};
   document.getElementById("index_Home").onmouseover=function(){ShowMenus("",-1)};
   document.getElementById("index_wowpage").onmouseover=function(){ShowMenus("",-1)};
   document.getElementById("index_Integral").onmouseover=function(){ShowMenus("",-1)};
   document.getElementById("index_100JB").onmouseover=function(){ShowMenus("",-1)};
   //document.getElementById("index_wowpackages").onmouseover=function(){ShowMenus("",-1)};
   
   document.getElementById("index_Dailian").onmouseover=function(){ShowMenus("Dailian",1)};
   document.getElementById("index_Dailian").onmouseout=function(){ShowMenus("Dailian",0)};
   document.getElementById("index_Recruitment").onmouseover=function(){ShowMenus("Recruitment",1)};
   document.getElementById("index_Recruitment").onmouseout=function(){ShowMenus("Recruitment",0)};
   document.getElementById("index_InfoCentre").onmouseover=function(){ShowMenus("InfoCentre",1)};
   document.getElementById("index_InfoCentre").onmouseout=function(){ShowMenus("InfoCentre",0)};
  
}catch(e){}

function ShowMenus(menu,n){
	if(menu==""){
	   NowMenu="";
	   document.getElementById("DailianMenu").style.display="none";
	   document.getElementById("RecruitmentMenu").style.display="none";
	   document.getElementById("InfoCentreMenu").style.display="none";
	   if(n==-2 && SelectMenu!=""){document.getElementById(SelectMenu+"Menu").style.display="block";NowMenu=SelectMenu;}
	}else{
	   if(n==1){
	   	  if(SelectMenu!=""){document.getElementById(SelectMenu+"Menu").style.display="none";}
		  NowMenu = menu;
		  document.getElementById(menu+"Menu").style.display="block";
	   }else{
		  document.getElementById(menu+"Menu").style.display="none";
		  if(SelectMenu!=""){HowShowMenus();}
	   }
	}
}

function HowShowMenus(){
    var m1=document.getElementById("DailianMenu").style.display;
    var m2=document.getElementById("RecruitmentMenu").style.display;
    var m3=document.getElementById("InfoCentreMenu").style.display;
    if(m1=="none" && m2=="none" && m3=="none" && (NowMenu=="" || NowMenu==SelectMenu)){
    	document.getElementById(SelectMenu+"Menu").style.display="block";NowMenu=SelectMenu;
    }
}

function indexsearch(){
	var stype=document.getElementById("searchtype").value;
	var shopinfo=jstrim(document.getElementById("getshopinfo").value);
	if(shopinfo=="" || shopinfo.indexOf("－－>") > -1){
		alert("请填写搜索的内容!");return false;
    }else if(shopinfo.indexOf(" ")>-1){
    	alert("搜索的内容不能含有空格。");return false;
	}else if(!checkstr(shopinfo,1) || shopinfo.indexOf("/")>-1){
		alert("搜索的内容不能含有如 (!@#$%^&*()'}{][|/\\:;\"`~) 的字符。");return false;
	}
	document.getElementById("searchiframe").innerHTML="<form method=POST name=indexsearchform target=_blank><input name=shopinfo type=hidden value='"+shopinfo+"'><input name=issearch type=hidden value=yes></form>";
	var theform=document.indexsearchform;
	if(stype=="shop"){
		theform.action=TopSite+"/workshop.asp";
		theform.submit();
	}else if(stype=="pinfo"){
		theform.action=TopSite+"/PinfoDailianinfo.asp";
		theform.submit();
	}else if(stype=="bill"){
		theform.action=TopSite+"/bill.asp";
		theform.submit();
    }else if(stype=="billcontact"){
		theform.action=TopSite+"/SearchBill.asp?key=" + shopinfo;
		theform.submit();
	}else{
		alert("请正确选择");return false;
	}
}

function changesearchtype(){
	var ishinfo=0;
	var stype=document.getElementById("searchtype").value;
	var shopinfo=jstrim(document.getElementById("getshopinfo").value);
	if(shopinfo=="" || shopinfo.indexOf("－－>") > -1){ishinfo=1;}
	if(stype=="shop"){
		if(ishinfo==1){
			document.getElementById("getshopinfo").value="－－> 请输入代练吧名称";
			document.getElementById("getshopinfo").style.color="#cccccc";
		}
	}else if(stype=="pinfo"){
		if(ishinfo==1){
			document.getElementById("getshopinfo").value="－－> 请输入游戏名及相关内容";
			document.getElementById("getshopinfo").style.color="#cccccc";
		}
	}else if(stype=="bill"){
		if(ishinfo==1){
			document.getElementById("getshopinfo").value="－－> 请输入订单号";
			document.getElementById("getshopinfo").style.color="#cccccc";
		}
	}else if(stype=="billcontact"){
		if(ishinfo==1){
			document.getElementById("getshopinfo").value="－－> 请输入电话号码或QQ号";
			document.getElementById("getshopinfo").style.color="#cccccc";
		}
	}
}

function indexsearchfocusblur(n){
	var shopinfo=jstrim(document.getElementById("getshopinfo").value);
	if(n==1){
		Pageinput="getshopinfo";
		if(shopinfo.indexOf("－－>") > -1){
		  document.getElementById("getshopinfo").value="";
	  	  document.getElementById("getshopinfo").style.color="#000000";
	  	}
	}else{
		Pageinput="";
		if(shopinfo==""){
		  changesearchtype();
		}
	}
}

function showNQGuide(){
	if(islitebox=="yes"){
		setCookie("ikbaoshowonload","yes",10000);
		if(isinitLightbox==""){initLightbox();}
		myLightbox.start('loadshow');
	}
}

function ShowIkbaoVoice(n){
	if(isinitLightbox==""){initLightbox();}
	var now= new Date(); 
	var hour=now.getHours(); 
	if(hour<10 || hour>21){
		showtype="partimevoice";
	}else if(n==0){
		showtype="timevoice";
	}else if(n==1){
		showtype="notimevoice";
	}
	myLightbox.start('IkbaoVoice');
}