function SetStatus(message)
{
    window.status=message;
}
function ltrim(string){
    string=new String(string);
    var string1=new Array();
    var i,j;
    for(i=0,j=0;i<string.length;i++)
    {
      if(j==0)
      {
        if(string.charAt(i)!=" ")
        {
            string1[j++]=string.charAt(i);
        }
      }
      else
      {
        string1[j++]=string.charAt(i);
      }
        
    }
    string="";
    for(i=0;i<string1.length;i++)
    {
      string+=string1[i];
    } 
    return string;
  }

function rtrim(string)
  {
    string=new String(string);
    var string1=new Array();
    var i,j;
    for(i=string.length;i>=0;i--)
    {
      if(string.charAt(i-1)==" ")
      {
        continue;
      }
      else
      {
        for(j=0;j<i;j++)
        {
          string1[j]=string.charAt(j);
        }
        break;
      }
        
    }
    string="";
    for(i=0;i<string1.length;i++)
    {
      string+=string1[i];
    }
    
    
    return string;
  }
  
  function trim(string)
  {
    string=ltrim(string); // // This function is used to trim the left side of a String
    string=rtrim(string);// This function is used to trim the right side of a String
    return string;
  }
  


function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function check_pickup_point(){
	
	if(document.formIom.pickup_point.value=="Meet and Greet - Other"){
		showdiv('info');
	}
	else
		hidediv('info');
}

// function is used to store selected location on hidden variable
function changeLocName(field)
{

	if(field=="pickup")
	{
		var selitem=document.formIom.pickup_point.selectedIndex;
		document.formIom.pickup_point1.value=document.formIom.pickup_point[selitem].text;
	}
	else if(field=="dropoff")
	{
		var selitem=document.formIom.dropoff_point.selectedIndex;
		document.formIom.dropoff_point1.value=document.formIom.dropoff_point[selitem].text;
	}
}

function check_pickup_deatils(){
	//alert("df");
	
   var pick_date = document.formIom.pick_year.value+"-"+document.formIom.pick_month.value+"-"+document.formIom.pick_day.value;
   var drop_date = document.formIom.drop_year.value+"-"+document.formIom.drop_month.value+"-"+document.formIom.drop_day.value;
   
    var pick_date1 = document.formIom.pick_month.value+"/"+document.formIom.pick_day.value+"/"+document.formIom.pick_year.value;
    var drop_date2 = document.formIom.drop_month.value+"/"+document.formIom.drop_day.value+"/"+document.formIom.drop_year.value;
   
	var pickup = document.formIom.pickup_point.value;
	var dropoff = document.formIom.dropoff_point.value;
	var pick_time = document.formIom.pick_hour.value+":"+document.formIom.pick_min.value+":00";
	var drop_time = document.formIom.drop_hour.value+":"+document.formIom.drop_min.value+":00";
	
   var mydate= new Date()
   var theyear=mydate.getFullYear()
   var themonth=mydate.getMonth()+1
   var thetoday=mydate.getDate()
   
   var curdate = new Date(theyear, themonth, thetoday);
   var date1 = new Date(document.formIom.pick_year.value, document.formIom.pick_month.value, document.formIom.pick_day.value);
 	var date2 = new Date(document.formIom.drop_year.value, document.formIom.drop_month.value,document.formIom.drop_day.value );

 // find date difference
  var pick_date11 = document.formIom.pick_day.value+"/"+document.formIom.pick_month.value+"/"+document.formIom.pick_year.value;
  var drop_date22 = document.formIom.drop_day.value+"/"+document.formIom.drop_month.value+"/"+document.formIom.drop_year.value;


//////////////////
 var date11 = new Date(document.formIom.pick_year.value, (Math.floor(document.formIom.pick_month.value)-1), document.formIom.pick_day.value);
var date21 = new Date(document.formIom.drop_year.value, (Math.floor(document.formIom.drop_month.value)-1),document.formIom.drop_day.value );



///////////////
  var flag=0;

  //if pickup and drop of date are same
  if(pick_date11==drop_date22)
  {
	 flag=1;
	 pick_timesec=(60*60*parseInt(document.formIom.pick_hour.value))+(60*parseInt(document.formIom.pick_min.value));
	 drop_timesec=(60*60*parseInt(document.formIom.drop_hour.value))+(60*parseInt(document.formIom.drop_min.value));
	 timediff=drop_timesec-pick_timesec;
	
  } 

	if(trim(document.formIom.pickup_point.value)=="")
	{
		alert("Please select the Pickup Point.");
		document.formIom.pickup_point.focus();
		return false;
	}
	
	else if (isDate(pick_date1)==false){
		  alert("Please select the correct Pickup Date.");
		  return false;
    }
    else if(trim(document.formIom.dropoff_point.value)==""){
		alert("Please select the Dropoff Point.");
		document.formIom.dropoff_point.focus();
		return false;
	}	
	else if (isDate(drop_date2)==false){
		  alert("Please select the correct Dropoff Date.");
		  return false;
    	}
	else if(curdate > date1)
  	{
	  alert("Please select the correct Pickup Date.");
     	return false;
    	}
	
	else if(flag==1 && timediff<=0)//pickup and drop date are same
	{
		alert("Please select the correct Dropoff time.");
		return false;
	}
	else if(Math.floor((date21.getTime() - date11.getTime())/(1000*60*60*24))<0)
	{
		
	    alert("Pickup Date cannot be greater than Dropoff Date.");
	    return false;
	}
	/*else if(checkDateDifference(pick_date11,drop_date22,"lt")==false) //pickup and drop date are differenct
	{
	    alert("Pickup Date cannot be greater than Dropoff Date.");
	    return false;
	}
    else if(date2 < date1)
	{
	    alert("Pickup Date cannot be greater than Dropoff Date.");
	    return false;
	}*/
	else if(trim(document.formIom.driver_age.value)==""){
		alert("Please enter the driver age.");
		document.formIom.driver_age.focus();
		return false;
	}
	else if(isNaN(document.formIom.driver_age.value)){
			alert("Please enter the correct driver age.");
			document.formIom.driver_age.focus();
			return false;
	}
	else if(document.formIom.driver_age.value<23 || document.formIom.driver_age.value>75){
			alert("We can only accept drivers who are 23 or over and under 76 years of age. If you do not meet this requirement, please contact us.");
			document.formIom.driver_age.focus();
			return false;
	}	
   var url = "check_dates.php?pick_time="+pick_time+"&drop_time="+drop_time+"&pick="+pickup+"&drop="+dropoff+"&pick_date="+pick_date+"&drop_date="+drop_date;
document.formIom.dropoff_point1.value
   excluded_date_check(url+"&pickup_location="+document.formIom.pickup_point1.value+" &drop_location="+document.formIom.dropoff_point1.value);
  
}




function excluded_date(){
   var pick_date = document.formIom.pick_year.value+"-"+document.formIom.pick_month.value+"-"+document.formIom.pick_day.value;
   var drop_date = document.formIom.drop_year.value+"-"+document.formIom.drop_month.value+"-"+document.formIom.drop_day.value;
   var url = "check_dates.php?pick_date="+pick_date+"&drop_date="+drop_date;
   excluded_date_check(url);
}
function validatelogin(url){
	  if(trim(document.frmlogin.username.value) == ""){
		  alert("Please enter the username.");
		  document.frmlogin.username.focus();
		  return false;
	  }
	  else if(trim(document.frmlogin.password.value) == ""){
		  alert("Please enter the password.");
		  document.frmlogin.password.focus();
		  return false;
	  }
	  else{
        var user = document.frmlogin.username.value;
        var pass = document.frmlogin.password.value;
    	var url  = url+"?"+"user="+user+"&pass="+encodeURIComponent(pass);
	    passlogin(url);
		return false;
	  }
}

function popup_image(url)
{
	var newwindow;
	newwindow=window.open(url,'name','height=300,width=450,left=300,top=300,resizable=yes,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) {
		newwindow.focus()}
}



function CompareDates(str1, str2)

{
   var yr1   = parseInt(str1.substring(0,4),10);
   var mon1  = parseInt(str1.substring(5,7),10);
   var dt1   = parseInt(str1.substring(8,10),10);
   
   var yr2   = parseInt(str2.substring(0,4),10);
   var mon2  = parseInt(str2.substring(5,7),10);
   var dt2   = parseInt(str2.substring(8,10),10);

   var date1 = new Date(yr1, mon1, dt1);

   var date2 = new Date(yr2, mon2, dt2);
   
   if(date2 < date1)

   {
      alert("From Date cannot be greater than To Date");
      return false;
   }
 	return true;
} 
function change_damage(){
	var url = "check_extra.php?damage="+document.formExtra.damage_excess.value;
	check_damage_charges(url);
}
function change_driver(){
	var url = "check_extra.php?driver="+document.formExtra.aditional_driver.value;
	check_driver_charges(url);
}
function change_infant(){
	var url = "check_extra.php?infant="+document.formExtra.infant_seat.value+"&child="+document.formExtra.child_seat.value+"&booster="+document.formExtra.booster_seat.value+"&days="+document.formExtra.num_days.value;	
	check_infant_charges(url);
}

function change_adlextra(adl_extra_id,optfldname){
	var field1=eval("document.formExtra.opt_ald"+adl_extra_id+"["+optfldname+"].value");

	if(adl_extra_id=="1")//store satellite status
		document.formExtra.satellite.value=field1;
	else if(adl_extra_id=="2")//store satellite status
		document.formExtra.localpay.value=field1;
	var url = "check_adlextra.php?adl_extra_id="+adl_extra_id+"&status="+field1+"&num_days="+document.formExtra.num_days.value;	
	check_adopt_charges(url,"adl_extra_id"+adl_extra_id);
}
function car_selection(group_code, charge){
	document.formCarlist.car_group_code.value=group_code;
	document.formCarlist.car_hire.value=charge;
	document.formCarlist.submit();
}

function car_process(location_type_id){
	if(location_type_id=="1")
		document.formCarlist.action="bookonline_step4.php";
	else
		document.formCarlist.action="bookonline_step5.php";
	document.formCarlist.submit();
}

function validate_email(value)
{
		 if(value==""){
			return true;
		  }
		
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
		{
			alert("Not a valid e-mail address.");
			//document.frmBroker.email_address.select();
			return false;
		}
		else
		{
			return true;
		}
	
}

function booking_details(){
	 if(trim(document.frmBooking.first_name.value) == ""){
		  alert("Please enter the Surname.");
		  document.frmBooking.first_name.focus();
		  return false;
	  }
	  else if(trim(document.frmBooking.last_name.value) == ""){
		  alert("Please enter the Forename.");
		  document.frmBooking.last_name.focus();
		  return false;
	  }
	  else if(trim(document.frmBooking.email.value) == ""){
		  alert("Please enter the email address.");
		  document.frmBooking.email.focus();
		  return false;
	  }
	  else if(!validate_email(trim(document.frmBooking.email.value))){
		   document.frmBooking.email.focus();
 			return false;
	  }
	  else if(trim(document.frmBooking.email.value) != trim(document.frmBooking.re_email.value)){
		  	alert("Please enter the correct Re-type Email address.");
		    document.frmBooking.re_email.focus();
 			return false;
	  }
	  else if (checkInternationalPhone(document.frmBooking.phone_num.value)==false){
		alert("Please Enter a Valid Phone Number")
		document.frmBooking.phone_num.value=""
		document.frmBooking.phone_num.focus()
		return false
	  }
	  else if(trim(document.frmBooking.house_name.value) == ""){
		  alert("Please enter the house name.");
		  document.frmBooking.house_name.focus();
		  return false;
	  }
	    else if(trim(document.frmBooking.postcode.value) == ""){
		  alert("Please enter the post code.");
		  document.frmBooking.postcode.focus();
		  return false;
	  }
	 else if (!validateZIP(trim(document.frmBooking.postcode.value))) {
		 	document.frmBooking.postcode.focus();
			return false;
	 }
	 /* else if(document.frmBooking.aditional_driver.value!=0){
			if(trim(document.frmBooking.driver_firstname.value) == ""){
			  alert("Please enter the first name.");
			  document.frmBooking.driver_firstname.focus();
			  return false;
			}
			else if(trim(document.frmBooking.driver_lastname.value) == ""){
			  alert("Please enter the last name.");
			  document.frmBooking.driver_lastname.focus();
			  return false;
			}
			else if(trim(document.frmBooking.driver_email.value) == ""){
				  alert("Please enter the email address.");
				  document.frmBooking.driver_email.focus();
				  return false;
			}
			else if(!validate_email(trim(document.frmBooking.driver_email.value))){
				 document.frmBooking.driver_email.focus();
 			   return false;
	        }
			else if (checkInternationalPhone(document.frmBooking.driver_phone.value)==false){
				alert("Please Enter a Valid Phone Number")
				document.frmBooking.driver_phone.value=""
				document.frmBooking.driver_phone.focus()
				return false
			}
			else if(trim(document.frmBooking.driver_housename.value) == ""){
			  alert("Please enter the house name.");
			  document.frmBooking.driver_housename.focus();
			  return false;
			}
			else if(trim(document.frmBooking.driver_postcode.value) == ""){
			  alert("Please enter the postcodes.");
			  document.frmBooking.driver_postcode.focus();
			  return false;
			}
			else if (!validateZIP(trim(document.frmBooking.driver_postcode.value))) {
			return false;
	       }
	  }*/
}


function validateZIP(field) {
	if(field==""){
		return true;
	}
var valid = "0123456789 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var hyphencount = 0;
	if(field.length < 3){
		alert("Invalid post code.");
		return false;
	}
	for (var i=0; i < field.length; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp == "-") hyphencount++;
		if (valid.indexOf(temp) == "-1") {
			alert("Invalid characters in your post code.  Please try again.");
			return false;
		}
	 /* if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
		alert("Please enter the correct post code.");
		return false;
	   }*/
   }
   return true;
}

/********************************************************************************************/

/**
 * phone number validation script.
 */

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 5;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
	 if(strPhone==""){
			return true;
	 }
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

/********************************************************************************************/


function check_terms(){
	 if(!document.formBooking.driver_terms.checked){
		 alert("We are very sorry but your booking cannot continue because you could not answer NO to all of the questions. Please contact us directly.");
		 return false;
	 }
	 if(document.formBooking.pickup_point.value == "Hotel / Guest House"){
		  if(document.formBooking.address2.value == ""){
			  alert("Please enter the address.");
			  document.formBooking.address2.focus();
			  return false;
		  }
	  }
	 if(!document.formBooking.terms.checked){
		  alert("Please agree our Terms and Conditions.");
		  return false;
	  }
}
/*********************************Date validation***************************************/
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false
	}
return true
}

function isDate_check(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (strMonth.length<1 || month<1 || month>12){
		// alert("Please enter the correct Card Expiry Date.")
		//	return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		// alert("Please enter the correct Card Expiry Date.")
		// return false
	}
return true
}
/*****************************************************************************************************************/

function popup_meet(url)
{
	var newwindow;
	newwindow=window.open(url,'name','height=300,width=450,left=300,top=300,resizable=yes,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) {
		newwindow.focus()}
}

function check_CreditCard () {
	
	  myCardNo = document.getElementById('cardNumber').value;
	  myCardType = document.getElementById('cardType').value;
	  if(document.frmBooking.cardType.value == ""){
		alert("Please select a Card.")
		document.frmBooking.cardType.focus();
		return false;
	  }
	  else if (!checkCreditCard (myCardNo,myCardType)) {
		  alert (ccErrors[ccErrorNo])
		  document.getElementById('cardNumber').focus();
		  return false;
	  }
	else if(trim(document.frmBooking.datevalidfrom.value) == ""){
		alert("Please enter the Card Valid From.")
		document.frmBooking.datevalidfrom.focus();
		return false;
	  }
	/* else if(trim(document.frmBooking.datevalidfrom.value) != ""){
		day =  document.frmBooking.datevalidfrom.value;
		var month  = parseInt(day.substring(0,2));
		var year   = parseInt(day.substring(3,7));

		datefrom = "01/"+day;	
		if(isDate_check(datefrom)==false)
		{

		document.frmBooking.datevalidfrom.select();
		return false;

		}
		today = new Date();
		expiry = new Date(year, month);
		if (today.getTime() > expiry.getTime()){
			// alert("Please enter the correct Card Expiry Date.")
			// document.frmBooking.expDate.focus();
			// return false;
		 }
	  }*/	
	  else if(trim(document.frmBooking.expDate.value) == ""){
		alert("Please enter the Card Expiry Date.")
		document.frmBooking.expDate.focus();
		return false;
	  }
	 /* else if(trim(document.frmBooking.expDate.value) != ""){
		day =  document.frmBooking.expDate.value;
		var month  = parseInt(day.substring(0,2));
		var year   = parseInt(day.substring(3,7));

		exdate = "01/"+day;
		if (isDate_check(exdate)==false){
			document.frmBooking.expDate.select();
			return false;
		}
		
		today = new Date();
		expiry = new Date(year, month);
		if (today.getTime() > expiry.getTime()){
			// alert("Please enter the correct Card Expiry Date.")
			// document.frmBooking.expDate.focus();
			// return false;
		 }
	  }*/
		

	  else if(trim(document.frmBooking.csvCode.value) == ""){
		alert("Please enter the Card CSV Code.")
		document.frmBooking.csvCode.focus();
		return false;
	  }
	/*else if(trim(document.frmBooking.issueNum.value)=="")
	{
		alert("Please enter the Issue Number.")
		document.frmBooking.issueNum.focus();
		return false;
	}*/
	   else if(trim(document.frmBooking.issueNum.value)!="" && !issueNum(trim(document.frmBooking.issueNum.value))){
		alert("Please enter the correct Issue Number.")
		document.frmBooking.issueNum.focus();
		return false;
	  }
      else if(trim(document.frmBooking.hoderName.value) == ""){
		alert("Please enter the Card Holder Name.")
		document.frmBooking.hoderName.focus();
		return false;
	  }
	  else if(trim(document.frmBooking.holderAddress.value) == ""){
		alert("Please enter the Card Holder Address.")
		document.frmBooking.holderAddress.focus();
		return false;
	  }
	  else if(trim(document.frmBooking.holderPhone.value) == ""){
		alert("Please enter the Card Holder Phone Number.")
		document.frmBooking.holderPhone.focus();
		return false;
	  }
	  else if (checkInternationalPhone(document.frmBooking.holderPhone.value)==false){
		alert("Please Enter a Valid Phone Number")
		document.frmBooking.holderPhone.focus()
		return false
	  }
	else 
		return true;
}

function isNum(argvalue) {
	argvalue = argvalue.toString();
	
	if (argvalue.length == 0)
		return false;
	
	for (var n = 0; n < argvalue.length; n++)
		if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9")
			return false;
	
	return true;
}

function add_holderdetails(){
	if(document.frmBooking.checkbox.checked){
		document.frmBooking.hoderName.value = document.frmBooking.first_name.value+" "+document.frmBooking.last_name.value;
		document.frmBooking.holderAddress.value = document.frmBooking.address.value+" "+document.frmBooking.city.value+" "+document.frmBooking.postcode.value;
		document.frmBooking.holderPhone.value = document.frmBooking.phone_num.value;
	}
	else{
		document.frmBooking.hoderName.value ="";
		document.frmBooking.holderAddress.value = "";
		document.frmBooking.holderPhone.value = "";
	}
}
function popup_print(url)
{
	var newwindow;
	newwindow=window.open(url,'name','height=600,width=700,left=300,top=300,resizable=yes,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) {
		newwindow.focus()}
}
function back_upgrade(){
	document.formCarlist.action="bookonline_step2.php";
	document.formCarlist.submit();
}
function validateContactus(){
	  if(trim(document.formContact.name.value) == ""){
		  alert("Please enter the name.");
		  document.formContact.name.focus();
		  return false;
	  }
	  else if (checkInternationalPhone(document.formContact.phone.value)==false){
		alert("Please enter a valid phone number")
		document.formContact.phone.value = "";
		document.formContact.phone.focus()
		return false
	  }
	  else if(trim(document.formContact.email.value) == ""){
		  alert("Please enter the email address.");
		  document.formContact.email.focus();
		  return false;
	  }
	  else if(!validate_email(trim(document.formContact.email.value))){
		   document.formContact.email.focus();
 			return false;
	  }
	  else if(trim(document.formContact.message.value) == ""){
		  alert("Please enter the message.");
		  document.formContact.message.focus();
		  return false;
	  }
}
function issueNum(s){
   var i;
   if(s == "")
   		return true;
   for (i = 0; i < s.length; i++){  
       // Check that current character is number.
       var c = s.charAt(i);
       if (((c < "1") || (c > "9"))){
		  return false;
	   }
   }
    // All characters are numbers.
    return true;
}
