// JavaScript Document
function checktip(index) {
    $("#tip" + menuin).hide();
    $("#t" + menuin).css("background-image", "");
    $("#t" + menuin).css("color", "#000");

    $("#t" + index).css("background-image", "url(/images/menufocus.gif)");
    $("#t" + index).css("color", "#fff");
    $("#tip" + index).css("margin-left", 90*index);
    $("#tip" + index).css("display", "block");
    $("#tip" + index).show();
    menuin = index;
    //$("#tip" + index).slideDown("fast", function () {
    //$("#tip" + index).css("display", "block");
    //alert($("#t"+index).offset().left);
    //});
    //    $("#tip" + index).mouseover(function () {
    //        $("#t" + index).css("background-image", "url(/images/menufocus.gif)").css("color", "#FFF");
    //    }).mouseout(function () {
    //        nowurl();
    //        $("#t" + index).css("background-image", "");
    //        $("#t" + index).css("color", "#000");
    //    });
}

function distip(index) {
    $("#t" + index).css("background-image", "");
    $("#tip" + index).css("display", "none");
    nowurl();
}

/*添加至购物车*/
function addcart(productid, productcount, color, yardage) {
    $.ajax({
        type: "POST",
        url: "../ashx/shoppingcart.ashx",
        data: "action=add&productid="+productid+"&productcount="+productcount+"&yardage="+yardage+"&color="+color+"",
        success: function (msg) {
            
        }
    });
}

function nowurl() {
    checktip(menuindex);
}

function nowindex() {
    var url = window.location.href;
    if (url.indexOf("index.aspx") > -1) {
        menuindex = 1;
    }
    else if (url.indexOf("aboutus/introduction.aspx") > -1 || url.indexOf("aboutus/sell.aspx") > -1 || url.indexOf("aboutus/honor.aspx") > -1 || url.indexOf("aboutus/job.aspx") > -1 || url.indexOf("aboutus/impact.aspx") > -1 || url.indexOf("aboutus/aboutus.aspx") > -1) {
        menuindex = 2;
    }
    else if (url.indexOf("news/list.aspx") > -1 || url.indexOf("news/media.aspx") > -1 || url.indexOf("news/news.aspx") > -1 || url.indexOf("news/view.aspx") > -1) {
        menuindex = 3;
    }
    else if (url.indexOf("shop/shop.aspx") > -1 || url.indexOf("shop/list.aspx") > -1 || url.indexOf("shop/info.aspx") > -1 || url.indexOf("shop/tglist.aspx") > -1) {
        menuindex = 4;
    }
    else if (url.indexOf("member/login.aspx") > -1 || url.indexOf("member/order_center.aspx") > -1 || url.indexOf("member/register.aspx") > -1 || url.indexOf("member/shoppingcart.aspx") > -1 || url.indexOf("member/shoppingcart2.aspx") > -1 || url.indexOf("member/shoppingcart3.aspx") > -1) {
        menuindex = 5;
    }
    else if (url.indexOf("service/help.aspx") > -1 || url.indexOf("service/view.aspx") > -1 || url.indexOf("service/contact.aspx") > -1) {
        menuindex = 6;
    }
    else if (url.indexOf("zslist.aspx") > -1) {
        menuindex = 7;
    }
    else if (url.indexOf("zsinfo.aspx") > -1) {
        menuindex = 7;
    }
    else if (url.indexOf("vendor") > -1) {
        menuindex = 8;
    }
    menuin = menuindex;
}

function setPTabs(index) {
    for (var i = 1; i <= 3; i++) {
        $("#pt" + i).css("display", "none");
        $("#p" + i).removeClass("se_titles");
        $("#p" + i).addClass("se_title");
    }
    $("#pt" + index).css("display", "");
    $("#p" + index).addClass("se_titles");
}

function setNTabs(index) {
    for (var i = 1; i <= 4; i++) {
        $("#nt" + i).css("display", "none");
        $("#n" + i).removeClass("se_titles");
        $("#n" + i).addClass("se_title");
    }
    $("#nt" + index).css("display", "");
    $("#n" + index).addClass("se_titles");
}

function setTTabs(index) {
    for (var i = 1; i <= 3; i++) {
        $("#tt" + i).css("display", "none");
        $("#tc" + i).css("background-image", "").css("color", "#757575");
    }
    $("#tt" + index).css("display", "");
    $("#tc" + index).css("background-image", "url(/images/product_search_title.gif)").css("color", "#FFF");
}

function CheckLogin() {
    var username = $("#username").val();
    var password = $("#password").val();
    $.get("../ashx/loginform.ashx", { username: username, password: password }, function (msg) {
        if (msg == "true") {
            location.href = "/index.aspx";
        }
        else {
            alert(msg);
        }
    });
}

function checkloginform() {
    var username = $("#username").val();
    var password = $("#password").val();
    if (username == "") {
        alert("请输入用户名！");
        return false;
    }
    else if (password == "") {
        alert("请输入密码！");
        return false;
    }
    else {
        return true;
    }
}
var menuindex = 1;
var menuin = 1;

$(document).ready(function () {
    $("#tc1").mousemove(function () { setTTabs(1); });
    $("#tc1").css("cursor", "hand");
    $("#tc2").mousemove(function () { setTTabs(2); });
    $("#tc2").css("cursor", "hand");
    $("#tc3").mousemove(function () { setTTabs(3); });
    $("#tc3").css("cursor", "hand");
    for (var i = 2; i <= 3; i++) {
        $("#tt" + i).css("display", "none");
    }
    setTTabs(1);
    $("#t1").mousemove(function () { checktip(1); });
    $("#t2").mousemove(function () { checktip(2); });
    $("#t3").mousemove(function () { checktip(3); });
    $("#t4").mousemove(function () { checktip(4); });
    $("#t5").mousemove(function () { checktip(5); });
    $("#t6").mousemove(function () { checktip(6); });
    $("#t7").mousemove(function () { checktip(7); });
    $("#t8").mousemove(function () { checktip(8); });
    $("#t1").click(function () { location.href = "/index.aspx"; });
    $("#t2").click(function () { location.href = "/aboutus/aboutus.aspx"; });
    $("#t3").click(function () { location.href = "/news/news.aspx"; });
    $("#t4").click(function () { location.href = "/shop/shop.aspx"; });
    $("#t5").click(function () { location.href = "/member/login.aspx"; });
    $("#t6").click(function () { location.href = "/service/view.aspx"; });
    $("#t7").click(function () { location.href = "/shop/zslist.aspx"; });
    $("#t8").click(function () { location.href = "/vendor/join.aspx"; });

    //$(".top_menu_m").mouseout(function () { nowurl(); });
    $(".top").hover(function () { }, function () { nowurl(); });
    $(".top_banner").hover(function () { nowurl(); });
    //查询
    $("#psearch").click(function () {
        var mulu = $("#selMulu").val();
        var type = $("#selType").val();
        var series = $("#selSeries").val();
        var time = $("#selTime").val();
        var price = $("#selPrice").val();
        var color = $("#selColor").val();
        location.href = "/shop/list.aspx?s=1&mulu=" + mulu + "&type=" + type + "&series=" + series + "&time=" + time + "&price=" + price + "&color=" + color;
    });

    $("#btnsearch").click(function () {
        var inputsearch = $("#inputsearch").val();
        location.href = "/shop/list.aspx?search=" + inputsearch;
    });

    getMulu("selMulu");
    getType("selType");
    getSeries("selSeries");
    getTime("selTime");
    getPrice("selPrice");
    getColor("selColor");
    nowindex();
    nowurl();
});
