﻿////********Mask by huangjun*************///////////

//添加到收藏夹
function addfavorite(url, name) {
    if (document.all) {
        window.external.addFavorite(url, name);
    }
    else if (window.sidebar) {
        window.sidebar.addPanel(name, url, "");
    }
}


$(document).ready(function () {
    //Search && watermark
    $("#shtxt").watermark("请输入演出、场馆、艺人名称...", "watermark");
    $("#TextBox1").watermark(" 用户昵称/会员ID", "watermark");
    $("#txtLogin").watermark(" 用户昵称/会员ID", "watermark");
    $("#txtSearchOrder").watermark(" 订单查询...", "watermark");
    $("#btn-sh").click(function () {
        window.open('/ConditionalSearch.aspx?refp=' + encodeURIComponent($("#shtxt").val()));
    });

    $("#home").click(function () {
        window.location.href = "/default.htm";
    });

    //对联广告
    $("#adl").jFloat({
        position: "left",
        top: 30,
        height: 200,
        width: 100,
        left: 20,
        allowClose: false
    });
    $("#adr").jFloat({
        position: "right",
        top: 30,
        height: 200,
        width: 100,
        right: 20,
        allowClose: false
    });

    $("a[rel=fd]").fancybox({
        'titlePosition': 'inside',
        'width': '40%',
        'height': '50%',
        'autoScale': false,
        'showNavArrows': false,
        'type': 'iframe'
    });

    $("a[rel=sms]").fancybox({
        'titlePosition': 'inside',
        'width': '60%',
        'height': '80%',
        'autoScale': false,
        'showNavArrows': false,
        'type': 'iframe'
    });

    $("a[rel=gift]").fancybox({
        'titlePosition': 'inside',
        'width': '70%',
        'height': '80%',
        'autoScale': false,
        'showNavArrows': false,
        'type': 'iframe'
    });

});


$(document).ready(function () {
    //普通和VIP会员
    $("#ImageButton2").css("display", "none");
    $("#putong").click(function () {
        $("#putong").removeClass("putong1");
        $("#vip").removeClass("vip1");
        $("#putong").addClass("putong");
        $("#vip").addClass("vip");

        $("#ImageButton1").css("display", "block");
        $("#ImageButton2").css("display", "none");

        $("#vipCard").css("display", "none");
    });

    $("#vip").click(function () {
        $("#putong").removeClass("putong");
        $("#vip").removeClass("vip");
        $("#putong").addClass("putong1");
        $("#vip").addClass("vip1");

        $("#ImageButton1").css("display", "none");
        $("#ImageButton2").css("display", "block");

        $("#vipCard").css("display", "block");
    });

    $("#checkuser").colorTip({ color: 'blue' });

    $("#check").click(function () {
        $("#rfv").css("display", "none");
        $("#Label1").css("display", "none");
        var username = $("#TextBox9").val();
        if ($.trim(username) == "") {
            $("#chkResult").empty(); //清空初始信息
            $("#chkResult").text("用户昵称不能为空！");
        }
        else {
            $.ajax({
                type: "get",
                dataType: "text",
                url: "Handler/CheckUser.ashx",
                data: 'name=' + username,
                error: function () { alert("出错啦！"); },
                beforeSend: function () {
                    $("#check").css("display", "none");
                    $("#loading").css("display", "block");
                    $("#chkResult").text("正在验证用户昵称，请耐心等待！");
                },
                success: function (txt) {
                    $("#chkResult").empty(); //清空初始信息
                    if (txt == "1") {
                        $("#chkResult").text("该用户昵称已经存在！");

                    }
                    else {
                        $("#chkResult").text("该用户昵称可以注册！");
                    }
                    $("#check").css("display", "block");
                    $("#loading").css("display", "none");
                }
            });
        }
    });

    $('.CartGridView').find("input[type=text]").spin({
        imageBasePath: 'Js/img/spin1/',
        lock: true,
        max: 100,
        min: 1
    });

    //确认支付
    $(".pay>ul>li").find("a").click(function () {
        if (this.className == "currt") { //选中自己
            //this.className = "";
            //dt = this.innerHTML;
        }
        else {
            $(".pay .currt").removeClass("currt");
            this.className = "currt";

            //Do Ajax to Bind PayInfor
            $("#detail").empty(); //清空初始信息
            $("#zid").empty();
            $.ajax({
                type: "get",
                dataType: "xml",
                url: "Handler/PayInfor.ashx",
                data: 'zid=' + this.id,
                error: function (xml) { alert('Error loading XML document' + xml.responseText); },
                beforeSend: function () { $("#loading").show(); },
                success: function (xml) {
                    $("#loading").hide();
                    $(xml).find('Table').each(function () {
                        var zid = $(this).find("ZID").text();
                        var name = $(this).find("descp").text();
                        $("#detail").html(name);
                        $("#zid").text(zid);
                    });

                }
            });
        }

    });

    $("#btnZhifu").click(function () {
        //update zid && into zhifu interface
        var number = $.trim($("#number").text());
        var zid = $.trim($("#zid").text());
        var tprice = $.trim($("#tprice").text());
        var deliver = $.trim($("#deliver").text());


        $.ajax({
            type: "get",
            dataType: "text",
            url: "Handler/AddZhifu.ashx",
            data: 'zid=' + zid + '&&number=' + number + '&&tprice=' + tprice + '&&deliver=' + deliver,
            error: function (data) { alert('Error loading XML document' + data.responseText); },
            success: function (data) {
                if (data == "1") {
                    window.location.href = "TraceOrder.aspx?orderID=" + number;
                }
                else if (data == "0") {
                    alert("支付方式没有提交成功,请使用IE浏览器进行提交!");
                }
                else {
                    window.location.href = data;
                    //alert(data);
                }
            }
        });
    });

    //限时抢购
    $("img[rel=qg]").click(function () {
        //update zid && into zhifu interface
        //alert(this.id);

        $.ajax({
            type: "get",
            dataType: "text",
            url: "Handler/QiangGou.ashx",
            data: 'gid=' + this.id,
            error: function (data) { alert('Error loading XML document' + data.responseText); },
            success: function (data) {
                if (data == "1") {
                    window.location.href = "PageCart.aspx";
                }
                else {
                    alert("抢购不成功,请联系管理员！");
                }
            }
        });
    });

    //积分兑换
    $("img[rel=dh]").click(function () {

        $("#lblSid").text(this.id);
        $("#lblSc").text(this.getAttribute("sc"));

        var sc = this.getAttribute("sc");
        $.ajax({
            type: "get",
            dataType: "text",
            cache: false,
            url: "Handler/DuiHuan.ashx",
            data: 'sid=' + this.id + '&&sc=' + sc,
            error: function (data) { alert('Error loading XML document' + data.responseText); },
            beforeSend: function () { $("#loadgift").show(); },
            success: function (data) {
                $("#loadgift").hide(); //接收数据完毕


                if (data == "0") {
                    alert("您的积分余额不足,无法兑换该礼品！");
                }
                else if (data == "1") {
                    alert("您已经换购过此礼品，不能重复换购，谢谢您的支持！");
                }
                else if (data == "2") {
                    //弹出收礼人信息
                    $.blockUI({
                        message: $('.OrderLink'),
                        css: { width: '600px', left: '36%', cursor: 'pointer', border: '1px solid #aaa' }
                    });
                }
                else {
                    window.location.href = "Error.aspx";
                }
            }
        });
        //alert(sc);
    });

    $("#Button1").click(function () {
        var sid = $("#lblSid").text();
        var sc = $("#lblSc").text();
        var gn = $("#Label1").text();
        var name = encodeURIComponent($.trim($("#TextBox1").val()));
        var phone = encodeURIComponent($.trim($("#TextBox2").val()));
        var address = encodeURIComponent($.trim($("#TextBox3").val()));

        $.ajax({
            type: "get",
            dataType: "text",
            cache: false,
            url: "Handler/AddGiftOrder.ashx",
            data: 'sid=' + sid + '&&sc=' + sc + '&&name=' + name + '&&phone=' + phone + '&&address=' + address + '&&gn=' + gn,
            error: function (data) { alert('Error loading XML document' + data.responseText); },

            success: function (data) {

                if (data == "1") {
                    alert("订单生成成功！");
                    $.unblockUI();
                }
                else {
                    window.location.href = "Error.aspx";
                }
            }
        });
        //alert(sid + "," + sc + name + phone + address);
    });

});

//IE6 PNG
$(document).ready(function () {
    $(document.body).fixpng({ scope: 'img' });
    $('div').fixpng();
    $('a').fixpng();
});
