var frMonth 
var frDay  
var frYear 
var toMonth
var toDay  
var toYear 
var y 
var m 
var d
function get_vars(frm) {
	frMonth = frm.fr_month.options[frm.fr_month.selectedIndex].value
	frDay   = frm.fr_day  .options[frm.fr_day  .selectedIndex].text
	frYear  = frm.fr_year .options[frm.fr_year .selectedIndex].text
	toMonth = frm.to_month.options[frm.to_month.selectedIndex].value
	toDay   = frm.to_day  .options[frm.to_day  .selectedIndex].text
	toYear  = frm.to_year .options[frm.to_year .selectedIndex].text
	//-- get now and adjust values --//
	var now = new Date()
	y = now.getYear()
	m = now.getMonth() + 1
	d = now.getDate()
	if (y < 1900) {
		y = y + 1900
	}
	if (m < 10) {
		m = "0" + m
	}
	if (d < 10) {
		d = "0" + d
	}
}
function chk_dom() {
	var mths = new Array ("01","02","03","04","05","06","07","08","09","10","11","12")
	var days = new Array ("31","29","31","30","31","30","31","31","30","31","31","31")
	for (var i = 0; i < mths.length; i++) {
		if ((mths[i] == frMonth && days[i] < frDay) ||
				(mths[i] == toMonth && days[i] < toDay)) {
			return false
		}
	}
}
function chk_leap_yrs() {
	if (frMonth == "02" && frYear % 4 > 0 && frDay > 28)
	{
		return false
	}
	else if (toMonth == "02" && toYear % 4 > 0 && toDay > 28)
	{
		return false
	}
}
function arrival_ok() {
	if (frYear + "-" + frMonth + "-" + frDay < y + "-" + m + "-" + d) {
		return false
	}
	return true
}
function departure_ok() {
	if (frYear + frMonth + frDay >= toYear + toMonth + toDay) {
		return false
	}
	return true
}
//-------------------------------
// get the form field numbers
// validate the day of the month
// validate leap years
// validate date ranges
//-------------------------------
function valid_dates(frm) {
	get_vars(frm)
	if (chk_dom() == false) {
		alert("You have specified an invalid date")
		return false
	}
	if (chk_leap_yrs() == false) {
		alert("You have specified an invalid date")
		return false
	}
	if (arrival_ok() == false) {
		alert("The arrival date cannot be before today")
		return false
	}
	if (departure_ok() == false) {
		alert("The departure date must be later than the arrival date")
		return false
	}
	return true;
}
//-- as above --//
function valid_upd_dates(frm) {
	get_vars(frm)
	if (chk_dom() == false) {
		alert("You have specified an invalid date")
		return false
	}
	if (chk_leap_yrs() == false) {
		alert("You have specified an invalid date")
		return false
	}
	if (arrival_ok() == false) {
		var msg = 
			"WARNING: The arrival date specified is earlier than today's date.\n" +
			"         If you are extending an already active booking or updating\n" +
			"         customer information then this MAY be ok.\n\n" +
			"         Do you wish to proceed with this update?"
		if (confirm(msg) == false) {
			return false;
		}
	}
	if (departure_ok() == false) {
		alert("The departure date must be later than the arrival date")
		return false
	}
	return true;
}

