function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function calculatecharge(thisObj)
{
var selValue = thisObj.value;
 
if(selValue.toLowerCase() == "1" )
{
document.getElementById("creditcard").style.display = "block";
document.getElementById("banktransfer").style.display = "none";

}
else if(selValue.toLowerCase() == "2" )
{
document.getElementById("creditcard").style.display = "none";
document.getElementById("banktransfer").style.display = "none";

}
else if(selValue.toLowerCase() == "3" )
{
document.getElementById("creditcard").style.display = "none";
document.getElementById("banktransfer").style.display = "block";

}
}


function showjourneytype(thisObj)
{
var selValue = thisObj.value;
 
if(selValue.toLowerCase() == "1" )
{
document.getElementById("outward").style.display = "block";
document.getElementById("return").style.display = "none";
}
else if(selValue.toLowerCase() == "2" )
{
document.getElementById("outward").style.display = "block";
document.getElementById("return").style.display = "block";

}
else if(selValue.toLowerCase() == "3" )
{
document.getElementById("outward").style.display = "none";
document.getElementById("return").style.display = "block";
}
}

function check_send()
{
	var ok_to_send = true;
	var datenow;
	var arrivedate;
	var taxidate;
	var arrivaldate;
	var arrivalmonth;
	var arrivalyear;
	var depdate; 
	var depmonth;
	var depyear;
	var depmonthnum;
	var arrivalmonthnum;
	datenow = new Date();
	arrivalmonth = document.form1.arrivalmonth.value;
	depmonth = document.form1.depmonth.value;
	if (document.form1.arrivalmonth.value == "Jan")
		{
		arrivalmonthnum = "01"
		}
	if (document.form1.arrivalmonth.value == "Feb")
		{
		arrivalmonthnum = "02"
		}
	if (document.form1.arrivalmonth.value == "Mar")
		{
		arrivalmonthnum = "03"
		}
	if (document.form1.arrivalmonth.value == "Apr")
		{
		arrivalmonthnum = "04"
		}
	if (document.form1.arrivalmonth.value == "May")
		{
		arrivalmonthnum = "05"
		}
	if (document.form1.arrivalmonth.value == "Jun")
		{
		arrivalmonthnum = "06"
		}
	if (document.form1.arrivalmonth.value == "Jul")
		{
		arrivalmonthnum = "07"
		}
	if (document.form1.arrivalmonth.value == "Aug")
		{
		arrivalmonthnum = "08"
		}
	if (document.form1.arrivalmonth.value == "Sep")
		{
		arrivalmonthnum = "09"
		}
	if (document.form1.arrivalmonth.value == "Oct")
		{
		arrivalmonthnum = "10"
		}
	if (document.form1.arrivalmonth.value == "Nov")
		{
		arrivalmonthnum = "11"
		}
	if (document.form1.arrivalmonth.value == "Dec")
		{
		arrivalmonthnum = "12"
		}
	if (document.form1.depmonth.value == "Jan")
		{
		depmonthnum = "01"
		}
	if (document.form1.depmonth.value == "Feb")
		{
		depmonthnum = "02"
		}
	if (document.form1.depmonth.value == "Mar")
		{
		depmonthnum = "03"
		}
	if (document.form1.depmonth.value == "Apr")
		{
		depmonthnum = "04"
		}
	if (document.form1.depmonth.value == "May")
		{
		depmonthnum = "05"
		}
	if (document.form1.depmonth.value == "Jun")
		{
		depmonthnum = "06"
		}
	if (document.form1.depmonth.value == "Jul")
		{
		depmonthnum = "07"
		}
	if (document.form1.depmonth.value == "Aug")
		{
		depmonthnum = "08"
		}
	if (document.form1.depmonth.value == "Sep")
		{
		depmonthnum = "09"
		}
	if (document.form1.depmonth.value == "Oct")
		{
		depmonthnum = "10"
		}
	if (document.form1.depmonth.value == "Nov")
		{
		depmonthnum = "11"
		}
	if (document.form1.depmonth.value == "Dec")
		{
		depmonthnum = "12"
		}

																			
	arrivaldate = document.form1.arrivaldate.value;
	arrivalyear = document.form1.arrivalyear.value;
	depdate = document.form1.depdate.value;
	depyear = document.form1.depyear.value;
	arrivedate = new Date();
	taxidate = new Date();
	arrivedate.setFullYear(arrivalyear,arrivalmonthnum-1,arrivaldate);
	taxidate.setFullYear(depyear,depmonthnum-1,depdate);
	
	with (document.forms.form1)
	{
		if (name.value == "")
		{
			alert("Please enter your name.");
			name.focus();
			ok_to_send = false;
		}		
		else if (email.value == "")
		{
			alert("Please enter your email address.");
			email.focus();
			ok_to_send = false;
		}
		else if (confirmemail.value == "")
		{
			alert("Please re-type your email address.");
			confirmemail.focus();
			ok_to_send = false;
		}
		else if (confirmemail.value != email.value)
		{
			alert("Please ensure that you have entered your email addresses correctly.");
			confirmemail.focus();
			ok_to_send = false;
		}
		else if (homeaddress.value == "")
		{
			alert("Please enter your home address.");
			homeaddress.focus();
			ok_to_send = false;
		}
		else if (telephone.value == "")
		{
			alert("Please enter your contact mobile telephone number in case we need to contact you while you are in Bulgaria.");
			telephone.focus();
			ok_to_send = false;
		}
		else if (accommodation.value == "")
		{
			alert("Please enter your hotel / accommodation address in Bulgaria.");
			accommodation.focus();
			ok_to_send = false;
		}
		else 
		
		if (journeydirection == 1) {
		if (datenow > arrivedate)
		{
			alert("Please select arrival date which is after today.");
			arrivaldate.focus();
			ok_to_send = false;
		} 
		else if (arrivalflightno.value == "")
		{
			alert("Please enter your arrival flight number.");
			arrivalflightno.focus();
			ok_to_send = false;
		}
		else if (arrivalcity.value == "")
		{
			alert("Please enter which airport you are arriving from.");
			arrivalcity.focus();
			ok_to_send = false;
		}
		else if (arrivalairport.value == "0")
		{
			alert("Please select which airport you are arriving/departing from.");
			arrivalairport.focus();
			ok_to_send = false;
		}
		else if (arrivaltime.value == "")
		{
			alert("Please enter your arrival time.");
			arrivaltime.focus();
			ok_to_send = false;
		}
		
		else if (paymenttype.value == "1")
		{
			if (cardtype.value == "0")
			{
				alert("Please select the type of credit/debit card you wish to use.");
				cardtype.focus();
				ok_to_send = false;
			} 
				else if (cardholdername.value == "")
			{
				alert("Please enter the card holder's name.");
				cardholdername.focus();
				ok_to_send = false;
			} 
				else if (cardnumber.value == "")
			{
				alert("Please enter the card number.");
				cardnumber.focus();
				ok_to_send = false;
			} 
				else if (securitycode.value == "")
			{
				alert("Please enter the 3-digit security code on the back of your card.");
				securitycode.focus();
				ok_to_send = false;
			}
			
			else if (agree.checked == false)
			{
			alert("You will need to agree to our terms and conditions before proceeding.");
			agree.focus();
			ok_to_send = false;
			}
		}}			
		else if (journeydirection == 2) {
		if (datenow > arrivedate)
		{
			alert("Please select arrival date which is after today.");
			arrivaldate.focus();
			ok_to_send = false;
		} 
		else if (datenow > taxidate)
		{
			alert("Please select return collection date which is after today.");
			depdate.focus();
			ok_to_send = false;
		}  
		else if (taxidate < arrivedate)
		{
			alert("The return collection date specified is before the arrival date.");
			depdate.focus();
			ok_to_send = false;
		}
		else if (arrivalflightno.value == "")
		{
			alert("Please enter your arrival flight number.");
			arrivalflightno.focus();
			ok_to_send = false;
		}
		else if (arrivalcity.value == "")
		{
			alert("Please enter which airport you are arriving from.");
			arrivalcity.focus();
			ok_to_send = false;
		}
		else if (arrivalairport.value == "0")
		{
			alert("Please select which airport you are arriving/departing from.");
			arrivalairport.focus();
			ok_to_send = false;
		}
		else if (arrivaltime.value == "")
		{
			alert("Please enter your arrival time.");
			arrivaltime.focus();
			ok_to_send = false;
		}
		
		else if (paymenttype.value == "1")
		{
			if (cardtype.value == "0")
			{
				alert("Please select the type of credit/debit card you wish to use.");
				cardtype.focus();
				ok_to_send = false;
			} 
				else if (cardholdername.value == "")
			{
				alert("Please enter the card holder's name.");
				cardholdername.focus();
				ok_to_send = false;
			} 
				else if (cardnumber.value == "")
			{
				alert("Please enter the card number.");
				cardnumber.focus();
				ok_to_send = false;
			} 
				else if (securitycode.value == "")
			{
				alert("Please enter the 3-digit security code on the back of your card.");
				securitycode.focus();
				ok_to_send = false;
			}
			
			else if (agree.checked == false)
			{
			alert("You will need to agree to our terms and conditions before proceeding.");
			agree.focus();
			ok_to_send = false;
			}
		}} else if (journeydirection == 3) {
		if (datenow > taxidate)
		{
			alert("Please select return collection date which is after today.");
			depdate.focus();
			ok_to_send = false;
		}  
		else if (depflightno.value == "")
		{
			alert("Please enter your depature flight number.");
			depflightno.focus();
			ok_to_send = false;
		}
		else if (arrivalcity.value == "")
		{
			alert("Please enter which airport you are arriving from.");
			arrivalcity.focus();
			ok_to_send = false;
		}
		else if (arrivalairport.value == "0")
		{
			alert("Please select which airport you are arriving/departing from.");
			arrivalairport.focus();
			ok_to_send = false;
		}
		else if (arrivaltime.value == "")
		{
			alert("Please enter your arrival time.");
			arrivaltime.focus();
			ok_to_send = false;
		}
		
		else if (paymenttype.value == "1")
		{
			if (cardtype.value == "0")
			{
				alert("Please select the type of credit/debit card you wish to use.");
				cardtype.focus();
				ok_to_send = false;
			} 
				else if (cardholdername.value == "")
			{
				alert("Please enter the card holder's name.");
				cardholdername.focus();
				ok_to_send = false;
			} 
				else if (cardnumber.value == "")
			{
				alert("Please enter the card number.");
				cardnumber.focus();
				ok_to_send = false;
			} 
				else if (securitycode.value == "")
			{
				alert("Please enter the 3-digit security code on the back of your card.");
				securitycode.focus();
				ok_to_send = false;
			}
			
			else if (agree.checked == false)
			{
			alert("You will need to agree to our terms and conditions before proceeding.");
			agree.focus();
			ok_to_send = false;
			}
		}}
		
					
								
		if (ok_to_send)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
}
function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }