﻿
//提示层
function redirct()
{
    self.location.href="base_tc.aspx";
}
function closediv()
{
   if(g("messagediv")!=null)
    g("messagediv").style.display="none";
else
    g("Bottom1_messagediv").style.display="none";
}
//中间其他搜索项
function searchOther(locUrl)
{
    var locUrl = location.protocol + '//' + location.host + location.pathname;
    var p=g("province_slt").value;
    var c=g("selCity").value;
    var t=g("posttime_value").value;
    var m=g("membertype").value;
    var s=g("sorttype").value; 
    var url="company/sendToServer/assServer.ashx?locUrl="+locUrl+"&province_slt="+p+"&selCity="+c+"&posttime_value="+t+"&membertype="+m+"&sorttype="+s+"&method=searchother&temp="+Math.random();
    sendToServerRedirect(url);
}

//首页搜索 四项
function search(txtid)
{
    if(g(txtid).value==""||g(txtid).value=="请输入您要查询的关键词")
    {
       g(txtid).value="请输入您要查询的关键词"; 
        return false;
    }   
    var url;
    if(txtid=="gy") //供应
    {
        url="supply.aspx";
    }
     if(txtid=="qg") //求购
    {
        url="buy.aspx";
    }
     if(txtid=="gs") //公司
    {
        url="enterprise.aspx";
    }
     if(txtid=="zx") //资讯
    {
        url="news.aspx";
    }
    url="company/sendToServer/assServer.ashx?url="+url+"&key="+g(txtid).value+"&method=redirect&temp="+Math.random();
    sendToServerRedirect(url,txtid,g(txtid).value);
    //self.location.href=url;
}
// JScript 文件 在线留言。。
function   URLEncode(strURL)   
  {   
  var   strSpecialUrl   =   "   <>\"#%{}|^[]`&?+";   
  var   strEncode="";   
  var   i,   j,   chUrl,   iCode,   iCodeBin,   num;   
  var   tempBin;   
  var   leadingzeros;   
    
  strURL+="";   
  for   (i=0;   i<strURL.length;   i++)   {   
  chUrl   =   strURL.charAt(i);   
  iCode   =   chUrl.charCodeAt(0);   
  if   (iCode<=parseInt("0x7F"))   {   
  if   (strSpecialUrl.indexOf(chUrl)!=-1)   {   
  //chUrl   is   a   special   character   that   needs   to   be   Url   encoded   
  strEncode+="%"+iCode.toString(16).toUpperCase();   
  }   else   {   
  //otherwise   chrUrl   is   normal   
  strEncode+=chUrl;   
  }   
  }   else   {   
  leadingzeros="";   
  iCodeBin=iCode.toString(2)   
  if   (iCode<=parseInt(0x7FF))   {   
  //glyph   is   represented   by   two   chars   
    
  //check   leading   zeros   on   iCodeBin   (should   be   11   digits)   
  for   (j=11;   j>iCodeBin.length;   j--)   leadingzeros+="0";   
  iCodeBin=leadingzeros+iCodeBin   
    
  tempBin="110"+iCodeBin.substr(0,5);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(5,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  }   else   {   
  if   (iCode<=parseInt(0xFFFF))   {   
  //glyph   is   represented   by   three   chars   
    
  //check   leading   zeros   on   iCodeBin   (should   be   16   digits)   
  for   (j=16;   j>iCodeBin.length;   j--)   leadingzeros+="0";   
  iCodeBin=leadingzeros+iCodeBin   
    
  tempBin="1110"+iCodeBin.substr(0,4);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(4,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(10,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  }   else   {   
  if   (iCode<=parseInt(0x1FFFFF))   {   
  //glyph   is   represented   by   four   chars   
    
  //check   leading   zeros   on   iCodeBin   (should   be   21   digits)   
  for   (j=21;   j>iCodeBin.length;   j--)   leadingzeros+="0";   
  iCodeBin=leadingzeros+iCodeBin   
    
  tempBin="11110"+iCodeBin.substr(0,3);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(3,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(9,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(15,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  }   else   {   
  if   (iCode<=parseInt(0x3FFFFFF))   {   
  //glyph   is   represented   by   five   chars   
    
  //check   leading   zeros   on   iCodeBin   (should   be   26   digits)   
  for   (j=26;   j>iCodeBin.length;   j--)   leadingzeros+="0";   
  iCodeBin=leadingzeros+iCodeBin   
    
  tempBin="111110"+iCodeBin.substr(0,2);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(2,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(8,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(14,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(20,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  }   else   {   
  if   (iCode<=parseInt(0x7FFFFFFF))   {   
  //glyph   is   represented   by   six   chars   
    
  //check   leading   zeros   on   iCodeBin   (should   be   31   digits)   
  for   (j=31;   j>iCodeBin.length;   j--)   leadingzeros+="0";   
  iCodeBin=leadingzeros+iCodeBin   
    
  tempBin="1111110"+iCodeBin.substr(0,1);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(1,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(7,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(13,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(19,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  tempBin="10"+iCodeBin.substr(25,6);   
  strEncode+="%"+parseInt(tempBin,2).toString(16).toUpperCase()   
  }   
  }   
  }   
  }   
  }   
  }   
  }   
  return   strEncode;   
  }  
function AddFavorite(sURL, sTitle)
    {
        try
        {
            window.external.addFavorite(sURL, sTitle);
        }
        catch (e)
        {
            try
            {
                window.sidebar.addPanel(sTitle, sURL, "");
            }
            catch (e)
            {
                alert("加入收藏失败，请使用Ctrl+D进行添加");
            }
        }
    }
    function SetHome(obj,vrl)
    {
        try
        {
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
        }
        catch(e)
	    {
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                        } 
                        catch (e) { 
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }
    }
    function counter(clientUrl)
    {
    //alert(clientUrl);
        var url="../../company/sendToServer/zxlyServer.ashx?method=counter&url="+clientUrl+"&temp="+Math.random();
        sendToServerCounter(url);
    }
    function sendToServerCounter(url)
    {
        var xmlHttp=getXmlHttp();
        xmlHttp.open("get", url, true); 
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); 
        xmlHttp.send(null); 
        xmlHttp.onreadystatechange = function() //回调函数
        { 
            if (xmlHttp.readyState == 4) 
            { 
                if(xmlHttp.status==200) 
                { 
                    var response = xmlHttp.responseText;  
                    xmlHttp=null;      
                    g("counter").innerText=response;
                    //alert(response); 
                    //self.location.reload();
                } 
                else
                {
                    //alert(xmlHttp.status);
                    xmlHttp=null;
                    g("counter").innerText="读取中..";
                }
            } 
            else
            {
                
            }
        } 
    }
    
  function send()
    {
        if(g("txtZZJZLM_ID").value=="")
        {
            alert("当前系统暂不允许发布留言");
            return false;
        }
        if(g("txtZZJZBDNR_BT").value=="")
        {
            alert("请输入标题");
            return false;
        }
        if(g("txtZZJZBDNR_XM").value=="")
        {
            alert("请输入您的姓名");
            return false;
        }
        if(g("txtZZJZBDNR_YX").value=="")
        {
            alert("请输入您的邮箱");
            return false;
        }
        if(g("txtZZJZBDNR_DH").value=="")
        {
            alert("请输入您的联系电话");
            return false;
        }
        if(g("txtZZJZBDNR_NR").value=="")
        {
            alert("请输入您的留言内容");
            return false;
        }
        if(g("txtZZJZBDNR_NR").value.length>500)
        {
            alert("留言内容限制在500字以内");
            return false;
        }
        var url="../../company/sendToServer/zxlyServer.ashx?txtZZJZLM_ID="+g("txtZZJZLM_ID").value
            +"&txtZZJZBDNR_BT="+URLEncode(g("txtZZJZBDNR_BT").value)
            +"&txtZZJZBDNR_XM="+URLEncode(g("txtZZJZBDNR_XM").value)
            +"&txtZZJZBDNR_YX="+URLEncode(g("txtZZJZBDNR_YX").value)
            +"&txtZZJZBDNR_DH="+URLEncode(g("txtZZJZBDNR_DH").value)
            +"&txtZZJZBDNR_NR="+URLEncode(g("txtZZJZBDNR_NR").value)
            +"&method=zxly&temp="+Math.random();
        
        sendToServer(url);
        cleartxt("txtZZJZBDNR_BT");
        cleartxt("txtZZJZBDNR_XM");
        cleartxt("txtZZJZBDNR_YX");
        cleartxt("txtZZJZBDNR_DH");
        cleartxt("txtZZJZBDNR_NR");
    }
    function cleartxt(txtID)
    {
        g(txtID).value="";
    }
    function g(txtID)
    {
        return document.getElementById(txtID);
    }
    function sendToServer(url)
    {
        var xmlHttp=getXmlHttp();
        var param=url.substring(url.indexOf("?")+1,url.length);
        url=url.substring(0,url.indexOf("?"));    
        xmlHttp.open("post", url, true); 
        xmlHttp.setRequestHeader('Content-length', url.length);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); 
        xmlHttp.send(param);
    
        xmlHttp.onreadystatechange = function() //回调函数
        { 
            if (xmlHttp.readyState == 4) 
            { 
                if(xmlHttp.status==200) 
                { 
                    var response = xmlHttp.responseText;  
                    xmlHttp=null;
                    //alert(response); 
                    //self.location.reload();
                } 
                else
                {
                   // alert(xmlHttp.status);
                    xmlHttp=null;
                    alert(" 未知的错误,或与管理员联系!");
                }
            } 
        } 
}
//提交服务器。页面转向
 function sendToServerRedirect(url,txtid,values)
    {
        var xmlHttp=getXmlHttp();
        var param=url.substring(url.indexOf("?")+1,url.length);
        url=url.substring(0,url.indexOf("?"));    
        xmlHttp.open("post", url, true); 
        xmlHttp.setRequestHeader('Content-length', url.length);
        xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); 
        xmlHttp.send(param);
    
        xmlHttp.onreadystatechange = function() //回调函数
        { 
       // alert(xmlHttp.responseText);
            if (xmlHttp.readyState == 4) 
            { 
                if(xmlHttp.status==200||xmlHttp.status==0) 
                { 
                    var response = xmlHttp.responseText;  
                    xmlHttp=null;      
                    //alert(response); 
                    self.location.href=response;
                    //g(txtid).value=values;
                } 
                else
                {
                   // alert(xmlHttp.status);
                          xmlHttp=null;
                    alert(" 未知的错误,或与管理员联系!");
                }
            } 
            else
            {
                
            }
        } 
}
//获取xmlhttp 对象
function getXmlHttp() 
{ 
        var xmlHttp = false;  
         try 
         { 
           xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); 
         } 
         catch (e) 
         { 
               try 
               { 
                     xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
               } catch (e2) 
               { 
                     xmlHttp = false; 
               } 
         } 
         if (!xmlHttp && typeof XMLHttpRequest != 'undefined') 
         {  
                xmlHttp = new XMLHttpRequest();  
         } 
                return xmlHttp;  
}