function validateForm() {
	var dateRegexp = new RegExp("^(\\d{2})/(\\d{2})/(\\d{4})$");
	var matched = null;	
	// dateIn validation
	matched = dateRegexp.exec(document.bookingForm.dateIn.value);
	if (matched != null) {
		if (!isValidDate2(matched[2], matched[1], matched[3])) {
			return handleError(document.bookingForm.dateIn, "Arrival is not a date with the form mm/dd/yyyy.");
		}
	} else {
		return handleError(document.bookingForm.dateIn, "Arrival is not a date with the form mm/dd/yyyy.");
	}
	// dateOut validation
	matched = dateRegexp.exec(document.bookingForm.dateOut.value);
	if (matched != null) {
		if (!isValidDate2(matched[2], matched[1], matched[3])) {
			return handleError(document.bookingForm.dateOut, "Departure is not a date with the form mm/dd/yyyy.");
		}
	} else {
		return handleError(document.bookingForm.dateOut, "Departure is not a date with the form mm/dd/yyyy.");
	}
	// guestCount validation
	if (document.bookingForm.guestCount < 1 || document.bookingForm.guestCount > 8) {
		return handleError(document.bookingForm.guestCount, "Number <br /> of Guests is required.");
	}
	// bookingId validation
	if (document.bookingForm.bookingId.type != "hidden") {
		if (document.bookingForm.bookingId.value == "") {
			return handleError(document.bookingForm.bookingId, "Choose a location is required.");
		}
	}
	return true;
}

function handleError(field, msg) {
	field.focus();
	alert(msg);
	return false;
}

function isValidDate2(day, month, year) {
    if (month < 1 || month > 12) {
        return false;
    }
    if (day < 1 || day > 31) {
        return false;
    }
    if ((month == 4 || month == 6 || month == 9 || month == 11) &&
        (day == 31)) {
        return false;
    }
    if (month == 2) {
        var leap = (year % 4 == 0 &&
           (year % 100 != 0 || year % 400 == 0));
        if (day>29 || (day == 29 && !leap)) {
            return false;
        }
    }
    return true;
}

var bookingProviderNames = new Array();

bookingProviderNames['6927'] = 'ihotelier';

bookingProviderNames['5062'] = 'ihotelier';

bookingProviderNames['GeoID_4=2523'] = 'ihotelierdest';

bookingProviderNames['6924'] = 'ihotelier';

bookingProviderNames['6942'] = 'ihotelier';

bookingProviderNames['5073'] = 'ihotelier';

bookingProviderNames['14937'] = 'ihotelier';

bookingProviderNames['2982'] = 'ihotelier';

bookingProviderNames['6941'] = 'ihotelier';

bookingProviderNames['6806'] = 'ihotelier';

bookingProviderNames['5705'] = 'ihotelier';

bookingProviderNames['3560'] = 'ihotelier';

bookingProviderNames['GeoID_4=2488'] = 'ihotelierdest';

bookingProviderNames['3562'] = 'ihotelier';

bookingProviderNames['GeoID_4=2483'] = 'ihotelierdest';

bookingProviderNames['6700'] = 'ihotelier';

bookingProviderNames['GeoID_4=2480'] = 'ihotelierdest';

bookingProviderNames['2994'] = 'ihotelier';

bookingProviderNames['5071'] = 'ihotelier';

bookingProviderNames['5067'] = 'ihotelier';

bookingProviderNames['2949'] = 'ihotelier';

bookingProviderNames['GeoID_4=2509'] = 'ihotelierdest';

bookingProviderNames['6702'] = 'ihotelier';

bookingProviderNames['4302'] = 'ihotelier';

bookingProviderNames['GeoID_4=2489'] = 'ihotelierdest';

bookingProviderNames['5028'] = 'ihotelier';

bookingProviderNames['GeoID_4=2484'] = 'ihotelierdest';

bookingProviderNames['14937'] = 'ihotelier';

bookingProviderNames['6943'] = 'ihotelier';

bookingProviderNames['5068'] = 'ihotelier';

bookingProviderNames['14933'] = 'ihotelier';

bookingProviderNames['GeoID_4=2502'] = 'ihotelierdest';

bookingProviderNames['3559'] = 'ihotelier';

bookingProviderNames['5029'] = 'ihotelier';

bookingProviderNames['5072'] = 'ihotelier';

bookingProviderNames['14887'] = 'ihotelier';

bookingProviderNames['14935'] = 'ihotelier';

bookingProviderNames['3553'] = 'ihotelier';

bookingProviderNames['2989'] = 'ihotelier';

bookingProviderNames['6701'] = 'ihotelier';

bookingProviderNames['2993'] = 'ihotelier';

bookingProviderNames['6703'] = 'ihotelier';

bookingProviderNames['GeoID_4=2493'] = 'ihotelierdest';

bookingProviderNames['SBP001'] = 'trust';

bookingProviderNames['14936'] = 'ihotelier';

bookingProviderNames['GeoID_4=2630'] = 'ihotelierdest';

bookingProviderNames['GeoID_4=2481'] = 'ihotelierdest';

bookingProviderNames['5076'] = 'ihotelier';

bookingProviderNames['6926'] = 'ihotelier';

bookingProviderNames['6928'] = 'ihotelier';

bookingProviderNames['5070'] = 'ihotelier';


function setBookingProviderName(bookingId) {
	if (!bookingId || null == bookingId || '' == bookingId) {
		document.bookingForm.bookingProviderName.value='';
	} else {
		document.bookingForm.bookingProviderName.value=bookingProviderNames[bookingId];
	}
	/* commented on 05/03/2007 according to Skip
	document.bookingForm.guestCount.options.length = 0;
	document.bookingForm.guestCount.options[document.bookingForm.guestCount.options.length] = new Option('1', '1', true, false);
	document.bookingForm.guestCount.options[document.bookingForm.guestCount.options.length] = new Option('2', '2', false, false);
	document.bookingForm.guestCount.options[document.bookingForm.guestCount.options.length] = new Option('3', '3', false, false);
	if (bookingProviderNames[bookingId] == 'ihotelier') {
		document.bookingForm.guestCount.options[document.bookingForm.guestCount.options.length] = new Option('4', '4', false, false);
	}*/
}