﻿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];
                    document.getElementById("divCustomer").innerHTML = arr[1];
                }
            }
        }
    }
}
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) {
                if (xmlHttp.responseText == "yes") {
                    showRet();
                }
            }
        }
    }
}
function submitApplication(companyname, linkman, linktel, onlinecontact, title, loginname, password, size, trade, address, why, product, source, description, uid, userTel, appId, refer) {
    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) + "&UserTel=" + userTel + "&UID=" + uid + "&AppId=" + appId + "&Refer=" + refer + "&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, type, version, year, limitusers, limitforms, 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) + "&Type=" + escape(type) + "&Version=" + escape(version) + "&LimitUsers=" + escape(limitusers) + "&LimitForms=" + limitforms + "&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) {
                if (xmlHttp.responseText == "yes") {
                    showRet();
                }
            }
        }
    }
}
function submitVote(value) {
    if (xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    var url = "code/SubmitVote.aspx?Value=" + escape(value) + "&Rnd=" + getRndParam();
    xmlHttp.open("get", url, true);
    xmlHttp.send(null);
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200) {
                if (xmlHttp.responseText == "yes") {
                    showRet();
                }
            }
        }
    }
}
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://www.zkcrm.com/cia/login.aspx?AliEntry=0&AppId=" + txtCompany.value + "&LoginName=" + txtLoginName.value + "&Password=" + pwd;
            }
        }
    }
}
function ShowTel() {
    if (GetUrlValue("tel") != null) {
        var s = "3799019|3698028|3799021|3799025|3799028|3698029|3799022|3799026|3799016|3799018|3799015|3799020|0579-83908868|021-65128159|020-38108951";
        var ok = false;
        var v = GetUrlValue("tel");
        var k = s.split("|");
        for (var i = 0; i < k.length; i++) {
            if (v == k[i]) {
                ok = true;
                break;
            }
        }
        if (ok) {
            if (v.indexOf("-") <= 0)
                v = "0592-" + v;
            lblTel2.innerText = v + " ";
        }
    }
}
function PageTarget(pageName) {
    var s = "";
    if (GetUrlValue("tel") != null) {
        s = "?tel=" + GetUrlValue("tel");
    }
    document.location = pageName + s;
}

function setCookie(name, value) {
    var exp = new Date();
    exp.setTime(exp.getTime() + 24 * 60 * 60 * 1000);
    document.cookie = name + "= " + escape(value) + ";expires= " + exp.toGMTString();
} 

function GetCookieVal(offset) {
    var endstr = document.cookie.indexOf(";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return GetCookieVal(j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}
function DeleteCookie(name) {
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval = GetCookie(name);
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
