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


<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .checktype
        {
             width:170px;
             height:23px; 
             padding:5px;
             line-height:13px;
             float:left;
        }
        .checktypeword
        {
            width:140px;
            height:22px;
            line-height:13px;  
            display:inline;
            padding-top:5px;
            padding-bottom:5px;
        }
        .childcontainer
        {
             margin-left:30px;
             width:550px;
        }
    </style>
    <script src="<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Scripts/CheckInfo.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#CurrentPosition").html("展商报名");

            //国家
            var country = $("#Country").val();
            var countryCode = "";
            $("#selCountry option").each(function () {
                if ($(this).text() == country) {
                    $(this).attr("selected", true);
                    countryCode = $(this).val();
                }
            });
            if (countryCode != "") {
                if (countryCode == "852" || countryCode == "853") {
                    $("#tel1").css("display", "none");
                    $("#fax1").css("display", "none");
                }
                else {
                    $("#tel1").css("display", "");
                    $("#fax1").css("display", "");
                }
                $("#tel0").val(countryCode);
                $("#fax0").val(countryCode);
            }
            //电话
            var tel = $("#Tel").val();
            var telStr = tel.split('-');
            for (var i = 0; i < 4; i++) {
                $("#tel" + i).val(telStr[i]);
            }
            //传真
            var fax = $("#Fax").val();
            var faxStr = fax.split('-');
            for (var i = 0; i < 4; i++) {
                $("#fax" + i).val(faxStr[i]);
            }
            //产品类别
            var selectID = $("#SelectTypeID").val();
            var IDList = selectID.split(",");
            for (var i = 0; i < IDList.length; i++) {
                var id = IDList[i]; 
                if (id != "") {
                    $("#TypID" + id).attr("checked", true);
                }
            }
            //验证码
            GetNewVCImg();
        });
        //选择国家
        function CountryChange() {
            var countryCode = $("#selCountry").val();
            if (countryCode != "") {
                if (countryCode == "852" || countryCode == "853") {
                    $("#tel1").css("display", "none");
                    $("#fax1").css("display", "none");
                    $("#tel1").val("");
                    $("#fax1").val("");
                }
                else {
                    $("#tel1").css("display", "");
                    $("#fax1").css("display", "");
                }
                $("#tel0").val("");
                $("#tel0").val(countryCode);
                $("#fax0").val("");
                $("#fax0").val(countryCode);
            }
            else {
                $("#tel1").css("display", "");
                $("#fax1").css("display", "");
                $("#tel0").val("");
                $("#fax0").val("");
            }
        }

        function Save() {
            //公司名称
            var comName = $.trim($("#ComName").val());
            if (comName == "") {
                $("#ComName").focus();
                MsgTip.show({ msg: "请输入公司名称！", ico: "warning", top: 340 });
                return;
            }
            //公司英文名称
            //联系人
            var name = $.trim($("#Name").val());
            if (name == "") {
                $("#Name").focus();
                MsgTip.show({ msg: "请输入姓名！", ico: "warning", top: 340 });
                return;
            } else {
                if (!checkChEn(name)) {
                    $("#Name").focus();
                    MsgTip.show({ msg: "姓名只能输入中文或英文！", ico: "warning", top: 340 });
                    return;
                }
            }
            //国家地区
            var country = $.trim($("#selCountry").find("option:selected").text());
            var countryCode = $.trim($("#selCountry").val());
            if (countryCode == "") {
                $("#selCountry").focus();
                MsgTip.show({ msg: "请选择国家地区！", ico: "warning", top: 340 });
                return;
            }
            $("#Country").val(country);
            //联系电话
            var tel0 = $.trim($("#tel0").val());
            var tel1 = $.trim($("#tel1").val());
            var tel2 = $.trim($("#tel2").val());
            var tel3 = $.trim($("#tel3").val());
            if (!checkNum(tel0)) {
                $("#tel0").focus();
                MsgTip.show({ msg: "请输入国家号！须为数字", ico: "warning", top: 340 });
                return;
            }
            if (tel0 != "852" && tel0 != "853") {
                if (!checkNum(tel1)) {
                    $("#tel1").focus();
                    MsgTip.show({ msg: "请输入区号！须为数字", ico: "warning", top: 340 });
                    return;
                }
            }
            if (!checkNum(tel2)) {
                $("#tel2").focus();
                MsgTip.show({ msg: "请输入电话号码！须为数字", ico: "warning", top: 340 });
                return;
            } else {
                if (tel2.length < 7) {
                    $("#tel2").focus();
                    MsgTip.show({ msg: "电话号码至少7位数字！", ico: "warning", top: 340 });
                    return;
                }
            }
            if (tel3 != "") {
                if (!checkNum(tel3)) {
                    $("#tel3").focus();
                    MsgTip.show({ msg: "请输入分机号码！须为数字", ico: "warning", top: 340 });
                    return;
                }
            } 
            $("#Tel").val(tel0 + "-" + tel1 + "-" + tel2 + "-" + tel3);
            //传真号码
            var fax0 = $.trim($("#fax0").val());
            var fax1 = $.trim($("#fax1").val());
            var fax2 = $.trim($("#fax2").val());
            var fax3 = $.trim($("#fax3").val());
            if (!checkNum(fax0)) {
                $("#fax0").focus();
                MsgTip.show({ msg: "请输入国家号！须为数字", ico: "warning", top: 340 });
                return;
            }
            if (tel0 != "852" && tel0 != "853") {
                if (!checkNum(fax1)) {
                    $("#fax1").focus();
                    MsgTip.show({ msg: "请输入区号！须为数字", ico: "warning", top: 340 });
                    return;
                }
            }
            if (!checkNum(fax2)) {
                $("#fax2").focus();
                MsgTip.show({ msg: "请输入传真号码！须为数字", ico: "warning", top: 340 });
                return;
            } else {
                if (fax2.length < 7) {
                    $("#fax2").focus();
                    MsgTip.show({ msg: "传真号码至少7为数字！", ico: "warning", top: 340 });
                    return;
                } 
            }
            if (fax3 != "") {
                if (!checkNum(fax3)) {
                    $("#fax3").focus();
                    MsgTip.show({ msg: "请输入分机号码！须为数字", ico: "warning", top: 340 });
                    return;
                }
            }
            $("#Fax").val(fax0 + "-" + fax1 + "-" + fax2 + "-" + fax3);
            //电子邮箱
            var email = $.trim($("#Email").val());
            if (email == "") {
                $("#Email").focus();
                MsgTip.show({ msg: "请输入电子邮箱！", ico: "warning", top: 340 });
                return;
            } else {
                if (!checkEmail(email)) {
                    $("#Email").focus();
                    MsgTip.show({ msg: "电子邮箱格式不正确！", ico: "warning", top: 340 });
                    return;
                }
            }
            //公司网址
            var webUrl = $.trim($("#WebUrl").val());
            if (webUrl != "") {
                if (!checkUrl(webUrl)) {
                    $("#WebUrl").focus();
                    MsgTip.show({ msg: "网址格式不正确！请以http://开头", ico: "warning", top: 340 });
                    return;
                }
            }
            //公司地址
            var address = $.trim($("#Address").val());
            if (address == "") {
                $("#Address").focus();
                MsgTip.show({ msg: "请输入公司地址！", ico: "warning", top: 340 });
                return;
            }
            //邮编
            var zipcode = $.trim($("#ZipCode").val());
            if (zipcode != "") {
                if (!checkNum(zipcode)) {
                    $("#ZipCode").focus();
                    MsgTip.show({ msg: "邮编只能输入数字！", ico: "warning", top: 340 });
                    return;
                }
            }
            //产品类型
            var checkItem = $("input[type=checkbox][name=TypID]:checked");
            if (checkItem.length <= 0) {
                MsgTip.show({ msg: "请选择产品分类！", ico: "warning", top: 340 });
                return;
            }

            $("#f1").submit();
        }

        function Back() {
            window.location = "<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Login/Login/" + $("#ExhID").val();
        }
    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <center>
            <form id="f1" action="" method="post">
            <% 
                FamousFurnitureExpo.Models.ActorApply aly = ViewData["ActorApply"] as FamousFurnitureExpo.Models.ActorApply;    
            %>
            <table width="100%" border="0" cellspacing="0" cellpadding="5">
                <tr><td>&nbsp;</td></tr>
                <tr>
                    <td colspan="4" align="left" style="font-size:14px; padding-top:0px; padding-bottom:0px;">
                        展商报名：
                    </td>
                </tr>
                <tr><td>&nbsp;</td></tr>
                <tr>
                    <td colspan="4" align="center">
                        <font color="red">请您认真填写以下内容，不正确或不完整的信息可能不被接受。
                        我们会及时收到您的申请并和您联系。</font>
                    </td>
                </tr>
                <tr>
                    <td width="20%" align="right">公司名称：</td>
                    <td width="30%" align="left">
                        <input type="text" class="text" id="ComName" name="ComName" value="<%=Server.HtmlEncode(aly.AlyComName) %>" />&nbsp;<font color="red">*</font>
                    </td>
                    <td width="20%" align="right">公司英文名称：</td>
                    <td width="30%" align="left">
                        <input type="text" class="text" id="ComEName" name="ComEName" value="<%=Server.HtmlEncode(aly.AlyComEName) %>" />
                    </td>
                </tr>
                <tr>
                    <td align="right">联系人：</td>
                    <td align="left">
                        <input type="text" class="text" id="Name" name="Name" value="<%=Server.HtmlEncode(aly.AlyPsnName) %>" />&nbsp;<font color="red">*</font>
                    </td>
                    <td align="right">国家地区：</td>
                    <td align="left">
                        <select id="selCountry" name="selCountry" onchange="CountryChange()" onkeyup='this.blur();this.focus();'
                            style="height: 22px; width: 130px;">
                            <option value="">--请选择--</option>
                            <option value="86">中国</option>
                            <% 
                                List<FamousFurnitureExpo.Models.ZipTel> countryLi = FamousFurnitureExpo.Models.ZipTel.GetZtpCountry();
                                foreach (FamousFurnitureExpo.Models.ZipTel zipTel in countryLi)
                                {
                            %>
                                <option value="<%=zipTel.ZtpCountryCode %>"><%=zipTel.ZtpCountry %></option>
                            <%        
                                }
                            %>
                        </select>
                        <input type="hidden" id="Country" name="Country" value="<%=Server.HtmlEncode(aly.AlyCountry) %>" />&nbsp;<font color="red">*</font>
                    </td>
                </tr>
                <tr>
                    <td align="right">联系电话：</td>
                    <td align="left">
                        <input type="text" id="tel0" name="tel0" class="text" style="width:30px" onkeyup="value=value.replace(/[^\d]/g,'')" /> -
                        <input type="text" id="tel1" name="tel1" class="text" style="width:30px" onkeyup="value=value.replace(/[^\d]/g,'')" /> -
                        <input type="text" id="tel2" name="tel2" class="text" style="width:90px" onkeyup="value=value.replace(/[^\d]/g,'')" /> -
                        <input type="text" id="tel3" name="tel3" class="text" style="width:30px" onkeyup="value=value.replace(/[^\d]/g,'')" />
                        <input type="hidden" id="Tel" name="Tel" value="<%=Server.HtmlEncode(aly.AlyTel) %>" />&nbsp;<font color="red">*</font>
                    </td>
                    <td align="right">传真号码：</td>
                    <td align="left">
                        <input type="text" id="fax0" name="fax0" class="text" style="width:30px" onkeyup="value=value.replace(/[^\d]/g,'')" /> -
                        <input type="text" id="fax1" name="fax1" class="text" style="width:30px" onkeyup="value=value.replace(/[^\d]/g,'')" /> -
                        <input type="text" id="fax2" name="fax2" class="text" style="width:90px" onkeyup="value=value.replace(/[^\d]/g,'')" /> -
                        <input type="text" id="fax3" name="fax3" class="text" style="width:30px" onkeyup="value=value.replace(/[^\d]/g,'')" />
                        <input type="hidden" id="Fax" name="Fax" value="<%=Server.HtmlEncode(aly.AlyFax) %>" />&nbsp;<font color="red">*</font>
                    </td>
                </tr>
                <tr>
                    <td align="right">电子邮箱：</td>
                    <td align="left">
                        <input type="text" class="text" id="Email" name="Email" value="<%=Server.HtmlEncode(aly.AlyEmail) %>" />&nbsp;<font color="red">*</font>
                    </td>
                    <td align="right">公司网址：</td>
                    <td align="left">
                        <input type="text" class="text" id="WebUrl" name="WebUrl" value="<%=Server.HtmlEncode(aly.AlyWebUrl) %>" />
                    </td>
                </tr>
                <tr>
                    <td align="right">公司地址：</td>
                    <td align="left">
                        <input type="text" class="text" id="Address" name="Address" value="<%=Server.HtmlEncode(aly.AlyAddress) %>" />&nbsp;<font color="red">*</font>
                    </td>
                    <td align="right">邮编：</td>
                    <td align="left">
                        <input type="text" class="text" id="ZipCode" name="ZipCode" value="<%=Server.HtmlEncode(aly.AlyZipCode) %>" onkeyup="value=value.replace(/[^\d]/g,'')" />
                    </td>
                </tr>
                <tr>
                    <td align="right">产品分类：</td>
                    <td align="left" colspan="3" style="border:1px solid #bfefff;">
                    <%
                        List<FamousFurnitureExpo.Models.TypeInfo> liAll = ViewData["TypeInfo"] as List<FamousFurnitureExpo.Models.TypeInfo>;
                        if (liAll.Count > 0)
                        {
                            int i = 0;
                            List<FamousFurnitureExpo.Models.TypeInfo> liType1 = liAll.FindAll(main => main.TypParentID.Trim() == "");
                            foreach (FamousFurnitureExpo.Models.TypeInfo ti1 in liType1)
                            {
                                List<FamousFurnitureExpo.Models.TypeInfo> liType2 = liAll.FindAll(child => child.TypParentID.Trim() == ti1.TypID.ToString());
                                bool type1HaveChild = false;
                                if (liType2.Count > 0)
                                {
                                    type1HaveChild = true;
                                }
                    %>
                        <%if (type1HaveChild&&i!=0) { %><%} %>
                        <div id="Type1-<%=ti1.TypID %>" class="checktype" style="font-weight:bolder;">
                        <%if (!type1HaveChild){ %>
                            <input type="checkbox" id="TypID<%=ti1.TypID %>" name="TypID" value="<%=ti1.TypID %>" style="vertical-align:top;" />
                        <%}%>
                            <div class="checktypeword">
                            <label for="TypID<%=ti1.TypID %>"><%=ti1.TypName%></label>
                            </div>
                        </div>
                        <%if (type1HaveChild){ %>
                        <table id="Child-Type1-<%=ti1.TypID %>" class="childcontainer"><tr><td>
                        <%} %>
                    <%
                                foreach (FamousFurnitureExpo.Models.TypeInfo ti2 in liType2)
                                {
                                    List<FamousFurnitureExpo.Models.TypeInfo> liType3 = liAll.FindAll(child => child.TypParentID.Trim() == ti2.TypID.ToString());
                                    bool type2HaveChild = false;
                                    if (liType3.Count > 0)
                                    {
                                        type2HaveChild = true;
                                    }  
                    %>
                            <%if (type2HaveChild) { %><%} %>
                            <div id="Type2-<%=ti2.TypID %>" class="checktype" style="font-weight:normal;">
                            <%if (!type2HaveChild){ %>
                                <input type="checkbox" id="TypID<%=ti2.TypID %>" name="TypID" value="<%=ti2.TypID %>" style="vertical-align:top;" />
                            <%}%>
                                <div class="checktypeword">
                                <label for="TypID<%=ti2.TypID %>"><%=ti2.TypName%></label>
                                </div>
                            </div>
                            <%if (type2HaveChild){ %>
                            <table id="Child-Type2-<%=ti2.TypID %>" class="childcontainer"><tr><td>
                            <%} %>
                    <% 
                                    foreach (FamousFurnitureExpo.Models.TypeInfo ti3 in liType3)
                                    {
                    %>
                                <div id="Type3-<%=ti3.TypID %>" class="checktype" style="font-weight:lighter;">
                                    <input type="checkbox" id="TypID<%=ti3.TypID %>" name="TypID" value="<%=ti3.TypID %>" style="vertical-align:top;" />
                                    <div class="checktypeword">
                                    <label for="TypID<%=ti3.TypID %>"><%=ti3.TypName%></label>
                                    </div>
                                </div>
                    <%                    
                                    }    
                    %>
                            <%if (type2HaveChild){ %>
                            </td></tr></table>
                            <%} %>
                    <%                
                                }  
                    %>
                        <%if (type1HaveChild){ %>
                        </td></tr></table>
                        <%} %>
                    <%
                                i++;
                            }
                    %>
                        <br />
                        <br />
                    <%
                        }
                    %>
                        <input type="hidden" id="SelectTypeID" name="SelectTypeID" value="<%=Server.HtmlEncode(aly.AlyPdtType) %>" />
                    </td>
                </tr>
                <tr>
                    <td align="right">验证码：</td>
                    <td align="left" colspan="3">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td><input type="text" class="text" style="width:50px;" id="VC" name="VC" />&nbsp;</td>
                                <td><img id="VCImg" src="" alt="验证码" />&nbsp;</td>
                                <td><a href="javascript:GetNewVCImg();">看不清，换一张</a></td>
                            </tr>
                        </table>
                        <script type="text/javascript">
                            function GetNewVCImg() {
                                $('#VCImg').attr('src', '<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Regist/ValidateCode?newID=' + getRandom());
                            }
                        </script>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="3">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td><div class="button" onclick="Save()">提交</div></td>
                                <td><div class="button" onclick="Back()">返回登录页</div></td>
                            </tr>
                        </table>
                        <input type="hidden" id="ExhID" name="ExhID" value="<%=ViewData["ExhID"] %>" />
                        <script type="text/javascript">
                            var message = "<%=ViewData["Message"] %>";
                            if (message != "") {
                                MsgTip.show({ msg: message, ico: "warning", top: 340 });
                            }
                        </script>
                    </td>
                </tr>
            </table>
            </form>
        </center>
    </div>
</asp:Content>
