﻿


function CreateXmlhttpIndex()
{
  var xmlHttp= window.XMLHttpRequest?(new XMLHttpRequest()):(new ActiveXObject("Microsoft.XMLHTTP"));
  return xmlHttp;
}


//首页顶部包括其他页面顶部对商机、行业资讯的搜索功能
 function setText()
   { var txtKey=document.getElementById("txtKeyword").value;
         
      if(txtKey.indexOf("请输入")!=-1)
      {
        document.getElementById("txtKeyword").value="";
      }

      document.getElementById("txtKeyword").style.color="black"; 
   }
   
   
   function setText2()
   {
     var txtKey=document.getElementById("txtKeyword").value;
     if(txtKey=="")
     {
      document.getElementById("txtKeyword").value="请输入您要搜索的关键字";
      }
            
   }
   
   
   
 
 
   
    
    function ChangeStyle(index)
    {
      //检测URL并赋值给不同的URL参数
      
  
      for(var i=1;i<=8;i=i+1)
	 {
	 document.getElementById("Search"+i).className="unfouce"
    //eval("Search"+i+".className=\"unfouce\";");
		
	 }
	 document.getElementById("Search"+index).className="onfouce"
	
		//eval("Search"+index+".className=\"onfouce\";");
	    document.getElementById("hiddenUrl").value=index;	
	    
	    var searchkey= document.getElementById("txtKeyword");
	    
	    //Tiansoft20080623新加
	    if(index==1)
	    {  if(searchkey.value.indexOf("请输入")!=-1)
	      {
	       searchkey.value="请输入要搜索的求购产品名称、关键字";
	      }
	    
	    }
	    
	     if(index==2)
	    {
	     if(searchkey.value.indexOf("请输入")!=-1)
	      {
	      searchkey.value="请输入要搜索的供应信息名称、企业名称关键字";
	      }
	    }
	    
	     if(index==3)
	    {   if(searchkey.value.indexOf("请输入")!=-1)
	      {
	      searchkey.value="请输入要搜索的资讯标题、关键字";
	      }
	    }
	    
	      if(index==4)
	    {
	     if(searchkey.value.indexOf("请输入")!=-1)
	      {
	      searchkey.value="请输入要搜索的企业库产品名称、企业名称关键字";
	      }
	    }
	    
	      if(index==5)
	    {
	      if(searchkey.value.indexOf("请输入")!=-1)
	      {
	      searchkey.value="请输入要搜索的展览标题、地点关键字";
	      }
	    }
	    
	      if(index==6)
	    {  
	     if(searchkey.value.indexOf("请输入")!=-1)
	      {
	      searchkey.value="请输入要搜索的行情标题关键字";
	      }
	    }
	    
	      if(index==7)
	    {  
	     if(searchkey.value.indexOf("请输入")!=-1)
	      {
	      searchkey.value="请输入要搜索的企业报价标题关键字";
	      }
	    }
	      if(index==8)
	    {  
	     if(searchkey.value.indexOf("请输入")!=-1)
	      {
	      searchkey.value="请输入要搜索的产品名称、企业名称关键字";
	      }
	    }
	     
	     document.getElementById("txtKeyword").style.color="#808080"; 
   }
      
      
    
    function SearchKeyDown()
  {
        if (event.keyCode == 13)
        {
        event.returnValue=false;
        event.cancel = true;
        Index_TopSearch_Cilick();
        }
  }



//搜索事件
function  Index_TopSearch_Cilick()
{


  var txtKey=document.getElementById("txtKeyword").value;
  if(txtKey=="" || txtKey.indexOf("请输入")!=-1)
  {
    alert('请输入您要搜索的关键字');
    document.getElementById("txtKeyword").value="";
    document.getElementById("txtKeyword").focus();
  }
  else
  {

    var url= document.URL.toLowerCase();

    switch(document.getElementById("hiddenUrl").value)
    {    
    
         case "1":          //求购     
         
          surl="/Trade/"+encodeURIComponent(txtKey)+"_BuySearch.shtml";
         if(url.indexOf("trade")!=-1)
         {     
         
        window.location.href=surl;
         
         }
         else
         {  
          window.open(surl);       
           
         }
         
          break;      
                
    	 case "2":         //供应
    	  surl="/Trade/"+encodeURIComponent(txtKey)+"_SupplySearch.shtml";
    	 if(url.indexOf("trade")!=-1)
         {     
         
        window.location.href=surl;
         
         }
         else
         {  
          window.open(surl);       
           
         }
    	  break;  
    	   
         case "3":         //行业新闻
         surl="/InfoCenter/News/"+encodeURIComponent(txtKey)+"_Search.shtml";
         
          if(url.indexOf("infocenter")!=-1)
         {     
         
        window.location.href=surl;
         
         }
         else
         {  
          window.open(surl);       
           
         }
          break; 
                   
  	     case "4":       //企业库
  	     surl="/Company/"+encodeURIComponent(txtKey)+"_Search.shtml";
  	     
  	        if(url.indexOf("company")!=-1)
         {     
         
        window.location.href=surl;
         
         }
         else
         {  
          window.open(surl);       
           
         }
  	      break;      
  	      
	     case "5":      //展览会议
	     surl="/InfoCenter/Exhibition/"+encodeURIComponent(txtKey)+"_Search.shtml";
	     
	        if(url.indexOf("infocenter")!=-1)
         {     
         
           window.location.href=surl;
         
         }
         else
         {  
          window.open(surl);       
           
         }
	     break;   
	        
         case "6":     //市场行情
         surl="/InfoCenter/Market/"+encodeURIComponent(txtKey)+"_Search.shtml";
         
              if(url.indexOf("infocenter")!=-1)
         {     
         
        window.location.href=surl;
         
         }
         else
         {  
          window.open(surl);       
           
         }
         break; 
                  
         case "7":       //企业报价  
         surl="/InfoCenter/Price/"+encodeURIComponent(txtKey)+"_Search.shtml";
         
          if(url.indexOf("infocenter")!=-1)
         {     
         
        window.location.href=surl;
         
         }
         else
         {  
          window.open(surl);       
           
         }
         break;  
         
          case "8":     //产品库
         surl="/Product/"+encodeURIComponent(txtKey)+"_ProductSearch.shtml";
         
              if(url.indexOf("product")!=-1)
         {     
         
        window.location.href=surl;
         
         }
         else
         {  
          window.open(surl);       
           
         }
         break;          
           
    }
//		      alert(surl);
		     
  }
  
}
////////////new search/////////////////
function SearchKeyWord()
{
    var txtKey=document.getElementById("txtKeyword").value;
    if(txtKey=="" || txtKey.indexOf("请输入")!=-1)
    {
        alert('请输入您要搜索的关键字');
        document.getElementById("txtKeyword").value="";
        document.getElementById("txtKeyword").focus();
    }
    else
    {
        var typeID='2';
        var url= document.URL.toLowerCase(); 
        var rbnKey=document.getElementsByName("rbnKeyType");
        {
            for(var i=0;i<rbnKey.length;i++)
            {
                if(rbnKey[i].checked)
                {
                    typeID=rbnKey[i].value;
                }
            }
        }
        switch(typeID)
        {
            case "1":    //供应
                surl="/Trade/"+encodeURIComponent(txtKey)+"_SupplySearch.shtml";
                if(url.indexOf("trade")!=-1)
                {
                    window.location.href=surl;
                }
                else
                {
                    window.open(surl); 
                }
                break;
            case "2":  //求购
                surl="/Trade/"+encodeURIComponent(txtKey)+"_BuySearch.shtml";
                if(url.indexOf("trade")!=-1)
                {
                    window.location.href=surl;
                }
                else
                {
                    window.open(surl); 
                }
                break;
             case "3":    //产品
                surl="/Product/"+encodeURIComponent(txtKey)+"_ProductSearch.shtml";
                if(url.indexOf("product")!=-1)
                {
                    window.location.href=surl;
                }
                else
                {
                    window.open(surl); 
                }
                break;
            case "4":  //企业
                surl="/Company/"+encodeURIComponent(txtKey)+"_Search.shtml";
                if(url.indexOf("company")!=-1)
                {
                    window.location.href=surl;
                }
                else
                {
                    window.open(surl); 
                }
                break;
             case "5":    //展会
                surl="/InfoCenter/Exhibition/"+encodeURIComponent(txtKey)+"_Search.shtml";
                if(url.indexOf("infocenter")!=-1)
                {
                    window.location.href=surl;
                }
                else
                {
                    window.open(surl); 
                }
                break;
            case "6":  //行情
                surl="/InfoCenter/Market/"+encodeURIComponent(txtKey)+"_Search.shtml";
                if(url.indexOf("infocenter")!=-1)
                {
                    window.location.href=surl;
                }
                else
                {
                    window.open(surl); 
                }
                break;
             case "7":    //报价
                surl="/InfoCenter/Price/"+encodeURIComponent(txtKey)+"_Search.shtml";
                if(url.indexOf("infocenter")!=-1)
                {
                    window.location.href=surl;
                }
                else
                {
                    window.open(surl); 
                }
                break;
        }
    }
    
}
//供应搜索
function SearchSupply()
{
    var url= document.URL.toLowerCase();
    var strKey=document.getElementById("txtkeyWord_1").value;
    if(strKey!="")
    {
        surl="/Trade/"+encodeURIComponent(strKey)+"_SupplySearch.shtml";
        if(url.indexOf("trade")!=-1)
        {
            window.location.href=surl;
        }
        else
        {
            window.open(surl); 
        }
    }
    else
    {
        alert('请输入您要搜索的关键字');
        document.getElementById("txtkeyWord_1").focus();
        return false;
    }
}
//求购搜索
function SearchBuy()
{
    var url= document.URL.toLowerCase();
    var strKey=document.getElementById("txtkeyWord_2").value;
    if(strKey!="")
    {
        surl="/Trade/"+encodeURIComponent(strKey)+"_BuySearch.shtml";
        if(url.indexOf("trade")!=-1)
        {
            window.location.href=surl;
        }
        else
        {
            window.open(surl); 
        }
    }
    else
    {
        alert('请输入您要搜索的关键字');
        document.getElementById("txtkeyWord_2").focus();
        return false;
    }
}
///////////////////////
 
 

 
 
//===========================================================求职招聘头部模块搜索功能================================================
//旧版数据库的定型和表设计的不一致造成了新版搜索方面的开发冗杂,详细代码业务逻辑原理请参考SawJobQZ\SawJobZP表－－Tiansoft(20080508)

function SearchJobCenter()
{
  
  //获取搜索对象的索引
  var SearchHref; 

  //引用职业分类控件、地点分类控件、发布日期控件、关键字控件
  var objBigWorkSort=document.getElementById("selectBigWorkSort"); // document.all.selectBigWorkSort;
  var objSmallWorkSort=document.getElementById("selectSmaillWorkSort"); //document.all.selectSmaillWorkSort;
  var objBigAddressSort=document.getElementById("selectBigProvince"); //document.all.selectBigProvince;
  var objSmallAddressSort=document.getElementById("selectSmallCity"); //document.all.selectSmallCity;
  var objSendDate=document.getElementById("selectDay");  //document.all.selectDay;
  var objtxtKey=document.getElementById("txtkey");  //document.all.txtkey;
  
  //获取职业大类－－－Text、Value
  
  
  var BigWorkText=objBigWorkSort.options[objBigWorkSort.selectedIndex].text;
  var BigWorkValue=objBigWorkSort.options[objBigWorkSort.selectedIndex].value;
  
  //获取职业小类－－－Text、Value
  var SmallWorkText=objSmallWorkSort.options[objSmallWorkSort.selectedIndex].text;
  var SmallWorkValue=objSmallWorkSort.options[objSmallWorkSort.selectedIndex].value;;
  
  //获取地点大类－－－Text、Value
  var BigAddressText=objBigAddressSort.options[objBigAddressSort.selectedIndex].text;
  var BigAddressValue=objBigAddressSort.options[objBigAddressSort.selectedIndex].value;
  
  
  //获取地点小类－－－Text、Value
  var SmallAddressText=objSmallAddressSort.options[objSmallAddressSort.selectedIndex].text;
  var SmallAddressValue=objSmallAddressSort.options[objSmallAddressSort.selectedIndex].value;
  
  //获取发布时间
  var SendDay=objSendDate.options[objSendDate.selectedIndex].value;
  
  //获取关键字控件的值
  var Skey=objtxtKey.value;
  
  var urlLink=document.URL.toLowerCase();

  
  if(document.getElementById("rdbZP").checked==true)
  {
  //Sort1       Sort2  计算机类    编程    City1    City2   福建     厦门
    
      SearchHref="/Job/"+BigWorkValue+"_"+SmallWorkValue+"_"+encodeURIComponent(BigAddressText)+"_"+encodeURIComponent(SmallAddressText)+"_"+SendDay+"_"+encodeURIComponent(Skey)+"CompanyZPSearch.shtml";
     if(urlLink.indexOf("companyzpsearch")!=-1)
  {
   window.location.href=SearchHref;
  }
  else
  {
   window.open(SearchHref);
  }
  
 
  }
  else
  {
  //SawJob1  SawJob2   2        8    SawWorkAdd1   SawWorkAdd2   陕西          四川
      SearchHref="/Job/"+BigWorkValue+"_"+SmallWorkValue+"_"+encodeURIComponent(BigAddressText)+"_"+encodeURIComponent(SmallAddressText)+"_"+SendDay+"_"+encodeURIComponent(Skey)+"PersonSearch.shtml";
     
      
     if(urlLink.indexOf("personsearch")!=-1)
  {
      window.location.href=SearchHref;
  }
  else
  {
   window.open(SearchHref);
  }
  
 }
  

   
  
  
}

//=====================================================================头部及时供求信息
//发送头部及时供求加载的请求信息
function GetTopFreeScaInfo(TagID)
{
  
  var objHttp=CreateXmlhttpIndex();
  
    var url = "/js/FrontPage.aspx?Action=toploadfreescainfo&Time="+Math.random();
     objHttp.open("GET", url, true);    
     objHttp.setRequestHeader("Cache-Control","no-cache"); 
     objHttp.send(null);
     objHttp.onreadystatechange =function(){ 


    if (objHttp.readyState == 4 && objHttp.status==200)
    {
   
      var result=objHttp.responseText;
      
      if(result!="")
      {
   
        document.getElementById(TagID).innerHTML=result;
      }     

    }
 
   }    
 

}


//=====================================================================控制首页对各个类似TabControl进行控制
function OnmouseoverShow(TagName,DivTag)
{
if(TagName=="M001")  //名人名企----编号M001
{
   document.getElementById("Index_MingQi").style.display ="none";
   document.getElementById("Index_MingRen").style.display ="none";
   document.getElementById(DivTag).style.display ="block";
}  
 
 if(TagName=="ZJ001")//制锯行业五个标签----编号WT001
 {
   document.getElementById("Index_TradeZJGY").style.display ="none";
   document.getElementById("Index_TradeZJQG").style.display ="none";
   document.getElementById(DivTag).style.display ="block";
 
 }
 
  
 if(TagName=="WT001")  //木工机械及配件商机五个标签---编号WT001
 {
   document.getElementById("Index_TradeWTGY").style.display ="none";
   document.getElementById("Index_TradeWTQG").style.display ="none";
   document.getElementById(DivTag).style.display ="block";
 
 }
 
 
 if(TagName=="GT001")  //农业园林机械商机五个标签----编号GT001
 {
    document.getElementById("Index_TradeGTGY").style.display ="none";
   document.getElementById("Index_TradeGTQG").style.display ="none";
   document.getElementById(DivTag).style.display ="block";
 }
  
}

function ChangeTradeClass(TagName,DivTag,classAllName,className)
{

if(TagName=="ZJ001")
{

document.getElementById("DivSortTrade_11").setAttribute("class",classAllName);
document.getElementById("DivSortTrade_11").setAttribute("className",classAllName);

document.getElementById("DivSortTrade_12").setAttribute("class",classAllName);
document.getElementById("DivSortTrade_12").setAttribute("className",classAllName);


DivTag.setAttribute("class",className);
DivTag.setAttribute("className",className);

}


if(TagName=="WT001")
{

document.getElementById("DivSortTrade_21").setAttribute("class",classAllName);
document.getElementById("DivSortTrade_21").setAttribute("className",classAllName);

document.getElementById("DivSortTrade_22").setAttribute("class",classAllName);
document.getElementById("DivSortTrade_22").setAttribute("className",classAllName);

DivTag.setAttribute("class",className);
DivTag.setAttribute("className",className);

}

 if(TagName=="GT001")  
 {
 
 document.getElementById("DivSortTrade_31").setAttribute("class",classAllName);
document.getElementById("DivSortTrade_31").setAttribute("className",classAllName);

document.getElementById("DivSortTrade_32").setAttribute("class",classAllName);
document.getElementById("DivSortTrade_32").setAttribute("className",classAllName);

DivTag.setAttribute("class",className);
DivTag.setAttribute("className",className);
 
 }




}




