var type = 'Product';

var classID = '1';

var page = 1;

var pagesize = 20;

var proUrl = '';



$(function() {
    /*Tab*/
    $('.tab').each(function(i) {
        $(this).children('li:not([class="div"])').each(function(j) {
            $(this).data('index', j);
        });
    });
    //    $('.tab li:not([class="div"])').click(function() {
    $('.tab li:not([class="div"])').live('click', function() {
        if ($(this).is('.now')) return false;
        var t = $(this).parent().attr('target');
        if (t) {
            var tabC = $(t).children('.cont');
        }
        else {
            var tabC = $(this).parent().next('.tabC').children('.cont');
        }
        var i = $(this).data('index');

        proUrl = $(".picUrl").eq(i).val();
        
        $(this).addClass('now').siblings().removeClass('now');
		
		
        tabC.hide().eq(i).show();
		cardImg=$(this).find("img").attr("src");
		//alert($(this).find("img").length);
    });
	
	cardImg=$("#smallList .now img").attr("src");

})



function goCard() {

    if (proUrl == '') {
        proUrl = $(".picUrl").eq(0).val();
    }
    window.location.href = '/product/card.aspx?proUrl=' + proUrl + "&classID=" + classID;
}

function GetProList() {
    var tbody = "";
    var smalltbody = "";
    $("#tabC_1").empty();
    $("#smallList").empty();
    $.ajax({
        type: "POST", //用POST方式传输
        dataType: "json", //数据格式:JSON
        url: '/Handle/GetList.ashx', //目标地址
        data: "type=" + type + "&classID=" + classID + "&page=" + page + "&size=" + pagesize,
        success: function(json) {
            var returnData = json;
            if (returnData != null) {
                $.each(returnData, function(i, n) {
                    var trs = "";
                    if (i == 0) {
                        trs += "<div  class=\"cont block\"><img src=\"" + n.img + "\"  alt=\"\" /></div>";
                    }
                    else {
                        trs += "<div  class=\"cont\"><img src=\"" + n.img + "\"  alt=\"\" /></div>";
                    }

                    tbody += trs;
                    if (i == 0) {
                        trs = "<li index=\"" + (i+1) + "\"   class=\"now\"><div ><img src=\"" + n.img + "\" width=\"94\"  height=\"94\" alt=\"\" /></div><p>" + n.name + "</p></li>";
                    }
                    else {
                        trs = "<li  index=\"" + (i + 1) + "\" ><div><img src=\"" + n.img + "\" width=\"94\"  height=\"94\" alt=\"\" /></div><p>" + n.name + "</p></li>";
                    }
                    smalltbody += trs;
                });
            }
            $("#tabC_1").append(tbody);
            $("#smallList").append(smalltbody);
        }

    });

}

function GetCatList() {
    var tbody = "";
    $(".catlist").empty();
    $.ajax({
        type: "POST", //用POST方式传输
        dataType: "json", //数据格式:JSON
        url: '/Handle/GetList.ashx', //目标地址
        data: "type=" + type + "&classID=" + classID + "&page=" + page + "&size=" + pagesize,
        success: function(json) {
            var returnData = json;
            if (returnData != null) {
                $.each(returnData, function(i, n) {
                    var trs = "";
                    if (n.img != '') {
                        trs += "<li><a href=\"" + n.img + "\"><img src=\"" + n.img + "\"  width=\"94\" heigth=\"94\" alt=\"\" /></a></li>";
                    }
                    else {
                        trs += "<li></li>";
                    }
                    tbody += trs;
                });
            }
            $(".catlist").append(tbody);
        }

    });

}


function GetDownList() {
    var tbody = "";
    $(".wallpaper_c").empty();
    $.ajax({
        type: "POST", //用POST方式传输
        dataType: "json", //数据格式:JSON
        url: '/Handle/GetList.ashx', //目标地址
        data: "type=" + type + "&classID=" + classID + "&page=" + page + "&size=" + pagesize,
        success: function(json) {
            var returnData = json;
            if (returnData != null) {
                $.each(returnData, function(i, n) {
                    var trs = "";
                    trs += "<li><a href=\"\"><img src=\"" + n.img + "\"  alt=\"\" /></a><p><a href=\"#\">" + n.name + "</a></p></li>";
                    tbody += trs;
                });
            }
            $(".wallpaper_c").append(tbody);
        }

    });

}
