function form_focus(){
	timeMonitor();
  	document.formbooking.firstname.focus();
}

function check_completed(){
	if(trim(document.formbooking.firstname.value) == ""){
		alert('First name is required !');
		document.formbooking.firstname.focus();
	}
	else if(trim(document.formbooking.lastname.value) == ""){
		alert('Last name is required !');
		document.formbooking.lastname.focus();
	}
	else if(trim(document.formbooking.email.value) == "" || e_mail(document.formbooking.email.value) == false){
		alert('E-Mail address is required !');
		document.formbooking.email.focus();
	}
	else if(trim(document.formbooking.telephone.value).length < 9){
		alert('Telephone number is required !');
		document.formbooking.telephone.focus();
	}
	else if(document.formbooking.country_id.value == ""){
		alert('Country is required !');
		document.formbooking.country_id.focus();
	}
	else if(document.formbooking.arrival_day.value == ""){
		alert('Arrival day is required !');
		document.formbooking.arrival_day.focus();
	}
	else if(document.formbooking.arrival_month.value == ""){
		alert('Arrival month is required !');
		document.formbooking.arrival_month.focus();
	}
	else if(document.formbooking.arrival_year.value == ""){
		alert('Arrival year is required !');
		document.formbooking.arrival_year.focus();
	}
	else if(document.formbooking.departure_day.value == ""){
		alert('Departure day is required !');
		document.formbooking.departure_day.focus();
	}
	else if(document.formbooking.departure_month.value == ""){
		alert('Departure month is required !');
		document.formbooking.departure_month.focus();
	}
	else if(document.formbooking.departure_year.value == ""){
		alert('Departure year is required !');
		document.formbooking.departure_year.focus();
	}
	else if(new Date(document.formbooking.arrival_month.value + '/' + document.formbooking.arrival_day.value + '/' + document.formbooking.arrival_year.value) <= new Date()){
		alert('Invalid arrival date !');
		document.formbooking.arrival_day.focus();
	}
	else if(new Date(document.formbooking.arrival_month.value + '/' + document.formbooking.arrival_day.value + '/' + document.formbooking.arrival_year.value) >= new Date(document.formbooking.departure_month.value + '/' + document.formbooking.departure_day.value + '/' + document.formbooking.departure_year.value)){
		alert('Invalid arrival and departure date !');
		document.formbooking.arrival_day.focus();
	}
	else if(trim(document.formbooking.person.value) == "" || document.formbooking.person.value == "0"){
		alert('Number of person is required !');
		document.formbooking.person.focus();
	}
	else if(document.formbooking.room_type.value == ""){
		alert('Room type is required !');
		document.formbooking.room_type.focus();
	}
	else{
		self.document.formbooking.submit();
	}
}

function e_mail(str){
	var i;
	str = trim(str)

	i = str.indexOf("@")

	if((i < 3) || (str.indexOf(".", i + 2) == -1)){
		return false;
	}
	else{
		return true;
	}
}

function trim(str){
	var i = 0;
	var temp = "";

	while((temp == "") && (i <= str.length)){
		temp = str.charAt(i);
		i++;
	}

	str = str.substring(i - 1, str.length);
	return str;
}

function confirm_booking(){
	document.formconfirm.confirm_flag.value = true;
	self.document.formconfirm.submit();
}

function prename_change(){
	document.formbooking.firstname.focus();
}

function country_change(){
	document.formbooking.arrival_day.focus();
}

function arrivalday_change(){
	document.formbooking.arrival_month.focus();
}

function arrivalmonth_change(){
	document.formbooking.arrival_year.focus();
}

function arrivalyear_change(){
	document.formbooking.departure_day.focus();
}

function departureday_change(){
	document.formbooking.departure_month.focus();
}

function departuremonth_change(){
	document.formbooking.departure_year.focus();
}

function departureyear_change(){
	document.formbooking.person.focus();
}
