﻿$(function () {
    /* 选项卡 */
    $(".pro2-tabs li").each(function (e) {
        $(this).click(function () {
            $(".pro2-tabs li").removeClass("n");
            $(this).addClass("n");
            $(".pro2-c ul").css("display", "none");
            $(".pro2-c ul:eq(" + e + ")").css("display", "block");
        });
    })
})
//$.post("/helper/IndexOpreate.ashx", {}, function (d) {
//    if (d != null) {
//        var jsonObj = eval(d);
//        if (jsonObj[0].ArticleHtml != undefined) {
//            $(".notice span").append(jsonObj[0].ArticleHtml);
//        }
////        if (jsonObj[0].ProductHtml != undefined) {
////            $(".class-c").append(jsonObj[0].ProductHtml);
////            $(".menu3").leftmenu();
////            $(".menu-left").bind("mouseleave", function () {
////                $(".menu-left").hide();
////            });
////        }
//    }
//});
var currentDomainUrl = domainNameForJs; //在setconfig里面的一个DomainName.js中配置
$(document).ready(function () {
    CreatProduct($("#ulNews"), "0", 8, true);
    CreatProduct($("#ulSpec"), "1", 4, true);
    CreatProduct($("#ulPops"), "2", 4, true);
    CreatProduct($("#ulSingle"), "3", 4, false);
    CreatProduct($("#ulWeek"), "4", 4, false);
    CreatProduct($("#ulFast"), "5", 4, false);
});
function CreatProduct(ulName, typeID, num, isBirthPrice) {
    var count = 1;
    for (var i = 0; i < products.length; i++) {
        if (products[i][7].indexOf('_') != -1) continue;
        if (count > num) { break; }
        var arrType = products[i][5].split(',');
        for (var x = 0; x < arrType.length; x++) {
            if (arrType[x] == typeID) {
                count++;
                if (isBirthPrice && products[i][14] != "0" && products[i][3] != products[i][14] && typeID==1) {
                    $(ulName).append("<li><a target=\"_blank\" href=\"/default/productInfo.aspx?productId=" + products[i][0] + "\"><img style=\"width:150px;height:150px;\" src=\"" + CutImageUrl(currentDomainUrl, products[i][2], '250', '250') + "\" alt=\"" + products[i][4] + "\" /></a><h3><a target=\"_blank\" href=\"/default/productInfo.aspx?productId=" + products[i][0] + "\">" + products[i][4] + "</a></h3><span class=\"oldPrice\">原里程 " + products[i][14] + "里程</span><span class=\"salePrice\">" + products[i][3] + "里程</span></li>");
                }
                else {
                    var quids = "";
                    if (!isBirthPrice && products[i][11] != "0") {
                        quids = " + <span class=\"money\">" + products[i][11] + "现金</span>"
                    }
                    $(ulName).append("<li><a target=\"_blank\" href=\"/default/productInfo.aspx?productId=" + products[i][0] + "\"><img style=\"width:150px;height:150px;\" src=\"" + CutImageUrl(currentDomainUrl, products[i][2], '250', '250') + "\" alt=\"" + products[i][4] + "\" /></a><h3><a target=\"_blank\" href=\"/default/productInfo.aspx?productId=" + products[i][0] + "\">" + products[i][4] + "</a></h3><span class=\"air\">" + products[i][3] + "里程" + quids + "</span></li>");
                }
            }
        }
    }
}
function NormalSeach() {
    var searchC = $(".input-s").val();
    var toUrl = "/default/goodsList.aspx?keyWords=" + searchC;
    location.href = toUrl;
}
//绑定查询回车事件
$(".service").keydown(function (event) {
    if (event.keyCode == 13) {
        NormalSeach();
        return false;
    }
});
