	function createObj()
	{
	  var o=null;
	  if(typeof(XMLHttpRequest)!="undefined") 
	  {
		return new XMLHttpRequest();
	  }
	  if(window.ActiveXObject)
	  {
		var MSXML=["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHTTP"];
		for(var i=0;i<MSXML.length;i++)
		{
		   try
		   {
			 o= new ActiveXObject(MSXML[i]);
			 return o;
		   }
		   catch(e)
		   {}
		}
	  }
	}
	function getLinkString()
	{
	  var o=createObj();
	  if(o)
	  {
		o.onreadystatechange=function(){
		if(o.readyState==4){
		        if(o.status==200){
		               document.getElementById("linkStringDiv").innerHTML=o.responseText;
		             //  alert(o.responseText+"==+++++++++++++++++++++++++++++++++++++++");
		               }
		      }
		 };
	    var nowdate = new Date();
		o.open("GET","../linkString.jsp?"+nowdate.getTime(),true);
		o.send(null);
	  }
	}
	function getLinkString2()
	{
	  var o=createObj();
	  if(o)
	  {
		o.onreadystatechange=function()
		{    
		       if(o.readyState==4)
			       {if(o.status==200){
					document.getElementById("linkStringDiv").innerHTML=o.responseText;
		         }
		   	}
		 };
		var nowdate=new Date();
		o.open("GET","../linkString.jsp?"+nowdate.getTime()+"&type=logout",true);
		o.send(null);
	  }
	}

	function getLoginName()
	{
	  var o=createObj();
	  if(o)
	  {
		o.onreadystatechange=function(){if(o.readyState==4){if(o.status==200){document.getElementById("loginNameDiv").innerHTML=o.responseText;}}};
		var nowdate = new Date();
		o.open("GET","../loginName.jsp?"+nowdate.getTime(),true);
		o.send(null);
	  }
	}
	function getLoginName2()
	{
	  var o=createObj();
	  if(o)
	  {
		   o.onreadystatechange=function()
		  { if(o.readyState==4)
			        {if(o.status==200){document.getElementById("loginNameDiv").innerHTML=o.responseText;}}
				};
		var nowdate=new Date();
		o.open("GET","../loginName.jsp?"+nowdate.getTime()+"&type=logout",true);
		o.send(null);
	  }
	}
	
function logout() 
{  
	   // alert("20000000000000000000000000000000000000");
		getLinkString2();
		getLoginName2();
}



 function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; 
	for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) {
		// alert(x.src+"++++---------------"+x.oSrc);
		   x.src = x.oSrc;
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if (d.images) {
  	if (!d.MM_p) 
  		d.MM_p = new Array();
  	    var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
  	    for (i = 0; i < a.length; i++) {
	  		if (a[i].indexOf("#") != 0) {
	  			d.MM_p[j] = new Image;
	  			d.MM_p[j++].src = a[i];
	  		}
  	}
  }
}

function MM_findObj(n, d) { //v4.01
   var p,i,x;  if(!d) d=document;
    if((p=n.indexOf("?"))>0&&parent.frames.length) {
             d=parent.frames[n.substring(p+1)].document; 
			 n=n.substring(0,p);
	  }
	  if (!(x = d[n]) && d.all) {
	  	   x = d.all[n];
	   }
	  for (i = 0; !x && i < d.forms.length; i++) {
	  	 x = d.forms[i][n];
	  }
	  for (i = 0; !x && d.layers && i < d.layers.length; i++) {
	  	x = MM_findObj(n, d.layers[i].document);
	  }
	  if (!x && d.getElementById) {
	  	  x = d.getElementById(n);
	  } 
   return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; 
   document.MM_sr=new Array; 
   for (i = 0; i < (a.length - 2); i += 3) {
    	if ((x = MM_findObj(a[i])) != null) {
   	    	document.MM_sr[j++] = x;
   		    if (!x.oSrc) 
   			  x.oSrc = x.src;
   		     x.src = a[i + 2];
   	   }
   }
}

// JavaScript Document
//菜单部分
var menuArr = null;
var divArr = null;
function loadMenu(index){  //加载当前页面菜单背景颜色
	getAllMenuArray("menudiv01");
	menuArr[index] = 2;
	changeMenuBg(index);
}

function changeMenuBg(index){  //改变菜单背景颜色 
	divArr[index].style.background="#FEC106";
}

function getAllMenuArray(menuId){  //设置所有的菜单状态为1 放进array
	var fdiv = document.getElementById(menuId);
	divArr = fdiv.getElementsByTagName("div");
	var index = divArr.length;
	menuArr = new Array(index);
	for(var i=0;i<index;i++){
		menuArr[i] = 1;
	}
}

function onMouseover(index) { //菜单鼠标事件效果1
	divArr[index].style.background="#FEC106";
}

function onMouseout(index) { //菜单鼠标事件效果2
	if(menuArr[index] == 1){
		divArr[index].style.background="#FFE783";
	}
}



//衣服换颜色部分
function changeClothesColor(index,d,fdiv){
	var odiv = document.getElementById(fdiv);
	var divArr = odiv.getElementsByTagName("img");
	for(var i = 0; i<divArr.length;i++){
		divArr[i].className="img_border1";
	}
	d.className="img_border2";
	
	//需补充改变上面衣服样式的函数
}

function partEnlargeClothes(index,d,fdiv){ 
	var odiv = document.getElementById(fdiv);
	var divArr = odiv.getElementsByTagName("div");
	for(var i = 0; i<divArr.length;i++){
		divArr[i].style.border="1px solid #2525D5";
	}
	d.style.border="2px solid #2525D5";
}


//显示2级菜单 （帐户中心）
function showNextMenu(divId){
	var divObj = document.getElementById(divId);
	var divStyle = divObj.style.display;
	if(divStyle == 'none'){
		divObj.style.display = "";
	}else{
		divObj.style.display = "none";	
	}
	
}

/*
openNewPage(index,baseclass)打开页面方法 在nav.lbi中调用
默认打开是首页
index=0  首页
index=1  最新活动
index==2 衬衫
index==3 恤
index==4 裤子
index==5 毛衫
index==6 茄克
index==7 服装饰品
参数indexdiv是在每个view上接收的，然后再view对应的页面上的body的onload调用的loadCurrentMenu方法中调用，保证让每个页面的当前tab显示高亮色
*/
function openNewPage(index,baseclass){
	var openurl = "index.htm";  
	if(index==0){
	   openurl = "index.htm";   
	}else if(index==1){
	  openurl="selectGift.jsp?indexdiv="+index;  
	}else if(index==2 || index==3 || index==4 || index==5 || index==6 || index==7 || index==8){
	  /*openurl="categories.jsp?indexdiv="+index+"&baseclass="+baseclass;  */
	  openurl="categories_"+index+"-"+baseclass+"-1.html";
	}
	window.open(openurl,"_self");
}
/*
  客服中心中使用的Top菜单打开方法,路径不同
  inout==0  根目录下的页面
  inout==1  service目录下的页面
*/
function openNewPageInOut(index,baseclass,inout){
	var openurl = "index.htm";  
	if(index==0){
	   openurl = "index.htm";   
	}else if(index==-1){
	  openurl = "../index.htm";   
	}else if(index==1){
	  openurl="../selectGift.jsp?indexdiv="+index;  
	}else if(index==2 || index==3 || index==4 || index==5 || index==6 || index==7 || index==8){
	   /*openurl="../categories.jsp?indexdiv="+index+"&baseclass="+baseclass;*/ 
	    openurl="../categories_"+index+"-"+baseclass+"-1.html";
	}
	if(inout==1){
	  openurl="../"+openurl;
	}
	window.open(openurl,"_self");
}

function loadCurrentMenu(){  //加载当前页面菜单背景颜色 在每个页面的body的onload方法中调用
	getAllMenuArray("menudiv01");
	menuArr[indexdiv] = 2;
	changeMenuBg(indexdiv);
}
function openNewPageForSubProductClass(index,baseclass,proLevelCode){
		var openurl = "index.htm";  
		if(index==0){
		   openurl = "index.htm";   
		}else if(index==1){
		  //openurl="selectGift.jsp?indexdiv="+index;  //TODO：HRH 暂时去掉礼包页面，改为显示正常商品页面
		  /*openurl="categories.jsp?indexdiv="+index+"&baseclass="+baseclass+"&proLevelCode="+proLevelCode;  */
		  openurl="categories_"+index+"-"+baseclass+"-"+proLevelCode+".htm";
		}else if(index==2 || index==3 || index==4 || index==5 || index==6 || index==7 || index == 8){
		  /*openurl="categories.jsp?indexdiv="+index+"&baseclass="+baseclass+"&proLevelCode="+proLevelCode; */
		   openurl="categories_"+index+"-"+baseclass+"-"+proLevelCode+".htm";
		}
		window.open(openurl,"_self");
}

function goSearch(){
	  var productSNameInput = document.getElementById("productSName");
	  var productSName = productSNameInput.value.replace(/(^\s*)|(\s*$)/g,"");
	  if((productSName != "")&&(productSName != "输入品号或品名等信息")){
	    var searchPath = "../searchProduct.jsp?searchvalue="+encodeURI(productSName);
	    window.open(searchPath,"_self");
	  }else{
		  alert("\u8bf7\u8f93\u5165\u641c\u7d22\u6761\u4ef6\uff01");
	  }
}


function loadTopMenu(){
	 var baseclass='${Request.baseclass}';
	 var textValues='<table width="984" border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
     var textValue='<td width="123"><a href="../../index.htm">';
	   if(baseclass==null||baseclass.length==0){
	    	textValue+='<img src="../images/sy.jpg" name="Image63" width="123" height="35" border="0" id="Image63" /></a></td>';
	   }else{
	     	textValue+='<img src="../images/sy2.jpg" name="Image63" width="123" height="35" border="0" id="Image63" /></a></td>';
	   }
	   textValue+=' <td width="123"><a href="javascript:openNewPageInOut(7,6,0);">';
	   if(baseclass=='6'){
	   	    textValue+='<img src="../images/xf2.jpg" name="Image64" width="123" height="35" border="0" id="Image64" /></a></td>';
	   }else{
	     	textValue+='<img src="../images/xf.jpg" name="Image64" width="123" height="35" border="0" id="Image64" /></a></td>';
	   }
	   textValue+=' <td width="123"><a href="javascript:openNewPageInOut(6,5,0);" >';
	   if(baseclass=='5'){
	   	    textValue+='<img src="../images/xxwt.jpg" name="Image65" width="123" height="35" border="0" id="Image65" /></a></td>';
	   }else{
	     	textValue+='<img src="../images/xxwt2.jpg" name="Image65" width="123" height="35" border="0" id="Image65" /></a></td>';
	   }
	  textValue+=' <td width="123"><a href="javascript:openNewPageInOut(2,1,0);" >';
	   if(baseclass=='1'){
	   	    textValue+='<img src="../images/cs.jpg" name="Image66" width="123" height="35" border="0" id="Image66" /></a></td>';
	   }else{
	     	textValue+='<img src="../images/cs2.jpg" name="Image66" width="123" height="35" border="0" id="Image66" /></a></td>';
	   }
	  textValue+=' <td width="123"><a href="javascript:openNewPageInOut(4,3,0);" >';
	   if(baseclass=='3'){
	   	    textValue+='<img src="../images/kz.jpg" name="Image67" width="123" height="35" border="0" id="Image67" /></a></td>';
	   }else{
	     	textValue+='<img src="../images/kz2.jpg" name="Image67" width="123" height="35" border="0" id="Image67" /></a></td>';
	   }
	   	  textValue+=' <td width="123"><a href="javascript:openNewPageInOut(5,4,0);" >';
	   if(baseclass=='4'){
	   	    textValue+='<img src="../images/ms.jpg" name="Image68" width="123" height="35" border="0" id="Image68" /></a></td>';
	   }else{
	     	textValue+='<img src="../images/ms2.jpg" name="Image68" width="123" height="35" border="0" id="Image68" /></a></td>';
	   }
	   
	  textValue+=' <td width="123"><a href="javascript:openNewPageInOut(3,2,0);" >';
	   if(baseclass=='2'){
	   	    textValue+='<img src="../images/T.jpg" name="Image69" width="123" height="35" border="0" id="Image69" /></a></td>';
	   }else{
	     	textValue+='<img src="../images/T2.jpg" name="Image69" width="123" height="35" border="0" id="Image69" /></a></td>';
	   }
	   
	   textValue+=' <td width="123"><a href="javascript:openNewPageInOut(8,7,0);" >';
	   if(baseclass=='7'){
	   	    textValue+='<img src="../images/ps.jpg" name="Image70" width="123" height="35" border="0" id="Image70" /></a></td>';
	   }else{
	     	textValue+='<img src="../images/ps1.jpg" name="Image70" width="123" height="35" border="0" id="Image70" /></a></td>';
	   }
       textValues+=textValue+"</tr></table>";
	   var objdiv=document.getElementById("pingDivTab");
	   objdiv.style.display="";
	   objdiv.innerHTML=textValues;
}
	
function goToCategoriesJsp(indexdiv,baseclass,proLevelCode){
  //var path = "categories.jsp?indexdiv="+indexdiv+"&baseclass="+baseclass+"&proLevelCode="+proLevelCode;
  var path="categories_"+ indexdiv + "-" + baseclass +"-" + proLevelCode +".htm"; 
  window.open(path,"_blank");
}
