	var email_reg = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
	var letters_reg  = /^[A-Za-z\u00C0-\u00ff\s]+$/;
	
function GetId(id) {
	if(document.getElementById) // standardised method first
		return document.getElementById(id);
	else if(document.all)
		return document.all[id];
	else if(document.layers)
		return document.layers[id];
	else
		return null;
}
function CheckField(field,classes,msg){
	GetId(field+'_box').innerHTML = msg;
	if(GetId(field))
		GetId(field).className = classes;
	GetId(field+'_box').className = classes;
}
function CountErrors(form_id){
	var err = 0;
	var cur_form = document.getElementById(form_id);
	var spans = document.getElementsByTagName('span');
	for(i=0;i!=spans.length;i++){
		if(spans[i].className == 'error')
			err++;
	}
	if(err == 0) return(true); else return(false);
}
function CheckFirstName(){
	first_name = GetId('first_name').value;
	if(first_name == "")
		CheckField('first_name','error','You must fill your first name');
	else {
		if(letters_reg.test(first_name) == false)
			CheckField('first_name','error','First name must be contain only letters and/or spaces');
		else
			CheckField('first_name','ok','OK');
	}
}
function CheckLastName(){
	last_name = GetId('last_name').value;
	if(last_name == "")
		CheckField('last_name','error','You must fill your last name');
	else {
		if(letters_reg.test(last_name) == false)
			CheckField('last_name','error','Last name must be contain only letters and/or spaces');
		else
			CheckField('last_name','ok','OK');
	}
}
function CheckEmail(){
	email = GetId('email').value;
	if(email == "")
		CheckField('email','error','You must fill your email');
	else {
		if(email_reg.test(email) == false)
			CheckField('email','error','Invalid email format');
		else
			CheckField('email','ok','OK');
	}
}
function CheckConfirmEmail(){
	confirm_email = GetId('confirm_email').value;
	if(confirm_email == "")
		CheckField('confirm_email','error','You must fill your confirmation email');
	else {
		if(confirm_email != email)
			CheckField('confirm_email','error','Confirmation email must be the same with email');
		else
			CheckField('confirm_email','ok','OK');
	}
}
function CheckCountry(){
	temp_country = GetId('country').selectedIndex;
	country = GetId('country')[temp_country].value;
	if(country == "")
		CheckField('country','error','You must choose your country');
	else 
		CheckField('country','ok','OK');
}
function CheckPhone(){
	phone = GetId('phone').value;
	if(phone == "")
		CheckField('phone','error','You must fill your phone number');
	else 
		CheckField('phone','ok','OK');	
}

function CheckGender(){
	temp_gender = GetId('gender').selectedIndex;
	gender = GetId('gender')[temp_gender].value;
	if(gender == "")
		CheckField('gender','error','You must choose your gender');
	else {
		if(gender == "female"){
			alert('Sorry, POW Escapes Experience is currently only available for men only. Please check back in the future!');
			CheckField('gender','error','For men only');
		}else
			CheckField('gender','ok','OK');
	}
}

function CheckAge(){
	temp_age = GetId('age').selectedIndex;
	age = GetId('age')[temp_age].value;
	if(age == "")
		CheckField('age','error','You must choose your answer');
	else {
		if(age == "no"){
			alert('Sorry, at the moment the POW Escapes Experience is only available for people between 25-55 years old.');
			CheckField('age','error','Only for 25-55 years old');
		}else
			CheckField('age','ok','OK');
	}
}

function CheckForm(){
	first_name = GetId('first_name').value;
	last_name = GetId('last_name').value;
	email = GetId('email').value;
	confirm_email = GetId('confirm_email').value;
	phone = GetId('phone').value;
	temp_country = GetId('country').selectedIndex;
	country = GetId('country')[temp_country].value;
	message = GetId('message').value;
	//alert(country);
	CheckGender();
	CheckAge();
	if(first_name == "")
		CheckField('first_name','error','You must fill your first name');
	else {
		if(letters_reg.test(first_name) == false)
			CheckField('first_name','error','First name must be contain only letters and/or spaces');
		else
			CheckField('first_name','ok','OK');
		}
	if(last_name == "")
		CheckField('last_name','error','You must fill your last name');
	else {
		if(letters_reg.test(last_name) == false)
			CheckField('last_name','error','Last name must be contain only letters and/or spaces');
		else
			CheckField('last_name','ok','OK');
		}
	
	if(email == "")
		CheckField('email','error','You must fill your email');
	else {
		if(email_reg.test(email) == false)
			CheckField('email','error','Invalid email format');
		else
			CheckField('email','ok','OK');
	}
	
	if(confirm_email == "")
		CheckField('confirm_email','error','You must fill your confirmation email');
	else {
		if(confirm_email != email)
			CheckField('confirm_email','error','Confirmation email must be the same with email');
		else
			CheckField('confirm_email','ok','OK');
	}
	
	if(country == "")
		CheckField('country','error','You must choose your country');
	else 
		CheckField('country','ok','OK');
		
	if(phone == "")
		CheckField('phone','error','You must fill your phone number');
	else
		CheckField('phone','ok','OK');	


	if(CountErrors('contact_form')) {
		GetId('contact_form').submit();
		alert('Thank you for your interest in POW Escapes. We will contact you very soon with complete details for your booking.');
	}
}
function SetVisible(flag){
	if(flag == 1){
		GetId('others').style.display = '';
		GetId('others').value = "from ?";
	}
	else if(flag == 0){
		GetId('others').style.display = 'none';
		GetId('others').value = "";
	}
}
function ClearValue(){
	GetId('others').value = "";
}