﻿function tab_onmouse(str) {
    if (str == "1") {
        tab_alloff();
        document.getElementById("img_tabl").src = "../../newimages/tab1_on.jpg";
        document.getElementById("img_tab_topic").src = "../../newimages/tab1_topic.jpg";
        document.getElementById("a_tab_topic").href = "/Product/detail.aspx?pid=3082";
        $("#mardiv1").show();
        $("#mardiv2").hide();
        $("#mardiv3").hide();
        $("#mardiv4").hide();
        $.ajax({
            type: "GET",
            url: "/product/ajax.aspx",
            data: "mod=tab_home_dvequip&v=" + new Date() + "&str=" + str,
            success: function (msg) {

                if (msg == "Error") {
                    alert("出错，请重新刷新页面或重新登录。");

                }
                else {
                    if (msg != "") {
                        $("#mardiv" + str).html(msg);
                        new Marquee("mardiv" + str, 2, 1, 720, 0, 72, 0, 0)
                    }
                }
            }
        });
    }
    if (str == "2") {
        tab_alloff();
        document.getElementById("img_tab2").src = "../../newimages/tab2_on.jpg";
        document.getElementById("img_tab_topic").src = "../../newimages/tab2_topic.jpg";
        document.getElementById("a_tab_topic").href = "/Product/detail.aspx?pid=3109";
        $("#mardiv1").hide();
        $("#mardiv2").show();
        $("#mardiv3").hide();
        $("#mardiv4").hide();

        $.ajax({
            type: "GET",
            url: "/product/ajax.aspx",
            data: "mod=tab_home_dvequip&v=" + new Date() + "&str=" + str,
            success: function (msg) {

                if (msg == "Error") {
                    alert("出错，请重新刷新页面或重新登录。");

                } else {
                    if (msg != "") {

                        $("#mardiv" + str).html(msg);
                        new Marquee("mardiv" + str, 2, 1, 720, 0, 72, 0, 0)
                    }
                }
            }
        });
    }
    if (str == "3") {
        tab_alloff();
        document.getElementById("img_tab3").src = "../../newimages/tab3_on.jpg";
        document.getElementById("img_tab_topic").src = "../../newimages/tab3_topic.jpg";
        document.getElementById("a_tab_topic").href = "/Product/detail.aspx?pid=3069";
        $("#mardiv1").hide();
        $("#mardiv2").hide();
        $("#mardiv3").show();
        $("#mardiv4").hide();
        $.ajax({
            type: "GET",
            url: "/product/ajax.aspx",
            data: "mod=tab_home_dvequip&v=" + new Date() + "&str=" + str,
            success: function (msg) {
                if (msg == "Error") {
                    alert("出错，请重新刷新页面或重新登录。");
                }
                else {
                    if (msg != "") {
                        $("#mardiv" + str).html(msg);
                        new Marquee("mardiv" + str, 2, 1, 720, 0, 72, 0, 0)
                    }
                }
            }
        });
    }
    if (str == "4") {
        tab_alloff();
        document.getElementById("img_tab4").src = "../../newimages/tab4_on.jpg";
        document.getElementById("img_tab_topic").src = "../../newimages/tab4_topic.jpg";
        document.getElementById("a_tab_topic").href = "/Product/detail.aspx?pid=3088";
        $("#mardiv1").hide();
        $("#mardiv2").hide();
        $("#mardiv3").hide();
        $("#mardiv4").show();
        $.ajax({
            type: "GET",
            url: "/product/ajax.aspx",
            data: "mod=tab_home_dvequip&v=" + new Date() + "&str=" + str,
            success: function (msg) {

                if (msg == "Error") {
                    alert("出错，请重新刷新页面或重新登录。");
                }
                else {

                    if (msg != "") {

                        $("#mardiv" + str).html(msg);
                        new Marquee("mardiv" + str, 2, 1, 720, 0, 72, 0, 0)

                    }

                }
            }
        });
    }
}
function tab_alloff() {
    document.getElementById("img_tabl").src = "../../newimages/tab1_off.jpg";
    document.getElementById("img_tab2").src = "../../newimages/tab2_off.jpg";
    document.getElementById("img_tab3").src = "../../newimages/tab3_off.jpg";
    document.getElementById("img_tab4").src = "../../newimages/tab4_off.jpg";
}
function btn_color(str_img) {
    var img_msg = "<img src='/img/color_" + str_img + ".gif' />";
    document.getElementById("div_color").innerHTML = img_msg;
    document.getElementById("hf_color").value = str_img;

}
function pro_bigger() {
    var _img = document.getElementById("bigimg").src;
    window.open("/product/showdetail.aspx?img=" + _img);
}
function copyToClipBoard() {
    var clipBoardContent = window.document.location.href;
    if (window.clipboardData) {
        window.clipboardData.clearData();
        window.clipboardData.setData("Text", clipBoardContent);
    } else if (navigator.userAgent.indexOf("Opera") != -1) {
        window.location = clipBoardContent;
    } else if (window.netscape) {
        try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        } catch (e) {
            alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
        }
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip)
            return;
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
        if (!trans)
            return;
        trans.addDataFlavor('text/unicode');
        var str = new Object();
        var len = new Object();
        var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
        var copytext = clipBoardContent;
        str.data = copytext;
        trans.setTransferData("text/unicode", str, copytext.length * 2);
        var clipid = Components.interfaces.nsIClipboard;
        if (!clip)
            return false;
        clip.setData(trans, null, clipid.kGlobalClipboard);
    }
    alert("地址已复制,可以粘贴到QQ/MSN上,推荐给你的好友!");
}
function sendCollect() {
    var _pid = document.getElementById("hf_pid").value;

    if (_pid != "") {
        xmlHttp.open("GET", "/product/ajax.aspx?mod=collect&pid=" + _pid, false);


        //          xmlHttp.setRequestHeader("Content-Type", "text/html;charset=UTF-8");
        // 当装载状态改变时
        xmlHttp.onreadystatechange = sendCollectData;
        //向服务器端发送数据
        xmlHttp.send(null);

    }

}
// 解析Xml文档的数据。
function sendCollectData() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {

            var msg = xmlHttp.responseText;
            // alert(msg);
            if (msg == "collectok") {

                alert("收藏成功，请在会员中心查看收藏记录！1");

            }

            if (msg == "recollect") {

                alert("此商品已被收藏，不能重复收藏！1");

            }

            if (msg == "notLogin") {

                alert("请先登录，再收藏！1");

            }
            if (msg == "Error") {

                alert("出错。1");
            }

        }
    }
}
function doClear() {
    document.getElementById("name").value = "";
}

function doChSub(event) {
    var myevent = event || window.event;
    if (myevent.keyCode == 13) {
        doSubmit();
    }
}
function searchQuery() {
    if ($("#name").val() == "" || $("#name").val() == "请输入关键词") {
        alert("请输入关键词");
        return false;

    }
    var var_language = $("#language").val();
    var var_searchkey = escape($("#name").val());
    var proclass = "";
    if (var_language != "" && var_searchkey != "") {
        if (var_language == "1") {
            proclass = "dv";
        }
        if (var_language == "2") {
            proclass = "dvequip"
        }
        location = "/product/index.aspx?proclass=" + proclass + "&searchkey=" + var_searchkey;
    }
}

function NewshotLi__new(n) {
    if (n == "1") {
        $("#Tab_newshot1").attr("className", "show__new_1");
        $("#Tab_newshot2").attr("className", "close__new_2");
        $("#Tab_newshotc01").attr("className", "");
        $("#Tab_newshotc02").attr("className", "undis__new");
    }

    if (n == "2") {
        $("#Tab_newshot2").attr("className", "show__new_2");
        $("#Tab_newshot1").attr("className", "close__new_1");
        $("#Tab_newshotc02").attr("className", "");
        $("#Tab_newshotc01").attr("className", "undis__new");
    }

}
