
// Checks if browser is Netscape 2.0x since the options array properties don't work with Netscape 2.0x
function isBrowserSupp() {
	// Get the version of the browser
	version =  parseFloat( navigator.appVersion );
	if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {
		return false;
	}
	else {
		return true;
	}

	return true;
}

function isLeapYear(yrStr)
{
	var leapYear=false;
	var year = parseInt(yrStr, 10);
	// every fourth year is a leap year
	if (year%4 == 0)
		{
		leapYear=true;
		// unless it's a multiple of 100
		if (year%100 == 0)
			{
			leapYear=false;
			// unless it's a multiple of 400
			if (year%400 == 0)
				{
				leapYear=true;
				}
			}
		}
	return leapYear;
}


function getDaysInMonth(mthIdx, YrStr)
{
	// all the rest have 31
	var maxDays=31;
	// expect Feb. (of course)
	if (mthIdx==2)
		{
		if (isLeapYear(YrStr))
			{
			maxDays=29;
			}
		else
			{
			maxDays=28;
			}
		}
	// thirty days hath...
	if (mthIdx==4 || mthIdx==6 || mthIdx==9 || mthIdx==11)
		{
		maxDays=30;
		}
	return maxDays;
}

function acheckIn(date, month, year) {
	document.getElementById('checkIn_Day').value = date;
	document.getElementById('checkIn_MonthYear').value = year+"-"+month;
//	checkOutAfterCheckIn(date, month, year);
}

function updatecheckIn(date, monthyear) {
	month = parseInt(monthyear.value.substring(5));
	year = parseInt(monthyear.value.substring(0,4));
	if (date.value > getDaysInMonth(month, year)){
		document.getElementById('checkIn_Day').value = getDaysInMonth(month, year);
	}
	calcheckIn.setCurrentMonth(month - 1);
	calcheckIn.setCurrentYear(year);
	if (document.getElementById('checkOut_Day')!= null) checkOutAfterCheckIn(date.value, month, year);
}

function checkOutAfterCheckIn(date, month, year){
	date = parseInt(date);
	month = parseInt(month);
	year = parseInt(year);

	checkOutDate = parseInt(document.getElementById('checkOut_Day').value);
	checkOutMonth = parseInt(document.getElementById('checkOut_MonthYear').value.substring(6));
	checkOutYear = parseInt(document.getElementById('checkOut_MonthYear').value.substring(0,4));

	if (checkOutYear > year) return;
	if (checkOutMonth > month && checkOutYear>=year) return;
	if (checkOutDate > date && checkOutMonth>=month && checkOutYear>=year) return;
	dateToUse = parseInt(date) + 1;
	if (getDaysInMonth(month, year)<dateToUse)
	{
		dateToUse = "1";
		month = parseInt(month) + 1;
		if (month>12){
			month = 1;
			year = year + 1;
		}
	}
	document.getElementById('checkOut_Day').value = dateToUse;
	document.getElementById('checkOut_MonthYear').value = year+"-"+month;
	calcheckOut.setCurrentMonth(month - 1);
	calcheckOut.setCurrentYear(year);
}

function acheckOut(date, month, year) {
	document.getElementById('checkOut_Day').value = date;
	document.getElementById('checkOut_Month').value = month;
	document.getElementById('checkOut_Year').value = year;
}

function updatecheckOut(date, monthyear) {
	month = parseInt(monthyear.value.substring(5));
	year = parseInt(monthyear.value.substring(0,4));
	if (date.value > getDaysInMonth(month, year)){
		document.getElementById('checkOut_Day').value = getDaysInMonth(month, year);
	}
	calcheckOut.setCurrentMonth(month - 1);
	calcheckOut.setCurrentYear(year);
}
