/*Validation js*/
var today=new Date();
var todate=today.getDate();
var tomonth=today.getMonth();
var toyear=today.getFullYear();
var checkOK = "0123456789";

//Leap year (Uma Chatterjee - 2.1.2006)
function leapYearCheck(y) {	
	if ( ( (y%4==0)&&(y%100 != 0) ) || (y%400==0) ) { 
		return true;
	} else {
		return false;
	}
}

//Days of month (Uma Chatterjee - 2.1.2006)
function addDays(datefield, num) {
	
	var numDays=Number(monthDays[num]);
	if(leapYearCheck(toyear) && (num==1)) {		
		numDays=29;
	}
	
	datefield.options.length=0;
	for(i=1; i<=numDays; i++) {
		datefield.options[datefield.options.length]=new Option(i, i);
	}
	
	if(datefield.options[0].value=="")
		datefield.remove(0);
		
}

//Leap year, month days (Uma Chatterjee - 2.1.2006)
monthDays=new Array("31", "28", "31", "30", "31",  "30", "31", "31", "30", "31", "30", "31");

//Leap year, month days (Uma Chatterjee - 2.1.2006)
function setCheckOutDateNew()
{
		var d=Number(document.searchform.strCheckindate.value);
		var m=Number(document.searchform.strCheckinmonth.value);
		var y=Number(document.searchform.strCheckinyear.value);
		var checkoutDay=d+1;
		var nextMonth=m;
		var checkoutYear=y;
		
		if(leapYearCheck(y)) {		
			monthDays[1]="29";
		} else {
			monthDays[1]="28";
		}
		
		if(leapYearCheck(y) && m==2) {
			addDays(document.searchform.strCheckindate, m-1);
			addDays(document.searchform.strCheckoutdate, m-1);
		}		
		
		
		if(document.searchform.strCheckinmonth.options.length!=monthDays[m-1]) {
			addDays(document.searchform.strCheckindate, m-1);
			addDays(document.searchform.strCheckoutdate, m-1);
		}
		
		if(checkoutDay > monthDays[m-1]) {
			nextMonth=m+1;
			if(nextMonth>12) {
				nextMonth=1;			
				checkoutYear+=1;
			}
			addDays(document.searchform.strCheckoutdate, nextMonth-1);
			checkoutDay=checkoutDay-monthDays[m-1];
		}
		
		if(d>monthDays[m-1]) {
			d=monthDays[m-1];
			checkoutDay=1;
		}
		
		document.searchform.strCheckinyear.value=y;
		document.searchform.strCheckinmonth.value=m;
		document.searchform.strCheckindate.value=d;
		
		document.searchform.strCheckoutyear.value=checkoutYear;
		document.searchform.strCheckoutmonth.value=nextMonth;
		document.searchform.strCheckoutdate.value=checkoutDay;
		
}

//Leap year, month days (Uma Chatterjee - 2.1.2006)
function setDates() {
	if(leapYearCheck(document.searchform.strCheckoutyear.value)) {		
		monthDays[1]="29";
	} else {
		monthDays[1]="28";
	}	
	var checkoutdate=document.searchform.strCheckoutdate.value;
	addDays(document.searchform.strCheckoutdate, document.searchform.strCheckoutmonth.selectedIndex);
	if(checkoutdate>document.searchform.strCheckoutdate.options.length) {
		document.searchform.strCheckoutdate.value=document.searchform.strCheckoutdate.options.length;
	} else {
		document.searchform.strCheckoutdate.value=checkoutdate;
	}
}

