// JavaScript Document

function y2k(number)    { return (number < 1000) ? number + 1900 : number; }

var today = new Date();
var day   = today.getDate();
var month = today.getMonth();
var year  = today.getYear();

function padout(number) { return (number < 10) ? '0' + number : number; }

function explode(item,delimiter) {
	tempArray=new Array(1);
	var Count=0;
	var tempString=new String(item);
	while (tempString.indexOf(delimiter)>0) {
		tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
		tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
		Count=Count+1
	}
	tempArray[Count]=tempString;
	return tempArray;
}

function restart(inputField) {
	document.form1.elements[inputField].value = '' + padout(day) + '/' + padout(month - 0 + 1) + '/' + year;
	mywindow.close();
}

function newWindow(inputName) {
	var currentValue = document.form1.elements[inputName].value;
	if(currentValue == '')
	{
		currentValue = day + '/' + month + '/' + year; 
	}
	var currentDate = explode(currentValue,'/');
	month = currentDate[1]-1;
	year = currentDate[2];
	mywindow=open('/css/cal.php?do=' + inputName,'myname','resizable=no,width=350,height=270');
	mywindow.location.href = '/css/cal.php?do=' + inputName;
	if (mywindow.opener == null) mywindow.opener = self;
} 
