function getStyle( elmID, style) {

	var elm = document.getElementById( elmID);
	
	if ( elm.currentStyle) {
		return elm.currentStyle[style];
	}
	else if (window.getComputedStyle) {
		return document.defaultView.getComputedStyle( elm, null).getPropertyValue( style);
	}
	
	return '';
}

var styleColor;
var styleColorBG;

function initStylesBookingEnquiry() {

	// get the original styling colours here as the page loads
	styleColor = getStyle( 'nights', 'color');
	styleColorBG = getStyle( 'nights', 'backgroundColor');
}

function initStylesContactForm() {

	// get the original styling colours here as the page loads
	styleColor = getStyle( 'email', 'color');
	styleColorBG = getStyle( 'email', 'backgroundColor');
}

function checkContactForm() {

	fullname = document.getElementById( 'fullname');
	email = document.getElementById( 'email');
	phone = document.getElementById( 'tel');
	query = document.getElementById( 'query');
	
	// perform checks
	check = new Array();

	check['fullname'] = fullname.value != '' ? true : false;
	check['email'] = email.value != '' ? true : false;
	check['tel'] = phone.value != '' ? true : false;
	check['query'] = query.value != '' ? true : false;
	
	// highlight any missing fields
	for( i in check) {
		
		elm = document.getElementById( i);

		if( elm != null) {
		
			if( !check[i]) {
				elm.style.backgroundColor = '#a00';
				elm.style.color = '#fff';
			}
			else {
				elm.style.backgroundColor = styleColorBG;
				elm.style.color = styleColor;
			}
		}
	}

	status = (check['fullname'] && check['email'] && check['tel'] && check['query']);
	
	// we have to do it like this due to the psychotic Internet Explorer treating false as a string?!
	if( status == false || status == 'false') {
		document.getElementById( 'missingFieldsMsg').style.display = 'block';
	}
	
	if( status == false || status == 'false') {
		return false;
	}
	
	// validation passed
	return true;
}

function checkBookingEnquiry()
{
	document.getElementById( 'missingFieldsMsg').style.display = 'none';

	nights = document.getElementById( 'nights');
	adults = document.getElementById( 'adults');
	children = document.getElementById( 'children');

	fullname = document.getElementById( 'fullname');
	email = document.getElementById( 'email');
	phone = document.getElementById( 'phone');
	info = document.getElementById( 'info');

	// perform checks
	check = [];

	check['nights'] 	= nights.value 		!= '' ? true : false;
	check['adults'] 	= adults.value 		!= '' ? true : false;
	check['fullname'] 	= fullname.value 	!= '' ? true : false;
	check['email'] 		= email.value 		!= '' ? true : false;
	check['phone'] 		= phone.value 		!= '' ? true : false;

	var status = "1";
	
	// highlight any missing fields
	for( i in check)
	{
		elm = document.getElementById(i);
		
		if(elm != null)
		{ 
			if(!check[i])
			{
				elm.style.backgroundColor = '#a00';
				elm.style.color = '#fff';
				
				status = "0";
			}
			else
			{
				elm.style.backgroundColor = styleColorBG;
				elm.style.color = styleColor;
			}
		}
	}

	if(status == "1")
	{
		// validation passed
		return true;
	}
	else
	{
		document.getElementById('missingFieldsMsg').style.display = 'block';
		return false;
	}
}
