﻿// JScript 文件
var timer1="";
function getFC(obj,id)
{
//debugger;
    var info='数据加载中...';
    document.getElementById('FCInfo').innerHTML=info;   
   
	if(PROCAT==1)
	{	
	    $("#FCInfo").load("Cache/class_"+id+"_1.html?random=" + (new Date().getTime()),function(data){});
	}
	else
	{
	    $("#FCInfo").load("Cache/class_"+id+".html?random=" + (new Date().getTime()),function(data){}); 
	}
	 showFC(obj,0,43,0);
	 DDLHide();
}
var curSC=false;
function getSC(obj,id)
{
   // debugger;
	  var info='数据加载中...';
	  $("#SecondClass").mouseover(SCShow);
	  document.getElementById('SCInfo').innerHTML=info;	  
	
	 $("#SCInfo").load("Cache/prolist_"+id+"_"+searchCat+".html?random=" + (new Date().getTime()),function(data){});
	 	showSC(obj,0,13,0);	
		
	if(curSC)
	{
		curSC.style.backgroundColor="white";
	}
	curSC=obj;
	obj.style.backgroundColor="#E0E0E0";
	curCListPager=1;
}
var curCListPager=1;
function CListPager(i,t)
{
	//debugger;
	if(i==-1&&curCListPager<t)
	{
	    $(".CList"+curCListPager).hide();
	    curCListPager++;
	    $(".CList"+curCListPager).show();
	    $("#CListPager_Cur").html(curCListPager);
	}
    if(i==1&&curCListPager>1)
    {
        $(".CList"+curCListPager).hide();
	    curCListPager--;
	    $(".CList"+curCListPager).show();
	    
	     $("#CListPager_Cur").html(curCListPager);
    }
    
    if(curCListPager>1)
    {
        $("#CListPager_Pre a").css("text-decoration","underline");
    }
    else
    {
        $("#CListPager_Pre a").css("text-decoration","none");
    }
    
    if(curCListPager<t)
    {
        $("#CListPager_Next a").css("text-decoration","underline");
    }
    else
    {
         $("#CListPager_Next a").css("text-decoration","none");
    }
}
var curBListPager=1;
function BListPager(i,t)
{
  
    	if(i==-1&&curBListPager<t)
	{
	    $(".BList"+curBListPager).hide();
	    curBListPager++;
	    $(".BList"+curBListPager).show();
	    $("#BListPager_Cur").html(curBListPager);
	}
    if(i==1&&curBListPager>1)
    {
        $(".BList"+curBListPager).hide();
	    curBListPager--;
	    $(".BList"+curBListPager).show();
	    
	     $("#BListPager_Cur").html(curBListPager);
    }
    
    if(curBListPager>1)
    {
        $("#BListPager_Pre a").css("text-decoration","underline");
    }
    else
    {
        $("#BListPager_Pre a").css("text-decoration","none");
    }
    
    if(curBListPager<t)
    {
        $("#BListPager_Next a").css("text-decoration","underline");
    }
    else
    {
         $("#BListPager_Next a").css("text-decoration","none");
    }
    
    
}

var curBP=false;
function getBP(obj,id)
{
    //debugger;
	    var info='数据加载中...';
		BPShow();
        var iWidth = (document.body.offsetWidth-980)/2;
	    document.getElementById('BrandInfo').innerHTML=info;
	    
		$("#BrandInfo").load("Cache/brandpro_"+id+"_"+searchCat+".html?random=" + (new Date().getTime()),function(data){});
		
		document.getElementById("BrandPanel").style.left=iWidth+310+"px";
		document.getElementById("BrandPanel").style.top=document.getElementById("BrandList2").style.top;
		
		if(curBP)
	{
		curBP.style.backgroundColor="white";
	}
	curBP=obj;
	obj.style.backgroundColor="#E0E0E0";
	curBListPager=1;
}
function handleMouseFunc(oEvent)
{
	if(oEvent.preventDefault) 
	{  
				//不是IE浏览器
		   oEvent.preventDefault();    
		   oEvent.stopPropagation();    
			} 
			else {    
				//IE浏览器
			   oEvent.cancelBubble=true;    
			   oEvent.returnValue = false;    
	}    
}
function BPShow()
{ 
    closeAllClass();
    $("#BrandPanel").show();
    $("#BrandList2").show();
    DDLHide();
    if(typeof(brandList)=="undefined")
    {
        $("#BrandList").show();
    }
}
function BPNoShow(theEvent){

  if (theEvent){
   　           var browser=navigator.userAgent;   //取得浏览器属性
   　           if (browser.indexOf("Firefox")>0){  //如果是Firefox
    　　             if (document.getElementById('BrandPanel').contains(theEvent.relatedTarget)) {  //如果是子元素
     　　                  return;   //结束函式
                        } 
                  } 
                  if (browser.indexOf("MSIE")>0){  //如果是IE
                         if (document.getElementById('BrandPanel').contains(event.toElement)) {  //如果是子元素
                                return;  //结束函式
                          }
                   }
             }
	$("#BrandPanel").hide();
	$("#BrandProPanel").hide();
	$("#BrandList2").hide();
	if(typeof(brandList)=="undefined")
	{
		$("#BrandList").hide();
	}
	DDLShow();
}
function BPPShow(){ 

$("#BrandProPanel").show(); $("#BrandPanel").show();if(typeof(brandList)=="undefined"){$("#BrandList").show();}
$("#BrandList2").show();
}
function BPPNoShow(){$("#BrandList2").hide();$("#BrandPanel").hide();$("#BrandProPanel").hide();if(typeof(brandList)=="undefined"){$("#BrandList").hide();}}


function BLShow(){ $("#BrandList").show(); DDLHide();}
function BLNoShow(theEvent){ 

         if (theEvent){
   　           var browser=navigator.userAgent;   //取得浏览器属性
   　           if (browser.indexOf("Firefox")>0){  //如果是Firefox
    　　             if (document.getElementById('BrandList').contains(theEvent.relatedTarget)) {  //如果是子元素
     　　                  return;   //结束函式
                        } 
                  } 
                  if (browser.indexOf("MSIE")>0){  //如果是IE
                         if (document.getElementById('BrandList').contains(event.toElement)) {  //如果是子元素
                                return;  //结束函式
                          }
                   }
             }
             
$("#BrandList").hide();$("#BrandList2").hide(); $("#BrandPanel").hide(); $("#BrandProPanel").hide(); DDLShow();}
function BL2Show(){ $("#BrandList2").show();BLShow()}
function BL2NoShow(theEvent){ 

 if (theEvent){
   　           var browser=navigator.userAgent;   //取得浏览器属性
   　           if (browser.indexOf("Firefox")>0){  //如果是Firefox
    　　             if (document.getElementById('BrandList2').contains(theEvent.relatedTarget)) {  //如果是子元素
     　　                  return;   //结束函式
                        } 
                  } 
                  if (browser.indexOf("MSIE")>0){  //如果是IE
                         if (document.getElementById('BrandList2').contains(event.toElement)) {  //如果是子元素
                                return;  //结束函式
                          }
                   }
             }
$("#BrandList2").hide(); $("#BrandPanel").hide(); $("#BrandProPanel").hide()}

function getBL()
{
//debugger;
     var info='数据加载中...';
	 document.getElementById('BrandListInfo').innerHTML=info;   

	 $("#BrandListInfo").load("Cache/brandlist_"+searchCat+".html?random=" + (new Date().getTime()),function(data){});
	 
	 showBL(-10,42,0);
}
var curBL2=null;
function showBL2(obj,id)
{
   //	alert(searchCat);
	$("#BrandList2").load("Cache/brandlist_"+id+"_"+searchCat+".html?random=" + (new Date().getTime()),function(data){});
	BL2Show();
	closeAllClass();
	var iWidth = (document.body.offsetWidth-980)/2;
	document.getElementById("BrandList2").style.left=iWidth+175+"px";
	
	//debugger;
	if(brandFlag)
	{
	    document.getElementById("BrandList2").style.top=document.getElementById('BrandList').style.top;
	}   
	else
	{
	    document.getElementById("BrandList2").style.top="139px";
	}
	if(curBL2)
	{
		curBL2.style.backgroundColor="white";
	}
	curBL2=obj;
	obj.style.backgroundColor="#E0E0E0";
}
function showBL(objleftoffset,objtopoffset,objtopfirefoxoffset)
{
//debugger;
    var obj=document.getElementById("navProBand");
     var p = getposition(obj);   
   
    document.getElementById('BrandList').style.display='block';
	
   
   if(objtopfirefoxoffset != null && objtopfirefoxoffset !=0 && !isie())
   {
        document.getElementById('BrandList').style.top=p['y']+"0px";
   }
   else
   {
        if(objtopoffset == 0)
        { 
			
		   document.getElementById('BrandList').style.top=p['y']-document.getElementById('BrandListInfo').offsetHeight-40+"px";
			
        }
        else
        {
			document.getElementById('BrandList').style.top=p['y']+objtopoffset+"px";
        }
   }
   document.getElementById('BrandList').style.left=p['x']+objleftoffset+"px";
}


function getBrandPro(obj,pic)
{
    var info;
    if(pic.length>5)
    {
	    info='<img src="'+pic+'" />';   
	}
	else
    {	info='<img src="images/nopic.gif" />';   
    }
	 document.getElementById('BrandProInfo').innerHTML=info;     
	 showBrandPro(obj,496,13,0); 	 
}
function showBrandList(obj, objleftoffset,objtopoffset,objtopfirefoxoffset)
{
   var iWidth = (document.body.offsetWidth-980)/2;
  
   var p = getposition(obj);   
   
   document.getElementById('BrandPanel').style.display='block';
   if(objtopfirefoxoffset != null && objtopfirefoxoffset !=0 && !isie())
   {
        document.getElementById('BrandPanel').style.top=p['y']+"0px";
   }
   else
   {
        if(objtopoffset == 0)
        { 
			
		   document.getElementById('BrandPanel').style.top=p['y']-document.getElementById('BrandInfo').offsetHeight-40+"px";
			
        }
        else
        {
			document.getElementById('BrandPanel').style.top=150+"px";
        }
   }
   document.getElementById('BrandPanel').style.left=iWidth+176+"px";
}
function showBrandPro(obj, objleftoffset,objtopoffset,objtopfirefoxoffset)
{
  // debugger;
   var p = getposition(obj);   
   
    document.getElementById('BrandProPanel').style.display='block';
	
   
   if(objtopfirefoxoffset != null && objtopfirefoxoffset !=0 && !isie())
   {
        document.getElementById('BrandProPanel').style.top=p['y']+"0px";
   }
   else
   {
        if(objtopoffset == 0)
        { 
			
		   document.getElementById('BrandProPanel').style.top=p['y']-document.getElementById('BrandProInfo').offsetHeight-40+"px";
			
        }
        else
        {
           
			document.getElementById('BrandProPanel').style.top=document.getElementById("BrandPanel").style.top;//p['y']+objtopoffset+"px";
        }
   }
   document.getElementById('BrandProPanel').style.left=parseInt($dom("BrandPanel").style.left.replace("px",""))+250+"px";
  
}
function getPD(obj,pic)
{
    var info;
    if(pic.length>5)
    {
	    info='<img src="'+pic+'" />';   
	}
	else
    {	info='<img src="images/nopic.gif" />';   
    }
	 document.getElementById('ProDetail').innerHTML=info;     
	 showPD(obj,501,13,0); 	 
}

function FCShow()
{	
		document.getElementById('FirstClass').style.display='block';	
		DDLHide();
}
function FC2Show()
{
    	document.getElementById('FirstClass2').style.display='block';	
    	document.getElementById('FirstClass').style.display='block';	
		DDLHide();
}
function SCShow()
{
    document.getElementById('FirstClass').style.display='block';
	document.getElementById('SecondClass').style.display='block';
	 if(searchCat!=1)
	 {
	        document.getElementById('FirstClass2').style.display='block';
		}	
	DDLHide();
}
function PDShow()
{
   	document.getElementById('FirstClass').style.display='block';
	document.getElementById('SecondClass').style.display='block';
	document.getElementById('ProDetail').style.display='block';
	 if(searchCat!=1)
	 {
	        document.getElementById('FirstClass2').style.display='block';	
	  }
	DDLHide();
}
function closeAllClass()
{
    document.getElementById('FirstClass2').style.display='none';	
	document.getElementById('FirstClass').style.display='none';
	document.getElementById('SecondClass').style.display='none';
	document.getElementById('ProDetail').style.display='none';
	DDLShow();
}
function DDLHide()
{
    var s=document.getElementsByTagName("select");
	for(var i=0;i<s.length;i++)
	{
		if(s.item(i).id.indexOf("DropDownList1")>=0)
		{
			s.item(i).style.display='none';
		}
	}
    if(document.getElementById("selectPanel"))
    {
        document.getElementById("selectPanel").style.display='none';
    }
}
function DDLShow()
{
   var s=document.getElementsByTagName("select");
	for(var i=0;i<s.length;i++)
	{
		if(s.item(i).id.indexOf("DropDownList1")>=0)
		{
			s.item(i).style.display='block';
		}
	}
     if(document.getElementById("selectPanel"))
    {
        document.getElementById("selectPanel").style.display='block';
    }
}

if(typeof(HTMLElement)!="undefined")   //给firefox定义contains()方法，ie下不起作用
  {   
      HTMLElement.prototype.contains=function(obj)   
      {   
          while(obj!=null&&typeof(obj.tagName)!="undefind"){ //通过循环对比来判断是不是obj的父元素
  　　　　if(obj==this)  return true;   
  　　　　obj=obj.parentNode;
   　　}   
          return false;   
      };   
  }   
  
function FCNoShow(theEvent)
{ 	            
         if (theEvent){
   　           var browser=navigator.userAgent;   //取得浏览器属性
   　           if (browser.indexOf("Firefox")>0){  //如果是Firefox
    　　             if (document.getElementById('FirstClass').contains(theEvent.relatedTarget)) {  //如果是子元素
     　　                  return;   //结束函式
                        } 
                  } 
                  if (browser.indexOf("MSIE")>0){  //如果是IE
                         if (document.getElementById('FirstClass').contains(event.toElement)) {  //如果是子元素
                                return;  //结束函式
                          }
                   }
             }
             
             
     closeAllClass();
}
function FC2NoShow(theEvent)
{ 	
         if (theEvent){
   　           var browser=navigator.userAgent;   //取得浏览器属性
   　           if (browser.indexOf("Firefox")>0){  //如果是Firefox
    　　             if (document.getElementById('FirstClass2').contains(theEvent.relatedTarget)) {  //如果是子元素
     　　                  return;   //结束函式
                        } 
                  } 
                  if (browser.indexOf("MSIE")>0){  //如果是IE
                         if (document.getElementById('FirstClass2').contains(event.toElement)) {  //如果是子元素
                                return;  //结束函式
                          }
                   }
             }
             
     closeAllClass();
}
function SCNoShow(theEvent)
{    
         if (theEvent){
   　           var browser=navigator.userAgent;   //取得浏览器属性
   　           if (browser.indexOf("Firefox")>0){  //如果是Firefox
    　　             if (document.getElementById('SecondClass').contains(theEvent.relatedTarget)) {  //如果是子元素
     　　                  return;   //结束函式
                        } 
                  } 
                  if (browser.indexOf("MSIE")>0){  //如果是IE
                         if (document.getElementById('SecondClass').contains(event.toElement)) {  //如果是子元素
                                return;  //结束函式
                          }
                   }
             }
    closeAllClass();
}
function PDNoShow()
{
   closeAllClass();
}
var curFC2=false;
function getFC2(obj,id)
{
      if(searchCat==1)
    {
        getSC(obj,id);
    }
    else
    {
       var info='数据加载中...';
        document.getElementById('FC2Info').innerHTML=info;   
       
	    //alert(id);	
	    $("#FC2Info").load("Cache/class_"+id+".html?random=" + (new Date().getTime()),function(data){});
	    FC2Show();
	     showFC2(obj,0,13,0);
	     DDLHide();
    	 
	 		    if(curFC2)
	    {
		    curFC2.style.backgroundColor="white";
	    }
	    curFC2=obj;
	    obj.style.backgroundColor="#E0E0E0";
	}
}
var curFC_left=0;
function showFC2(obj, objleftoffset,objtopoffset,objtopfirefoxoffset)
{

     var iWidth = document.body.offsetWidth;  

   // debugger;
    x=document.getElementById("FirstClass").style.left.replace("px","");
    if(curFC_left==0)
    {
         x=parseInt(x)+120;  //置右
    }
    else
    {
        x=parseInt(x)-120;//置左
    }
   document.getElementById('FirstClass2').style.top=document.getElementById("FirstClass").style.top;
   document.getElementById('FirstClass2').style.left=x+"px";
}

function showFC(obj, objleftoffset,objtopoffset,objtopfirefoxoffset)
{
 
    //自适应位置
    //debugger;
 //   alert("dsf");
  var iWidth = document.body.offsetWidth-980+800;    
   var p = getposition(obj);   
   if(p['x']>iWidth)
   {
        p['x']=iWidth;
   }
   
   var off=Math.ceil((document.body.offsetWidth-980)/2);
   
   if(p['x']-off>450)
   {
        curFC_left=1;
   }
   else
   {
        curFC_left=0;
   }
   
 //结束
    document.getElementById('FirstClass').style.display='block';
   
   if(objtopfirefoxoffset != null && objtopfirefoxoffset !=0 && !isie())
   {
        document.getElementById('FirstClass').style.top=p['y']+"0px";
   }
   else
   {
        if(objtopoffset == 0)
        { 
			
		   document.getElementById('FirstClass').style.top=p['y']-document.getElementById('FCInfo').offsetHeight-40+"px";
			
        }
        else
        {
			document.getElementById('FirstClass').style.top=p['y']+objtopoffset+"px";
        }
   }
   document.getElementById('FirstClass').style.left=p['x']+objleftoffset+"px";
  //   curFC_left=p['x']+objleftoffset;
}



//修改后的代码
function showSC(obj, objleftoffset,objtopoffset,objtopfirefoxoffset)
{
    
    //自适应位置

   var iWidth = document.body.offsetWidth;  
  
  if(searchCat==1)
  {
     x=document.getElementById("FirstClass").style.left.replace("px","");
  }
  else
  {
        x=document.getElementById("FirstClass2").style.left.replace("px","");
   }
   if(curFC_left==0)
    {
         x=parseInt(x)+120;  //置右
    }
    else
    {
        x=parseInt(x)-170;//置左
    }
    
   SCShow();
   
   document.getElementById('SecondClass').style.top=document.getElementById("FirstClass").style.top;
      
   document.getElementById('SecondClass').style.left=x+"px";
   
   
  // alert("sdf");
}

function showPD(obj, objleftoffset,objtopoffset,objtopfirefoxoffset)
{
   
   //自适应位置
  // var iWidth = document.body.offsetWidth-980+450;  
    var iWidth = document.body.offsetWidth;  
  // alert(document.body.offsetWidth);
   x=document.getElementById("SecondClass").style.left.replace("px","");
    
    if(curFC_left==0)
    {
         x=parseInt(x)+190;  //置右
    }
    else
    {
        x=parseInt(x)-135;//置左
    }
  //  x=parseInt(x)+250;
    
   PDShow();
   
   document.getElementById('ProDetail').style.top=document.getElementById("SecondClass").style.top;
      
   document.getElementById('ProDetail').style.left=x+"px";   
   
}
function $dom(id)
{
	return document.getElementById(id);
}
function isie()
{
   if(navigator.userAgent.toLowerCase().indexOf('msie') != -1)
   {
       return true;
   }
   else
   {
       return false;
   }
}  
function getposition(obj) {

	var r = new Array();
	r['x'] = obj.offsetLeft;
	r['y'] = obj.offsetTop;
	while(obj = obj.offsetParent) {
		r['x'] += obj.offsetLeft;
		r['y'] += obj.offsetTop;
	}
	//alert("x:"+r['x']+"|y:"+r['y']);
	return r;
}