<%
include("language.html")
if _SESSION["username"] ~= nil and _SESSION["currentpath"] ~= nil then
%>
<!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>
<title>Time Selector</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
	background-color: #E7E6DA;
	padding:0px;
	margin:10px;
}

button{
border:none;background:none;padding:0;
margin:0;width:auto;overflow:visible;text-align:center;	
white-space:nowrap;height:24px;line-height:22px;
cursor:pointer;
color:#000;
margin-left:2px;
margin-top:2px;
}
button span, button em{
display:block;height:24px;line-height:22px;margin:0;
}	
button span{
padding-left:14px;
background:url("images/button_left.gif") no-repeat 0 0;
}
button em{
font-style:normal;padding-right:14px;
background:url("images/button.gif") no-repeat 100% 0;
}
button:hover{
filter:alpha(opacity=60);
opacity:0.60;
color:#5488C9;
}
button span:hover{
filter:alpha(opacity=60);
opacity:0.60;
color:#5488C9;
}
.buttonhover{
filter:alpha(opacity=60);
opacity:0.60;
color:#5488C9;
}


.m_fieldset {
	padding: 0px 10px 5px 10px;
	text-align: center;
	width: 200px;
}
.m_legend {
	font-family: Tahoma;
	font-size: 11px;
	padding-bottom: 5px;
}
.m_frameborder {
	border-left: 2px inset #D4D0C8;
	border-top: 2px inset #D4D0C8;
	border-right: 2px inset #FFFFFF;
	border-bottom: 2px inset #FFFFFF;
	margin-left:3px;
	width: 140px;
	height: 19px;
	background-color: #FFFFFF;
	overflow: hidden;
	text-align: right;
	font-family: "Tahoma";
	font-size: 10px;
}
.m_arrow {
	width: 16px;
	height: 16px;
	font-size: 8px;
	line-height: 2px;
	padding-left: 2px;
	cursor: default;
}
.m_input {
	width: 18px;
	height: 14px;
	border: 0px solid black;
	font-family: "Tahoma";
	font-size: 9px;
	text-align: right;
	ime-mode:disabled;
}
</style>
<script language="javascript" src="include/common.js"></script>
<script language="javascript">
function getEvent()
{
  if(window.event)
  {
    return window.event;
  }
  func=getEvent.caller;
  while(func!=null)
  {
    var arg0=func.arguments[0];
    if(arg0)
    {
      if((arg0.constructor==Event || arg0.constructor ==MouseEvent)
		||(typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation))
       {
          return arg0;
       }
    }
    func=func.caller;
  }
  return null;
}

if(window.HTMLElement) 
{
    HTMLElement.prototype.__defineSetter__("outerHTML",function(sHTML){
        var r=this.ownerDocument.createRange();
        r.setStartBefore(this);
        var df=r.createContextualFragment(sHTML);
        this.parentNode.replaceChild(df,this);
        return sHTML;
        });

    HTMLElement.prototype.__defineGetter__("outerHTML",function(){
    var attr;
        var attrs=this.attributes;
        var str="<"+this.tagName.toLowerCase();
        for(var i=0;i<attrs.length;i++){
            attr=attrs[i];
            if(attr.specified)
                str+=" "+attr.name+'="'+attr.value+'"';
            }
        if(!this.canHaveChildren)
            return str+">";
        return str+">"+this.innerHTML+"</"+this.tagName.toLowerCase()+">";
        });
        
	HTMLElement.prototype.__defineGetter__("canHaveChildren",function(){
	switch(this.tagName.toLowerCase()){
            case "area":
            case "base":
			case "basefont":
            case "col":
            case "frame":
            case "hr":
            case "img":
            case "br":
            case "input":
            case "isindex":
            case "link":
            case "meta":
            case "param":
            return false;
        }
        return true;

     });
}
 


function right(mainStr,lngLen) 
{
if (mainStr.length-lngLen>=0 && mainStr.length>=0 && mainStr.length-lngLen<=mainStr.length) {
return mainStr.substring(mainStr.length-lngLen,mainStr.length)}
else{return null}
}

function minute(name,fName,initHour,initMin,initSec)
{
	this.name = name;
	this.fName = fName || "m_input";
	this.timer = null;
	this.fObj = null;
	
	this.toString = function()
	{
		var objDate = new Date();
		var sMinute_Common = "class=\"m_input\" maxlength=\"2\" name=\""+this.fName+"\" onclick=\""+this.name+".setFocusObj(this)\" onblur=\""+this.name+".setTime(this)\" onkeyup=\""+this.name+".prevent(this)\" onkeypress=\"if (!/[0-9]/.test(String.fromCharCode(event.keyCode)))event.keyCode=0\" onpaste=\"return false\" ondragenter=\"return false\"";
		var sButton_Common = "class=\"m_arrow\" onfocus=\"this.blur()\" onmouseup=\""+this.name+".controlTime()\" "
		var str = "";
		str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
		str += "<tr>"
		str += "<td>"
		str += "<div class=\"m_frameborder\">"
		str += "<input alt=\"24\" value=\""+(initHour == null ? this.formatTime(objDate.getHours()):initHour)+"\" "+sMinute_Common+">:"
		str += "<input alt=\"60\" value=\""+(initMin == null ? this.formatTime(objDate.getMinutes()):initMin)+"\" "+sMinute_Common+">:"
		str += "<input alt=\"60\" value=\""+(initSec == null ? this.formatTime(objDate.getSeconds()):initSec)+"\" "+sMinute_Common+">"
		str += "</div>"
		str += "</td>"
		str += "<td>"
		str += "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">"
		str += "<tr><td><input type='button' value='+' id=\""+this.fName+"_up\" "+sButton_Common+"></td></tr>"
		str += "<tr><td><input type='button' value='-' id=\""+this.fName+"_down\" "+sButton_Common+"></td></tr>"
		str += "</table>"
		str += "</td>"
		str += "</tr>"
		str += "</table>"
		return str;
	}
	this.play = function()
	{
		this.timer = setInterval(this.name+".playback()",1000);
	}
	this.formatTime = function(sTime)
	{
		sTime = ("0"+sTime);
		return sTime.substr(sTime.length-2);
	}
	this.playback = function()
	{
		var objDate = new Date();
		var arrDate = [objDate.getHours(),objDate.getMinutes(),objDate.getSeconds()];
		var objMinute = document.getElementsByName(this.fName);
		for (var i=0;i<objMinute.length;i++)
		{
			objMinute[i].value = this.formatTime(arrDate[i])
		}
	}
	this.prevent = function(obj)
	{
		clearInterval(this.timer);
		this.setFocusObj(obj);
		var value = parseInt(obj.value,10);
		var radix = parseInt(obj.alt,10)-1;
		if (obj.value>radix||obj.value<0)
		{
			obj.value = obj.value.substr(0,1);
		}
	}
	this.controlTime = function(cmd)
	{
		if (!this.fObj) return;
		clearInterval(this.timer);
		var evt = getEvent();
		var element = evt.srcElement || evt.target;
		var cmd = element.value=="+"?true:false;
		var i = parseInt(this.fObj.value,10);
		var radix = parseInt(this.fObj.alt,10)-1;
		if (i==radix&&cmd)
		{
			i = 0;
		}
		else if (i==0&&!cmd)
		{
			i = radix;
		}
		else
		{
			cmd?i++:i--;
		}
		this.fObj.value = this.formatTime(i);
		this.fObj.select();
	}
	this.setTime = function(obj)
	{
		obj.value = this.formatTime(obj.value);
	}
	this.setFocusObj = function(obj)
	{
		this.fObj = obj;
	}
	this.getTime = function()
	{
		var arrTime = new Array(2);
		for (var i=0;i<document.getElementsByName(this.fName).length;i++)
		{
			arrTime[i] = document.getElementsByName(this.fName)[i].value;
		}
		return arrTime.join(":");
	}
}
</script>
<style type="text/css">
body {
	background-color: #E7E6DA;
}
.c_fieldset {
	padding: 0px 10px 5px 10px;
	text-align: center;
	width: 200px;
}
.c_legend {
	font-family: Tahoma;
	font-size: 11px;
	padding-bottom: 5px;
}
.c_frameborder {
	border-left: 2px inset #D4D0C8;
	border-top: 2px inset #D4D0C8;
	border-right: 2px inset #FFFFFF;
	border-bottom: 2px inset #FFFFFF;
	background-color: #FFFFFF;
	overflow: hidden;
	font-family: "Tahoma";
	font-size: 10px;
	width:160px;
	height:120px;
}
.c_frameborder td {
	width: 23px;
	height: 16px;
	font-family: "Tahoma";
	font-size: 11px;
	text-align: center;
	cursor: default;
}
.c_frameborder .selected {
	background-color:#0A246A;
	width:12px;
	height:12px;
	color:white;
}
.c_frameborder span {
	width:12px;
	height:12px;
}
.c_arrow {
	width: 16px;
	height: 16px;
	font-size: 8px;
	line-height: 2px;
	padding-left: 2px;
	cursor: default;
}
.c_year {
	font-family: "Tahoma";
	font-size: 11px;
	cursor: default;
	width:55px;
}
.c_month {
	width:75px;
	font:11px "Tahoma";
}
.c_dateHead {
	background-color:#808080;
	color:#D4D0C8;
	font-size: 8px;
}
</style>
<script language="javascript">
function calendar(name,fName,initYear,initMonth,initDay)
{
	this.name = name;
	this.fName = fName || "calendar";
	var objDate = new Date();
	this.year = initYear == null ? objDate.getFullYear():parseInt(initYear,10);
	this.month = initMonth == null ? objDate.getMonth():parseInt(initMonth,10)-1;
	this.date = initDay == null ? objDate.getDate():parseInt(initDay,10);
	//private
	this.toString = function()
	{
		var str = "";
		str += "<table border=\"0\" cellspacing=\"3\" cellpadding=\"0\">";
		str += "<tr>";
		str += "<td>";
		str += this.drawMonth();
		str += "</td>";
		str += "<td align=\"right\">";
		str += this.drawYear();
		str += "</td>";
		str += "</tr>";
		str += "<tr>";
		str += "<td colspan=\"2\">";
		str += "<div class=\"c_frameborder\">";
		str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"c_dateHead\">";
		str += "<tr>";
		str += "<%=LANG['calendar_weekdays_str']%>";
		str += "</tr>";
		str += "</table>";
		str += this.drawDate();
		str += "</div>";
		str += "</td>";
		str += "</tr>";
		str += "</table>";
		return str;
	}
	//private
	this.drawYear = function()
	{
		var str = "";
		str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		str += "<tr>";
		str += "<td>";
		str += "<input class=\"c_year\" maxlength=\"4\" value=\""+this.year+"\" name=\""+this.fName+"\" id=\""+this.fName+"_year\" readonly>";
		//DateField
		str += "<input type=\"hidden\" name=\""+this.fName+"\" value=\""+this.date+"\" id=\""+this.fName+"_date\">";
		str += "</td>";
		str += "<td>";
		str += "<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\">";
		str += "<tr>";
		str += "<td><input type='button' value='+' class=\"c_arrow\" onfocus=\"this.blur()\" onclick=\"document.getElementById('"+this.fName+"_year').value++;"+this.name+".redrawDate()\"></td>";
		str += "</tr>";
		str += "<tr>";
		str += "<td><input type='button' value='-' class=\"c_arrow\" onfocus=\"this.blur()\" onclick=\"document.getElementById('"+this.fName+"_year').value--;"+this.name+".redrawDate()\"></td>";
		str += "</tr>";
		str += "</table>";
		str += "</td>";
		str += "</tr>";
		str += "</table>";
		return str;
	}
	//priavate
	this.drawMonth = function()
	{
		var aMonthName = [<%=LANG["calendar_months"]%>];
		var str = "";
		str += "<select class=\"c_month\" name=\""+this.fName+"\" id=\""+this.fName+"_month\" onchange=\""+this.name+".redrawDate()\">";
		for (var i=0;i<aMonthName.length;i++) {
			str += "<option value=\""+(i+1)+"\" "+(i==this.month?"selected":"")+">"+aMonthName[i]+"</option>";
		}
		str += "</select>";
		return str;
	}
	//private
	this.drawDate = function()
	{
		var str = "";
		var fDay = new Date(this.year,this.month,1).getDay();
		var fDate = 1-fDay;
		var lDay = new Date(this.year,this.month+1,0).getDay();
		var lDate = new Date(this.year,this.month+1,0).getDate();
		str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\""+this.fName+"_dateTable"+"\">";
		for (var i=1,j=fDate;i<7;i++)
		{
			str += "<tr>";
			for (var k=0;k<7;k++)
			{
				str += "<td><span"+(j==this.date?" class=\"selected\"":"")+" onclick=\""+this.name+".redrawDate(this.innerHTML)\">"+(isDate(j++))+"</span></td>";
			}
			str += "</tr>";
		}
		str += "</table>";
		return str;
		function isDate(n)
		{
			return (n>=1&&n<=lDate)?n:"";
		}
	}
	//public
	this.redrawDate = function(d)
	{
		this.year = document.getElementById(this.fName+"_year").value;
		this.month = document.getElementById(this.fName+"_month").value-1;
		this.date = d || this.date;
		document.getElementById(this.fName+"_year").value = this.year;
		document.getElementById(this.fName+"_month").selectedIndex = this.month;
		document.getElementById(this.fName+"_date").value = this.date;
		if (this.date>new Date(this.year,this.month+1,0).getDate()) this.date = new Date(this.year,this.month+1,0).getDate();
		document.getElementById(this.fName+"_dateTable").outerHTML = this.drawDate();
	}
	//public
	this.getDate = function(delimiter)
	{
		if (!delimiter) delimiter = "-";
		var aValue = [this.year,right("0"+(this.month+1),2),right("0"+this.date,2)];
		return aValue.join(delimiter);
	}
}

function returnTime()
{
	try
	{
		var timevalue = c.getDate()+" "+m.getTime();
		top.closewindow(timevalue);
	}
	catch(e){}
}
</script>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr><td  align="center">
<fieldset class="c_fieldset"><legend class="c_legend"><%=LANG["calendar_static_date"]%></legend>
<!-- call calendar -->
<script>
var mydate = '<%=_GET["mydate"] or ""%>';
var c = null;
if(mydate != "")
{
	mydate = mydate.split("-");
	c = new calendar("c","cc",mydate[0],mydate[1],mydate[2]);
}
else
{
	c = new calendar("c");
}
document.write(c);
</script>
</fieldset>
</td></tr>
<tr>
<td valign="top"  align="center">
<fieldset class="m_fieldset"><legend class="m_legend"><%=LANG["calendar_static_time"]%></legend>
<script>
var mytime = '<%=_GET["mytime"] or ""%>';
var m = null;
if(mytime != "")
{
	mytime = mytime.split(":");
	m = new minute("m","mm",mytime[0],mytime[1],mytime[2]);
}
else
{
	m = new minute("m");
}
document.write(m);
</script>
</fieldset>
</td></tr>
<tr>
<td align="center">
<button type='submit' onclick='returnTime();'><span><em><%=LANG["create_submit"]%></em></span></button>&nbsp;<button onclick='top.closewindow();'><span><em><%=LANG["create_cancel"]%></em></span></button>
</td>
</tr>
</table>
</body>
</html>

<% 
else
	print("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>")
	print("<script>top.location='login.html';</script>")
end 
%>

<noscript><center><H2><%=LANG["error_nojavascript"]%></H2></center></noscript>