﻿function GetObj(s) {
    return document.getElementById(s);
}
function SetCookie(name, value) {
    var expdate = new Date();
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    if (expires != null) expdate.setTime(expdate.getTime() + (expires * 1000));
    document.cookie = name + "=" + escape(value) + ((expires == null) ? "" : ("; expires=" + expdate.toGMTString()))
			+ ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain))
			+ ((secure == true) ? "; secure" : "");
}
function GetCookie(sName) {
    var aCookie = document.cookie.split("; ");
    for (var i = 0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
            return unescape(aCrumb[1]);
    }
    return null;
}
function GetUserName() {
    var uid = GetCookie("userid");
    var unm = GetCookie("jcusername");
    if (uid == null || uid == "") {
        //	GetObj('liwlc').style.display="none";		
        GetObj('lilg').style.display = "";
        GetObj('lirg').style.display = ""
    }
    else {
        if (unm != null && unm != undefined && unm != "") {
            GetObj('lilg').style.display = "none";
            GetObj('lirg').style.display = "none";
            var wlc = GetObj('liwlc');
            var wlc2 = GetObj('liwlc2');
            var wlc3 = GetObj('liwlc3');
            var url = document.location;
            wlc.style.display = "";
            wlc.innerHTML = "<strong>" + unm + "</strong>" + "&nbsp;您好!&nbsp;"
            wlc2.innerHTML = "";
            wlc3.innerHTML = "<a href='http://www.jctrans.com/office/login.html?flag=1&forward=" + url + "' class='a2'>退出登录</a>"
        }
        else {
            GetObj('liwlc').style.display = "none";
            GetObj('liwlc2').style.display = "none";
            GetObj('liwlc3').style.display = "none";
            GetObj('lilg').style.display = "";
            GetObj('lirg').style.display = ""
        }
    }
}

function Ustitle() {
    var uid = GetCookie("userid");
    var um = GetCookie("jcusername");

    var furl = document.location;
    var userstatus = GetCookie("userstatus");
    var islg = GetCookie("islg");
    var ut = GetObj("dvustitle");

    if (ut == null) {
        return;
    }

    var content = "进入我的办公室";
    var officeurl = "http://www.jctrans.com/office/index.html";
    if ((userstatus != null && typeof (userstatus) != 'undefined' && userstatus == 1) || (islg != null && typeof (islg) != 'undefined' && islg != 0)) {
        content = "进入我的微博";
        officeurl = "http://t.jctrans.com/Home"
    }

    if (uid != null && typeof (uid) != 'undefined' && um != null && typeof (um) != 'undefined') {
        ut.innerHTML = "<ul class=\"shoudao\"><li class=\"user-info\"><strong>" + um + "</strong> ,欢迎来到锦程物流网</li><li class=\"use_alink\"><a href='" + officeurl + "' target='_blank'>" + content + "</a></li><li class=\"use_alink\"><a href='http://www.jctrans.com/office/login.html?flag=1&forward=" + furl + "'>退出</a></li></ul>";
    }
    else {
        ut.innerHTML = "<ul class=\"shoudao\"><li class=\"logininput\"><input type=\"text\" name=\"logname\" value=\"请输入用户名\" id=\"logusername\" onfocus=\"TxtString(this,'请输入用户名')\" onblur=\"TxtString(this,'请输入用户名')\"  onkeydown=\"PageLogin13()\"/><input type=\"password\" name=\"psd\" value=\"请输入密码\" id=\"logpassword\" onfocus=\"TxtString(this,'请输入密码')\" onblur=\"TxtString(this,'请输入密码')\" onkeydown=\"PageLogin13()\"/></li><li class=\"dl\"><a href=\"http://www.jctrans.com/login.html\" id=\"alogin\" onclick=\"return PageLogin()\" >登录</a></li><li class=\"zc\"><a href=\"http://t.jctrans.com/Login/ComRegister\" target=\"_blank\">免费注册</a></li></ul>";
    }
}
Ustitle();
function PageLogin() {
    var un = RemoveSp(Trim(GetObj("logusername").value));
    var up = RemoveSp(Trim(GetObj("logpassword").value));
    if ((un != "" && up != "") && un != "请输入用户名" || up != "请输入密码") {

        GetObj("alogin").href = "http://www.jctrans.com/login.html?loginun=" + escape(un) + "&loginpw=" + escape(up);
    }
    else {
        GetObj("alogin").href = "http://www.jctrans.com/login.html";
    }
    return true;
}
function PageLogin13() {
    var c = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
    if (c == 13) { GetObj("alogin").click(); }
}
function Trim(inputString) {
    return inputString.replace(/^ +/, "").replace(/ +$/, "");
}
function RemoveSp(str) {
    var re = /(!)|(@)|(&amp)|(#)|,|'|(\^)|(\$)|(\.)|(\*)|(\")|(\|)|(\-)/gim
    str = str.replace(re, "");
    return str;
}
function TxtString(obj, s) {
    var os = Trim(obj.value);
    if (os == s) { obj.value = ''; }
    else if (os == '') { obj.value = s; }
}
function ReTxtString(obj, s) {
    var os = Trim(obj.value);
    if (os == s) { return ""; }
    else { return obj.value; }
}
function Showweek() {
    var now = new Date();
    if (now.getDay() == 0) { return ("星期日"); }
    if (now.getDay() == 1) { return ("星期一"); }
    if (now.getDay() == 2) { return ("星期二"); }
    if (now.getDay() == 3) { return ("星期三"); }
    if (now.getDay() == 4) { return ("星期四"); }
    if (now.getDay() == 5) { return ("星期五"); }
    if (now.getDay() == 6) { return ("星期六"); }
}
function Showdate() {
    var now = new Date()
    var year = now.getYear()
    var month = now.getMonth() + 1
    var day = now.getDate()
    return year + "年" + month + "月" + day + "日"
}
if (document.getElementById("ql-pop-txt")) {
    var txt = document.getElementById("ql-pop-txt");
    if (txt.innerHTML == "") {
        txt.innerHTML = "<li><a href=\"http://gcp.jctrans.com\" target=\"_blank\">国际信誉通(GCP)</a></li><li><a href=\"http://cpf.jctrans.com/\" target=\"_blank\">采购通(CPF)系统</a></li><li><a href=\"http://www.jctrans.com/lh/zhuanti/02_01_05.htm\" target=\"_blank\">专业服务商</a></li><li><a href=\"http://www.jctrans.com/lh/zhuanti/02_01_06.htm\" target=\"_blank\">庄家</a></li><li><a href=\"http://www.jctrans.com/adservice/index.htm\" target=\"_blank\">广告</a></li><li><a href=\"http://webim.jctrans.com/wlt/index.htm\" target=\"_blank\">物流通</a></li><li><a href=\"http://www.jctrans.com/2010/phone/\" target=\"_blank\">手机揽货</a></li><li>";
    }
}
function showdiv(obj) {
    document.getElementById(obj).style.display = "block";
}
function closediv(obj) {
    document.getElementById(obj).style.display = "none";
}
function QueryString(fieldName) {
    var urlString = document.location.search;
    if (urlString != null) {
        var typeQu = fieldName + "=";
        var urlEnd = urlString.indexOf(typeQu);
        if (urlEnd != -1) {
            var paramsUrl = urlString.substring(urlEnd + typeQu.length);
            var isEnd = paramsUrl.indexOf('&');
            if (isEnd != -1) {
                return paramsUrl.substring(0, isEnd);
            }
            else {
                return paramsUrl;
            }
        }
        else {
            return null;
        }
    }
    else {
        return null;
    }
}
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != "function") { window.onload = func; } else { window.onload = function () { oldonload(); func(); } };
}
