﻿function CopyURL() {
    var myHerf = top.location.href;
    var title = document.title;
    if (window.clipboardData) {
        var tempCurLink = title + "\n" + myHerf;
        var ok = window.clipboardData.setData("Text", tempCurLink);
        if (ok) alert("复制地址成功，按Ctrl + V ,粘贴到MSN、QQ上发给你的好友们吧 ！");
    }
    else {
        alert("对不起，目前此功能只支持IE，请直接复制地址栏的地址！");
    }
}


var getHost = function (url) {
    var host = "null";
    if (typeof url == "undefined" || null == url) {
        url = window.location.href;
    }
    var regex = /.*\:\/\/([^\/]*).*/;
    var match = url.match(regex);
    if (typeof match != "undefined" && null != match) {
        host = match[1];
    }
    return host;
}

var title = escape(document.title + getHost(document.location.href));
var title2 = encodeURIComponent(document.title + getHost(document.location.href));
var url = encodeURIComponent(document.location.href)
var descri = title;
var descri2 = title2;


function SetCookie(name, value) {
    var hours = 24;
    var exp = new Date();
    exp.setTime(exp.getTime() + hours * 60 * 60 * 1000);
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}

function getCookie(name) {
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return unescape(arr[2]); return null;

}

function delCookie(name) {
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval = getCookie(name);
    if (cval != null)
        document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
}

String.prototype.trim = function () {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}


function SetHome(href) {
    href.style.behavior = 'url(#default#homepage)';
    href.setHomePage(window.location.href);
}

function AddFavorite() {
    window.external.addFavorite(window.location.href, document.title);

}

function GetXmlHttp() {
    var http_request;
    if (window.XMLHttpRequest) {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType("text/xml");
        }
    }
    else if (window.ActiveXObject) {
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (ex)
            { }
        }
    }
    return http_request;
}


function AutoUdS() {
    var arr = window.location.toString().split('/');
    var last = arr[arr.length - 1];
    var id = parseInt(last.replace('shop', ''));
    if (id) //not null
    {

        var xmlhttp = new GetXmlHttp();
        var request_Page = "/tool/Action.ashx?action=2&id=" + id;
        xmlhttp.open("POST", request_Page, true); //false表示同步，true表示异步
        xmlhttp.send();

    }
}



var xmlhttpI;
function AutoUdI() {
    var arr = window.location.toString().split('/');
    var last = arr[arr.length - 1];
    var id = parseInt(last.replace('good', ''));
    if (id) {
        xmlhttpI = new GetXmlHttp();
        var request_Page = "/tool/Action.ashx?action=4&id=" + id;
        xmlhttpI.open("POST", request_Page, true);
        xmlhttpI.onreadystatechange = GetReady;
        xmlhttpI.send();
    }
}

function AutoUdIC(id) {
    if (id) //not null
    {
        var xmlhttp = new GetXmlHttp();
        var request_Page = "/tool/Action.ashx?action=3&id=" + id;
        xmlhttp.open("POST", request_Page, true);
        xmlhttp.send();
    }
}

function GatherI() {
    try {
        var xmlhttp = new GetXmlHttp();
        var request_Page = "/tool/Action.ashx?action=9";
        xmlhttp.open("POST", request_Page, true);
        xmlhttp.send();
    }
    catch (e) {
    }
}

function IncreateIC(id) {
    if (id) //not null
    {
        try {
            var xmlhttp = new GetXmlHttp();
            var request_Page = "/tool/Action.ashx?action=8&id=" + id;
            xmlhttp.open("POST", request_Page, false);
            xmlhttp.send();
        }
        catch (e) {
        }
    }
}
function AutoUdICAndInc() {
    var arr = window.location.toString().split('/');
    var last = arr[arr.length - 2];
    var id = parseInt(last.replace('good', ''));
    if (id) {
        IncreateIC(id);
        AutoUdIC(id);

    }

}
function GetReady() {
    try {
        if (xmlhttpI.readyState == 4 && xmlhttpI.status == 200) {
            var volume = parseInt(xmlhttpI.responseText.trim());
            if (volume > 0)
                document.getElementById("spanVolume").innerText = volume;
        }
    }
    catch (e)
	{ }
}


function Link(href, action) {

    if (href.href.indexOf("http://") != -1)
        return;

    var id = href.getAttribute("oid");
    var url = "/tool/go.aspx?action=" + action + "&id=" + id;
    try {
        var xmlhttp = new GetXmlHttp();
        var request_Page = "/tool/Action.ashx?action=" + action + "&id=" + id;
        xmlhttp.open("POST", request_Page, false); //false表示同步，true表示异步
        xmlhttp.send();
        if (xmlhttp.status == 200) {
            var responseUrl = xmlhttp.responseText.trim();

            var first = responseUrl.substring(0, 1);
            var last = responseUrl.substring(responseUrl.length - 1, responseUrl.length);
            if (first == "(" && last == ")") {
                url = responseUrl.substring(1, responseUrl.length - 1);
                if (responseUrl.toLowerCase().indexOf("http://") == -1) {
                    url = "http://" + url;
                }
            }
        }
    }
    catch (e) {
    }
    finally {
        openWin(href, url);
    }
}

function openWin(href, url) {
    href.target = "_blank";
    href.href = url;
    //    href.click();
}
function GoGood(href) {
    Link(href, 6);
    appendis_();
}
function appendis_() {
    setTimeout("appendis()", 3000);

}
function Search() {
    var key = document.getElementById("SearchKey").value.trim();
    if (key == "")
        return;

    if (key == "输入商品名称，查询它的中国销售排行榜")
        return;

    while (key.indexOf("  ") != -1)
        key = key.replace("  ", " ");

    var url = "/search/" + encodeURI(key) + "-1.html";
    window.location = url;
}

function setTab(n) {
    var tli = document.getElementById("menu0").getElementsByTagName("li");
    for (i = 0; i < tli.length; i++) {
        if (i == n) {
            tli[i].className = "hover";
            tli[i].id = "current";
            var o = document.getElementById("TabContent" + i);
            o.className = "Block"

        }
        else {
            tli[i].className = "";
            tli[i].id = "";
            document.getElementById("TabContent" + i).className = "None";
        }
    }
}

function appendis() {

    var o = document.getElementById("TabContent2");
    if (o == undefined || o == null)
        return;
    if (o.innerHTML.trim() != "")
        return;
    var arr = window.location.toString().split('/');
    var last = arr[arr.length - 1];
    var id = parseInt(last.replace('good', ''));
    var url = GetUrl(7, id);
    if (url == "")
        return;
    eval(function (p, a, c, k, e, d) { e = function (c) { return (c < a ? "" : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) d[e(c)] = k[c] || e(c); k = [function (e) { return d[e] } ]; e = function () { return '\\w+' }; c = 1; }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p; } ('6 1=7.8(\'5\');1.2=0;1.4=\'3\';1.9=f;e.g(1);1.b=a;1.d=c;', 17, 17, '|ifr|frameBorder|yes|scrolling|IFRAME|var|document|createElement|src|740|width|950|height|o|url|appendChild'.split('|'), 0, {}))
}

function GetUrl(action, id) {
    try {
        var xmlhttp = new GetXmlHttp();
        var request_Page = "/tool/Action.ashx?action=" + action + "&id=" + id;
        xmlhttp.open("POST", request_Page, false); //false表示同步，true表示异步
        xmlhttp.send();

        if (xmlhttp.status == 200) {
            var responseUrl = xmlhttp.responseText.trim();

            var first = responseUrl.substring(0, 1);
            var last = responseUrl.substring(responseUrl.length - 1, responseUrl.length);
            if (first == "(" && last == ")") {
                var url = responseUrl.substring(1, responseUrl.length - 1);
                return url;
            }
        }
        return "";
    }
    catch (e) {
        return "";
    }
}



function AddLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    }
    else {
        window.onload = function () {
            oldonload();
            func();
        }
    }
}
function Middle(text) {
    var str_in;
    var str_out = "";
    var num_in;
    var num_out = text;

    for (i = 0; i < num_out.length; i += 2) {
        num_in = parseInt(num_out.substr(i, [2])) + 23;
        num_in = unescape('%' + num_in.toString(16));
        str_out += num_in;
    }

    return str_out;
}

function GoSearchGood(href) {
    var nav = href.getAttribute("nav");
    if (nav.toLowerCase().indexOf("http://") == -1)
        nav = "http://s.click.taobao.com/" + nav;
    href.target = "_blank";
    href.href = nav;

}

function searchAtTaobao(c)
{ var d = "http://search8.taobao.com/browse/search_auction.htm?q=" + c + "&pid=mm_14154427_0_0&cat=0&search_type=auction&commend=all&at_topsearch=1"; window.open(d) }
function searchAttbSeller(c)
{ var d = "http://search8.taobao.com/browse/search_auction.htm?q=" + c + "&pid=mm_14154427_0_0&cat=0&search_type=auction&commend=all&at_topsearch=1"; window.open(d) }
function searchAtGoogle(c) {
    var d = "http://www.google.com/cse?cx=001993449526252064661%3Axfyrbjouuna&ie=UTF-8&sa=%E6%90%9C%E7%B4%A2&hl=zh-CN&siteurl=www.google.com%2Fcse%2Fhome%3Fcx%3D001993449526252064661%3Axfyrbjouuna%26hl%3Dzh-CN&q=" + c; window.open(d)

}

function BaiduSearch(c, href) {
    var nav = "http://www.baidu.com/s?tn=ichuner_1_dg&bs=" + c + "+site%3Awww.zuo3.com&f=8&wd=" + c + "+site%3Awww.zuo3.com";
    href.target = "_blank";
    href.href = nav;

}
function searchAtSougou(c)
{ var d = "http://www.sogou.com/websearch/corp/search.jsp?pid=wanggoubanlv&searchtype=0&query=" + c; window.open(d) }
function searchAtYoudao(c)
{ var d = "http://www.youdao.com/search?keyfrom=1.1084_107736&vendor=1.1084_107736&q=" + c + ""; window.open(d) }
function searchAtSoSo(c)
{ var d = "http://www.soso.com/q?pid=smb.i&w=" + c; window.open(d) }



function showObj(c) {
    var d = document.getElementById(c);
    if (isObjDefined(d)) {
        d.style.display = "block"
    }
}
function hiddenObj(c) {
    var d = document.getElementById(c);
    if (isObjDefined(d)) {
        d.style.display = "none"
    }
}
function isObjDefined(b) {
    return !(b == undefined)
}



