<%@ page title="" language="C#" masterpagefile="~/Member/MyShopMasterPage.master" autoeventwireup="true" inherits="Member_MBF_BuyGiftCards, WebApp_deploy" %>

<asp:Content ID="Content0" ContentPlaceHolderID="CPHead" runat="Server">
    <link href="CSS/giftcards.css" rel="stylesheet" type="text/css" />
    <script src="../Skin/Index/js/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script src="Js/slideli.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {

            $.globalEval('<%=JSInitCode %>');

            $("input[type=radio]").click(function () {
                //alert($(this).attr("festname"));
                $("#h_FestivalName").val($(this).attr("festname")); //节日名
                var jstitle = "";
                jstitle = $(this).next(":eq(0)").html(); //标题
                $("#current_Title").html(jstitle);
                $("#h_Title").val(jstitle);
                var jssrc = $(this).prev(":eq(0)").attr("src"); //图片地址
                $("#current_Picture").attr("src", jssrc);
                $("#h_Picture").val(jssrc);
                $.post("/WebService/MBFmember.ashx", { newdate: new Date().getMilliseconds(), action: 'GetGiftValuesByFestivalName', festivalname: $(this).attr("festname") }, function (data) {
                    if (data != "" && data != "error") {
                        var sel = $("#selectFaceValue");
                        sel.empty();
                        sel.append("<option value=''>…请选择…</option>");
                        var vals = data.split(',');
                        for (var i = 0; i < vals.length; i++) {
                            var curval = vals[i].split('_');
                            sel.append("<option rate='" + curval[1] + "' value='" + curval[0] + "'>￥" + curval[0] + "</option>");
                        }

                    }
                    else {
                        alert("无面值数据，可能是后台管理还没添加！");
                    }
                }, "text");
                //post-end
                location.href = "#a_buygift";

            });
            $("#txtRecieveName").change(function () {
                //post-start
                if ($(this).val().Trim() != "") {
                    $.post("/WebService/MBFmember.ashx", { newdate: new Date().getMilliseconds(), action: 'GetUserIDByUserName', username: $(this).val() }, function (data) {
                        if (data != "" && data != "error") {
                            if (data == "isself") {
                                $("#span_receivename").html("不能送给自己！").css("color", "Red");
                                $("#h_RecieveID").val("");
                            }
                            else {
                                $("#span_receivename").html("用户名存在").css("color", "Green");
                                $("#h_RecieveID").val(data);
                            }
                        }
                        else {
                            $("#span_receivename").html("用户名不存在，请重新输入！").css("color", "Red");
                            $("#h_RecieveID").val("");
                        }
                    }, "text");
                    //post-end
                }
                else {
                    $("#span_receivename").html("*").css("color", "Red");
                }
            });
            $("#selectFaceValue").change(function () {
                var val1 = $(this).val();
                if (val1 == "") {
                    $("#span_disrate").html("");
                    $("#h_disrate").val("");
                }
                else {
                    var disrate = $("#selectFaceValue option[value=" + val1 + "]").attr("rate");
                    $("#span_disrate").html("奖励比率:" + disrate + "%");
                    $("#h_disrate").val(disrate);
                }
            });
            $("#cb_send").change(function () {
                if ($(this).is(":checked")) {
                    $("#td_email,#td_email1,#td_name,#td_name1,#td_leave,#td_leave1").show("slow");
                }
                else {
                    $("#txtRecieveName,#h_RecieveID").val("");
                    $("#span_receivename").html("*").css("color", "Red");
                    $("#td_email,#td_email1,#td_name,#td_name1,#td_leave,#td_leave1").hide("slow");
                }
            });
        });
        function checkData() {
            var ret = true;
            if ($("#current_Title").html().Trim() == "") {
                ret = false;
                alert("请选择礼品卡！");
                return ret;
            }
            if ($("#selectFaceValue").val().Trim() == "") {
                ret = false;
                alert("请选择面值！");
                return ret;
            }
            if ($("#cb_send").is(":checked")) {
                if ($("#h_RecieveID").val().Trim() == "") {
                    ret = false;
                    alert("请输入一个本商城的用户！");
                    return ret;
                }
                if ($("#txtReceiveEmail").val().Trim() == "") {
                    ret = false;
                    alert("请输入接收礼品卡的邮箱！");
                    return ret;
                }
                var regu = /^([0-9a-zA-Z]+([_.0-9a-zA-Z-]*[0-9a-zA-Z-]+)?)@([a-zA-Z0-9-]+[.])+([a-zA-Z]|net|NET|asia|ASIA|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT|cn|CN|cc|CC)$/;
                //var re = new RegExp(regu);
                if (!regu.test($("#txtReceiveEmail").val())) {
                    alert("接收邮箱地址格式不正确！");
                    return false;
                }

            }
            return ret;
        }

    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="pageTitle">
        <font color="red">购买礼品卡</font></div>
    <br />
    <div style="width: 95%;">
        <asp:Repeater ID="Repeater_Festival" runat="server" OnItemDataBound="Repeater_Festival_ItemDataBound">
            <ItemTemplate>
                <div id='giftcard_<%#Eval("FestivalName") %>' class="list_box giftcards">
                    <div class="title">
                        <h3>
                            [<%#Eval("FestivalName") %>]礼品卡(面值：<%#GetFeceValues(Eval("FestivalName")) %>)</h3>
                    </div>
                    <div class="more">
                        <!-- <a href="#"><span>更多》</span></a> -->
                    </div>
                    <div class="controller">
                        <a href="javascript:;" class="prev">上一组</a> <a href="javascript:;" class="next">下一组</a>
                    </div>
                    <div class="inner">
                        <ul>
                            <asp:Repeater ID="Repeater_category" runat="server">
                                <ItemTemplate>
                                    <li>
                                        <img src='../UpLoadFile/VIPCardPic/<%#Eval("Picture") %>' class="pic picborder" alt='礼品卡图片'
                                            title='<%#Eval("Title") %>' />
                                        <input id='Radio_<%#Eval("id") %>' festname='<%#Eval("FestivalName") %>' type="radio" name="giftcard" /><label for="Radio_<%#Eval("id") %>"
                                            class="tit"><%#Eval("Title") %></label>
                                    </li>
                                </ItemTemplate>
                            </asp:Repeater>
                        </ul>
                    </div>
                </div>
            </ItemTemplate>
        </asp:Repeater>
        <a name="a_buygift"></a>
        <div class="list_box giftcards">
            <div class="title">
                <h3>
                    礼品卡购买信息</h3>
            </div>
        </div>
        <div id='giftcard_Buyinfo' class="list_box giftcards">
            <div>
                <table id="tb_Buyinfo" style="width: 100%;">
                    <tr>
                        <td class="card_left_01">
                            当前选择：
                            <input id="h_FestivalName" name="h_FestivalName" type="hidden" />
                            <input id="h_Picture" name="h_Picture" type="hidden" />
                            <input id="h_Title" name="h_Title" type="hidden" />
                        </td>
                        <td>
                            <div id="current_Title">请在上面选择一张礼品卡</div>
                            <img src="" id="current_Picture" style="width: 160px; height: 90px;" alt="当前选择礼品卡图片" />
                        </td>
                    </tr>
                    <tr>
                        <td class="card_left_01">
                            选择面值：
                        </td>
                        <td>
                            <select id="selectFaceValue" name="selectFaceValue" class="card_left_02">
                                <option value="">…请选择…</option>
                            </select><span id="span_disrate" style="color:Gray;"></span><input id="h_disrate" name="h_disrate" type="hidden" />
                        </td>
                    </tr>
                    <tr>
                        <td class="card_left_01">
                        </td>
                        <td>
                            <input id="cb_send" name="cb_send" value="cb_send" type="checkbox" /><label for="cb_send" class="cursor_pointer">送给亲朋好友</label>
                        </td>
                    </tr>
                    <tr>
                        <td class="card_left_01 none" id="td_email">
                            接收人邮箱：
                        </td>
                        <td id="td_email1" class="none">
                            <input id="txtReceiveEmail" name="txtReceiveEmail" type="text" class="card_left_02" />
                        </td>
                    </tr>
                    <tr>
                        <td class="card_left_01 none" id="td_name" >
                            接收人用户名：<input id="h_RecieveID" name="h_RecieveID" type="hidden" />
                        </td>
                        <td id="td_name1" class="none">
                            <input id="txtRecieveName" name="txtRecieveName" type="text" class="card_left_02" /><span
                                id="span_receivename" style="color: Red;">*</span>&nbsp;<span style="color: Gray;">本商城的用户名</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="card_left_01 none" id="td_leave">
                            留言(300字以内)：
                        </td>
                        <td id="td_leave1" class="none">
                            <textarea id="ta_LeaveWords" name="ta_LeaveWords" rows="3" cols="46"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td class="card_left_01">
                        </td>
                        <td>
                            <asp:Button ID="btn_next" runat="server" Text="下一步" CssClass="cursor_pointer" 
                                OnClientClick="return checkData();" onclick="btn_next_Click" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</asp:Content>
