﻿function GetCustomer(getTop)
{
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    xmlHttp.open("get","code/GetCustomer.aspx?GetTop=" + getTop + "&Rnd=" + getRndParam(), true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                document.getElementById("divCustomer").innerHTML = xmlHttp.responseText;
             }
        }
    }
}
function GetKnowledge()
{
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    xmlHttp.open("get","code/GetKnowledge.aspx?Rnd=" + getRndParam(), true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                document.getElementById("divKnowledge").innerHTML = xmlHttp.responseText;
             }
        }
    }
}
function GetProductPrice()
{
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    xmlHttp.open("get","code/GetPrice.aspx?Rnd=" + getRndParam(), true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                var arr =  xmlHttp.responseText.split("|");
                document.getElementById("txtSetupPrice").value = arr[0];
                document.getElementById("txtOnlinePrice").value = arr[1];
             }
        }
    }
}
function GetMessage()
{
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    xmlHttp.open("get","code/GetMessage.aspx?Rnd=" + getRndParam(), true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                document.getElementById("divMessage").innerHTML = xmlHttp.responseText;
             }
        }
    }
}
function GetNews(getTop, year)
{
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    xmlHttp.open("get","code/GetNews.aspx?GetTop=" + getTop + "&Year=" + year + "&Rnd=" + getRndParam(), true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                document.getElementById("divNews").innerHTML = xmlHttp.responseText;
             }
        }
    }
}
function GetTopInfo()
{
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    xmlHttp.open("get","code/GetTopInfo.aspx?Rnd=" + getRndParam(), true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                var s = xmlHttp.responseText;
                if(s != "")
                {      
                    var arr = s.split("<sep>");
                    document.getElementById("divNews").innerHTML = arr[0];
                } 
             }
        }
    }
}
function GetNewsView(id)
{
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    xmlHttp.open("get","code/GetNews_View.aspx?Id=" + id + "&Rnd=" + getRndParam(), true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                document.getElementById("divNews").innerHTML = xmlHttp.responseText;
             }
        }
    }
}
function GetKnowledgeView(id)
{
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    xmlHttp.open("get","code/GetKnowledge_View.aspx?Id=" + id + "&Rnd=" + getRndParam(), true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                document.getElementById("divKnowledge").innerHTML = xmlHttp.responseText;
             }
        }
    }
}
function submitAgent(companyname, size, trade, site, address, linkman, linktel, salecount, marketing, succeedcase, agentproduct, agenttype, source, description)
{
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    var url = "code/SubmitAgent.aspx?CompanyName=" + escape(companyname) + "&Size=" + escape(size) + "&Trade=" + escape(trade) + "&Site=" + escape(site) + "&Address=" + escape(address) + "&Linkman=" + escape(linkman) + "&LinkTel=" + escape(linktel) + "&SaleCount=" + escape(salecount) + "&Marketing=" + escape(marketing) + "&SucceedCase=" + escape(succeedcase) + "&AgentProduct=" + escape(agentproduct) + "&AgentType=" + escape(agenttype) + "&Source=" + escape(source) + "&Description=" + escape(description) + "&Rnd=" + getRndParam();
    xmlHttp.open("get", url, true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                showRet(xmlHttp.responseText);
             }
        }
    }
}
function submitApplication(companyname,linkman,linktel,onlinecontact, title, loginname, password, size, trade, address, why, product, source, description)
{
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    var url = "code/SubmitApplication.aspx?CompanyName=" + escape(companyname) + "&Linkman=" + escape(linkman) + "&LinkTel=" + escape(linktel) + "&OnlineContact=" + escape(onlinecontact) + "&Title=" + escape(title) + "&LoginName=" + escape(loginname) + "&Password=" + escape(password) + "&Size=" + escape(size) + "&Trade=" + escape(trade) + "&Address=" + escape(address) + "&Why=" + escape(why) + "&Product=" + escape(product) + "&Source=" + escape(source) + "&Description=" + escape(description) + "&Rnd=" + getRndParam();
    xmlHttp.open("get", url, true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                showRet(xmlHttp.responseText);
             }
        }
    }
}
function submitOrder(companyname,linkman,linktel,onlinecontact, title, address, description)
{
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    var url = "code/SubmitOrder.aspx?CompanyName=" + escape(companyname) + "&Linkman=" + escape(linkman) + "&LinkTel=" + escape(linktel) + "&OnlineContact=" + escape(onlinecontact) + "&Title=" + escape(title) + "&Address=" + escape(address) + "&Description=" + escape(description) + "&Rnd=" + getRndParam();
    xmlHttp.open("get", url, true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                showRet(xmlHttp.responseText);
             }
        }
    }
}
function submitMessage(name, tel, message)
{
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    var url = "code/SubmitMessage.aspx?Name=" + escape(name) + "&Tel=" + escape(tel) + "&Message=" + escape(message) + "&Rnd=" + getRndParam();
    xmlHttp.open("get", url, true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                showRet(xmlHttp.responseText);
             }
        }
    }
}
var xmlHttp = null;
function CreateXMLHttpRequest()
{
   // Initialize Mozilla XMLHttpRequest object
   if (window.XMLHttpRequest)
   {
       xmlHttp = new XMLHttpRequest();
   }
   // Initialize for IE/Windows ActiveX version
   else if (window.ActiveXObject)
   {
       try
       {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
        } 
       catch (e)
       {
                try
                {
                     xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }  
                catch(e)
                {
                     alert('对不起，您的浏览器不支持XMLHttpRequest对像！');
                }
          }   
   }
   return xmlHttp;
}
function getRndParam()
{
    var rnd=  new Date().getTime();
    return rnd;
}
function GetUrlValue(name){ 
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i"); 
    var r = window.location.search.substr(1).match(reg); 
    if (r!=null) 
        return unescape(r[2]); 
    return null; 
}
function clearNoNum(obj)
{
    var v = obj.value;
    var j = 0; 
    for(var i = 0; i < v.length; i++)
    {
        if(v.charAt(i) == '0')
             j++;
        else
            break;  
    }
    obj.value = obj.value.substring(j);
    obj.value = obj.value.replace(/[^\d.]/g,"");
    obj.value = obj.value.replace(/^\./g,"");
    obj.value = obj.value.replace(/\.{2,}/g,".");
    obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
    if(obj.value == "")
        obj.value = "0";
}
function OpenWindow(url, wndName, width, height)
{
    var left,top,features,wnd;
    if(width == 0 && height==0) {
        features =
        'width=' + width + 'px,' +
        'height=' + height + 'px,' +
        'status=1, scrollbars=1, resizable=1';
        wnd = window.open(url, wndName, features);        wnd.moveTo(0,0) 
        wnd.resizeTo(screen.availWidth,screen.availHeight) 
    }
    else
    {
        left =  Math.ceil((window.screen.availWidth - width) / 2); 
        top =  Math.ceil((window.screen.availHeight - height) / 2);
        if(top >= 30)
            top -= 30;  
        features =
            'width=' + width + 'px,' +
            'height=' + height + 'px,' +
            'left=' + left + 'px,' +
            'top=' + top + 'px,' +
            'status=1, scrollbars=1, resizable=1';
        wnd = window.open(url, wndName, features);
        wnd.focus(); 
    }   
}
function login()
{
    if(txtCompany.value == "")
    {
         alert("请填写公司帐号！");
        return;  
   }
    if(txtLoginName.value == "")
    {
         alert("请填写登录帐号！");
        return;  
   }
    if(txtPassword.value == "")
   {
        alert("请填写密码！");
        return;  
   }
    if(xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    xmlHttp.open("get","../Descrypt.aspx?UrlPassword=" + txtPassword.value + "&Rnd=" + getRndParam(), true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
             if(xmlHttp.status==200)
             {
                var pwd = xmlHttp.responseText;
                location.href="http://oa.golongsoft.com/oa/login.aspx?AliEntry=0&AppId=" + txtCompany.value + "&LoginName=" + txtLoginName.value + "&Password=" + pwd;
             }
        }
    }
}