/*
'<!--$$Revision: 7 $-->
'<!--$$Author: david $-->
'<!--$$Date: 14/07/10 2:19p $-->
'<!--$$Logfile: /ajax/subs.js $-->
'<!--$$NoKeywords: $-->
*/
	var http_request = false;
	var loadstatustext="<img src=images/loading.gif width=16 height=16>";
	var workingDiv="divWorking";
	
function rotateAds() {
	var theString ="ajax/subs.asp?action=rotateads";
	getDoc(theString,'divPPartners','');		
	setTimeout("rotateAds()",1000*30)
}
function setGift(v) {

	var f=document.Form1
	if (v==1) {
		f.voucherFirstName.disabled=false;
		f.voucherLastName.disabled=false;
		f.voucherEmail.disabled=false;
		f.voucherMessage.disabled=false;
		f.voucherMessageFrom.disabled=false;
	} else if (v==2) {
		f.voucherFirstName.disabled=true;
		f.voucherFirstName.value=f.firstName.value;
		f.voucherLastName.disabled=true;
		f.voucherLastName.value=f.lastName.value;
		f.voucherEmail.disabled=true;
		f.voucherEmail.value=f.email.value;
		f.voucherMessage.disabled=true;
		f.voucherMessage.value="";
		f.voucherMessageFrom.disabled=true;
		f.voucherMessageFrom.value="";
	} else {
		f.voucherFirstName.disabled=true;
		f.voucherFirstName.value="";
		f.voucherLastName.disabled=true;
		f.voucherLastName.value="";
		f.voucherEmail.disabled=true;
		f.voucherEmail.value="";
		f.voucherMessage.disabled=true;
		f.voucherMessage.value="";
		f.voucherMessageFrom.disabled=true;
		f.voucherMessageFrom.value="";
	}
}
function clearRideTimes(isParent) {
	var rideproductid=document.Form1.rideproductid
	if (rideproductid) {
		if (isParent=="True") {
			document.getElementById('divRideSlotTimes'+rideproductid.value).innerHTML=" ";

		} else if(rideproductid.length == undefined) {
			document.getElementById('divRideSlotTimes'+rideproductid.value).innerHTML=" ";
		} else {
			for(var i = 0; i < rideproductid.length; i++) {
				document.getElementById('divRideSlotTimes'+rideproductid[i].value).innerHTML=" ";
			}
		}
	}
}
function getBuyTimes(raceTrackId,slotDate,driveOrRide,frontOrBackSeat,bookingProductId,driveDate,driveSlotStartTime,isOctaneDreams,isParent,isMatesRates,pId) {
	document.getElementById("divSlotTimesTitle"+bookingProductId).innerHTML="Times:";
	clearRideTimes(isParent)
	var theString =SSLDomain+"ajax/subs.asp?action=getbuytimes&isParent="+isParent+"&raceTrackId="+raceTrackId+"&slotDate="+slotDate+"&driveOrRide="+driveOrRide+"&frontOrBackSeat="+frontOrBackSeat+"&bookingProductId="+bookingProductId+"&driveDate="+driveDate+"&driveSlotStartTime="+driveSlotStartTime+"&isOctaneDreams="+isOctaneDreams+"&isMatesRates="+isMatesRates+"&pId="+pId;
	var aObj=new Array(); 
	var ajaxIndex = aObj.length;
	aObj[ajaxIndex] = new sack();
	aObj[ajaxIndex].requestFile = theString;
	aObj[ajaxIndex].onCompletion = function(){
		document.getElementById("divSlotTimes0").innerHTML=aObj[ajaxIndex].response;
		if (slotDate!="") {
		getBuyRideTimes(raceTrackId,slotDate,driveOrRide,bookingProductId,driveDate,driveSlotStartTime,isParent);
		}
	};  	
	aObj[ajaxIndex].runAJAX();
}
function getBuyRideTimes(raceTrackId,slotDate,driveOrRide,bookingProductId,driveDate,driveSlotStartTime,isParent) {

	var rideproductidVal=0
	if (document.Form1.rideproductid) {
		var rideproductid=document.Form1.rideproductid
		var radioLength = rideproductid.length;
		if(isParent=="True") { //bundled ride

				clearRideTimes(isParent)
				var theString =SSLDomain+"ajax/subs.asp?action=getbuytimes&isParent="+isParent+"&getridetimes=true&raceTrackId="+raceTrackId+"&slotDate="+slotDate+"&driveOrRide=ride&bookingProductId="+bookingProductId+"&driveDate="+driveDate+"&driveSlotStartTime="+driveSlotStartTime;
				getDoc(theString,'divRideSlotTimes'+rideproductid.value,'');	
			
			
		}else if(rideproductid.length == undefined) {//if this is not a radio, then we're on schedule.asp
			var theString =SSLDomain+"ajax/subs.asp?action=gettimes&isParent="+isParent+"&getridetimes=true&raceTrackId="+raceTrackId+"&slotDate="+slotDate+"&driveOrRide=ride&bookingProductId="+bookingProductId+"&driveDate="+driveDate+"&driveSlotStartTime="+driveSlotStartTime;
			getDoc(theString,'divRideSlotTimes'+rideproductid,'');	
		} else { //if it's a radio, then this is buy.asp
			rideproductidVal=getCheckedValue(rideproductid)
			if (rideproductidVal>0) {
				clearRideTimes(isParent)
				var theString =SSLDomain+"ajax/subs.asp?action=getbuytimes&isParent="+isParent+"&getridetimes=true&raceTrackId="+raceTrackId+"&slotDate="+slotDate+"&driveOrRide=ride&bookingProductId="+bookingProductId+"&driveDate="+driveDate+"&driveSlotStartTime="+driveSlotStartTime;
				getDoc(theString,'divRideSlotTimes'+rideproductidVal,'');	
			}
		}
	}
}
function getTimes(raceTrackId,slotDate,driveOrRide,bookingProductId,driveDate,driveSlotStartTime,isOctaneDreams,isMatesRates) {
	document.getElementById("divSlotTimesTitle"+bookingProductId).innerHTML="Times:";
	var theString =SSLDomain+"ajax/subs.asp?action=gettimes&raceTrackId="+raceTrackId+"&slotDate="+slotDate+"&driveOrRide="+driveOrRide+"&bookingProductId="+bookingProductId+"&driveDate="+driveDate+"&driveSlotStartTime="+driveSlotStartTime+"&isOctaneDreams="+isOctaneDreams+"&isMatesRates="+isMatesRates;
	var aObj=new Array(); 
	var ajaxIndex = aObj.length;
	aObj[ajaxIndex] = new sack();
	aObj[ajaxIndex].requestFile = theString;
	aObj[ajaxIndex].onCompletion = function(){
		document.getElementById("divSlotTimes"+bookingProductId).innerHTML=aObj[ajaxIndex].response;
	};  	
	aObj[ajaxIndex].runAJAX();
}
function getRideTimes(raceTrackId,slotDate,driveOrRide,frontOrBackSeat,bookingProductId,driveDate,driveSlotStartTime,currentDriveSlotTime) {

	var rideproductidVal=0
	if (document.Form1.rideproductid) {
	
		var rideproductid=document.Form1.rideproductid
		var radioLength = rideproductid.length;
//		if(rideproductid.length == undefined) {//if this is not a radio, then we're on schedule.asp
			var theString =SSLDomain+"ajax/subs.asp?action=gettimes&getridetimes=true&raceTrackId="+raceTrackId+"&slotDate="+slotDate+"&driveOrRide=ride&frontOrBackSeat="+frontOrBackSeat+"&bookingProductId="+bookingProductId+"&driveDate="+driveDate+"&driveSlotStartTime="+driveSlotStartTime+"&currentDriveSlotTime="+currentDriveSlotTime;
			getDoc(theString,'divSlotTimes'+bookingProductId,'');	
//		} else { //if it's a radio, then this is buy.asp
//			rideproductidVal=getCheckedValue(rideproductid)
//			if (rideproductidVal>0) {
//				if(radioLength == undefined) {
//					document.getElementById('divRideSlotTimes'+rideproductid.value).innerHTML=" ";
//				} else {
//				for(var i = 0; i < radioLength; i++) {document.getElementById('divRideSlotTimes'+rideproductid[i].value).innerHTML=" ";}
//				}	
//				var theString =SSLDomain+"ajax/subs.asp?action=gettimes&getridetimes=true&raceTrackId="+raceTrackId+"&slotDate="+slotDate+"&driveOrRide=ride&bookingProductId="+bookingProductId+"&driveDate="+driveDate+"&driveSlotStartTime="+driveSlotStartTime+"&currentDriveSlotTime="+currentDriveSlotTime;
//				getDoc(theString,'divSlotTimes'+bookingProductId,'');	
//			}
//		}
	}
}
function findCustomer() {
	if(findCustomerCheck()!=false) {
		document.Form1.submit()
	}	
}
function findCustomerCheck() {
	var f=document.Form1
	if (f.email.value !="")  {
		if(emailCheck(f.email.value))	{
		} else {
		f.email.focus();
		return (false);
		}
	} else {
		alert("Please enter Email.");
		f.email.focus();
		return (false);
	}
	if (f.lastName.value =="") {
	alert("Please enter Last Name.");
	f.lastName.focus();
	return (false);
	}
}
function regionList(countryCode,regionId,stateRegion) {
	var theString =SSLDomain+"ajax/subs.asp?action=regionlist&countryCode="+countryCode+"&regionId="+regionId+"&stateRegion="+stateRegion;
	getDoc(theString,'divRegionList','divRegionList');		
}
