﻿
$(document).ready(function () {
	$("#GoPay").click(function () {
        	window.location.href = "GoPay.aspx";
    	});    
	//初始化加载热门推荐
    $.ajax({
        type: "post",
        dataType: "json",
        url: "Handler/Recommend.ashx",
        beforeSend: function () { $("#load").show(); },
        complete: function () { $("#load").hide(); }, //接收数据完毕
        error: function () { $("#tabDetail").text("Error!"); },

        success: function (jsn) {
            $("#rec").tmpl(jsn).appendTo("#tabDetail");
        }
    });

    //分类推荐
    $(".menuList>ul>li").find("a").click(function () {
        if (this.className == "currt") {
            //this.className = ""
        }
        else {
            $(".menuList .currt").removeClass("currt");
            this.className = "currt";

            $("#tabDetail").empty();
            $("#MoreProduct").empty();
            //Ajax Bind
            $.ajax({
                type: "post",
                dataType: "json",
                url: "Handler/Recommend.ashx?fid=" + this.id,
                beforeSend: function () { $("#load").show(); },
                complete: function () { $("#load").hide(); }, //接收数据完毕
                error: function () { $("#tabDetail").text("Error!"); },

                success: function (jsn) {
                    $("#rec").tmpl(jsn).appendTo("#tabDetail");
                }
            });

            var link = "<a href='PageList/Page" + this.id + ".htm'><img src='images/moreProduct.jpg' /></a>";
            $("#MoreProduct").html(link);
        }
    });

    //热门推荐
    $("#hot").click(function () {
        $(".menuList .currt").removeClass("currt");
        $("#tabDetail").empty();
        $("#MoreProduct").empty();
        //Ajax Bind
        $.ajax({
            type: "post",
            dataType: "json",
            url: "Handler/Recommend.ashx",
            beforeSend: function () { $("#load").show(); },
            complete: function () { $("#load").hide(); }, //接收数据完毕
            error: function () { $("#tabDetail").text("Error!"); },

            success: function (jsn) {
                $("#rec").tmpl(jsn).appendTo("#tabDetail");
            }
        });
        var link = "<a href='PageList/PageAll.htm'><img src='images/moreProduct.jpg' /></a>";
        $("#MoreProduct").html(link);
    });

    //导航模块
    $(".picSetmenu>ul>li").find("a").click(function () {
        if (this.className == "currt") {
            return;
        }
        else {
            $(".picSetmenu .currt").removeClass("currt");
            this.className = "currt";
        }
    });

    $("#nav1").click(function () {
        $(".picSetContent1").css("display", "block");
        $(".picSetContent2").css("display", "none");
    });
    $("#nav2").click(function () {
        $(".picSetContent1").css("display", "none");
        $(".picSetContent2").css("display", "block");
        $(".picSetContent2").empty();
        //Ajax Bind
        $.ajax({
            type: "post",
            dataType: "xml",
            url: "Handler/Place.ashx",
            beforeSend: function () { $("#loadData").show(); },
            complete: function () { $("#loadData").hide(); }, //接收数据完毕
            error: function () { $(".picSetContent2").text("Error!"); },

            success: function (xml) {
                var pp = "";

                $(xml).find('Table').each(function () {
                    var cid = $(this).find("CID").text();
                    var name = $(this).find("name").text();
                    var pic = $(this).find("pic").text();

                    pp += "<div class=place><p><a href='PlaceDetail/page" + cid + ".htm' ><img src='Piaowu/" + pic + "' /></a></p><p>" + name + "</p></div>";
                });
                $(".picSetContent2").html(pp);
            }
        });
    });

    //Picset
    $('.picSetLeft img').hoverpulse().each(function () {
        var $img = $(this);
        var link = $img.attr('data-link');
        $img.attr('title', 'Goto: ' + link);
        $img.click(function () {
            window.open(link);
            return false;
        });
    });

    $('img.captify').captify({
        animation: "always-on",
        opacity: "0.35",
        position: "top"
    });
});

