var dateform='B';
var months=new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var days=new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
var mydate='';
var leadtime=5;
if(dateform=='A'){mydate='%e-%B-%Y';}else{mydate='%B-%e-%Y';}
function pushDate(){
	var today=new Date();
	var arrive=new Date(today.getFullYear(),today.getMonth(),(today.getDate()+leadtime));
	if(document.SearchForm){
		if(dateform=='A'){
			document.SearchForm.CheckInDate.value=arrive.getDate()+'-'+months[arrive.getMonth()]+'-'+arrive.getFullYear();}
		else{
			document.SearchForm.CheckInDate.value=months[arrive.getMonth()]+'-'+arrive.getDate()+'-'+arrive.getFullYear();}}
			if(document.HotelForm){
		if(dateform=='A'){
			document.HotelForm.CheckInDate.value=arrive.getDate()+'-'+months[arrive.getMonth()]+'-'+arrive.getFullYear();}
		else{
			document.HotelForm.CheckInDate.value=months[arrive.getMonth()]+'-'+arrive.getDate()+'-'+arrive.getFullYear();}}}
function checkDate(arg1){
	var dd='',mm='',yy='',i=0,j=0;
	var today=new Date();
	var arrive=new Date(today.getFullYear(),today.getMonth(),(today.getDate()+leadtime));
	var mydata=arg1.split('-');
	if(dateform=='A'){
		dd=mydata[0];
		mm=mydata[1];}
	else{
		dd=mydata[1];
		mm=mydata[0];}
	yy=mydata[2];
	for(i=0;i<12;i++){
		if(mm==months[i]){
			j=i;
			break;}}
	var arrdate=new Date(yy,j,dd);
	if((arrdate-arrive)<0){
		alert('Earliest arrival date is: '+arrive);
		return(false);}
	else{return(true);}}
function EnableFlds(arg){
	if(arg==1){
		document.SearchForm.ChildAge1.disabled=false;
		document.SearchForm.ExtraBed.disabled=false;}
	else{
		if(arg==2){
			document.SearchForm.ChildAge1.disabled=false;
			document.SearchForm.ChildAge2.disabled=false;
			document.SearchForm.ExtraBed.disabled=false;}
		else{
			document.SearchForm.ChildAge1.value="";
			document.SearchForm.ChildAge2.value="";
			document.SearchForm.ChildAge1.disabled=true;
			document.SearchForm.ChildAge2.disabled=true;
			document.SearchForm.ExtraBed.disabled=true;
			document.SearchForm.ExtraBed.checked=false;}}}
function validateQKForm(form){
	var isok=true;
	if(!checkDate(form.CheckInDate.value)){return(false);}
	if(form.City.options[form.City.options.selectedIndex].value=="XX"){
		alert("Select a City");
		return(false);}
	else{
	form.CityName.value=form.City.options[form.City.options.selectedIndex].text;
	return(true);}}
function validateAVForm(form){
	var adult=form.NumAdult.selectedIndex+1;
	var child=form.NumChild.selectedIndex;
	var roomtype=form.RoomCode.options[form.RoomCode.options.selectedIndex].value;
	var cots=form.Cots.options[form.Cots.options.selectedIndex].value;
	var extrabed=form.ExtraBed.checked;
	if(!checkDate(form.CheckInDate.value)){return(false);}
	if(form.City.options[form.City.options.selectedIndex].value=="XX"){
		alert("Select a City");
		return(false);}
	if((roomtype=="SB" || roomtype=="TS") && (adult+child)>1){
		alert("Only one person allowed in a single room");
		return(false);}
	if((roomtype=="DB" || roomtype=="TB") && (adult+child)>3){
		alert("Only 2 adults and one child, or 1 adult and 2 children\nallowed in a double or twin room");
		return(false);}
	if(roomtype=="TR" && ((adult+child)>4 || adult>3)){
		alert("Only 3 adults and one child, or 2 adults and 2 children\nallowed in a triple room");
		return(false);}
	if(roomtype=="Q" && (adult+child)>5){
		alert("Only 4 adults and one child, or 3 adults and 2 children\nallowed in a quad room");
		return(false);}
	if((roomtype=="SB" || roomtype=="TS") && cots==2){
		alert("Only one baby cot allowed in a single room");
		return(false);}
	if(roomtype!="SB" && extrabed && cots==2){
		alert("Cannot have 2 cots and an extra bed in a double, twin, triple or quad room");
		return(false);}
	if(child>0 && (isNaN(parseInt(form.ChildAge1.value)) || parseInt(form.ChildAge1.value)>12 || parseInt(form.ChildAge1.value)<3)){
		alert("Invalid age for Child 1, age must be from 3 to 12");
		return(false);}
	if(child>1 && (isNaN(parseInt(form.ChildAge2.value)) || parseInt(form.ChildAge2.value)>12 || parseInt(form.ChildAge2.value)<3)){
		alert("Invalid age for Child 2, age must be from 3 to 12");
		return(false);}
	if(child==0 && extrabed){
		alert("Cannot have an extra beds unless you include at least 1 child");
		return(false);}
	return(true);}
function pushLocation(form){
	form.CityName.value=form.City.options[form.City.options.selectedIndex].text;}
