﻿function chooseAll(sender) {
    var inputs = document.all.tags("INPUT");
    // 遍历页面上所有的 input 
    for (var i = 0; i < inputs.length; i++) {
        //如果此input元素的类型为checkbox，并且其id中包含chkSelect
        if (inputs[i].type == "checkbox" && inputs[i].id.indexOf("chkSelect") >= 0) {
            //设置此复选框的checked与全选复选框相同
            inputs[i].checked = document.getElementById(sender).checked;
            inputs[i].onclick();
        }
    }
}

function highLightSelected(chkSelect) {
    if (chkSelect.checked)
        chkSelect.parentElement.parentElement.style.backgroundColor = '#CCCCFF';
    else
        chkSelect.parentElement.parentElement.style.backgroundColor = 'white';
}
function showstatus(message) {
    window.status = message;
}


///倒计时  
function show_date_time(trq, bj) {
    window.setTimeout("show_date_time('" + trq + "','" + bj + "')", 1000);
    var date = function(datetime) {//定义一个新的date类
        var a = datetime.split(" ");
        var b = a[0].split("-");
        var c = a[1].split(":");
        return new Date(b[2], b[1] - 1, b[0], c[0], c[1], c[2]);
    };
    var dt = new date(trq);
    today = new Date();
    timeold = (dt.getTime() - today.getTime());
    sectimeold = timeold / 1000;
    secondsold = Math.floor(sectimeold);
    msPerDay = 24 * 60 * 60 * 1000;
    e_daysold = timeold / msPerDay
    daysold = Math.floor(e_daysold);
    e_hrsold = (e_daysold - daysold) * 24;
    hrsold = Math.floor(e_hrsold);
    e_minsold = (e_hrsold - hrsold) * 60;
    minsold = Math.floor((e_hrsold - hrsold) * 60);
    seconds = Math.floor((e_minsold - minsold) * 60);
    if (daysold < 0) {
        document.getElementById(bj).innerHTML = "抢购已结束";
    }
    else {
        if (daysold < 10) { daysold = "0" + daysold }
        if (daysold < 100) { daysold = "0" + daysold }
        if (hrsold < 10) { hrsold = "0" + hrsold }
        if (minsold < 10) { minsold = "0" + minsold }
        if (seconds < 10) { seconds = "0" + seconds }
        if (daysold < 3) {
            document.getElementById(bj).innerHTML = "<font color=red>" + daysold + "天" + hrsold + "小时" + minsold + "分" + seconds + "秒</font>";
        }
        else {
            document.getElementById(bj).innerHTML = daysold + "天" + hrsold + "小时" + minsold + "分" + seconds + "秒";
        }
    }
}

//选择文本框进行复制
function Copy(target) {
    var text = document.getElementById(target);
    if (target.value == "") { alert("没有内容"); target.focus(); return; }
    target.select();                                  //用select函数将文本内容选择
    js = target.createTextRange();      //createTextRange()用于获取myimg文本框内容
    js.execCommand("Copy");           //execCommand("Copy")将js里面的字符串复制到剪切板。
    alert("已复制完毕");
}

//复制命令
function copytext(inputid) {
    var text = document.getElementById(inputid);
    if (text.value == "") { alert("没有内容"); text.focus(); return; }
    text.select(); //选择对象
    document.execCommand("Copy"); //执行浏览器复制命令
    alert("已复制好，可贴粘。");
}

///评论引用  
function quote(target, text) {
    document.getElementById(target).value = '引用：\n' + text + "\n------------------------------------\n";
}
function keywordfocus() {
    if (document.getElementById("key").value == '请输入您想要查找的商城') {
        document.getElementById("key").value = '';
        document.getElementById("key").className = 'Searchkey_onFocus';
    }
}
function keywordblur() {
    if (document.getElementById("key").value == '') {
        document.getElementById("key").value = '请输入您想要查找的商城';
        document.getElementById("key").className = 'Searchkey';
    }
}
function GoSearch_onclick() {
    var strkeyword = document.getElementById("key").value.replace(/(^\s*)|(\s*$)/g, "");
    if (strkeyword == '' || strkeyword == "请输入您想要查找的商城") {
        var win = window.open("allmall.aspx");
        return;
    }
    else {
        var url1 = "search.aspx?selstr=" + strkeyword;
        var win = window.open(encodeURI(url1));
    }
}
function ss() {
    if (event.keyCode == 13) {
        GoSearch_onclick();
    }
}
//商城种类
(jQuery); (function($) {
    $.widthForIE6 = function(option) {
        var s = $.extend({
            max: null,
            min: null,
            padding: 0
        },
        option || {});
        var init = function() {
            var w = $(document.body);
            if ($.browser.client().width >= s.max + s.padding) {
                w.width(s.max + "px");
            } else if ($.browser.client().width <= s.min + s.padding) {
                w.width(s.min + "px");
            } else {
                w.width("auto");
            }
        };
        init();
        $(window).resize(init);
    }
})


(jQuery); (function($) {
    $.fn.hoverForIE6 = function(option) {
        var s = $.extend({
            current: "hover",
            delay: 10
        },
        option || {});
        $.each(this,
        function() {
            var timer1 = null,
            timer2 = null,
            flag = false;
            $(this).bind("mouseover",
            function() {
                if (flag) {
                    clearTimeout(timer2);
                } else {
                    var _this = $(this);
                    timer1 = setTimeout(function() {
                        _this.addClass(s.current);
                        flag = true;
                    },
                    s.delay);
                }
            }).bind("mouseout",
            function() {
                if (flag) {
                    var _this = $(this);
                    timer2 = setTimeout(function() {
                        _this.removeClass(s.current);
                        flag = false;
                    },
                    s.delay);
                } else {
                    clearTimeout(timer1);
                }
            })
        })
    }
})

(jQuery); (function($) {
    $.fn.jdTab = function(option, callback) {
        if (typeof option == "function") {
            callback = option;
            option = {};
        };
        var s = $.extend({
            type: "static",
            auto: false,
            source: "data",
            event: "mouseover",
            currClass: "curr",
            tab: ".tab",
            content: ".tabcon",
            itemTag: "li",
            stay: 5000,
            delay: 100,
            mainTimer: null,
            subTimer: null,
            index: 0
        },
        option || {});
        var tabItem = $(this).find(s.tab).eq(0).find(s.itemTag),
        contentItem = $(this).find(s.content);
        if (tabItem.length != contentItem.length) return false;
        var reg = s.source.toLowerCase().match(/http:\/\/|\d|\.aspx|\.ascx|\.asp|\.php|\.html\.htm|.shtml|.js|\W/g);
        var init = function(n, tag) {
            s.subTimer = setTimeout(function() {
                hide();
                if (tag) {
                    s.index++;
                    if (s.index == tabItem.length) s.index = 0;
                } else {
                    s.index = n;
                };
                s.type = (tabItem.eq(s.index).attr(s.source) != null) ? "dynamic" : "static";
                show();
            },
            s.delay);
        };
        var autoSwitch = function() {
            s.mainTimer = setInterval(function() {
                init(s.index, true);
            },
            s.stay);
        };
        var show = function() {
            tabItem.eq(s.index).addClass(s.currClass);
            switch (s.type) {
                default:
                case "static":
                    var source = "";
                    break;
                case "dynamic":
                    var source = (reg == null) ? tabItem.eq(s.index).attr(s.source) : s.source;
                    tabItem.eq(s.index).removeAttr(s.source);
                    break;
            };
            if (callback) {
                callback(source, contentItem.eq(s.index), s.index);
            };
            contentItem.eq(s.index).show();
        };
        var hide = function() {
            tabItem.eq(s.index).removeClass(s.currClass);
            contentItem.eq(s.index).hide();
        };
        tabItem.each(function(n) {
            $(this).bind(s.event,
            function() {
                clearTimeout(s.subTimer);
                clearInterval(s.mainTimer);
                init(n, false);
                return false;
            }).bind("mouseleave",
            function() {
                if (s.auto) {
                    autoSwitch();
                } else {
                    return;
                }
            })
        });
        if (s.type == "dynamic") {
            init(s.index, false);
        };
        if (s.auto) {
            autoSwitch();
        }
    }
})


function SelectNav(a) {
    var navlist = $("#nav5 ul li a");
    var curclassname;
    var b;
    for (i = 0; i < navlist.length; i++) {
        curclassname = navlist.eq(i).attr("class");
        if (i == a) {
            if (curclassname == "one" || curclassname == "two") {
                navlist.eq(i).removeClass();
                navlist.eq(i).addClass(curclassname + '_no');
            }
        }
        else {
            navlist.eq(i).removeClass();
            if (curclassname == "one" || curclassname == "one_no") {
                b = "one";
            }
            else {
                b = "two";
            }
            navlist.eq(i).addClass(b);
        }
    }
}

       
