<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="datetime.aspx.cs" Inherits="PPFOR.Admin.CustomView.datetime" %>
<!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 id="Head1" runat="server">
    <title>时间管理</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
    <link href="../Css/global.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../JS/opopup.js"></script>  
    <script type="text/javascript" language="javascript">  
    function checkTime(v){     
        if(validateTime(v)==false){
            showErrMsg("时间格式不对");
        }
    }
    function checkDate(v){
        if(validateDate(v)==false){
            showErrMsg("日期格式不对");
        }
    }
    function checkCurrenTime(){
        var t=document.getElementById("PPFOR_currentTime").value;
        var d=document.getElementById("PPFOR_currentDate").value;
        if(validateTime(t)==true && validateDate(d)==true){
            var v=d + " " + t;
            var objs=window.parent.document.getElementsByTagName('input');
            var rid=document.getElementById("PPFOR_rid").value;
            if(objs!=null && rid!='')
            {                
                for(var i=0;i<objs.length;i++)
                {                
                    if(objs[i].getAttribute('rtype')!=null && objs[i].getAttribute('rtype')=='datetime' && objs[i].getAttribute("rid")!=null && objs[i].getAttribute("rid")==rid){
                        objs[i].value=v;                         
                        if(document.all)
                        {
                            objs[i].fireEvent("onchange");
                        }
                        else
                        {
                            var evt = document.createEvent('HTMLEvents');   
                            evt.initEvent('change',true,true);   
                            objs[i].dispatchEvent(evt);   
                        }                  
                        break;
                    }
                }
            }
            parent.popup_close();
        }else{
            showErrMsg("日期时间格式不对");
        }
    }
    function showErrMsg(msg){
        var obj=document.getElementById("PPFOR_errText");
        if(obj!=null) obj.innerHTML=msg;
        showDiv('divErr',"Error",300,100);
    }
    function validateDate(v){
        var regStr=/^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]((((0?[13578])|(1[02]))[\-\/\s]((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]((((0?[13578])|(1[02]))[\-\/\s]((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]((0?[1-9])|(1[0-9])|(2[0-8]))))))$/;
        return regStr.test(v);
    }
    function validateTime(v){
        var regStr=/^((0?[0-9])|(2[0-3])|(1[0-9]))\:([0-5]?[0-9])$/;
        return v=='' || regStr.test(v);
    }
    function showDiv(id,title,width,height)
    {
        popup_show(title,id,width,height);
    }
    function closePopup()
    {
        popup_close();
    }
 </script>
</head>
<body>
<form id="form1" runat="server">
<div id="popupClass" class="popup_class" style="visibility: hidden; display: none;">
   <iframe id="popupIFrame" class="iframe_for_hide" frameborder="0"></iframe>
      <div class="menu_form_header" id="popupDrag">
	    <img alt="" class="menu_form_exit" id="popupExit" src="../Images/close.png" />
	    <label id="popupTitle">标题</label>
    </div>
   <div id="divErr" class="menu_form_body" style="display:none;">
       <p><asp:Label ID="PPFOR_errText" Text="Err" Font-Bold="true" runat="server" Font-Names="Verdana" Font-Size="12px"></asp:Label><br /><br />
       <input type="button" value="确定" onclick="closePopup();" />       
       </p>
   </div>   
</div>   
   <div style="padding:5px;" >
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="fortable">
        <tr>
        <td style="width:60px" align="right" valign="middle">当前时间：</td>
        <td valign="middle" align="center"><asp:TextBox ID="PPFOR_currentDate" runat="server" Font-Names="Verdana" Font-Size="12px" Width="100px"></asp:TextBox></td>
        <td valign="middle" align="center"><asp:TextBox ID="PPFOR_currentTime" Text="00:00" runat="server" Font-Names="Verdana" Font-Size="12px" Width="60px"></asp:TextBox></td>
        <td valign="middle" align="center"><input id="selectCurTime" type="button" class="inputbutton" onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'" value="选择" style="width:80px;" onclick="checkCurrenTime();" /><asp:HiddenField ID="PPFOR_rid" runat="server"></asp:HiddenField>        
        </td>
        </tr>
        </table>
    </div>
    <div>
    <asp:Calendar ID="PPFOR_datetime" runat="server" OnSelectionChanged="PPFOR_datetimeChange" BackColor="#FFFFCC" BorderColor="#FFCC66" BorderWidth="0px" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" ForeColor="#663399" Height="200px" ShowGridLines="True" Width="98%" CssClass="forgridview">
        <SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
        <TodayDayStyle BackColor="#FFCC66" ForeColor="White" />
        <SelectorStyle BackColor="#FFCC66" />
        <OtherMonthDayStyle ForeColor="#CC9966" />
        <NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
        <DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
        <TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt" ForeColor="#FFFFCC" />
    </asp:Calendar>
    </div>
</form>
</body>
</html>