<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ExhibitorMaster.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <div>
        <form id="f1" action="" method="post">
        <table width="100%" cellspacing="0" cellpadding="0" class="table">
            <thead>
                <tr>
                    <th colspan="2">
                    <br />
                        <h3>
                            <span>发送电子版参观邀请函</span></h3>
                    </th>
                </tr>
            </thead>
            <tbody>
                <%
                    string type = ViewData["Type"].ToString();

                    int ImeID = 0;
                    string ImeName = "";
                    string ImeComName = "";
                    string ImeEmail = "";
                    string ImeGender = "";
                    string ImeTel = "";
                    //string ImeInviteLan = "";

                    System.Data.DataRow dr = ViewData["DataRow"] as System.Data.DataRow;
                    if (type == "Edit")
                    {
                        ImeID = Convert.ToInt32(dr["ImeID"].ToString());
                        ImeName = Server.HtmlEncode(dr["ImeName"].ToString());
                        ImeComName = Server.HtmlEncode(dr["ImeComName"].ToString());
                        ImeEmail = Server.HtmlEncode(dr["ImeEmail"].ToString());
                        ImeGender = Server.HtmlEncode(dr["ImeGender"].ToString());
                        ImeTel = Server.HtmlEncode(dr["ImeTel"].ToString());
                        //ImeInviteLan = Server.HtmlEncode(dr["ImeInviteLan"].ToString());
                    }
                            
                %>
                <tr>
                    <td width="25%">
                        <div class="dnnTooltip">
                            <label>
                                <span>姓名:</span>
                            </label>
                        </div>
                    </td>
                    <td>
                        <input name="ImeName" type="text" id="ImeName" value="<%=ImeName %>" />
                        <span id="checkImeName" class="" style="color: Red;">※</span>
                    </td>
                </tr>
                <tr>
                    <td width="25%">
                        <div class="dnnTooltip">
                            <label>
                                <span>公司名称:</span>
                            </label>
                        </div>
                    </td>
                    <td>
                        <input name="ImeComName" type="text" id="ImeComName" value="<%=ImeComName %>" />
                        <span id="checkImeComName" class="" style="color: Red;">※</span>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="dnnTooltip">
                            <label>
                                <span>称谓:</span>
                            </label>
                        </div>
                    </td>
                    <td>
                        <select name="selImeGender" id="selImeGender">
                            <option value="先生">先生</option>
                            <option value="女士">女士</option>
                        </select>
                        <input type="hidden" id="ImeGender" name="ImeGender" value="<%=ImeGender %>" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="dnnTooltip">
                            <label>
                                <span>电子邮箱:</span>
                            </label>
                        </div>
                    </td>
                    <td>
                        <input name="ImeEmail" type="text" id="ImeEmail" value="<%=ImeEmail %>" />
                        <span id="checkImeEmail" class="" style="color: Red;">※</span>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="dnnTooltip">
                            <label>
                                <span>联系电话:</span>
                            </label>
                        </div>
                    </td>
                    <td>
                        <input name="ImeTel0" type="text" maxlength="4"
                            id="ImeTel0" onkeypress="OnlyNum();"  onkeyup="value=value.replace(/[^\d]/g,'')" style="width: 30px;" />
                        <label>
                            -</label>
                        <input name="ImeTel1" type="text" maxlength="4"
                            id="ImeTel1" onkeypress="OnlyNum();"  onkeyup="value=value.replace(/[^\d]/g,'')" style="width: 35px;" />
                        <label>
                            -</label>
                        <input name="ImeTel2" type="text" maxlength="20" id="ImeTel2" onkeypress="OnlyNum();"  onkeyup="value=value.replace(/[^\d]/g,'')"
                            style="width: 70px;" />
                        <label>
                            -</label>
                        <input name="ImeTel3" type="text" maxlength="4"
                            id="ImeTel3" onkeypress="OnlyNum();"  onkeyup="value=value.replace(/[^\d]/g,'')" style="width: 35px;" />
                            <span id="checkImeTel" class="" style="color: Red;"></span>
                        <div class="alert alert-info">
                            <div class="dnnTooltip">
                                <label>
                                    <span>(格式：国家号-区号-电话号-分机)</span>
                                </label>
                            </div>
                        </div>
                        <input type="hidden" id="ImeTel" name="ImeTel" value="<%=ImeTel %>" />
                        
                    </td>
                </tr>
                <%--<tr>
                    <td>
                        <div class="dnnTooltip">
                            <label>
                                <span>语言:</span>
                            </label>
                        </div>
                    </td>
                    <td>
                        <table>
                            <tr>
                                <td>
                                    <table border="0">
                                        <tr>
                                            <td>
                                                <input id="ImeInviteLan1" type="radio" name="InviteLan"
                                                    value="cn" checked="checked" /><label for="ImeInviteLan1">中文</label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <input id="ImeInviteLan2" type="radio" name="InviteLan"
                                                    value="en" /><label for="ImeInviteLan2">英文</label>
                                            </td>
                                        </tr>
                                        <input type="hidden" id="ImeInviteLan" name="ImeInviteLan" value="<%=ImeInviteLan %>" />
                                    </table>
                                    <br />
                                </td>
                                <td>
                                    <a href="<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Content/Template/pre-reg_cn.htm" target="_blank"
                                        class="btn btn-success">中文电子邀请函</a><br />
                                    <br />
                                    <a href="<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Content/Template/pre-reg_en.htm" target="_blank"
                                        class="btn btn-success">英文电子邀请函</a>
                                </td>
                            </tr>
                        </table>
                        <div class="alert alert-info">
                            <div class="dnnTooltip">
                                <label>
                                    <span>(系统将会根据您的语言选择发送中文或英文电子邀请函)</span>
                                </label>
                            </div>
                        </div>
                    </td>
                </tr>--%>
            </tbody>
            <tfoot>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                       <%-- <input type="hidden" id="IfSend" name="IfSend" value="" />--%>
                        <input type="hidden" id="Type" name="Type" value="<%=ViewData["Type"] %>" />
                        <input type="hidden" id="ImeID" name="ImeID" value="<%=ViewData["ImeID"] %>" />
                        <%--<a id="SubmitSend" title="确认信息并发送" class="btn btn-success"
                            href="javascript:Save(true);" style="display: inline-block; border-style: None;"><span style=" color:White;">确认信息并发送</span> </a>--%> <a title="保存信息稍后发送" class="btn btn-success"  href="javascript:Save();"
                                style="display: inline-block; border-style: None; background-color:#4EB0AE;"><span style=" color:White;">保存信息</span></a> <a title="取消" class="btn btn-success" href="javascript:Cancel();" style="display: inline-block; border-style: None; background-color:#4EB0AE;"><span style=" color:White;">取消</span></a> 
                    </td>
                </tr>
            </tfoot>
        </table>
        </form>
    </div>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Scripts/bootstrap.min.css" rel="stylesheet" type="text/css" />
   <script src="<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Scripts/CheckInfo1.js"
        type="text/javascript"></script>
    <script src="<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Scripts/DynaForm1.js"
        type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#CurrentPosition").html("发送电子版参观邀请函");
//        MenuActive(7);
        $("#ImeName").blur(function () {
            checkImeName();
        });
        $("#ImeComName").blur(function () {
            checkImeComName();
        });
        $("#ImeEmail").blur(function () {
            checkImeEmail();
        });
        $("#ImeTel0").blur(function () {
            checkImeTel();
        });
        $("#ImeTel1").blur(function () {
            checkImeTel();
        });
        $("#ImeTel2").blur(function () {
            checkImeTel();
        });
        $("#ImeTel3").blur(function () {
            checkImeTel();
        });

        if ($("#ImeGender").val() != "") {
            $("#selImeGender option[value='" + $("#ImeGender").val() + "']").attr("selected", true);
        }

        var tel = $("#ImeTel").val();
        if (tel != "") {
            $("#ImeTel0").val(tel.split("-")[0]);
            $("#ImeTel1").val(tel.split("-")[1]);
            $("#ImeTel2").val(tel.split("-")[2]);
            $("#ImeTel3").val(tel.split("-")[3]);
        }

        // $("input[name='InviteLan'][value=" + $("#ImeInviteLan").val() + "]").attr("checked", "checked");


        checkAll();

        iframeAutoFit();
    });


    function OnlyNum() {
        var realKey = String.fromCharCode(event.keyCode)
        var myReg = /^(-|\+)?\d+$/;
        if (myReg.test(event.srcElement.value + realKey) == false) {
            event.returnValue = false;
        }
    }

    function checkAll() {
        checkImeName(); checkImeComName(); checkImeEmail(); checkImeTel();
    }

    function showMessage(message) {
        showMsg(message);
    }

    function showCheckTag(id, ispass, message, isshowpass) {
        if (ispass == true) {
            $("#" + id).removeClass();
            if (isshowpass == true) {
                $("#" + id).html('<img src="../content/images/success-icn.png">');
            }
            else {
                $("#" + id).html('');
            }
        } else {
            if (message == null) {
                message = "";
            }
            $("#" + id).removeClass().addClass("alert alert-error");
            $("#" + id).html('<font color="red">※' + message + '</font>');
        }
    }

    function checkImeName() {
        var ImeName = $("#ImeName").val();
        var error = BrdName_Check("姓名", ImeName);
        if (error != "") {
            showCheckTag("checkImeName", false, error, true);
            return false;
        }
        showCheckTag("checkImeName", true, "", true);
        return true;
    }

    function checkImeComName() {
        var ImeComName = $("#ImeComName").val();
        var error = BrdName_Check("公司名称", ImeComName);
        if (error != "") {
            showCheckTag("checkImeComName", false, error, true);
            return false;
        }
        showCheckTag("checkImeComName", true, "", true);
        return true;
    }

    function checkImeEmail() {
        var ImeEmail = $("#ImeEmail").val();
        var error = Email_Check("电子邮箱", ImeEmail);
        if (error != "") {
            showCheckTag("checkImeEmail", false, error, true);
            return false;
        }
        showCheckTag("checkImeEmail", true, "", true);
        return true;
    }

    function checkImeTel() {
        var tel0 = $("#ImeTel0").val();
        var tel1 = $("#ImeTel1").val();
        var tel2 = $("#ImeTel2").val();
        var tel3 = $("#ImeTel3").val();

        if (tel0 != "" && (tel1 == "" || tel2 == "")) {
            showCheckTag("checkImeTel", false, "请完整输入联系电话", true);
            return false;
        }
        if (tel1 != "" && (tel0 == "" || tel2 == "")) {
            showCheckTag("checkImeTel", false, "请完整输入联系电话", true);
            return false;
        }
        if (tel2 != "" && (tel0 == "" || tel1 == "")) {
            showCheckTag("checkImeTel", false, "请完整输入联系电话", true);
            return false;
        }
        if (tel3 != "" && (tel0 == "" || tel1 == "" || tel2 == "")) {
            showCheckTag("checkImeTel", false, "请完整输入联系电话", true);
            return false;
        }
        showCheckTag("checkImeTel", true, "", false);
        if (tel0 != "" && tel1 != "" && tel2 != "") {
            $("#ImeTel").val(tel0 + "-" + tel1 + "-" + tel2 + "-" + tel3);
        }
        return true;

    }

    function Save() {
        if (!checkImeName()) {
            showMessage("请输入姓名！");
            $("#ImeName").focus().select();
            return ;
        }
        if (!checkImeComName()) {
            showMessage("请输入公司名称！");
            $("#ImeComName").focus().select();
            return ;
        }

        if (!checkImeEmail()) {
            showMessage("请正确输入电子邮箱！");
            $("#ImeEmail").focus().select();
            return ;
        }

        if (!checkImeTel()) {
            showMessage("请完整输入联系电话！");
            $("#ImeTel1").focus().select();
            return ;
        }
        $("#ImeGender").val($("#selImeGender").find("option:selected").text());
            $("#f1").submit();
       
    }

//    function checkSaveInfo() {
//        if (!checkImeName()) {
//            showMessage("请输入姓名！");
//            $("#ImeName").focus().select();
//            return false;
//        }
//        if (!checkImeComName()) {
//            showMessage("请输入公司名称！");
//            $("#ImeComName").focus().select();
//            return false;
//        }

//        if (!checkImeEmail()) {
//            showMessage("请正确输入电子邮箱！");
//            $("#ImeEmail").focus().select();
//            return false;
//        }

//        if (!checkImeTel()) {
//            showMessage("请完整输入联系电话！");
//            $("#ImeTel1").focus().select();
//            return false;
//        }

//        $("#ImeInviteLan").val($("input[name='InviteLan']:checked").val());
//        $("#ImeGender").val($("#selImeGender").find("option:selected").text());

//        return true;
//    }

    function Cancel() {
        window.location = "<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Invitation/EmailInvitation";
    }                            

    </script>
</asp:Content>
