﻿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("divNews2").innerHTML = arr[1];
                    document.getElementById("divCustomer").innerHTML = arr[2];
                }
            }
        }
    }
}
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, imply, userName, Email) {
    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 + "&Imply=" + imply + "&UserName=" + userName + "&Email="+Email + "&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, description, pd) {
    if (xmlHttp == null)
        xmlHttp = CreateXMLHttpRequest();
    var url = "code/SubmitOrder.aspx?CompanyName=" + escape(companyname) + "&Linkman=" + escape(linkman) + "&LinkTel=" + escape(linktel) + "&Description=" + escape(description) + "&Pd=" + escape(pd) + "&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;
                if (txtCompany.value.toLowerCase() == "media") {
                    location.href = "http://61.152.108.35:8090/Login.aspx?LoginName=" + txtLoginName.value + "&Password=" + pwd;
                }
                else
                    location.href = "http://www.zkcrm.com/cia/login.aspx?AliEntry=0&AppId=" + txtCompany.value + "&LoginName=" + txtLoginName.value + "&Password=" + pwd;
            }
        }
    }
}
function ShowTel() {
    var ok = false;
    if (GetUrlValue("tel") != null) {
        var v = "";
        var k1 = ["3799020", "3799015", "3799025", "3799028", "3799021", "3799018", "3698028", "3698029", "3799016", "18721668960", "知客CRM", "13521842962", "3799019", "3799017"];
        var k2 = ["pf", "yh", "yx", "bb", "ww", "rf", "gw", "my", "ql", "ss", "zkcrm", "cb", "xl","wl"];
        var t = 0;
        var p = GetUrlValue("tel");
        for (var i = 0; i < k1.length; i++) {
            if (p == k1[i]) {
                ok = true;
                t = i;
                break;
            }
        }
        if (ok) {
            if (k1[t].length == 11)
                v = k1[t];
            else if (k1[t].length == 4)
                v = k1[t];
            else
                v = "0592-" + k1[t];
            lblTel2.innerText = v;
        }
    }
    else if (GetUrlValue("p") != null) {
        var v = "";
        var k1 = ["3799020", "3799015", "3799025", "3799028", "3799021", "3799018", "3698028", "3698029", "3799016", "18721668960", "知客CRM", "13521842962", "3799019", "3799017"];
        var k2 = ["pf", "yh", "yx", "bb", "ww", "rf", "gw", "my", "ql", "ss", "zkcrm", "cb", "xl","wl"];
        var t = 0;
        var p = GetUrlValue("p");
        for (var i = 0; i < k2.length; i++) {
            if (p == k2[i]) {
                ok = true;
                t = i;
                break;
            }
        }
        if (ok) {
            if (k1[t].length == 11)
                v = k1[t];
            else if (k1[t].length == 4)
                v = k1[t];
            else
                v = "0592-" + k1[t];
            lblTel2.innerText = v;
        }
    }
}

function ShowK3() {
    var ok = false;
    if (GetUrlValue("p") != null) {
        var v = "";
        var k1 = ["3799020", "3799015", "3799025", "3799028", "3799021", "3799018", "3698028", "3698029", "3799016", "18721668960", "知客CRM", "13521842962", "3799019", "3799017"];
        var k2 = ["pf", "yh", "yx", "bb", "ww", "rf", "gw", "my", "ql", "ss", "zkcrm", "cb", "xl", "wl"];
        var k3 = ["鹏飞", "永华", "知客CRM", "李珊珊", "三万", "小胡", "国文", "少彬", "肖处", "上海升晟科技", "知客", "北京才博", "小林", "王琳"];
        var t = 0;
        var p = GetUrlValue("p");
        for (var i = 0; i < k2.length; i++) {
            if (p == k2[i]) {
                ok = true;
                t = i;
                break;
            }
        }
        if (ok) {
            v = k3[t];
            Label1.innerText = escape(v);
        }
    }
    else if (GetUrlValue("tel") != null) {
        var v = "";
        var k1 = ["3799020", "3799015", "3799025", "3799028", "3799021", "3799018", "3698028", "3698029", "3799016", "18721668960", "知客CRM", "13521842962", "3799019", "3799017"];
        var k2 = ["pf", "yh", "yx", "bb", "ww", "rf", "gw", "my", "ql", "ss", "zkcrm", "cb", "xl", "wl"];
        var k3 = ["鹏飞", "永华", "知客CRM", "李珊珊", "三万", "小胡", "国文", "少彬", "肖处", "上海升晟科技", "知客", "北京才博", "小林", "王琳"];
        var t = 0;
        var p = GetUrlValue("tel");
        for (var i = 0; i < k1.length; i++) {
            if (p == k1[i]) {
                ok = true;
                t = i;
                break;
            }
        }
        if (ok) {
            v = k3[t];
            Label1.innerText = escape(v);
        }
    }
}


function PageTarget(pageName) {
    var s = "";
    if (GetUrlValue("tel") != null) {
        s = "?tel=" + GetUrlValue("tel");
    }
    else if (GetUrlValue("p") != null) {
        s = "?p=" + GetUrlValue("p");
    }
    if (GetUrlValue("imply") != null) {
        s += "&imply=" + GetUrlValue("imply");
    }
    else if (GetUrlValue("i") != null) {
        s += "&i=" + GetUrlValue("i");
    }
    pageName.href = pageName + s;
    return true;
}
function PageTarget1(pageName) {
    var s = "";
    if (GetUrlValue("tel") != null) {
        s = "?tel=" + GetUrlValue("tel");
    }
    else if (GetUrlValue("p") != null) {
        s = "?p=" + GetUrlValue("p");
    }
    if (GetUrlValue("imply") != null) {
        s += "&imply=" + GetUrlValue("imply");
    }
    else if (GetUrlValue("i") != null) {
        s += "&i=" + GetUrlValue("i");
    }
    open(pageName + s);
}
function PageTarget2(pageName) {
    open(pageName);
}
function PageTarget3(pageName) {
    document.location = pageName   
    return true;
}
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();
}
