function Calculate(objForm,action){
	//lets calculate if the dates stack up...
	var strErrorMessage="";
	var intNumberNights=Number(objForm.F15_no_nights.value);
	var dateStart=Date.parse(objForm.F03_dates.value);
	var dateEnd=Date.parse(objForm.F033_dates.value);
	var intCalcDays=(new TimeSpan(dateEnd-dateStart)).getDays();
	var dateToday=new Date();
	var minDays=5;
	if (intNumberNights!=intCalcDays){
		strErrorMessage+=" * The number of nights entered does not match the start and end dates of your stay. \n";
		ColorError(objForm.F15_no_nights);
		ColorError(objForm.F03_dates)
	}
	if (objForm.F06_extra_bed.value=="Need Extra bed" & objForm.F04_room_type.value=="Deluxe Building Double"){
		strErrorMessage+=" * Sorry, no extra beds are available in the Deluxe Building. \n";
		ColorError(objForm.F06_extra_bed);
	}
	if (objForm.F44_status.value=="instantConfirm"){//apply the instatnt confirm busniess rules...
	/*	if (intNumberNights>4){
			strErrorMessage+=" * The maximum number of nights available for instant booking is 4 \n";
			ColorError(objForm.F15_no_nights)
		}*/
		var intHourSpan=(new TimeSpan(dateStart-dateToday)).getHours()+((new TimeSpan(dateStart-dateToday)).getDays()*24);
		if (intHourSpan<16){
			strErrorMessage+=" * Start date too close, please allow for at least one day for us to process your booking \n" 
			ColorError(objForm.F03_dates);
		}
/*		if ((new TimeSpan(dateStart-dateToday)).getDays()>14){
			strErrorMessage+=" * Start date too far away- please use 'Normal Booking'. Last minute booking is only for \n    bookings up to 2 weeks in advance \n";
			ColorError(objForm.F03_dates);
			ColorError(objForm.F44_status);
		}	*/
		//make sure this is not in high season...
		if (dateEnd>(new Date("november 01, 2009"))){
			strErrorMessage+=" * Sorry, this booking is in High Season, we are currently only doing low season instant bookings. \n    Please submit a normal booking \n";
			ColorError(objForm.F44_status);
		}
	}
	else {//Normal booking
		if ((new TimeSpan(dateStart-dateToday)).getDays()<minDays){
			strErrorMessage+=" * We need at least "+ minDays +" days notice for a normal booking, please try using the 'Last Minute Booking'\n    Option  \n";
			ColorError(objForm.F03_dates);
			ColorError(objForm.F44_status);
		}	
	}
	
	if (strErrorMessage!="")alert("The following errors below were detected when processing the form: \n" + strErrorMessage);
	else {
		objForm.F03_dates.value+=" To "+objForm.F033_dates.value;
		objForm.submit();
	}
}


function InstantConditions(strValue){
	var selField= document.getElementById("F04_room_type");
	if(strValue=="instantConfirm" & selField.length==8 & document.getElementById("F14_subject").value=="Railay Bay Bungalows"){
		//remove some options....
		selField.length=4;
		//document.getElementById("pickup1").style.display='none';
		//document.getElementById("pickup2").style.display='none';
//		alert("To make an instant booking the following conditions must be met:  \n * The maximum number of nights you can book is 4 \n * Instant bookings can only be booked up to 2 weeks in advance \n * Although we can confirm your booking, it will still take up to 16 hours (depending on time \n    differences and weekends etc) from the time of your payment is made, to the issue of \n    your check in voucher.");
		
	}else if (selField.length==4 & document.getElementById("F14_subject").value=="Railay Bay Bungalows"){
	//put them back...
		//document.getElementById("pickup1").style.display='';
		//document.getElementById("pickup2").style.display='';
		if(document.getElementById("F14_subject").value=="Railay Bay Bungalows"){//if railay bay....
			var elOptNew1 = document.createElement('option');
			var elOptNew2 = document.createElement('option');
			var elOptNew3 = document.createElement('option');
			var elOptNew4 = document.createElement('option');
			elOptNew1.text = "Deluxe Building Triple";
			elOptNew1.value = "Deluxe Building Triple";
			elOptNew2.text = "Railay Suite Beach Front";
			elOptNew2.value = "Railay Suite Beach Front";
			elOptNew3.text = "Railay Deluxe Cottage";
			elOptNew3.value = "Railay Deluxe Cottage";
			elOptNew4.text = "Railay Garden Pool Villa";
			elOptNew4.value = "Railay Garden Pool Villa";
			try {
				selField.add(elOptNew1, null); // standards compliant; doesn't work in IE
				selField.add(elOptNew2, null);
				selField.add(elOptNew3, null);
				selField.add(elOptNew4, null);
			}
			catch(ex) {
				selField.add(elOptNew1); // IE only
				selField.add(elOptNew2);
				selField.add(elOptNew3);
				selField.add(elOptNew4);
			}
		}

	
	}
}