function recGetDomain() {
    var RecCurrentUrl = location.href;
    if (/360buy\.com/.test(RecCurrentUrl)) {
        return "jd.com";
    }
    if (/jd\.com/.test(RecCurrentUrl)) {
        return "jd.com";
    }
};
var RecRecommendCorrentDomain = recGetDomain();
function GetWarePriceimg(sku) {
    return "<img  onerror=\"this.src='http://www."+RecRecommendCorrentDomain+"/images/no1.gif'\" src=\"http://jprice.360buyimg.com/price/gp" + sku + "-1-1-1.png\" />";
}
function getPuoductlink(sku) {
    if (sku > 10000000 && sku < 20000000) {
        return "http://book."+RecRecommendCorrentDomain+"/" + sku + ".html";
    }
    else if (sku > 20000000 && sku < 30000000) {
        return "http://mvd."+RecRecommendCorrentDomain+"/" + sku + ".html";
    }
    else {
        return "http://item.jd.com/" + sku + ".html";
    }
}
function GetImgMasterUrl(wid, Folder) {
    var domain = 10;
    switch (wid % 5) {
        case 0:
            domain = 10;
            break;
        case 1:
            domain = 11;
            break;
        case 2:
            domain = 12;
            break;
        case 3:
            domain = 13;
            break;
        case 4:
            domain = 14;
            break;
        default:
            domain = 10;
            break;
    }
    return "http://img" + domain + ".360buyimg.com/" + Folder + "/";
}
function verifyPrice(price) {
    if (!price || price == '') {
        return price;
    }
    var result;
    var i = price.toString().split('.');
    if (i.length == 1) {
        result = i[0] + '.' + '00';
    }
    else if (i.length == 2) {
        if (i[1].length == 1) {
            result = i[0] + '.' + i[1] + '0';
        }
        else if (i[1].length == 2) {
            result = price;
        }
        else if (i[1].length > 2) {
            result = i[0] + '.' + i[1].substring(0, 2);
        }
    }
    return result;
}
function accAdd(arg1, arg2) {
    var r1, r2, m;
    try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
    try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
    m = Math.pow(10, Math.max(r1, r2))
    return (arg1 * m + arg2 * m) / m
}
function accSub(arg1, arg2) {
    var r1, r2, m, n;
    try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
    try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
    m = Math.pow(10, Math.max(r1, r2));
    n = (r1 >= r2) ? r1 : r2;
    return ((arg1 * m - arg2 * m) / m).toFixed(n);
}
function reClick(type2, pwid, sku, num) {
    name = "reWids" + type2;
    reWids = getCookie(name);
    if (reWids != null) {
        reWids = reWids.toString();
        var pos = reWids.indexOf(sku);
        if (pos < 0) {
            reWids = reWids + "," + sku;
        }
    }
    else {
        reWids = sku;
    }
    setCookie(name, reWids, 2);
    sku = String(sku);
    if (sku.indexOf("#") > 0) {
        sku = sku.split("#");
        log(3, type2, sku[0]);
        log('RC', 'CK', type2, pwid, sku[0], num);
    }
    else {
        log(3, type2, sku);
    }
}
function setCookie(name, value, date) {
    var Days = date;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";path=/;domain=." + RecRecommendCorrentDomain;
}
function getCookie(name) {
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return unescape(arr[2]); return null;
}
//我的京东改版后“猜你喜欢”的推荐--------start-------------------------------------
function GuessYouLike() {
    $.getJSON("http://prs."+RecRecommendCorrentDomain+"/GuessYouLike.aspx?jsoncallback=?",
    function(json) {
        GuessYouLikeCallback(json)
    })
}
GuessYouLikeCallback = function(json) {
    if (json != undefined && json != "" && json.length > 0) {
        $("#GuessLike").html(json);
        log('R3', 'Show', 12);
        $("#GuessLike").jdMarquee({
            deriction: "right",
            width: 548,
            height: 183,
            step: 3,
            speed: 4,
            delay: 10,
            control: true,
            _front: "#recoright01",
            _back: "#recoleft01"
        });

    }
}
//初始化方法
Init = function() {
    if ($('#jdhome_orderlist_recproduct').length != 0) {
        OrderPageRe();
    }
}
Init();