<%@ page language="C#" autoeventwireup="true" inherits="Rest_order_QuicklyPlaceOrder, DoodiiShop" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register Src="../../Controls/BottomNo51la1.ascx" TagName="BottomNo51la1" TagPrefix="uc2" %>
<%@ Register Src="../../Controls/BriefnessTop.ascx" TagName="BriefnessTop" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>电话订餐下单</title>

    <script type="text/javascript" src="/system/js/func.js"></script>

    <script type="text/javascript" src="/system/js/Format.js"></script>

    <script type="text/javascript" src="/system/js/jquery.js"></script>

    <script type="text/javascript" src="/system/js/dropdown/dropdown.js"></script>

    <link rel="Stylesheet" type="text/css" href="/system/css/Public.css" />
    <link rel="stylesheet" type="text/css" href="/css/v5/Lib.css" />
    <link href="/css/NewCSS/RestManageContain.css" rel="stylesheet" type="text/css" />
    <link type="text/css" rel="stylesheet" href="/js/jquery-calendar/jquery-calendar.css" />

    <script type="text/javascript" src="/js/jquery-calendar/jquery-calendar.js"></script>

    <script type="text/javascript" src="/js/thickbox/thickbox.js"></script>

    <link href="/js/thickbox/thickbox.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="/js/Nav.js"></script>

    <script type="text/javascript" src="/js/Lib/Tabs1.js"></script>

    <script src="/js/jtip.js" type="text/javascript"></script>

    <script type="text/javascript" src="/js/jtip/jtip.js"></script>

    <script type="text/javascript" src="/js/Lib/WindowsManager.js"></script>

    <script type="text/javascript" src="/js/Lib/AreaSelector2.js"></script>

    <script type="text/javascript" src="/js/Lib/PageNavigator.js"></script>

    <link href="/css/CSS.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
#divConfirmOrderInfo
{
    width:710px;
    height:330px;
    overflow:auto;  
}
.tbl_2{width:694px;}
.tbl_2 th{text-align:center;}
.tbl_2 td{padding-top:5px;padding-bottom:5px;margin-left:1px;}
a.lnkPhoneSelected:link, a.lnkPhoneSelected:visited, a.lnkPhoneSelected:hover{ width:41px;}
a.lnkPhoneSelected span.Input_span1{}
html{background:url('')}
.dianhua{ float:left; width:914px; height:57px; margin-bottom:10px; background:#f2fbff; border:1px solid #2890cf;}
 .dian{ float:left; width:695px; height:40px; padding-top:17px; line-height: 22px; font-weight:bold; margin-bottom:10px; padding-left:15px;}
.lianxi{float:left; width:917px; height:141px;}
.xinxi{ float:left; width:895px; height:26px; line-height:26px; font-size:14px; font-weight:bold;
 padding-left:22px;  background-image:url(/images/v6top/fk06.gif);color:#ffffff; margin-bottom:4px;}
#divUserInfo{float:left; width:915px; height:111px; background:#f2fbff; border:1px solid #2890cf;}
.canpin{float:left; width:917px; height:auto; margin-top:12px;}
.can_two{float:left; width:602px; height:26px; line-height:26px; font-size:14px;font-weight:bold; padding-left:22px;
 background-image:url(/images/v6top/fg28.gif);color:#ffffff;}
.canhetiao{float:left; width:251px;line-height:26px;font-size:14px;font-weight:bold; padding-left:22px; 
margin-bottom:6px; background-image:url(/images/v6top/ff03.gif);color:#ffffff;}
.canhekuan{float:left; text-align:center;width:252px;background:#ffffff;  border: 1px solid #2890cf; padding:12px 9px 12px 10px;}
.tbl_1{text-align:center;width:250px;line-height:28px;}
.MyMealbox_styleyi{float: left; margin-top: 15px; width: 106px; color:#fff; height: 23px; line-height: 23px; text-align: center; background-image: url("/images/index/four1_09.gif");}
.gsan{
    background-color: #FFFFFF;
    border: 1px solid #2890CF;
    float: left;
    line-height: 20px;
    padding: 5px 10px;
    width: 672px;
}
.gsi{margin-top: 10px; float: left; width: 650px;}
.MyMealbox_styley
{
    background-image:url("/images/v6top/four1_06.gif");
    color: #FFFFFF;
    height: 23px;
    line-height: 23px;
    text-align: center;
    width: 58px;}
a.All_Input_4:link, a.All_Input_4:visited, a.All_Input_4:hover{
    background: none repeat scroll 0 0 #1C9507;
    border: 2px solid #FFFFFF;
    color: #FFFFFF;
    float: left;
    height: 30px;
     width: 90px;
    line-height: 30px;
    padding: 0 5px;
    margin-left: 3px;    
    display: inline;}
.wqi{float: left;width:60px;}
.wba{float: left;width:40px;}
.tongxun,a.lnkPhone:hover,a.lnkPhone:visited,a.lnkPhone:link
{float:left; text-align:center; border: 1px solid gray; width:40px; background:#ede7e9;  height: 20px; line-height: 20px;color:gray;}
a.lnkPhoneSelected:link, a.lnkPhoneSelected:visited, a.lnkPhoneSelected:hover {background: #1c9507;border: 1px solid #fff;color:white;}
.vWindowDialog .title1
{
    background-image:url(/images/index/four1.gif);
}
</style>
</head>
<body style="background: url('../../images/v6top/bj.jpg') repeat-x scroll center top rgb(27, 75, 151);">
    <form id="form1" runat="server">
        <uc1:BriefnessTop ID="BriefnessTop1" runat="server" />
        <input type="hidden" value="" id="MealBox_thistime" runat="server" />
        <div style="clear: both; width: 952px; margin: 0 auto; line-height: 48px; height: 48px;
            background-image: url(/images/v6top/11_03.gif);">
            <span style="float: left; padding-left: 302px; width: 53px; color: #ffee00;"><a id="lblLogin"
                style="color: #ffee00;" href="/member/Login.aspx">管理首页</a></span> <span style="float: left;
                    width: 115px; color: #ffffff;">&gt;&gt;电话订餐下单</span> <span style="float: right; width: 63px;
                        padding-right: 18px;"><a style="color: #ffee00;" href="javascript:history.go(-1);">返回上一页</a></span>
        </div>
        <div style="clear: both; margin: 0 auto; height: auto;">
            <div class="Band" style="padding-bottom: 1px; width: 952px; background-color: White;">
                <div style="float: left; background: #ffffff; height: auto; padding-left: 18px; padding-bottom: 10px;">
                    <div id="divDemo" runat="server" style="color: red; font-size: 24px; margin: 0px;
                        background-color: white; padding: 0px;">
                        <strong>&nbsp;如果您需要申请试用或购买本模块请<a href='http://www.doulaiding.com/buy/' target="_blank">联系我们</a>！</strong><br />
                    </div>
                    <div runat="server" id="divContent">
                        <%--提取用户信息--%>
                        <div class="xinxi">
                            提取信息</div>
                        <div class="dianhua">
                            <div class="dian"><span style="float: left;">联系电话：</span><input onkeypress="EnterTextBox(event)" style="width: 122px;
                                margin-right: 8px; margin-top: 4px; float: left;" type="text" id="tbMobileS"
                                runat="server" />
                            <span style="float: left; text-align: center; border: 2px solid #fff; background: #1c9507;
                                width: 90px; height: 20px; line-height: 20px;"><a style="color: #fff;" href="JavaScript:GetUserInfo()">
                                    提取用户信息</a></span> <span style="float: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;联系信息：</span>
                            <span style="float: left; background: url(/images/v6top/dq_03.gif) no-repeat; width: 321px;
                                height:21px;cursor:pointer;border:#999 solid 0px; text-indent:0.5em;" onclick="divOtherShow()" id="spUserInfo">暂无信息！</span>
                            <div style="display:none; position:absolute; width: 320px; margin-left: 374px; z-index:998;
                                margin-top: -3px;border-color:#999;" id="divOtherUserInfo">
                            </div>
                            </div>
                          <div style="margin-top:15px; cursor:hand;" onmousemove="javascript:$('#spHelp').css('display','inline');" onmouseout="javascript:$('#spHelp').hide();"><span style="float:left; font-weight:normal; width:162px; margin-left:20px; display:inline; line-height:20px;
                             height:auto; border:1px solid #666666; background:#fdfeb8; text-align:center;">&nbsp;<img src="../../images/v6top/as_03.gif" />&nbsp;<span style="color:Red;">帮助小贴士</span>
                             </span>
                        </div>
                        <span id="spHelp" style=" margin-left:-164px; margin-top:22px; display:none;position:absolute;float:left; font-weight:normal; width:162px;line-height:20px;height:auto; border:1px solid #666666; background:#fdfeb8;">联系电话支持输入手机号码：<br />例如：13712345678；<br />支持7或8位固话号(可加1-5位分机号)：<br />例如：固话：12345678；<br />固话+分机：<br />12345678-12345。</span>
                        </div>
                        <%--联系信息--%>
                        <div id="divMyMealBox" class="lianxi" style="width: 100%">
                            <div class="xinxi">
                                联系信息</div>
                            <div id="divUserInfo">
                                <table style="float: left; width: 900px; line-height:35px; margin-left: 15px; margin-top: 16px;
                                    display: inline;">
                                    <tr>
                                        <td style="width: 65px; font-weight: bold;">
                                            联系电话：</td>
                                        <td style="width: 276px;">
                                            <span><a class="tongxun lnkPhoneSelected" id="lnkMobile" href="javascript:void(0);">
                                                手机</a> <span style="float: left; line-height: 25px;">&nbsp;或&nbsp;</span> <a class="tongxun_1 lnkPhone"
                                                    id="lnkPhone" href="javascript:void(0);">固话</a> </span><span style="float: left;
                                                        width: 148px; margin-left: 5px; display: inline; margin-top: 5px;">
                                                        <div id="divMobile">
                                                            <input style="width: 141px;" type="text" id="tbMobile" runat="server" maxlength="11" /></div>
                                                        <div id="divPhone" style="display: none;">
                                                            <input class="wqi" type="text" id="tbPhone" runat="server" maxlength="8" />
                                                            <span style="float: left; line-height: 20px;">&nbsp;分机：</span><input class="wba"
                                                                id="tbExtension" runat="server" maxlength="5" type="text" />
                                                        </div>
                                                    </span>
                                            <div id="divLogin_PhoneInfo" style="display: none;">
                                            </div>
                                        </td>
                                        <td style="float: right; font-weight: bold;text-align:right;">
                                            姓名：</td>
                                        <td style="width: 118px; text-align:left;">
                                            <div id="divLogout_Name">
                                                <input style="width: 90px;" type="text" id="tbName" runat="server" maxlength="10" />
                                            </div>
                                            <div id="divLogin_Name" style="display: none;">
                                            </div>
                                        </td>
                                        <td style="font-weight: bold;text-align:right;">
                                            楼宇/小区：</td>
                                        <td style="width: 116px;text-align:left;">
                                            <asp:TextBox ID="tbArea" Style="width: 90px" runat="server"></asp:TextBox>
                                        </td>
                                        <td style="width: 68px; font-weight: bold;text-align:right;">
                                            详细地址：</td>
                                        <td style="text-align:left;">
                                            <div id="divLogout_AddressInfo">
                                                <span class="louyu" style="display: none;" id="divAreaName"></span>
                                                <input class="wshi" style="width: 90px;" id="tbAddress" type="text" runat="server" />
                                            </div>
                                            <div id="divLogin_AddressInfo" style="display: none;">
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style=" font-weight: bold;">
                                            送达日期：<%-- </td>
                                        <td style=" width:85px;">--%>
                                        </td>
                                        <td style="font-weight: bold;">
                                            <span style="padding-right:35px; font-weight:normal;color: Red;" id="spDeliverDate" runat="server"></span>
                                            送达时间：<%--</td>
                                    <td style=" width:115px; line-height:28px;">--%>
                                            <select id="selHour" style="color: Red;">
                                                <option>请选择..</option>
                                            </select>
                                            <%--点<select id="selMinute"></select>分--%>
                                            <div style="width: 115px;">
                                                <span id="spDeliverDateShow" style="color: Red; display: none;" runat="server"></span>
                                                <select id="ddlDeliverTime" style="color: Red; display: none;" runat="server">
                                                    <option>12:00</option>
                                                </select>
                                            </div>
                                        </td>
                                        <td style="float: right; font-weight: bold;text-align:right;">
                                            备注：</td>
                                        <td colspan="2">
                                            <asp:TextBox ID="tbNote" runat="server" TextMode="MultiLine" MaxLength="50" Rows="1" Width="160px"></asp:TextBox>
                                        </td>
                                        <td colspan="2" align="center" class="wssan">
                                            <a class="All_Input_4" href="javascript:MealBox_ConfirmOrderInfo();">确认订单信息</a>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div id="divMsg" style="display: none;">
                                您还未订购餐品，请快快订餐吧！</div>
                        </div>
                        <div id="divConfirmOrderInfo" class="vWindowDialog" style="height: 420px; width: 775px;
                            padding-top: 13px; overflow: hidden;z-index:999">
                            <div class="title1">
                                确认订单信息</div>
                            <div class="gyi" style="width: 724px; border-left: 6px solid #2890CF; border-bottom: 6px solid #2890CF;
                                border-right: 6px solid #2890CF; height: 340px; margin: 0 auto; overflow: auto;">
                                <div style="float: left; padding-left: 8px;">
                                    <div class="MyMealbox_styley">
                                        我的餐盒</div>
                                    <div id="divMealBox2" style="float: left;">
                                    </div>
                                    <div class="MyMealbox_styleyi">
                                        我的地址联系信息
                                    </div>
                                    <br />
                                    <div id="divMealBoxOtherInfo" class="gsan">
                                        姓名：<span id="divConfirmOrderInfo_Name"></span>&nbsp;&nbsp;&nbsp;&nbsp; 电话：<span id="divConfirmOrderInfo_PhoneInfo"></span>&nbsp;&nbsp;&nbsp;&nbsp;
                                        地址：<span id="divConfirmOrderInfo_AddressInfo"></span>&nbsp;&nbsp;&nbsp;&nbsp; 要求：<span
                                            id="divConfirmOrderInfo_DeliverTime" style="color: Red;"></span>送达
                                        <br />
                                        备注：<span id="divConfirmOrderInfo_Note"></span>&nbsp;&nbsp;&nbsp;&nbsp;
                                    </div>
                                    <div class="gsi">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span id="divConfirmOrderInfo_RestName" style="color: Red;"></span><span
                                            style="color: Green;"> 提示您：我们将竭尽全力按时送送，但可能路上人多车多，交通不畅，如有偏差，希望您能体谅！</span>
                                        <div id="restPromises" runat="server" style="padding-top: 8px;">
                                        </div>
                                    </div>
                                    <div style="float: left; padding-bottom: 25px; margin-top: 8px; padding-left: 220px;">
                                        <div class="SorryMessage011">
                                            <div class="SorryMessage021">
                                                <div class="SorryMessage031" style="float: left; width: 400px;">
                                                    <a class="Style_Input" style="float: left;" id="lnkMealBox_SaveOrderOtherInfo" href="javascript:MealBox_SaveOrderOtherInfo(false);">
                                                        提交订单</a> <a class="Style_Input" style="float: left; background-image: url(/images/index/Input4.gif);
                                                            background-repeat: no-repeat; width: 116px; color: #000; margin-left: 10px;"
                                                            href="javascript:void(0);" onclick="vWindowsManager.HideDialog()">返回继续订餐</a>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="Style_dikuangyi">
                                &nbsp
                            </div>
                        </div>
                        <%--选择餐品--%>
                        <div class="canpin">
                            <div style="float: left; width: 624px;">
                                <div class="can_two">
                                    选择餐品
                                </div>
                                <div style="float: left; width: 622px; padding-top: 10px; height: auto; border-bottom: 1px solid #2890cf;
                                    border-left: 1px solid #2890cf; border-right: 1px solid #2890cf;">
                                    <asp:Label ID="lblrestId" runat="server" Text="0" Visible="false"></asp:Label>
                                    <input type="hidden" id="hdweekcount" runat="server" />
                                    <div class="Style_time">
                                        <div class="qsan">
                                        </div>
                                        <ul id="week" runat="server">
                                            <li style="vertical-align: middle;"><span runat="server" id="order"></span></li>
                                        </ul>
                                    </div>
                                    <div class="Style_content">
                                        <div id="divMenuClassList" class="Style_foodnav">
                                        </div>
                                        <div style="clear: both;">
                                        </div>
                                        <div class="xuanzecanpin">
                                            <div id="divMealPrice" class="MealPrice1">
                                                <span class="xuanzecanpinyi"></span><span class="xuanzecanpiner">&nbsp;金额筛选： </span>
                                                &nbsp; <span id="spMenuPriceList"></span>
                                            </div>
                                            <%--菜单开始--%>
                                            <div id="divMealList" class="Meal">
                                            </div>
                                            <div id="divMealListNav" class="MealShow1" style="display: none;">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div id="divLoading" style="display: none; position: absolute; background: white;">
                                <img src='/images/System/loading.gif' alt='正在载入...' /></div>
                            <%--餐盒开始--%>
                            <div style="float: right; width: 273px; background: #ffffff; height: auto;">
                                <div class="canhetiao">
                                    <span>餐盒信息</span></div>
                                <span style="color: #000;" id="DeliverArea_msg"></span>
                                <div class="canhekuan">
                                    <div id="divMealBox" style="float: left; width: 250px; padding-bottom:15px;">
                                    </div>
                                    <div style="text-align: center; padding-top: 15px; padding-bottom:5px;">
                                        <a class="normal" onclick="if (MealBox_TotalAmount>0) {if(!confirm('是否清空餐盒?'))return;orderClear();}else{alert('您还没有选择餐品！');}">
                                            ［清空餐盒］</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <input type="hidden" id="hidMealBoxColorIndex" value="<%=MealBoxIndex.ToString() %>" />
            <input type="hidden" id="hidMealBoxColorSMax" value="3" />
        </div>
        <uc2:BottomNo51la1 ID="BottomNo51la1_1" runat="server" />
    </form>
</body>
</html>

<script type="text/javascript">

    
var Deliver_IsCs=1;
var MealBox_tbNullColor = "#989898";//提示信息色
var MealBox_tbColor = "#000000";//正常显示色

var MealBoxColorIndex = 0;
var MealBox_RestName = "<%=MealBox_RestName %>";
var MealBox_RestID = "<%=MealBox_RestID %>";
var MealBox_AreaID = 0;
var MealBox_AddressID = 0;
var MealBox_IsLogin = <%=MealBox_IsLogin.ToString().ToLower() %>;
var MealBox_OrderOtherInfo = [{name:"",mobile:"",phone:""}];
var MB_thisTime;

$(document).ready(function(){
    MealBoxShow();
    MealBox_loginUserOrderInfoInit();
    
    IsNoMenu();
    addressAppendInit();
    $("#<%=tbArea.ClientID %>").bind("focus", function(){      
        DeliverAddress_objAreaSelector2.show();//显示选择楼宇层
        DeliverAddress_getAreaList(1);//刷新楼宇列表
    });
    MealBox_UserOrderInfoInit();
    
    
   var spUserInfo = document.getElementById("spUserInfo");
   $("#divOtherUserInfo")[0].style.left = (GetPosition(spUserInfo).x-373) + "px";
   $("#divOtherUserInfo")[0].style.top = (GetPosition(spUserInfo).y+4 + spUserInfo.offsetHeight) + "px"; 
});
function EnterTextBox(evt)
{
    if(evt.keyCode == 13) //按下了回车，并且文本框里有值
    {
        GetUserInfo();
    }
}
//显示送达时间
function MealBox_GetDeliverTimeList()
{
    if (MealBox_RestID>0 && DeliverDayStr!="" && MealBox_AreaID>0)
    {
        var ret = Rest_order_QuicklyPlaceOrder.GetDeliverTimeList(MealBox_RestID,DeliverDayStr,MealBox_AreaID).value;
        if (ret != null)
        {   
            ddlBind(ret,"selHour",null,"text","value");
        }
    }
}
function GetUserInfo()
{
    var tel=$.trim($("#<%=tbMobileS.ClientID %>").val());
    var reg=/^([2-9][0-9]{6,7})+(\-[0-9]{1,5})?$/;
    var reg1=/^\d{11}$/;
    var r=tel.match(reg);
    var r1=tel.match(reg1);
    if(r==null && r1==null)
    {
        alert("请填写正确的联系电话！");
        return;
    }
    var mobile="";
    var phone="";
    if(tel.substring(0,1)=="1") mobile=tel;
    else phone=tel;
    var ret=Rest_order_QuicklyPlaceOrder.GetUserInfo(mobile,phone).value;
    if(ret!=null && ret.Rows.length>0)
    {
        var infoStr=ret.Rows[0]["name"]+"&nbsp;"+ret.Rows[0]["AreaName"]+"&nbsp;"+ret.Rows[0]["address"];
        $("#spUserInfo").html(infoStr);
        var otherInfoStr="<ul>";
        for(var i=0;i<ret.Rows.length;i++)
        {
            var name=ret.Rows[i]["name"];
            var areaid=ret.Rows[i]["areaId"];
            var address=ret.Rows[i]["address"];
            var areaname=ret.Rows[i]["AreaName"];
            if(i==0)
            {
                checkUserInfo(name,areaid,address,areaname);
                MealBox_GetDeliverTimeList();
            }
            /*otherInfoStr+="<li style='background:#ffffc7; float:left; width:319px; hight:18px; border:1px solid #000;'><span style='float:left;' onclick='checkUserInfo(\""+name+"\","+areaid+",\""+address+"\",\""+areaname+"\")'>"
                        +name+"&nbsp;"+areaname+"&nbsp;"+address+"</span>"
                        +"&nbsp;<span style=' margin-left:160px; display: inline;' onclick='deleteUserInfo("+ret.Rows[i]["id"]+")'><a style=' color:#ff0000;' href='#' target='_blank'>X</a></span></li>";
                        */
            otherInfoStr+="<li style='background:#FDFED8; float:left; width:319px; hight:18px; border:1px solid #999;'>"
                    +"<table width='100%' style='cursor:pointer; text-indent:0.5em;' onclick='checkUserInfo(\""+name+"\","+areaid+",\""+address+"\",\""+areaname+"\")'><tr><td>"
                     +name+"&nbsp;"+areaname+"&nbsp;"+address+"</td>"
                        +"<td onclick='deleteUserInfo("+ret.Rows[i]["id"]+")' style='color:red;cursor:pointer;width:10px;text-align:right;font-size:18px;'>"
                        + "×</td>"
                        + "<td onclick='deleteUserInfo("+ret.Rows[i]["id"]+")' style='font-weight:normal;color:red;width:30px;text-align:left;'>删除</td></tr></table></li>";
        }
        otherInfoStr+="</ul>";
        $("#divOtherUserInfo").html(otherInfoStr);
        $("#spUserInfo").css("background","url('/images/v6top/dq_03.gif') no-repeat");
        $("#divOtherUserInfo").css("display","none");
    }
    else
    {
        $("#spUserInfo").html("不存在此用户！").css("background","url('/images/v6top/dq_02.gif') no-repeat");
        $("#divOtherUserInfo").html("");
        checkUserInfo("",0,"","");
    }
    
}
//function NewTop_PopDivCity(obj)
//    {       
//        var PopMessageCity = document.getElementById("PopMessageCity");
//        if (PopMessageCity.style.display == "none")
//        {
//           PopMessageCity.style.left = NewTop_GetPosition(obj).x + "px";
//           PopMessageCity.style.top = NewTop_GetPosition(obj).y + obj.offsetHeight + "px";
//           $("#PopMessageCity").show();
//        }
//        else
//        {
//            $("#PopMessageCity").hide();
//        }
//    }
   
    function GetPosition(obj)
    {
        var o = null;
        if (typeof obj == 'string')
          o = document.getElementById(obj);
        else
          o = obj;
          
        var x=y=0;
        do{
            x+=o.offsetLeft;
            y+=o.offsetTop;
        }
        while (o=o.offsetParent);
        return {"x":x,"y":y};
    }



function checkUserInfo(name,areaid,address,areaname)
{
    var tel=$.trim($("#<%=tbMobileS.ClientID %>").val());
    if(tel.substring(0,1)=="1")
    {
        $("#<%=tbMobile.ClientID %>").val(tel);
        changeContactInfo(1);
        $("#<%=tbPhone.ClientID %>").val("");
        $("#<%=tbExtension.ClientID %>").val("");
    }
    else
    {
        if(tel.indexOf("-")>0)
        {
            var ex=tel.substring((tel.indexOf("-")+1),tel.length);
            var phone=tel.substring(0,tel.indexOf("-"));  
            $("#<%=tbPhone.ClientID %>").val(phone);
            $("#<%=tbExtension.ClientID %>").val(ex);
        }
        else
            $("#<%=tbPhone.ClientID %>").val(tel);
        $("#<%=tbMobile.ClientID %>").val("");
        changeContactInfo(2)
    }
    if(name!=""&&areaid!=0&&address!="" &&areaname!="")
    $("#spUserInfo").html(name+"&nbsp"+areaname+"&nbsp;"+address);
    $("#<%=tbName.ClientID %>").val(name);
    $("#<%=tbAddress.ClientID %>").val(address);
    $("#<%=tbArea.ClientID %>").val(areaname);
    $("#divOtherUserInfo").css("display","none");
    MealBox_AreaID=areaid;
    tbName_focus();
    tbMobile_focus();
    tbPhone_focus();
    tbExtension_focus();
    tbAddress_focus();
    
    tbName_blur();
    tbMobile_blur();
    tbPhone_blur();
    tbExtension_blur();
    tbAddress_blur();
}
function deleteUserInfo(id)
{
    if(!window.confirm("你确定要删除此地址吗？"))
    {
        return;
    }
    var ret=Rest_order_QuicklyPlaceOrder.deleteUserInfo(id).value;
    if(ret==0)
    {
        alert("删除成功！");
        GetUserInfo();
    }
    else
    {
        alert("删除失败！");
        return;        
    }
        
}
function divOtherShow()
{
    if($("#divOtherUserInfo").css("display")=="none")
        $("#divOtherUserInfo").css("display","block");
    else
        $("#divOtherUserInfo").css("display","none");
}
//Area
function addressAppendInit()
{
     DeliverAddress_objAreaSelector2 = new AreaSelector2({
        onRegionChangeFunc: DeliverAddress_AreaSelector_onRegionChange,
        onPageChangeFunc: DeliverAddress_AreaSelector_onPageChange,
        onKeywordChangeFunc: DeliverAddress_AreaSelector_onKeywordChange,
        onSelectAreaFunc: DeliverAddress_AreaSelector_onSelectArea,
        onLettersChangeFunc:DeliverAddress_AreaSelector_onLettersChange,
        onClosedFunc:Deliver_onClose,            
        offsetX: 0,
        offsetY: -5 ,
        pageStyle:1,
        divToolbarDomContent:"<span style='color:#666; float:left; line-height:32px;'>&nbsp;&nbsp;如果楼宇太多，不方便查找您可以直接在这里搜索。</span><a class='All_Input1' style='width:108px; padding-left:12px; margin-left:10px; margin-top:4px;' href='javascript:void(0);' onclick='DeliverAddress_objAreaSelector2.close();'><span class='Input_span'>我想先去店里逛逛</span><span class='Input_span2'></span></a>"
        });
        
}
 //楼宇选择控件JS
    function DeliverAddress_AreaSelector_onRegionChange(index)
    {
        DeliverAddress_getAreaList();
    }
    function DeliverAddress_AreaSelector_onPageChange(index)
    {
        DeliverAddress_getAreaList(index);
    }
    function DeliverAddress_AreaSelector_onKeywordChange(keyword)
    {
        DeliverAddress_getAreaList();
    }
    function DeliverAddress_AreaSelector_onSelectArea(objAreaInfo)
    {   
        MealBox_AreaID = objAreaInfo.areaId;
        MealBox_GetDeliverTimeList();
        $("#<%=tbArea.ClientID %>").val(objAreaInfo.areaName);
        DeliverAddress_objAreaSelector2.hide();
         
    }
    function DeliverAddress_AreaSelector_onLettersChange(letter)
    {
       DeliverAddress_getAreaList();
    }
    function Deliver_onClose()
    {
    }
    function DeliverAddress_getAreaList(pageIndex)
    {     
         if (pageIndex!=null)
            DeliverAddress_objAreaSelector2.pageIndex = pageIndex;
        else
            DeliverAddress_objAreaSelector2.pageIndex = 1;  
         Rest_order_QuicklyPlaceOrder.GetSuggestAreaList(
            -1,
            -1,
            -1,
            DeliverAddress_objAreaSelector2.keyword,
            DeliverAddress_objAreaSelector2.letter,
            DeliverAddress_objAreaSelector2.pageIndex,
            DeliverAddress_objAreaSelector2.pageSize,
            MealBox_RestID,
            DeliverAddress_getAreaList_Callback
        );
    }
    
    function DeliverAddress_getAreaList_Callback(res)
    {
        DeliverAddress_objAreaSelector2.clearAreaResult();
        var ret = res.value;
        if (ret == null) return;
        for (var i = 0; i < ret.Items.length; i++)
        {
            var areaName = ret.Items[i].Name;
            var areaId = parseInt(ret.Items[i].Id);
            DeliverAddress_objAreaSelector2.appendArea(areaId, areaName);
        }
        Rest_order_QuicklyPlaceOrder.showPage(ret.PageInfo.TotalPage);
        if (ret.Items.length == 0)
        {
            if ($.trim(DeliverAddress_objAreaSelector2.keyword) != "")
            {
                var s = "";
            }
            else
            {
                var s = "当前区域暂时没有楼宇/小区。";
            }
            DeliverAddress_objAreaSelector2.setMessage(s);
        }
       
        
    }

function _menu_boxclare()
{
         $("#<%=tbAddress.ClientID %>").val("");
        
}
function ContentAmountAdd(index)
{
    var ret = Rest_order_QuicklyPlaceOrder.ContentAmountAdd(index).value;    
    if (ret==1) 
        MealBoxShow();   
    else
        alert("错误！请您刷新本页再试！");    
}
function ContentAmountSub(index)
{
    var ret = Rest_order_QuicklyPlaceOrder.ContentAmountSub(index).value;    
    if (ret==1) 
        MealBoxShow();   
    else
        alert("错误！请您刷新本页再试！");    
}
function ContentAmountAdd2(index)
{
    ContentAmountAdd(index);MealBoxShow2();
}
function ContentAmountSub2(index)
{
   ContentAmountSub(index);MealBoxShow2();
}

function deleteMenu(restid,menuid,configID,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10) 
{ 
　Rest_order_QuicklyPlaceOrder.deleteMenu(restid,menuid,configID,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10, 0, 0);
　MealBoxShow();
}
function deleteMenu2(restid,menuid,configID,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10) 
{ 
　deleteMenu(restid,menuid,configID,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10);
　MealBoxShow2();
}
 
function deleteSMenu(restid,menuid) 
{ 
　Rest_order_QuicklyPlaceOrder.deleteSMenu(restid,menuid, 0, 0);
　MealBoxShow();
} 
function deleteSMenu2(restid,menuid) 
{ 
　deleteSMenu(restid,menuid) 
　MealBoxShow2();
} 

//清除我的餐盒
function orderClear()
{    
	Rest_order_QuicklyPlaceOrder.orderClear(0, 0);
	MealBoxShow(); 
}

var MealBox_TotalAmount = 0;
//显示我的餐盒
function MealBoxShow()
{
    if (!MealBox_CheckLoginState()){ return; }//检查页面登录状态
    var ret=Rest_order_QuicklyPlaceOrder.GetDifference(MealBox_AreaID).value;
    var hidMealBoxColorIndex=document.getElementById("hidMealBoxColorIndex");
    var divMyMealBox = document.getElementById("divMyMealBox");
    var divMealBox = document.getElementById("divMealBox");    
    var hidMealBoxColorIndex = document.getElementById("hidMealBoxColorIndex");
    var ret = Rest_order_QuicklyPlaceOrder.GetOrderTable(0,0,hidMealBoxColorIndex.value).value;        
    if(ret!=null)
    {
    divMyMealBox.style.display = "";
    divMealBox.innerHTML = ret.ListStr;   
    MealBox_TotalAmount = ret.TotalAmount;
    MealBoxColorIndex = ret.MealBoxColorIndex;

    $("#<%=spDeliverDate.ClientID %>").html(ret.DeliverDate);
    }
}
/* 检查订单是否同一餐馆 */
function CheckOrderRest()
{
    var chkRet = Rest_order_QuicklyPlaceOrder.CheckOrderRest(<%=RestID %>).value;
    if (chkRet > 0)
    {
        return 1;
    }
    if (chkRet<0)    
    {   
        if (confirm("您餐盒里的餐与您当前所在的餐馆不一致，是否清空餐盒重新订餐？"))
        {
          orderClear();          
          return 1;
        }
        else
        {
            return 0;
        }
    }
    return 1;
}
//确认送餐信息
function ConfirmDeliverInfo()
{    
//    if (!confirm("是否确认送餐信息?"))
//        return;
    if(!DeliverMenu_CheckShopState(<%=RestID %>)) //检测餐馆营业状态
    {
        
        return;
    }
    if (MealBox_TotalAmount>0)
    {
        var chkRet = Rest_order_QuicklyPlaceOrder.CheckOrderRest(<%=RestID %>).value;
        if (chkRet < 0)//不一致
        {  
            if (confirm("您餐盒里的餐与您当前所在的餐馆不一致，是否清空餐盒重新订餐？"))
            {
              orderClear();
            }
            return;        
        }

         ret=Rest_order_QuicklyPlaceOrder.getAlert().value;
         if(ret.state==0)
         {alert(ret.alert);return}
         
         if(ret.state==1)
         {if(!confirm(ret.alert))
         {return;}
         else{}}
         if(ret.state==2)
         {}
         
        var BackUrl = getQuery("BackUrl",window); 
        var restID = <%=RestID %>;
        if (BackUrl==1)
            window.location = "/Shop/" + restID + "/Order/ConfirmOrderInfo.shtml";
        else
            window.location = "/Shop/" + restID + "/Order/InputOrderInfo.shtml"; 
    }
    else
        alert("您还没有选择餐品！");
}
function changeContactInfo(value)
{  
    if (value==1)
    {
        $("#lnkMobile").attr("class","lnkPhoneSelected tongxun");
        $("#lnkPhone").attr("class","lnkPhone tongxun_1");        
        $("#divPhone").hide();  
        $("#divMobile").show();                  
    }
    else
    {
        $("#lnkPhone").attr("class","lnkPhoneSelected tongxun");
        $("#lnkMobile").attr("class","lnkPhone tongxun_1")        
        $("#divMobile").hide();
        $("#divPhone").show();                 
    }
}

function tbName_focus()
{         
    $("#<%=tbName.ClientID %>").css("color",MealBox_tbColor);
    if ($.trim($("#<%=tbName.ClientID %>").val())=="填写真实姓名")
        $("#<%=tbName.ClientID %>").val("");    
    MealBox_SetMessage("<%=tbName.ClientID %>",1)
}
function tbName_blur()
{
     //alert($("#<%=tbName.ClientID %>").css("color") + "|" + MealBox_tbNullColor);
   if($("#<%=tbName.ClientID %>").css("color")==MealBox_tbNullColor
       || $.trim($("#<%=tbName.ClientID %>").val())=="") 
   {
        $("#<%=tbName.ClientID %>").css("color",MealBox_tbNullColor); 
        $("#<%=tbName.ClientID %>").val("填写真实姓名");
   }
   else
   {
        $("#<%=tbName.ClientID %>").css("color",MealBox_tbColor);
   }
   
   MealBox_SetMessage("<%=tbName.ClientID %>",0);
  
}
function tbMobile_focus()
{
    $("#<%=tbMobile.ClientID %>").css("color",MealBox_tbColor); 
    if ($.trim($("#<%=tbMobile.ClientID %>").val())=="填写您的11位手机号码")
        $("#<%=tbMobile.ClientID %>").val("");
    MealBox_SetMessage("<%=tbMobile.ClientID %>",1); 
}
function tbMobile_blur()
{
   if($("#<%=tbMobile.ClientID %>").css("color")==MealBox_tbNullColor
       || $.trim($("#<%=tbMobile.ClientID %>").val())=="") 
   {
        $("#<%=tbMobile.ClientID %>").css("color",MealBox_tbNullColor); 
        $("#<%=tbMobile.ClientID %>").val("填写您的11位手机号码");
   } 
   else
   {
        $("#<%=tbMobile.ClientID %>").css("color",MealBox_tbColor); 
   }
   MealBox_SetMessage("<%=tbMobile.ClientID %>",0); 
}
function tbPhone_focus()
{
    $("#<%=tbPhone.ClientID %>").css("color",MealBox_tbColor); 
    if ($.trim($("#<%=tbPhone.ClientID %>").val())=="填写固话")
        $("#<%=tbPhone.ClientID %>").val("");
    MealBox_SetMessage("<%=tbPhone.ClientID %>",1); 
}
function tbPhone_blur()
{
   if($("#<%=tbPhone.ClientID %>").css("color")==MealBox_tbNullColor
       || $.trim($("#<%=tbPhone.ClientID %>").val())=="") 
   {
        $("#<%=tbPhone.ClientID %>").css("color",MealBox_tbNullColor); 
        $("#<%=tbPhone.ClientID %>").val("填写固话");
   }
   else
   {
        $("#<%=tbPhone.ClientID %>").css("color",MealBox_tbColor);
   }
   MealBox_SetMessage("<%=tbPhone.ClientID %>",0); 
}
function tbExtension_focus()
{
    $("#<%=tbExtension.ClientID %>").css("color",MealBox_tbColor); 
    if ($.trim($("#<%=tbExtension.ClientID %>").val())=="分机")
        $("#<%=tbExtension.ClientID %>").val("");  
    MealBox_SetMessage("<%=tbExtension.ClientID %>",1);   
}
function tbExtension_blur()
{
   if($("#<%=tbExtension.ClientID %>").css("color")==MealBox_tbNullColor
       || $.trim($("#<%=tbExtension.ClientID %>").val())=="") 
   {
        $("#<%=tbExtension.ClientID %>").css("color",MealBox_tbNullColor); 
        $("#<%=tbExtension.ClientID %>").val("分机");
   }
   else
   {
        $("#<%=tbExtension.ClientID %>").css("color",MealBox_tbColor); 
   }
   MealBox_SetMessage("<%=tbExtension.ClientID %>",0); 
}
function tbAddress_focus()
{
    $("#<%=tbAddress.ClientID %>").css("color",MealBox_tbColor); 
    if ($.trim($("#<%=tbAddress.ClientID %>").val())=="填写详细地址")
        $("#<%=tbAddress.ClientID %>").val("");   
    MealBox_SetMessage("<%=tbAddress.ClientID %>",1);  
}
function tbAddress_blur()
{
   if( $("#<%=tbAddress.ClientID %>").css("color")==MealBox_tbNullColor
       || $.trim($("#<%=tbAddress.ClientID %>").val())=="")
   {
        $("#<%=tbAddress.ClientID %>").css("color",MealBox_tbNullColor); 
        $("#<%=tbAddress.ClientID %>").val("填写详细地址");
   }
   else
   {
        $("#<%=tbAddress.ClientID %>").css("color",MealBox_tbColor); 
   }
   MealBox_SetMessage("<%=tbAddress.ClientID %>",0);   
}
function tbNote_focus()
{   
    $("#<%=tbNote.ClientID %>").css("color",MealBox_tbColor); 
    if ($.trim($("#<%=tbNote.ClientID %>").val())=="最多50个汉字")
        $("#<%=tbNote.ClientID %>").val("");   
    MealBox_SetMessage("<%=tbNote.ClientID %>",1);  
}
function tbNote_blur()
{   
    if( $("#<%=tbNote.ClientID %>").css("color")==MealBox_tbNullColor
       || $.trim($("#<%=tbNote.ClientID %>").val())=="")
   {
        $("#<%=tbNote.ClientID %>").css("color",MealBox_tbNullColor); 
        $("#<%=tbNote.ClientID %>").val("最多50个汉字");
   }
   else
   {
        $("#<%=tbNote.ClientID %>").css("color",MealBox_tbColor); 
   }
   MealBox_SetMessage("<%=tbNote.ClientID %>",0);  
}
function tbMobileS_focus()
{   
    $("#<%=tbMobileS.ClientID %>").css("color",MealBox_tbColor); 
    if ($.trim($("#<%=tbMobileS.ClientID %>").val())=="请填写手机或电话")
        $("#<%=tbMobileS.ClientID %>").val("");   
    MealBox_SetMessage("<%=tbMobileS.ClientID %>",1);  
}
function tbMobileS_blur()
{   
    if( $("#<%=tbMobileS.ClientID %>").css("color")==MealBox_tbNullColor
       || $.trim($("#<%=tbMobileS.ClientID %>").val())=="")
   {
        $("#<%=tbMobileS.ClientID %>").css("color",MealBox_tbNullColor); 
        $("#<%=tbMobileS.ClientID %>").val("请填写手机或电话");
   }
   else
   {
        $("#<%=tbMobileS.ClientID %>").css("color",MealBox_tbColor); 
   }
   MealBox_SetMessage("<%=tbMobileS.ClientID %>",0);  
}
function MealBox_ddlDeliverTime_onChange()
{
    
}
//未登录用户订单信息初始化
function MealBox_logoutUserOrderInfoInit()
{
    $("#lnkMobile").bind("mousedown",function(){changeContactInfo(1)})
    $("#lnkPhone").bind("mousedown",function(){changeContactInfo(2)});
    changeContactInfo(1);
    $("#divLogin_Name").css("display","none");
    $("#divLogin_PhoneInfo").css("display","none");    ; 
    $("#divLogin_AddressInfo").css("display","none");
    $("#divLogout_Name").css("display","block");
    $("#divLogout_PhoneInfo").css("display","block");
    $("#divLogout_AddressInfo").css("display","block");
//    $("#lnkModifyAddressInfo").css("display","none");
    $("#<%=tbName.ClientID%>").val("");
    $("#<%=tbMobile.ClientID%>").val(""); 
    $("#<%=tbPhone.ClientID %>").val("");
    $("#<%=tbExtension.ClientID %>").val("");
    $("#<%=tbAddress.ClientID %>").val(""); 
     
    tbName_focus();
    tbMobile_focus();
    tbPhone_focus();
    tbExtension_focus();
    tbAddress_focus();
    tbNote_focus();
    tbMobileS_focus();
    
    tbName_blur();
    tbMobile_blur();
    tbPhone_blur();
    tbExtension_blur();
    tbAddress_blur();
    tbNote_blur();
    tbMobileS_blur();
      
}
//登录用户订单信息初始化
function MealBox_loginUserOrderInfoInit()
{
    $("#divLogout_Name").css("display","none");
    $("#divLogout_PhoneInfo").css("display","none");
    $("#divMobile").css("display","none");   
    $("#divPhone").css("display","none")
    $("#divLogout_AddressInfo").css("display","none");
    $("#divLogin_Name").css("display","block");
    $("#divLogin_PhoneInfo").css("display","block");
    $("#divLogin_AddressInfo").css("display","block");
//    $("#lnkModifyAddressInfo").css("display","block");
    $("#<%=tbName.ClientID%>").val("");
    $("#<%=tbMobile.ClientID%>").val(""); 
    $("#<%=tbPhone.ClientID %>").val("");
    $("#<%=tbExtension.ClientID %>").val("");
    $("#<%=tbAddress.ClientID %>").val("");   
    $("#<%=tbArea.ClientID%>").val("");
}
//未登录用户订单信息填写
function MealBox_logoutUserOrderInfoSet(areaID)
{
    MealBox_AreaID = areaID;    
    if (areaID>0)
    {         
        var orderOtherInfo = MealBox_GetOrderOtherInfo();
        if (orderOtherInfo!=null)
        {    
            if ($("#<%=tbName.ClientID %>").css("color") == MealBox_tbNullColor 
                || $.trim($("#<%=tbName.ClientID %>").val()) == "")
            { 
                $("#<%=tbName.ClientID%>").val(orderOtherInfo.Name);
            }
            
            if ($("#<%=tbMobile.ClientID %>").css("color") == MealBox_tbNullColor 
                || $.trim($("#<%=tbMobile.ClientID %>").val()) == "")
            {   
                $("#<%=tbMobile.ClientID%>").val(orderOtherInfo.Mobile);
            }
            if (areaID == orderOtherInfo.AreaID)
            {//alert(orderOtherInfo.Phone);     
                var phoneS = orderOtherInfo.Phone.split('-');
                $("#<%=tbPhone.ClientID %>").val(phoneS[0]);
                $("#<%=tbExtension.ClientID %>").val(phoneS[1]);
                $("#<%=tbAddress.ClientID %>").val(orderOtherInfo.Address);            
            }
        }
        var addressInfo = MealBox_GetAddressInfo(areaID);
        if (addressInfo != null)
            $("#divAreaName").html( addressInfo.AreaName + "（" + addressInfo.RegionName + "）");
        else
        {
            alert("楼宇有误");
        }
        
    }
    tbName_focus();
    tbMobile_focus();
    tbPhone_focus();
    tbExtension_focus();
    tbAddress_focus();
    tbNote_focus();
    
    tbName_blur();
    tbMobile_blur();
    tbPhone_blur();
    tbExtension_blur();
    tbAddress_blur();
    tbNote_blur();
}

//登录用户订单信息填写
//function MealBox_loginUserOrderInfoSet(addressID)
//{
//    MealBox_AddressID = addressID;   
//    if (addressID>0)
//    {       
//        var userAddressInfo = MealBox_GetUserAddressInfo(addressID);
//        if (userAddressInfo!=null)
//        {
//            MealBox_AreaID = userAddressInfo.AreaId;
//            $("#<%=tbName.ClientID%>").val(userAddressInfo.ContactPerson);
//            $("#<%=tbMobile.ClientID%>").val(userAddressInfo.ContactMobile);
//            var phoneS = userAddressInfo.ContactPhone.split('-');
//            $("#<%=tbPhone.ClientID %>").val(phoneS[0]);
//            $("#<%=tbExtension.ClientID %>").val(phoneS[1]);
//            $("#<%=tbAddress.ClientID %>").val(userAddressInfo.Address);
//            $("#divAreaName").html(userAddressInfo.AreaName + "（" + userAddressInfo.RegionName + "）")
//            
//            $("#divLogin_Name").html(userAddressInfo.ContactPerson);
//            $("#divLogin_PhoneInfo").html(userAddressInfo.ContactMobile + " " + userAddressInfo.ContactPhone);
//            $("#divLogin_AddressInfo").html(userAddressInfo.AreaName + " " + userAddressInfo.Address );          
//            tbName_focus();
//    tbMobile_focus();
//    tbPhone_focus();
//    tbExtension_focus();
//    tbAddress_focus();
//        }
//        else
//        {
//            alert("我的送餐地址有误！");
//        }
//    } 
//     
//}
//接收楼宇信息ID
function MealBox_UserOrderInfoSet(id)
{  
    if (!MealBox_CheckLoginState()){ return; }//检查页面登录状态
    
    if (MealBox_IsLogin == false || Deliver_IsCs==1)
    {
        MealBox_logoutUserOrderInfoSet(id);
    }
    else
    {
    }
    if (id>0)     
    {   MealBoxShow();  
        MealBox_GetDeliverTimeList();   
    }
    
}
//初始化
function MealBox_UserOrderInfoInit()
{
    MealBox_Init();
    if (!MealBox_CheckLoginState()){ return; }//检查页面登录状态
    
    if (MealBox_IsLogin == false || Deliver_IsCs==1)
     { 
        MealBox_logoutUserOrderInfoInit();
     }
    else if(MealBox_IsLogin==true && Deliver_IsCs==0 )
     { 
        MealBox_loginUserOrderInfoInit();
     } 
}
function MealBox_CheckLoginState()
{//检查页面登录状态
    if (MealBox_IsLogin != Rest_order_QuicklyPlaceOrder.IsLogin().value)
    {//如果已在页面停留但登录状态改变，刷新页面 
        if (MealBox_IsLogin)
            alert("您已经退出了登录！");
        else
            alert("您已经登录了！");
        window.location.replace(window.location);
        return false;
    }
    else
        return true;
}
///取得订单用户Cookie信息
function MealBox_GetOrderOtherInfo()
{
    return Rest_order_QuicklyPlaceOrder.GetOrderOtherInfo().value;
}
//取得用户送餐地址
function MealBox_GetUserAddressInfo(id)
{
    return Rest_order_QuicklyPlaceOrder.GetUserAddressInfo(id).value;
}
function MealBox_GetAddressInfo(id)
{
    return Rest_order_QuicklyPlaceOrder.GetAddressInfo(id).value;
}
//设置提示-1错误,0未处理,1当前,2正确
function MealBox_SetMessage(objName,state)
{
    if (state == -1)
        $("#" + objName).css("background","#FF9966");
    if (state == 0)
        $("#" + objName ).css("background","#FFFFFF");
    if (state == 1)
        $("#" + objName ).css("background","#CAFCA9");
    if (state == 2)
        $("#" + objName ).css("background","#EEEEEE");
}
function filtrateTelChar(e)
{
    var evt = window.event || e;
    var keyCode = evt.keyCode || evt.which;
    if (keyCode < 48 || keyCode > 57)
    {
        if (keyCode != 8 && keyCode != 46 && keyCode != 37 && keyCode != 39)
            return false;
        else
            return true;
    }
    return true;
}
function MealBox_tbNoteOnchange()
{
    var length = $("#<%=tbNote.ClientID %>").val().replace(/[^\x00-\xff]/g,"xx").length;        
   
}
//提交订单信息
function MealBox_CheckOrderInfo()
{
    MealBox_SetMessage("<%=tbName.ClientID %>",0);
    MealBox_SetMessage("<%=tbMobile.ClientID %>",0); 
    MealBox_SetMessage("<%=tbPhone.ClientID %>",0); 
    MealBox_SetMessage("<%=tbExtension.ClientID %>",0); 
    var error = "";  
    if  (!MealBox_IsLogin)
    {
        if ($("#<%=tbName.ClientID %>").css("color") == MealBox_tbNullColor 
            || $.trim($("#<%=tbName.ClientID %>").val()) == "")
        {        
            error += "请填写姓名！\n";
            MealBox_SetMessage("<%=tbName.ClientID %>",-1); 
        }
        
        var phone = $("#<%=tbPhone.ClientID %>").val();
        var subPhone = $("#<%=tbExtension.ClientID %>").val();
        var mobile = $("#<%=tbMobile.ClientID %>").val();
        if (
            ($("#<%=tbPhone.ClientID %>").css("color") == MealBox_tbNullColor || phone == "" )
            && ($("#<%=tbMobile.ClientID %>").css("color") == MealBox_tbNullColor || mobile == "")
           )
        {
            error += "手机和固定电话至少要填其中一个！\n";  
            changeContactInfo(1)
            MealBox_SetMessage("<%=tbMobile.ClientID %>",-1);         
            //return ;
        }
        else
        {        
            if (mobile != "" && $("#<%=tbMobile.ClientID %>").css("color") != MealBox_tbNullColor)
            {
                var pattern = /^[0-9]{11}$/;
                if (pattern.test(mobile) == false)
                {
                    error += "请填写11位的手机号码！\n";
                    changeContactInfo(1)
                    MealBox_SetMessage("<%=tbMobile.ClientID %>",-1); 
                    //return ;
                }
            }  
            if (($("#<%=tbPhone.ClientID %>").css("color") != MealBox_tbNullColor && phone != "") 
                || ($("#<%=tbExtension.ClientID %>").css("color") != MealBox_tbNullColor && subPhone != "")
                )
            {
                var pattern = /^[0-9]{7,8}$/;
                if (pattern.test(phone) == false)
                {
                    error += "请填写7或8位的固定电话号码！\n";
                    changeContactInfo(2);
                    MealBox_SetMessage("<%=tbPhone.ClientID %>",-1); 
                    //return ;
                }
                if ($("#<%=tbExtension.ClientID %>").css("color") != MealBox_tbNullColor && subPhone != "")
                {
                    var pattern = /^[0-9]/;
                    if (pattern.test(subPhone) == false)
                    {
                        error += "请填写正确的分机号码！\n";
                        changeContactInfo(2);
                        MealBox_SetMessage("<%=tbExtension.ClientID %>",-1); 
                        //return ;
                    }
                }
            }
        }
        if ($("#<%=tbAddress.ClientID %>").css("color") == MealBox_tbNullColor
            || $.trim($("#<%=tbAddress.ClientID %>").val()) == ""
           )
        {
           error += "请填写详细地址！\n";
           MealBox_SetMessage("<%=tbAddress.ClientID %>",-1); 
        }
    }
    if($.trim($("#<%=tbArea.ClientID %>").val())=="")
    {
        error+="请选择楼宇小区！\n";
        MealBox_SetMessage("<%=tbArea.ClientID %>",-1); 
    }
//    if($("#selHour").val()==-1)
//    {
//        error+="请选择正确的送达时间！\n";
//    }
    if (document.getElementById("selHour").value=="")
    {
        
        error += "请选择要求送达时间！\n";
        
    }        
    var length = $("#<%=tbNote.ClientID %>").val().replace(/[^\x00-\xff]/g,"xx").length;
    if (length>100)
    {
        error += "备注最多50个汉字！\n";
    }
    
    if (error != "")
    {
        alert(error);return false;
    } 
    else
    {
        
        return true;
    }
}
//提交订单信息
function MealBox_ConfirmOrderInfo()
{
    if (!MealBox_CheckLoginState()){ return; }//检查页面登录状态
    var ret = Rest_order_QuicklyPlaceOrder.CheckOrderRest(MealBox_RestID).value;        
    if (ret=="0")        
        alert("您还没有选择餐品！");    
    else if (ret<0)
    {
        if (confirm("您餐盒里的餐与您当前所在的餐馆不一致，是否清空餐盒重新订餐？"))
        {
          orderClear();
        }
        return;
    }
    else
    {     
        if (!MealBox_CheckOrderInfo())
        {
            return;    
        }
        if ($("#<%=tbAddress.ClientID %>").css("color") == MealBox_tbNullColor
            || $.trim($("#<%=tbAddress.ClientID %>").val()) == ""
           )
        {alert("请填写详细地址！\n");return;}
          //提示外送费
         var ret=Rest_order_QuicklyPlaceOrder.getAlert(MealBox_AreaID,MealBox_RestID).value;
         if(ret.state == 1)
         {
           if(!confirm(ret.alert))return;
         }
         
        if (!MealBox_divConfirmOrderInfo(true))
        {
            return;
        }
        MealBox_divConfirmOrderInfo(false);
 
    }
}
//显示确认订单信息
function MealBox_divConfirmOrderInfo(isCheck)
{
    if (!isCheck)
    {   
        MealBoxShow2();        
    }
    
    //alert($("#<%=tbName.ClientID %>").css("color"));
      MealBox_OrderOtherInfo.name = "";
      MealBox_OrderOtherInfo.mobile = "";
      MealBox_OrderOtherInfo.phone = "";
      if ( $("#<%=tbName.ClientID %>").css("color") != MealBox_tbNullColor && $.trim($("#<%=tbName.ClientID %>").val())!="")
       {     
            $("#divConfirmOrderInfo_Name").html($.trim($("#<%=tbName.ClientID %>").val()));    
            MealBox_OrderOtherInfo.name = $.trim($("#<%=tbName.ClientID %>").val());
       }
        var phoneInfo = "";
        if ($("#<%=tbMobile.ClientID %>").css("color") != MealBox_tbNullColor && $.trim($("#<%=tbMobile.ClientID %>").val())!="")
        {    
            phoneInfo += $.trim($("#<%=tbMobile.ClientID %>").val()) + "&nbsp;&nbsp;";
            MealBox_OrderOtherInfo.mobile = $.trim($("#<%=tbMobile.ClientID %>").val());
        }
        if ($("#<%=tbPhone.ClientID %>").css("color") != MealBox_tbNullColor && $.trim($("#<%=tbPhone.ClientID %>").val())!="")
        {   phoneInfo += $.trim($("#<%=tbPhone.ClientID %>").val());
            MealBox_OrderOtherInfo.phone = $.trim($("#<%=tbPhone.ClientID %>").val());
            if  ($("#<%=tbExtension.ClientID %>").css("color") != MealBox_tbNullColor && $.trim($("#<%=tbExtension.ClientID %>").val())!="")
            {   
                phoneInfo += "-" + $.trim($("#<%=tbExtension.ClientID %>").val());
                MealBox_OrderOtherInfo.phone += "-" +$.trim($("#<%=tbExtension.ClientID %>").val());
            }
            phoneInfo += "&nbsp;&nbsp;";  
        }
        $("#divConfirmOrderInfo_PhoneInfo").html(phoneInfo);
        $("#divConfirmOrderInfo_AddressInfo").html($.trim($("#<%=tbArea.ClientID %>").val()) + "&nbsp;&nbsp;" + $.trim($("#<%=tbAddress.ClientID %>").val())  );
       
    var time=new Date();
    var nowDate=time.getFullYear()+"-"+(((time.getMonth()+1)<10)?"0"+(time.getMonth()+1):(time.getMonth()+1))+"-"+(time.getDate()<10?("0"+time.getDate()):time.getDate());
    if(nowDate!=$("#spDeliverDate").html())
    document.getElementById("divConfirmOrderInfo_DeliverTime").innerHTML =$("#spDeliverDate").html()+"&nbsp;"+ $("#selHour").val();// + ":" +$("#selMinute").val();
    else
    document.getElementById("divConfirmOrderInfo_DeliverTime").innerHTML = "今天" + "&nbsp;"+ $("#selHour").val();
    if ($("#<%=tbNote.ClientID %>").css("color") != MealBox_tbNullColor && $.trim($("#<%=tbNote.ClientID %>").val())!="")
        $("#divConfirmOrderInfo_Note").html($.trim($("#<%=tbNote.ClientID %>").val()) );
    
    $("#divConfirmOrderInfo_RestName").html(MealBox_RestName);
      
    if (!isCheck)
    {    
        vWindowsManager.ShowDialog("divConfirmOrderInfo");
    }
    else
    {        
        return MealBox_SaveOrderOtherInfo(isCheck);

    }
    
}
//保存订单信息
function MealBox_SaveOrderOtherInfo(isCheck)
{
    if (!isCheck)
    {
        var ret=Rest_order_QuicklyPlaceOrder.getAlert(MealBox_AreaID,MealBox_RestID).value;
        if(ret.state<1)
        {
            alert(ret.alert);
            if (isCheck)
                return false
            else
                return;
        }     
        if(ret.state==1)
        {
             if(!confirm(ret.alert))
             {
                if (isCheck)
                    return false;
                else
                    return;
             }       
        }       
    }
    if (!MealBox_CheckLoginState()){ return; }//检查页面登录状态
    if (MealBox_CheckOrderInfo() == false) return;    
    var deliverDate = document.getElementById("<%=spDeliverDate.ClientID %>").innerHTML.trim();
    var deliverTime =$.trim($("#selHour").val());// + ":" +$("#selMinute").val();
    
    var name = MealBox_OrderOtherInfo.name;
    var phone = MealBox_OrderOtherInfo.phone;    
    var mobile = MealBox_OrderOtherInfo.mobile;
    var areaID = MealBox_AreaID;
    var addressID = MealBox_AddressID;
    var address = document.getElementById("<%=tbAddress.ClientID %>").value.trim();
    var note= "";
    if ($("#<%=tbNote.ClientID %>").css("color") != MealBox_tbNullColor && $.trim($("#<%=tbNote.ClientID %>").val())!="")
        note=document.getElementById("<%=tbNote.ClientID %>").value.trim();  
              
    if (addressID == "")
        addressID = 0;
    if (MealBox_AreaID == "")
        MealBox_AreaID = 0;
    //alert("MealBox_RestID:" + MealBox_RestID + "|deliverDate:" + deliverDate + "|deliverTime:" + deliverTime + "|name:" + name + "|"  + "phone:" + phone + "|mobile:" + mobile + "|addressID:" + addressID + "|areaID:" + areaID + "|address:" + address + "|note:" + note);
    //return ;
    $("#lnkMealBox_SaveOrderOtherInfo").attr("disabled", false);
    var ret = Rest_order_QuicklyPlaceOrder.SaveOrderOtherInfo(MealBox_RestID,deliverDate,deliverTime,name,phone,mobile,addressID,MealBox_AreaID,address,note,isCheck).value;       
    var message = ret.Message;
    if (isCheck && ret.Result>0)
    {      
        return true;
    }           
    else if (!isCheck && ret.Result>0)
    {
        alert(message);
        window.location.href ="/Rest/order/QuicklyPlaceOrder.aspx";
//        var orderid = ret.OrderID;
//        alert(message);
//        var str = "/Shop/Order/SuccessOrderInfo.aspx?orderId=" + orderid+"&restid="+MealBox_RestID;
//        window.location.href =str;
    }       
    else if(ret.Result == "-20")
    {
          var deliveTime = ret.DeliveTime; 
          window.alert(message); 
          ddlAdd("<%=ddlDeliverTime.ClientID %>",deliveTime,deliveTime);
          $("#<%=ddlDeliverTime.ClientID %> option[@value=" + deliveTime + "]").attr("selected", true);
          document.getElementById("divConfirmOrderInfo_DeliverTime").innerHTML = "今天" + "&nbsp;"+ $("#selHour").val();
         //document.getElementById("divConfirmOrderInfo_DeliverTime").innerHTML =$("#spDeliverDate").html()+"&nbsp;"+ $("#selHour").val();// + ":" +$("#selMinute").val();
          alert(message);
    }
    else if(ret.Result =="-2")
    {
        window.alert(message);
        return;
    }
    else if(ret.Result == "-100")
    {//没有餐品
        window.alert(message); 
    }
    else
    {
        window.alert(message);        
    }
    if (isCheck)
        return false;
}
//function MealBox_ModifyMyAddress()
//{
//    if (MealBox_AddressID>0)
//        window.location = "/MyDelivery/Default.aspx?AddressId=" + MealBox_AddressID;
//    else
//        window.location = "/MyDelivery/Default.aspx";
//}
//显示订单信息2
function MealBoxShow2()
{    
    var ret = Rest_order_QuicklyPlaceOrder.GetOrderTable2(0,0).value;   
    if (ret == null)
    {
        alert("获取订单信息错误！");
        return ;
    }
    //$("#divConfirmOrderInfo_spOrderIntegral").html(ret.OrderIntegral + "分");
    $("#divMealBox2").html(ret.ListStr); 
}
function MealBox_onPopUpWindowPost()
{
    //window.location.reload();
    //MyAddress_GetAddressList();
}
function MealBox_getIsHaveTime()
{
    var flag=true;
    if (MealBox_RestID>0 && DeliverDayStr!="" && MealBox_AreaID>0)
    {
        var ret = Rest_order_QuicklyPlaceOrder.GetDeliverTimeList(MealBox_RestID,DeliverDayStr,MealBox_AreaID).value;
        var maxd=(ret.Rows.length-1);
        var thisTime=$("#<%=MealBox_thistime.ClientID %>").val();
        if(ret.Rows[maxd].value.replace(":",".")<thisTime)
        {
           alert("很抱歉，本店外卖时间已过！");
           flag=false;
        }
    }
    return flag;
}
function MealBox_Init()
{
    var txt = document.createElement("input");
    txt.type = "text";
    txt.style.color = MealBox_tbColor;
    MealBox_tbColor = txt.style.color;
    txt.style.color = MealBox_tbNullColor;
    MealBox_tbNullColor = txt.style.color;
    $("#<%=tbName.ClientID %>").bind("focus",function(){tbName_focus();});
    $("#<%=tbName.ClientID %>").bind("blur",function(){tbName_blur();}); 
    $("#<%=tbMobile.ClientID %>").bind("focus",function(){tbMobile_focus();});
    $("#<%=tbMobile.ClientID %>").bind("blur",function(){tbMobile_blur();});
    $("#<%=tbPhone.ClientID %>").bind("focus",function(){tbPhone_focus();});
    $("#<%=tbPhone.ClientID %>").bind("blur",function(){tbPhone_blur();});
    $("#<%=tbExtension.ClientID %>").bind("focus",function(){tbExtension_focus();});
    $("#<%=tbExtension.ClientID %>").bind("blur",function(){tbExtension_blur();});
    $("#<%=tbAddress.ClientID %>").bind("focus",function(){tbAddress_focus();});
    $("#<%=tbAddress.ClientID %>").bind("blur",function(){tbAddress_blur();}); 
    $("#<%=tbNote.ClientID %>").bind("focus",function(){tbNote_focus();});
    $("#<%=tbNote.ClientID %>").bind("blur",function(){tbNote_blur();}); 
    $("#<%=tbNote.ClientID %>").bind("keyup",function(){noteL();}); 
    $("#<%=tbMobileS.ClientID %>").bind("blur",function(){tbMobileS_blur();}); 
    $("#<%=tbMobileS.ClientID %>").bind("focus",function(){tbMobileS_focus();}); 
    
    $("#tbPhone").bind("keypress", function(e){ return filtrateTelChar(e); });
    $("#tbExtension").bind("keypress", function(e) { return filtrateTelChar(e); });
    $("#tbMobile").bind("keypress", function(e) { return filtrateTelChar(e); }); 
    
     MealBoxShow();
}
function noteL()
{
   if( $("#<%=tbNote.ClientID %>").val().length>50)
   {
        alert("备注不能超过50个");
        $("#<%=tbNote.ClientID %>").val($("#<%=tbNote.ClientID %>").val().substring(0,50));
        return;
   }
}
</script>

<script type="text/javascript">
var WeekDayArray = new Array(<%=WeekDayStr %>);
var weekClientID = "<%=week.ClientID%>";
function MenuChang(index,time)
{   
    $("#<%=spDeliverDate.ClientID %>").html(time);
   MenuClassListGet(index-1);
   if ($("#<%=week.ClientID%> li a").size()>1)
   {
       $("#<%=week.ClientID%> li a").each(function(){this.className="import"});
       index = index - $("#<%=hdweekcount.ClientID%>").val();
       $("#<%=week.ClientID%> li a:eq(" + index + ")").attr("class", "btn_14");      
   }   
}


</script>

<script type="text/javascript">
var isDebug = false;
var MenuCountMax = <%=MenuCountMax %>;
var RestID = <%=RestID %> ;
var DeliverDayStr = "";
var Shop_NoMenu=0;
var ClassID = 0;
var OrderByPrice = 0;
var PageIndex=1;
var PageSize=12;
var PriceListCount = 0;
var TabsMenuClass = null;
var NavMenu = null;
var MenuClassList = new Array();
var errDeliverDateStr = "您选择的餐品送餐日期不同，是否清除购物车并重新订餐？";

//预定餐品
function Menu_close()
{
   //DeliveryUserIsLogin2();

}
function Menu_close2()
{
    vWindowsManager.HideDialog();
}
//暂停订餐
function stopOrder()
{

}
//取得菜单类
function MenuClassListGet(index)
{
   //MenuDetailClose();//关闭配置
    var divMealList = document.getElementById("divMealList");    
    divMealList.innerHTML = "";
    var divMealPrice = document.getElementById("divMealPrice");
    divMealPrice.style.display = "none";
    var divMealListNav = document.getElementById("divMealListNav");
    divMealListNav.style.display = "none";
    var DayIndex = <%=DayIndex %>;
    if (DayIndex<7)
        DeliverDayStr = WeekDayArray[index];    
    else
        DeliverDayStr = "<%=DateTime.Now.ToString("yyyy-MM-dd") %>";
       
    MealBox_GetDeliverTimeList()//加载送餐时间
    var divMenuClassList = document.getElementById("divMenuClassList");
    divMenuClassList.innerHTML = "";    
    var spMenuPriceList = document.getElementById("spMenuPriceList");     
    spMenuPriceList.innerHTML = "";
    var ret = Rest_order_QuicklyPlaceOrder.GetMenuClass(RestID,DeliverDayStr).value;
    if (ret != null)
    {
        var MenuClassListStr = "";
        for(var i=0;i<ret.length;i++)
        {
            MenuClassList[i] = ret[i].ID;
            MenuClassListStr += ret[i].Name + ",";
        }
        if (MenuClassListStr.length>0)        
        {   
            MenuClassListStr = MenuClassListStr.substring(0,MenuClassListStr.length-1);
            TabsMenuClass = new vensonTabs1("divMenuClassList"
                ,"MenuClassList_onChangeTabIndex",MenuClassListStr,1, "Default1");             
            TabsMenuClass.changeIndex(0);
        }
        else
        {
            $("#Shop_IsMenu").val("-1");
            //alert("dd");
            MealNone();//没有餐品
        }
    }
    
}
function MenuClassList_onChangeTabIndex(index)
{   
    ClassID = MenuClassList[index];
    OrderByPrice = 0;
    NavMenu.pageIndex = 1;
    MealListGet();//取得订制菜单列表
}
//取得菜单价格列表
function SuiteMenuPriceListGet()
{ 
    var spMenuPriceList = document.getElementById("spMenuPriceList");  
    var divMealPrice = document.getElementById("divMealPrice");
    var ret = Rest_order_QuicklyPlaceOrder.GetSuiteMenuPriceListStr(RestID,DeliverDayStr,ClassID,OrderByPrice).value;
    spMenuPriceList.innerHTML = "";
    if (ret!=null)
    {
        divMealPrice.style.display = "";
        spMenuPriceList.innerHTML = ret.PriceListStr;   
        PriceListCount = ret.Count;        
    }
}
function SuiteMenuPriceList_Click(index,price)
{   
    for(var i=0;i<PriceListCount;i++)
    {
        var lnk = document.getElementById("DeliverMenu_lnkPriveList" + i);
        if (index == i)
        {
            lnk.className = "import PriceListImport";
        }
        else
        {
            lnk.className = "replace_f14";
        }
    }        
    OrderByPrice = price;   
    NavMenu.pageIndex = 1;
    MealListGet();//取得订制菜单列表
}
//取得订制菜单列表
function MealListGet()
{   
    MealLoading();    
    Rest_order_QuicklyPlaceOrder.GetMealListStr(RestID,DeliverDayStr,ClassID,OrderByPrice,NavMenu.pageIndex,PageSize,MealListGetReturn);
    function MealListGetReturn(res)
    {
       if (res.value!=null)        
       {            
            MealLoadingClear();
            var ret = res.value;
            var divMealList = document.getElementById("divMealList");
            divMealList.innerHTML = ret.ListStr;            
            NavMenu.render(ret.PageInfo.PageIndex, ret.PageInfo.TotalPage);
            if (ret.ListStr!="")
            {
                var divMealListNav = document.getElementById("divMealListNav");
                divMealListNav.style.display = "none";                
            }
            else
            {
                $("#Shop_IsMenu").val("-1");
                MealNone();//没有餐品

            }
       }
    }    
}

//显示餐品配置
//显示餐品配置
function MenuDetailShow(i,row,restID,menuID,menuName)
{
       $(".ulMenuDetailSelect1").attr("className","ulMenuDetail1");
       $(".LiMenuSelect1").attr("tag", "0");
       $(".LiMenuSelect1").attr("className","LiMenuDiv1");
        
       $("#tr_"+ row).css("display","");
       $("#tr_"+ row).attr("className","ulMenuDetailSelect1");
       $("#li_Menu_"+ i).attr("className","LiMenuSelect1");
       $("#li_Menu_"+ i).attr("tag", "1");
    var divMenuDetail = document.getElementById("#divSuiteMenuConfig_"+row);
    var divMealList = document.getElementById("divMealList");
    var ret = Rest_order_QuicklyPlaceOrder.MenuDetailGet(restID,menuID,OrderByPrice).value;
    if (ret != null)
    {
        document.getElementById("divSuiteMenuConfig_"+row).innerHTML = ret;
    }
     MealLoadingClear();
    
   // spMenuName.innerHTML = menuName;
    
}
function MealNone()
{

    var divMealList = document.getElementById("divMealList");
    divMealList.className = "divMealListNone";
    divMealList.innerHTML = "很抱歉，本店今日已无餐品！";
}
function MealNone2()
{

    var divMealList = document.getElementById("divMealList");
    divMealList.className = "divMealListNone";
    vWindowsManager.ShowDialog("ShopMenu_none"); 
    divMealList.innerHTML = "很抱歉，本店今日已无餐品！";
}
function MealLoading()
{
    var divLoading = document.getElementById("divLoading");  
    var divMealList = document.getElementById("divMealList"); 
    divLoading.style.zIndex = 999; 
    divLoading.style.left = (getPosition("divMealList").x + divMealList.offsetWidth/2-50) + "px";
    divLoading.style.top = (getPosition("divMealList").y + 108-50)+ "px";
    divLoading.style.display = "";
}
function MealLoadingClear()
{
    var divLoading = document.getElementById("divLoading");
    divLoading.style.display = "none";
}
function suiteMenuOrderAdd(restID,menuID,configID,IntegralCount,RuleMark)
{	 
    //if (stopOrder()) return;//节日是否停止订餐
    IntegralCount=0;
    if(!DeliverMenu_CheckShopState(restID)) //检测餐馆营业状态
     {
            return;
     }
    if(!MealBox_getIsHaveTime())
    {
       
       return;
    }
     //window.alert(Deliver_AreaId +"  ddfdf "+Deliver_AddressId);
    var dgCtrlName="rest" + restID + "_menu" + menuID + "_config" + configID + "_";
	var amount=getValue(dgCtrlName,"txtAmount").trim();
	if (!checkNumber(amount) || amount.length==0)
    {
        alert("请输入1到" + MenuCountMax + "之间的数！");
        return;
    }
	var m1=getValue(dgCtrlName,"M1");
	var m2=getValue(dgCtrlName,"M2");
	var m3=getValue(dgCtrlName,"M3");
	var m4=getValue(dgCtrlName,"M4");
	var m5=getValue(dgCtrlName,"M5");
	var m6=getValue(dgCtrlName,"M6");
	var m7=getValue(dgCtrlName,"M7");
	var m8=getValue(dgCtrlName,"M8");
	var m9=getValue(dgCtrlName,"M9");
	var m10=getValue(dgCtrlName,"M10");
	var	weekname = Rest_order_QuicklyPlaceOrder.is67().value;
	var nowClock = Rest_order_QuicklyPlaceOrder.getHour().value;

	weekname='Monday';
	   
	    //检查送餐日期
	    if (checkDeliverDate()!=1)
	       return;
	    if (CheckOrderRest()!=1)
	        return;   
	　   var r=Rest_order_QuicklyPlaceOrder.add2Order(restID,menuID,configID,amount,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10, 0, 0,DeliverDayStr,IntegralCount,RuleMark).value; 
	    switch(r)
	    {	      
	        case 1:
	        {
	             var hidMealBoxColorIndex = document.getElementById("hidMealBoxColorIndex");
	             var hidMealBoxColorSMax = document.getElementById("hidMealBoxColorSMax");
	             hidMealBoxColorIndex.value = hidMealBoxColorIndex.value + 1;
	             hidMealBoxColorIndex.value =  hidMealBoxColorIndex.value % hidMealBoxColorSMax.value;
	             
	             MealBoxShow();break;	   
	        }  
	        case -1: alert("订餐失败！"); break;			   
	        case -11: alert("对不起,该餐馆不提供外送功能！"); break;
	        case -12: alert("对不起,该菜类今天不外卖,请您选择其他菜类！"); break;
	        case -13: alert("对不起,该菜今天不外卖,请您选择其他菜！"); break;
	        case -14: alert("每种餐品的数量最少1份，最多" + MenuCountMax + "份！"); break;	
	        case -15: alert("该菜单没有配置菜单内容，不能提供预定！"); break;	
	        case -16: 
	                if (confirm(errDeliverDateStr))
	                {
	                    orderClear();
	                }
	                ;break;
	        case -17:alert("订餐日期错误！");break; 
	        case -18:alert("餐已售完！");break;       
	        case -20: alert("操作异常请与网站管理员联系！"); break;			   	   
	        case -100: alert("每种餐品的数量最少1份，最多" + MenuCountMax + "份！");break;	 //  已经到达了最大可订份数，不能再加了！     
	        case -101: alert("每种餐品的数量最少1份，最多" + MenuCountMax + "份！");break;	//选定的总份数超过了最大可订份数，不能再加了！       		   	   
	        case -102: alert("最多只能选择15种菜品！");break;
	        default: alert("该餐馆暂停提供外卖,请您谅解！"); break;
	    }	    
}

function getValue(objArray,objName)
{
	try
	{
	return document.getElementById(objArray+objName).value;
	}
	catch(e)
	{
	return 0;
	
	}
}
//验证时间
function checkNow(t)
{
    return Rest_order_QuicklyPlaceOrder.checkNow(t).value;
}
/* 验证送餐日期 */
function checkDeliverDate()
{
    var chkRet = Rest_order_QuicklyPlaceOrder.CheckDeliverDate(0, 0,DeliverDayStr).value;
    if (chkRet == 1)
    {
        return 1;
    }
    else if (chkRet == -1)
    {
        if (confirm(errDeliverDateStr))
        {
            orderClear();
            MealBox_GetDeliverTimeList();//从新加载送餐时间
            return 1;
        }
        else
        {
            return 0;
        }
    }
    else
    {        
        orderClear();
        //MealBox_GetDeliverTimeList();//从新加载送餐时间
        return 1;        
    }        
}
//检测餐馆的营业状态
function DeliverMenu_CheckShopState(shopId)
{
    var state = Rest_order_QuicklyPlaceOrder.CheckShopState(shopId,DeliverDayStr).value;
    if(state ==1)
    {
        return true;
    }
    else
    {
        window.alert(state);
        return false;
    }
}
//$(document).ready(IsNoMenu()
//});
function IsNoMenu()
{
    var DayIndex = <%=DayIndex %>;
    $("#divMenuDetail").fadeTo("fast",0);
    NavMenu = new vensonNav("divMealListNav", "MealListGet");
    NavMenu.pageIndex = 1;  
    if (DayIndex>6)
    {
        $("#" + weekClientID + " li").eq(7).html("<a href='javascript:void(0);' class='btn_13' onclick='MenuChang(7,'<%=DateTime.Now.ToString("yyyy-MM-dd") %>');'>周日</a>")    
        WeekDayArray[WeekDayArray.length] = "<%=DateTime.Now.ToString("yyyy-MM-dd") %>";
    }  
    MenuChang(DayIndex,"<%=DateTime.Now.ToString("yyyy-MM-dd") %>");//调用DeliverDay.ascx  
}  
function OnmouseOver(obj)
{
    var val = $(obj).attr("tag");
    if (val == "0" || val == null) obj.className="LiMenuDiv1_hover";
}
function OnmouseOut(obj)
{
    var val = $(obj).attr("tag");
    if (val == "0" || val == null) obj.className="LiMenuDiv1";
}
</script>

