﻿var WebDatePicker2DialogHtml = "";
WebDatePicker2DialogHtml +="<!DOCTYPE HTML PUBLIC '-////W3C//DTD HTML 4.0 Transitional////EN' >";
WebDatePicker2DialogHtml +="<html>";
WebDatePicker2DialogHtml +="<head>";
WebDatePicker2DialogHtml +="<title>DatePicker2</title>";
WebDatePicker2DialogHtml +="<style>";
WebDatePicker2DialogHtml +=".Calendar{";
WebDatePicker2DialogHtml +="  background: #667766;";
WebDatePicker2DialogHtml +="  border: 1px solid #667766;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +=".Calendar_Header {";
WebDatePicker2DialogHtml +="  background: #ddffbb;";
WebDatePicker2DialogHtml +="  border: 1px solid #ddffbb;";
WebDatePicker2DialogHtml +="  text-align: center;";
WebDatePicker2DialogHtml +="  font-size:9pt;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +=".Calendar_Time {";
WebDatePicker2DialogHtml +="  background: #ddffbb;";
WebDatePicker2DialogHtml +="  border: 0px solid #ddffbb;";
WebDatePicker2DialogHtml +="  text-align: left;";
WebDatePicker2DialogHtml +="  font-size:9pt;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +=".Calendar_HeaderTitle {";
WebDatePicker2DialogHtml +="  background: #225500;";
WebDatePicker2DialogHtml +="  border: 1px solid #225500;";
WebDatePicker2DialogHtml +="  color: #eeffaa;";
WebDatePicker2DialogHtml +="  text-align: center;";
WebDatePicker2DialogHtml +="  font-size:9pt;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="  cursor: hand;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +=".Calendar_Close {";
WebDatePicker2DialogHtml +="  background: #667766;";
WebDatePicker2DialogHtml +="  border: 1px solid #667766;";
WebDatePicker2DialogHtml +="  color: #ffffff;";
WebDatePicker2DialogHtml +="  text-align: center;";
WebDatePicker2DialogHtml +="  font-size:9pt;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="  cursor: hand;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +=".Calendar_Navigate {";
WebDatePicker2DialogHtml +="  background: #667766;";
WebDatePicker2DialogHtml +="  border: 1px solid #667766;";
WebDatePicker2DialogHtml +="  color: #ffffff;";
WebDatePicker2DialogHtml +="  text-align: center;";
WebDatePicker2DialogHtml +="  font-size:9pt;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +=".Calendar_Days {";
WebDatePicker2DialogHtml +="  background: #eeffee;";
WebDatePicker2DialogHtml +="  border: 1px solid #eeffee;";
WebDatePicker2DialogHtml +="  color: #556644;";
WebDatePicker2DialogHtml +="  text-align: center;";
WebDatePicker2DialogHtml +="  font-size:9pt;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +=".Calendar_Holiday {";
WebDatePicker2DialogHtml +="  background: #eeffee;";
WebDatePicker2DialogHtml +="  border: 1px solid #eeffee;";
WebDatePicker2DialogHtml +="  color: #aa6666;";
WebDatePicker2DialogHtml +="  text-align: center;";
WebDatePicker2DialogHtml +="  font-size:9pt;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +=".Calendar_SelectedDay {";
WebDatePicker2DialogHtml +="  background: #f8fff8;";
WebDatePicker2DialogHtml +="  border: 1px solid #000000;";
WebDatePicker2DialogHtml +="  font-weight:bold;";
WebDatePicker2DialogHtml +="  text-align: center;";
WebDatePicker2DialogHtml +="  font-size:9pt;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +=".Calendar_Today {";
WebDatePicker2DialogHtml +="  background: #f8fff8;";
WebDatePicker2DialogHtml +="  border: 1px solid #ff0000;";
WebDatePicker2DialogHtml +="  text-align: center;";
WebDatePicker2DialogHtml +="  font-size:9pt;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +=".Calendar_DaysMouseOver {";
WebDatePicker2DialogHtml +="  background: #eeffdd;";
WebDatePicker2DialogHtml +="  border: 1px solid #bbbbbb;";
WebDatePicker2DialogHtml +="  text-align: center;";
WebDatePicker2DialogHtml +="  font-size:9pt;";
WebDatePicker2DialogHtml +="  color: #000;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="  cursor: hand;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +=".Calendar_HeaderMouseOver {";
WebDatePicker2DialogHtml +="  background: #aaffaa;";
WebDatePicker2DialogHtml +="  border: 1px solid #008844;";
WebDatePicker2DialogHtml +="  text-align: center;";
WebDatePicker2DialogHtml +="  font-size:9pt;";
WebDatePicker2DialogHtml +="  color: #000;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="  cursor: hand;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +=".Calendar_DropDownList {";
WebDatePicker2DialogHtml +="  background: #ddffbb;";
WebDatePicker2DialogHtml +="  border: 1px solid #ddffbb;";
WebDatePicker2DialogHtml +="  text-align: center;";
WebDatePicker2DialogHtml +="  font-size:9pt;";
WebDatePicker2DialogHtml +="  color: #000;";
WebDatePicker2DialogHtml +="  padding: 0px;";
WebDatePicker2DialogHtml +="}";
WebDatePicker2DialogHtml +="</style>";
WebDatePicker2DialogHtml +="</head>";
WebDatePicker2DialogHtml +="<body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">";
WebDatePicker2DialogHtml +="<table width=\"200\" id=\"dialog_table\" class=\"Calendar\" cellspacing=\"0\" cellpadding=\"0\">";
WebDatePicker2DialogHtml +="	<tr>";
WebDatePicker2DialogHtml +="		<td>";
WebDatePicker2DialogHtml +="		<table border=\"0\" width=\"100%\" height=\"18px\" id=\"table2\" cellspacing=\"0\" cellpadding=\"0\">";
WebDatePicker2DialogHtml +="			<tr>";
WebDatePicker2DialogHtml +="				<td  id=\"dialog_save\" class=\"Calendar_Close\" width=\"30\" align=\"center\">&#8730</td>";
WebDatePicker2DialogHtml +="				<td width=\"140\">";
WebDatePicker2DialogHtml +="		            <table border=\"0\" width=\"100%\" height=\"22px\" id=\"table8\" cellspacing=\"0\" cellpadding=\"0\" style=\"font-size:9pt;color:eeffaa; font-weight:bold\">";
WebDatePicker2DialogHtml +="			            <tr>";
WebDatePicker2DialogHtml +="				            <td width=\"45%\" id=\"dialog_headermonth\" class=\"Calendar_HeaderTitle\"><span id=\"dialog_month\" style=\"width:98%\"></span><select size=\"1\" id=\"select_month\" style=\"font-size:8pt;display:none\" class=\"Calendar_DropDownList\"></select></td>";
WebDatePicker2DialogHtml +="				            <td width=\"5\" class=\"Calendar_HeaderTitle\">&nbsp;</td>";
WebDatePicker2DialogHtml +="				            <td width=\"50%\" id=\"dialog_headeryear\" class=\"Calendar_HeaderTitle\"><span id=\"dialog_year\" style=\"width:98%\"></span><select size=\"1\" id=\"select_year\" style=\"font-size:8pt;display:none\" class=\"Calendar_DropDownList\"></select></td>";
WebDatePicker2DialogHtml +="			            </tr>";
WebDatePicker2DialogHtml +="		            </table>";
WebDatePicker2DialogHtml +="				</td>";
WebDatePicker2DialogHtml +="				<td id=\"dialog_close\" class=\"Calendar_Close\" width=\"30\" align=\"center\">x</td>";
WebDatePicker2DialogHtml +="			</tr>";
WebDatePicker2DialogHtml +="		</table>";
WebDatePicker2DialogHtml +="		</td>";
WebDatePicker2DialogHtml +="	</tr>";
WebDatePicker2DialogHtml +="	<tr>";
WebDatePicker2DialogHtml +="		<td>";
WebDatePicker2DialogHtml +="		<table border=\"0\" width=\"100%\" id=\"table2\" class=\"Calendar_Navigate\" cellspacing=\"0\" cellpadding=\"0\">";
WebDatePicker2DialogHtml +="			<tr>";
WebDatePicker2DialogHtml +="				<td id=\"dialog_preyear\" class=\"Calendar_Navigate\" width=\"30\" align=\"center\">&#x00ab;</td>";
WebDatePicker2DialogHtml +="				<td id=\"dialog_premonth\" class=\"Calendar_Navigate\" width=\"30\" align=\"center\">&#x2039;</td>";
WebDatePicker2DialogHtml +="				<td id=\"dialog_today\" class=\"Calendar_Navigate\" align=\"center\">今天</td>";
WebDatePicker2DialogHtml +="				<td id=\"dialog_nextmonth\" class=\"Calendar_Navigate\" width=\"30\" align=\"center\">&#x203a;</td>";
WebDatePicker2DialogHtml +="				<td id=\"dialog_nextyear\" class=\"Calendar_Navigate\" width=\"30\" align=\"center\">&#x00bb;</td>";
WebDatePicker2DialogHtml +="			</tr>";
WebDatePicker2DialogHtml +="		</table>";		
WebDatePicker2DialogHtml +="		</td>";
WebDatePicker2DialogHtml +="	</tr>";
WebDatePicker2DialogHtml +="	<tr>";
WebDatePicker2DialogHtml +="		<td>";
WebDatePicker2DialogHtml +="		<table border=\"1\" width=\"100%\" id=\"table3\" class=\"Calendar_Header\" cellspacing=\"0\" cellpadding=\"0\">";
WebDatePicker2DialogHtml +="			<tr height=\"18px\">";
WebDatePicker2DialogHtml +="				<td align=\"center\" width=\"28px\" class=\"Calendar_Header\">日</td>";
WebDatePicker2DialogHtml +="				<td align=\"center\" width=\"28px\" class=\"Calendar_Header\">一</td>";
WebDatePicker2DialogHtml +="				<td align=\"center\" width=\"28px\" class=\"Calendar_Header\">二</td>";
WebDatePicker2DialogHtml +="				<td align=\"center\" width=\"28px\" class=\"Calendar_Header\">三</td>";
WebDatePicker2DialogHtml +="				<td align=\"center\" width=\"28px\" class=\"Calendar_Header\">四</td>";
WebDatePicker2DialogHtml +="				<td align=\"center\" width=\"28px\" class=\"Calendar_Header\">五</td>";
WebDatePicker2DialogHtml +="				<td align=\"center\" width=\"28px\" class=\"Calendar_Header\">六</td>";				
WebDatePicker2DialogHtml +="			</tr>";
WebDatePicker2DialogHtml +="		</table>";
WebDatePicker2DialogHtml +="		</td>";
WebDatePicker2DialogHtml +="	</tr>";
WebDatePicker2DialogHtml +="	<tr>";
WebDatePicker2DialogHtml +="		<td>";
WebDatePicker2DialogHtml +="		<table id=\"dialog_day\" class=\"Calendar_Days\" border=\"0\" width=\"100%\" id=\"table3\" cellspacing=\"0\" cellpadding=\"0\">";
WebDatePicker2DialogHtml +="		</table>";
WebDatePicker2DialogHtml +="		</td>";
WebDatePicker2DialogHtml +="	</tr>";
WebDatePicker2DialogHtml +="	<tr id=\"dialog_time\" style=\"display:none\">";
WebDatePicker2DialogHtml +="		<td class=\"Calendar_Time\" height=\"20px\">";
WebDatePicker2DialogHtml +="		<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">";
WebDatePicker2DialogHtml +="		<tr class=\"Calendar_Time\">";
WebDatePicker2DialogHtml +="		<td>&nbsp;Time:</td>";
WebDatePicker2DialogHtml +="		<td align=\"right\">";
WebDatePicker2DialogHtml +="		    <select id=\"dialog_hour\" class=\"Calendar_DropDownList\"><option selected>00</option><option>01</option><option>02</option><option>03</option><option>04</option><option>05</option><option>06</option><option>07</option><option>08</option><option>09</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>21</option><option>22</option><option>23</option></select>";
WebDatePicker2DialogHtml +="		    &nbsp;:&nbsp;";
WebDatePicker2DialogHtml +="		    <select id=\"dialog_minute\" class=\"Calendar_DropDownList\"><option selected>00</option><option>01</option><option>02</option><option>03</option><option>04</option><option>05</option><option>06</option><option>07</option><option>08</option><option>09</option><option>10</option><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>21</option><option>22</option><option>23</option><option>24</option><option>25</option><option>26</option><option>27</option><option>28</option><option>29</option><option>30</option><option>31</option><option>32</option><option>33</option><option>34</option><option>35</option><option>36</option><option>37</option><option>38</option><option>39</option><option>40</option><option>41</option><option>42</option><option>43</option><option>44</option><option>45</option><option>46</option><option>47</option><option>48</option><option>49</option><option>50</option><option>51</option><option>52</option><option>53</option><option>54</option><option>55</option><option>56</option><option>57</option><option>58</option><option>59</option></select>";
WebDatePicker2DialogHtml +="		</td>";
WebDatePicker2DialogHtml +="		</tr>";
WebDatePicker2DialogHtml +="		</table>";
WebDatePicker2DialogHtml +="	</tr>";
WebDatePicker2DialogHtml +="</table>";
WebDatePicker2DialogHtml +="</body>";
WebDatePicker2DialogHtml +="</html>";

document.writeln("<div id='WebDatePicker2_DialogDiv' width='200' style='position: absolute;  overflow:hidden; display: none; z-index: 99999;width:200px; height:194px; background-color: #FFFF00' tabindex='-1'>\n");
document.writeln("<iframe name='WebDatePicker2_DialogDivFrame' scrolling=no frameborder=0 width=100% height=192px src='javascript:new String(\"<html></html>\")'></iframe>\n");
document.writeln("</div>\n");

var WebDatePicker2Iframe = window.frames("WebDatePicker2_DialogDivFrame"); 
if(WebDatePicker2Iframe != null)
{
    with(WebDatePicker2Iframe)
    {
	    document.writeln(WebDatePicker2DialogHtml); 
	    document.close();
    }	
}

function WebDatePickerDialog()
{
    this.Dialog = document.getElementById("WebDatePicker2_DialogDiv");
    this.DialogDocument = window.frames("WebDatePicker2_DialogDivFrame").document;
    
	this.MonthNames = new Array('一','二','三','四','五','六','七','八','九','十','十一','十二');
	this.MonthFullNames = new Array('一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月');
  
    this.IsShowTime = false;
    this._date = new Date();
    this._showdate = null;
//    this.Year = "";
//    this.Month = "";
//    this.Day = "";
//    this.Minute = "";    
//    this.Second = "";

    this.onchange = null;
    this._oldStyleClass = null;
    
    var me = this;

    this._GetDialogElement = function(id)
    {
        return me.DialogDocument.getElementById(id);
    }
    this.DialogTable = me._GetDialogElement("dialog_table");    
    this.HeaderMonth = me._GetDialogElement("dialog_headermonth");
    this.HeaderYear = me._GetDialogElement("dialog_headeryear");    
    this.MonthTitle = me._GetDialogElement("dialog_month");
    this.SelectMonth = me._GetDialogElement("select_month");
    this.YearTitle = me._GetDialogElement("dialog_year"); 
    this.SelectYear = me._GetDialogElement("select_year");      
    this.CloseButton = me._GetDialogElement("dialog_close");
    this.SaveButton = me._GetDialogElement("dialog_save");
    this.PreYearButton = me._GetDialogElement("dialog_preyear");
    this.PreMonthButton = me._GetDialogElement("dialog_premonth");
    this.TodayButton = me._GetDialogElement("dialog_today");    
    this.NextMonthButton = me._GetDialogElement("dialog_nextmonth");
    this.NextYearButton = me._GetDialogElement("dialog_nextyear");
    this.DaysTable = me._GetDialogElement("dialog_day");
    this.TimeArea = me._GetDialogElement("dialog_time");
    this.SelectHour = me._GetDialogElement("dialog_hour");
    this.SelectMinute = me._GetDialogElement("dialog_minute");

    this.SetLocation = function(x, y)
    {
    	var o = me.Dialog.style;
		o.left = x;
		o.top = y;
    }
    this.ShowDialog = function()
    {
        me._showdate = me._date;
        me.RefreshDialog();
    	var o = me.Dialog.style;
    	o.display=""; 
    }
    
    this.HideDialog = function()
    {
    	var o = me.Dialog.style;
    	o.display="none";    
    }
    
    this.GetDate = function()
    {
        return me._date;
    }
    
    this.PutDate = function(vValue)
    {
        me._date = vValue;
    }
    
    this.SetDate = function(vValue)
    {
        me.PutDate(vValue);
        if(me.GetDate != vValue)
        {
            me.setChanged();
        }
    }
    
    this.setChanged = function()
    {
		if(me.onchange != null && typeof(me.onchange) == 'function')
		{
			me.onchange(me);
		} 
	}

    this.HeaderMouseOver = function()
    {
        me._oldStyleClass = this.className;
        this.className = "Calendar_HeaderMouseOver";    
    }
    this.HeaderMouseOut = function()
    {
        this.className = me._oldStyleClass;    
    }        
    this.MonthTitle.onmouseover = this.HeaderMouseOver;
    this.MonthTitle.onmouseout = this.HeaderMouseOut;
    this.YearTitle.onmouseover = this.HeaderMouseOver;
    this.YearTitle.onmouseout = this.HeaderMouseOut;    
    this.CloseButton.onmouseover = this.HeaderMouseOver;
    this.CloseButton.onmouseout = this.HeaderMouseOut;
    this.PreYearButton.onmouseover = this.HeaderMouseOver;
    this.PreYearButton.onmouseout = this.HeaderMouseOut;
    this.PreMonthButton.onmouseover = this.HeaderMouseOver;
    this.PreMonthButton.onmouseout = this.HeaderMouseOut;
    this.TodayButton.onmouseover = this.HeaderMouseOver;
    this.TodayButton.onmouseout = this.HeaderMouseOut;
    this.NextMonthButton.onmouseover = this.HeaderMouseOver;
    this.NextMonthButton.onmouseout = this.HeaderMouseOut;
    this.NextYearButton.onmouseover = this.HeaderMouseOver;
    this.NextYearButton.onmouseout = this.HeaderMouseOut;
    
    this.CellClick = function()
    {
        //me._date = new Date((me._showdate.getMonth()+1) +"/"+ this.innerHTML +"/"+ me._showdate.getFullYear());
        me._date = new Date(me._showdate.getFullYear(), me._showdate.getMonth(), this.innerHTML, me.SelectHour.options[me.SelectHour.selectedIndex].text, me.SelectMinute.options[me.SelectMinute.selectedIndex].text);
        me.YearTitle.style.display="";
		me.SelectYear.style.display = "none";
		me.MonthTitle.style.display="";
		me.SelectMonth.style.display = "none";		
        me.setChanged();
    }
    this.CellMouseOver = function()
    {
        me._oldStyleClass = this.className;
        this.className = "Calendar_DaysMouseOver";
    }
    this.CellMouseOut = function()
    {
        this.className = me._oldStyleClass;
    }
	this.RefreshDialog = function()
	{
	    var _showYear = me._showdate.getFullYear();
	    var _showMonth = me._showdate.getMonth();
	    var _showDay = me._showdate.getDate();
	    var _showHour = me._showdate.getHours();
	    var _showMinutes = me._showdate.getMinutes();
	    
	    if(me.IsShowTime == true)
	    {
	        me.TimeArea.style.display ="";
	    }
	    else
	    {
	        me.TimeArea.style.display ="none";	    
	    }
	    me.MonthTitle.innerHTML = me.MonthFullNames[_showMonth];
	    me.YearTitle.innerHTML = _showYear;
	    while(me.DaysTable.rows.length >0)
	    {
	        me.DaysTable.deleteRow(0);  
	    }
        var MonthFirstDay=new Date(_showYear,_showMonth,1);	    
	    var firstDayAtWeek = MonthFirstDay.getDay();
        var MonthNextFirstDay=new Date(_showMonth,_showMonth+1,1);
        var MonthLastDay=new Date(MonthNextFirstDay-86400000);
        var MonthDaysCount = MonthLastDay.getDate();
        
        var rowCount = (firstDayAtWeek + MonthDaysCount) > 35 ? 6: 5;
    
        var writeCount = 0;

		for(var x=0; x<rowCount; x++)
		{
		    var newRow=me.DaysTable.insertRow(me.DaysTable.rows.length);
		    newRow.style.height = "18px";  
			for(var y=0; y<7; y++)
			{
			    if(firstDayAtWeek > 0)
			    {
                    var newCell=newRow.insertCell(newRow.cells.length);
                    newCell.innerHTML = "&nbsp;";
                    newCell.className = "Calendar_Days";
                    newCell.style.width = "28px"                    
                    firstDayAtWeek--;		    
			    }
			    else
			    {
			        if(writeCount < MonthDaysCount)
			        {
                        var newCell=newRow.insertCell(newRow.cells.length);
                        newCell.innerHTML = (writeCount+1).toString(); 
                        newCell.style.width = "28px";
                        if((_showYear == me._date.getFullYear())&&(_showMonth == me._date.getMonth())&&((writeCount+1) == _showDay))
                        {
                            newCell.className = "Calendar_SelectedDay";                        
                        } 
                        else if((_showYear == new Date().getFullYear())&&(_showMonth == new Date().getMonth())&&((writeCount+1) == new Date().getDate()))
                        {
                            newCell.className = "Calendar_Today";                        
                        }
                        else if((y==0)||(y==6))
                        {
                            newCell.className = "Calendar_Holiday";
                        } 
                        else
                        {
                            newCell.className = "Calendar_Days";
                        }
                        writeCount++;				    
                    }
                    else
                    {
                        var newCell=newRow.insertCell(newRow.cells.length);
                        newCell.innerHTML = "&nbsp;";
                        newCell.style.width = "28px"                         
                        newCell.className = "Calendar_Days";
                    }
			    }
			}
		}
		for(var i =0; i < me.DaysTable.rows.length; i++)
		{
		    var row = me.DaysTable.rows[i];
		    for(var j =0; j < row.cells.length; j++)
		    {
		        var cell =  row.cells[j]
		        if(cell.innerHTML != "&nbsp;")
		        {
		            cell.onclick = me.CellClick;
		            cell.onmouseover = me.CellMouseOver;
		            cell.onmouseout = me.CellMouseOut;
		        }
		    }
		}
		
		var DialogHeight = 155;

		if(rowCount == 6)
		{
		    DialogHeight += 18;
		}
	    if(me.IsShowTime == true)
	    {
            DialogHeight += 21;
            me.SelectHour.selectedIndex = _showHour;            
            me.SelectMinute.selectedIndex = _showMinutes;
        }
        me.Dialog.style.height = DialogHeight+"px";        
	}
}

function WebDatePickerDialog_Init()
{
    var dialog = new WebDatePickerDialog();
    for(var i=1; i<13;i++)
    {
		var opt = document.createElement('OPTION');
		opt.value = i;
		opt.text = i;
		dialog.SelectMonth.options.add(opt);
    }
    for(var i=1930; i<2030;i++)
    {
		var opt = document.createElement('OPTION');
		opt.value = i;
		opt.text = i;
		dialog.SelectYear.options.add(opt);
    }
    dialog.SaveButton.onclick = function()
    {
        dialog.PutDate(new Date(dialog.GetDate().getFullYear(), dialog.GetDate().getMonth(), dialog.GetDate().getDate(), dialog.SelectHour.options[dialog.SelectHour.selectedIndex].text, dialog.SelectMinute.options[dialog.SelectMinute.selectedIndex].text));
        dialog.YearTitle.style.display="";
		dialog.SelectYear.style.display = "none";
		dialog.MonthTitle.style.display="";
		dialog.SelectMonth.style.display = "none";	
        dialog.setChanged();
    }
    dialog.CloseButton.onclick = function()
    {
        dialog.YearTitle.style.display="";
		dialog.SelectYear.style.display = "none";
		dialog.MonthTitle.style.display="";
		dialog.SelectMonth.style.display = "none";	    
        dialog.HideDialog();
    }
    dialog.MonthTitle.onclick = function()
    {
        var showMonth = dialog._showdate.getMonth();    
		dialog.SelectMonth.options[showMonth].selected = true;
        dialog.YearTitle.style.display="";
		dialog.SelectYear.style.display = "none";        
		dialog.MonthTitle.style.display="none";
		dialog.SelectMonth.style.display = "";
    }
    
    dialog.YearTitle.onclick = function()
    {
        var showYear = dialog._showdate.getFullYear();
        for(var i=0; i<dialog.SelectYear.options.length; i++){
			if(dialog.SelectYear.options[i].value == showYear){
				dialog.SelectYear.options[i].selected = true;
				break;
			}
		}
		dialog.MonthTitle.style.display="";
		dialog.SelectMonth.style.display = "none";      
    	dialog.YearTitle.style.display="none";
		dialog.SelectYear.style.display = "";
    }    
    dialog.SelectMonth.onchange = function()
    {
        var showDate = dialog._showdate;
		var selectedMonth = dialog.SelectMonth.options[dialog.SelectMonth.selectedIndex].value
        var newDate =  new Date(showDate.getFullYear(),parseInt(selectedMonth,10)-1,1);
		dialog._showdate = newDate;
        dialog.RefreshDialog();    
    }
    dialog.SelectYear.onchange = function()
    {
        var showDate = dialog._showdate;
		var selectedYear = dialog.SelectYear.options[dialog.SelectYear.selectedIndex].value
        var newDate =  new Date(parseInt(selectedYear,10),showDate.getMonth(),1);
        dialog._showdate = newDate;
        dialog.RefreshDialog();    
    }    
    dialog.PreMonthButton.onclick = function()
    {
        var showDate = dialog._showdate;
        if(showDate.getMonth() == 0)
        {
            var newDate =  new Date(showDate.getYear()-1,11,1);
            dialog._showdate = newDate;
        }else
        {
            var newDate =  new Date(showDate.getYear(),showDate.getMonth()-1,1);
            dialog._showdate = newDate;
        }
        dialog.YearTitle.style.display="";
		dialog.SelectYear.style.display = "none";
		dialog.MonthTitle.style.display="";
		dialog.SelectMonth.style.display = "none";	        
        dialog.RefreshDialog();
         
    }
    dialog.NextMonthButton.onclick = function()
    {
        var showDate = dialog._showdate;
        if(showDate.getMonth() == 11)
        {
            var newDate =  new Date(showDate.getYear()+1,1,1);
            dialog._showdate = newDate;
        }else
        {
            var newDate =  new Date(showDate.getYear(),showDate.getMonth()+1,1);
            dialog._showdate = newDate;
        }
        dialog.YearTitle.style.display="";
		dialog.SelectYear.style.display = "none";
		dialog.MonthTitle.style.display="";
		dialog.SelectMonth.style.display = "none";	        
        dialog.RefreshDialog();
         
    }
    dialog.PreYearButton.onclick = function()
    {
        var showDate = dialog._showdate;
        var newDate =  new Date(showDate.getYear()-1,showDate.getMonth(),1);
        dialog._showdate = newDate;
        dialog.YearTitle.style.display="";
		dialog.SelectYear.style.display = "none";
		dialog.MonthTitle.style.display="";
		dialog.SelectMonth.style.display = "none";	        
        dialog.RefreshDialog();
         
    }
    dialog.NextYearButton.onclick = function()
    {
        var showDate = dialog._showdate;
        var newDate =  new Date(showDate.getYear()+1,showDate.getMonth(),1);
        dialog._showdate = newDate;
        dialog.YearTitle.style.display="";
		dialog.SelectYear.style.display = "none";
		dialog.MonthTitle.style.display="";
		dialog.SelectMonth.style.display = "none";	        
        dialog.RefreshDialog();
     
    }
    dialog.TodayButton.onclick = function()
    {
        var date = new Date();
        dialog.PutDate(new Date(date.getFullYear(), date.getMonth(), date.getDate(), dialog.SelectHour.options[dialog.SelectHour.selectedIndex].text, dialog.SelectMinute.options[dialog.SelectMinute.selectedIndex].text));
        dialog.setChanged();
        dialog._showdate = date;
        dialog.YearTitle.style.display="";
		dialog.SelectYear.style.display = "none";
		dialog.MonthTitle.style.display="";
		dialog.SelectMonth.style.display = "none";	                
        dialog.RefreshDialog();
    }
    dialog.SelectHour.onchange = function()
    {
        dialog.PutDate(new Date(dialog.GetDate().getFullYear(), dialog.GetDate().getMonth(), dialog.GetDate().getDate(), dialog.SelectHour.options[dialog.SelectHour.selectedIndex].text, dialog.SelectMinute.options[dialog.SelectMinute.selectedIndex].text));
    }
    dialog.SelectMinute.onchange = function()
    {
        dialog.PutDate(new Date(dialog.GetDate().getFullYear(), dialog.GetDate().getMonth(), dialog.GetDate().getDate(), dialog.SelectHour.options[dialog.SelectHour.selectedIndex].text, dialog.SelectMinute.options[dialog.SelectMinute.selectedIndex].text));
    }    
    return dialog;
}

var WebDatePicker2Dialog = WebDatePickerDialog_Init();

