function FlightDateCheck(){

var now = new Date()
var today = now.getDate()
var tomonth = now.getMonth()+1
var toyear = now.getYear()

if (document.booknow.flightcheck.checked)
{
var str1=document.booknow.ardate.value;
var str2=document.booknow.depdate.value;
var msga = "Please correct your  arrival date, it is earlier than today date";
var msgb = "Departure date sholud be later than the arrival date";
var msgc = "Renting a Car is minimum 3 days!"
var x=3;
}
else
{
var str1=document.booknow.pdate.value;
var str2=document.booknow.ddate.value;
var msga = "Please correct your  pick-up date, it is earlier than today date";
var msgb = "Drop-off date sholud be later than the pick-up date";
var msgc = "Renting a Car is minimum 3 days!"
var x=3;
}

var firstdate  =str1.substring(0,2);
var firstmonth  =str1.substring(3,5);
var firstyear  =str1.substring(6,10);

var seconddate  =str2.substring(0,2);
var secondmonth  =str2.substring(3,5);
var secondyear  =str2.substring(6,10);


if (firstyear < toyear){
alert(msga);
return false;
}

if (firstyear == toyear){
if (firstmonth < tomonth){
alert(msga);
return false;
}
}
else
{
if (firstdate < today){
alert(msga);
return false;
}
}

if (firstyear == toyear && firstmonth == tomonth)
{
if (firstdate < today){
alert(msga);
return false;
}
}
////////////////////////////////////////////////////////////////////////////////
if (secondyear < firstyear){
alert(msgb);
return false;
}

if (secondyear == firstyear){
if (secondmonth < firstmonth){
alert(msgb);
return false;
}
}
else
{
if (seconddate < firstdate){
alert(msgb);
return false;
}
else
{
var fd=(firstdate-today);
var sd=(seconddate-today);
var dategap=(sd-fd);

if (dategap < x){
alert(msgc);
return false;
}
}
}

if (secondyear == firstyear && secondmonth == firstmonth)
{
if (seconddate < firstdate){
alert(msgb);
return false;
}
else
{
var fd=(firstdate-today);
var sd=(seconddate-today);
var dategap=(sd-fd);

if (dategap < x){
alert(msgc);
return false;
}
}
}
return true;

}

//*****************************************************************************
/*function transfer(){
if (document.booknow.airport.value=='la'){
alert("No rental car transpassing from North Cyprus to South Cyprus.\nTherefore Asal Tour charge transfer money for the Larnaca Airport!")
}

if (document.booknow.airport.value=='pa'){
alert("No rental car transpassing from North Cyprus to South Cyprus.\nTherefore Asal Tour charge transfer money for the Paphos Airport!")
}
}*/
//*****************************************************************************
function checkchar(pass){
if (pass==1)
{
field=document.booknow.name.value;
target=booknow.name;
var msg="Please remove numbers & special characters from the name field!"
}

if (pass==2)
{
field=document.booknow.country.value;
target=booknow.country;
var msg="Please remove numbers & special characters from the country field!"
}


		var notvalid;
		for (var i=0, notvalid="0123456789!@#$%^&*()+=-[]\\\';,./{}|\":<>?"; i<field.length; i++)
		{
       		if (notvalid.indexOf(field.charAt(i)) != -1)
		{
			alert(msg);
			target.focus(); 
			return false;
		}
		}
		

}

//*****************************************************************************
function DateofBirth(){
var strdob = document.booknow.dob.value;

if(strdob.length > 1)
{

if (strdob.indexOf('/')==-1 || strdob.indexOf('/') > 2 ){
alert("Please enter your Date of Birth in right format");
return false;
booknow.dob.focus();
}
else
{
slasha = strdob.substring(2,3);
slashb = strdob.substring(5,6);



if (slasha != "/" || slashb != "/"){
alert ("Please enter your Date of Birth in right format")
return false;
booknow.dob.focus();
}
else
{
slash1 = strdob.substring(0,1);
slash2 = strdob.substring(1,2);
slash3 = strdob.substring(3,4);
slash4 = strdob.substring(4,5);
slash5 = strdob.substring(6,7);
slash6 = strdob.substring(7,8);
slash7 = strdob.substring(8,9);
slash8 = strdob.substring(9,10);

if (slash1 == "/" || slash2 == "/" || slash3 == "/" || slash4 == "/" || slash5 == "/" || slash6 == "/" || slash7 == "/" || slash8 == "/"){
alert ("Please enter your Date of Birth in right format")
return false;
booknow.dob.focus();
}
}
}
}
string = strdob.substring(6,10);
if (string.length < 4){
alert ("Please enter your Date of Birth in right format")
return false;
booknow.dob.focus();
}
}

//*****************************************************************************
function checknum(){

field=document.booknow.telmob.value;
target=booknow.tel;
var msg="Please use only numbers in the tel./mob. field!"

var notvalid;
		for (var i=0, notvalid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()=-[]\\\';,./{}|\":<>?"; i<field.length; i++)
		{
       		if (notvalid.indexOf(field.charAt(i)) != -1)
		{
			alert(msg);
			target.focus(); 
			return false;
		}
		}

}

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

function checkemail(){
var cemail=document.booknow.email.value;
if (cemail.length > 1 )
{

if(cemail.indexOf('_@')!=-1 || cemail.indexOf('@_')!=-1 || cemail.indexOf('_.')!=-1 || cemail.indexOf('-@')!=-1 || cemail.indexOf('@-')!=-1 || cemail.indexOf('-.')!=-1)
{
alert("Please input a valid email address!\n\n Ex: me@noname.com");
booknow.email.focus();
return false;
}

var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

if (filter.test(cemail))
return true;
else
{
alert("Please input a valid email address!\n\nEx: me@noname.com");
booknow.email.focus();
return false;
}
}
}
//*****************************************************************************
function checkspecial(spec)
{
if (spec==1)
{
field=document.booknow.arflightno.value;
target=booknow.arflightno;
var msg="Please do not use special characters in the arrival flight-no field!"
}

if (spec==2)
{
field=document.booknow.depflightno.value;
target=booknow.depflightno;
var msg="Please do not use special characters in the departure flight-no field!"
}

var notvalid;
		for (var i=0, notvalid="!@#$%^&*()+=-[]\\\';,./{}|\":<>?"; i<field.length; i++)
		{
       		if (notvalid.indexOf(field.charAt(i)) != -1)
		{
			alert(msg);
			target.focus(); 
			return false;
		}
		}

}
//*****************************************************************************
function openflights() {
	

	if (document.booknow.flightcheck.checked)
	{

	document.booknow.airport.style.visibility = 'visible';
		
	document.booknow.arflightno.style.visibility = 'visible';
	document.booknow.ardate.style.visibility = 'visible';
	document.booknow.arimg.style.visibility = 'visible';
	document.booknow.arhr.style.visibility = 'visible';
	document.booknow.armin.style.visibility = 'visible';
	
	document.booknow.depflightno.style.visibility = 'visible';
	document.booknow.depdate.style.visibility = 'visible';
	document.booknow.depimg.style.visibility = 'visible';
	document.booknow.dephr.style.visibility = 'visible';
	document.booknow.depmin.style.visibility = 'visible';
	
	document.booknow.pdate.style.visibility = 'hidden';
	document.booknow.pimg.style.visibility = 'hidden';
	document.booknow.pdate.value="";
	
	document.booknow.ddate.style.visibility = 'hidden';
	document.booknow.dimg.style.visibility = 'hidden';
	document.booknow.ddate.value="";
		
		}
	else
	{
	
	document.booknow.airport.style.visibility = 'hidden';
	document.booknow.airport.value="Airport";
	
	document.booknow.arflightno.style.visibility = 'hidden';
	document.booknow.arflightno.value="";
	document.booknow.ardate.style.visibility = 'hidden';
	document.booknow.ardate.value="";
	document.booknow.arimg.style.visibility = 'hidden';
	
	document.booknow.arhr.style.visibility = 'hidden';
	document.booknow.arhr.value="hr";
	document.booknow.armin.style.visibility = 'hidden';
	document.booknow.armin.value="min";
	
	document.booknow.depflightno.style.visibility = 'hidden';
	document.booknow.depflightno.value="";
	document.booknow.depdate.style.visibility = 'hidden';
	document.booknow.depdate.value="";
	document.booknow.depimg.style.visibility = 'hidden';
	
	document.booknow.dephr.style.visibility = 'hidden';
	document.booknow.dephr.value="hr";
	document.booknow.depmin.style.visibility = 'hidden';
	document.booknow.depmin.value="min";
	
	document.booknow.pdate.style.visibility = 'visible';
	document.booknow.pimg.style.visibility = 'visible';
	
	document.booknow.ddate.style.visibility = 'visible';
	document.booknow.dimg.style.visibility = 'visible';
				}
		}

//*****************************************************************************
function transmission() {

	document.booknow.rad[0].checked=false;
	document.booknow.rad[1].checked=false;
	
	if (document.booknow.car.value=='Car type'){
	document.booknow.rad[0].disabled=true;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='Mercedes A150 Elegance- 3 door'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='Mercedes A150 Elegance- 5 door'){
	document.booknow.rad[0].disabled=true;
	document.booknow.rad[1].disabled=false;
	}
	
	if (document.booknow.car.value=='Mercedes CLK200 Kompressor - Cabriolet'){
	document.booknow.rad[0].disabled=true;
	document.booknow.rad[1].disabled=false;
	}
	
	if (document.booknow.car.value=='Mercedes E200 Kompressor Elegance'){
	document.booknow.rad[0].disabled=true;
	document.booknow.rad[1].disabled=false;
	}

	if (document.booknow.car.value=='Mercedes CLK 200 Kompressor Avantgarde'){
	document.booknow.rad[0].disabled=true;
	document.booknow.rad[1].disabled=false;
	}
	
	if (document.booknow.car.value=='Land Rover FreeLander'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='VolksWagen Touran'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='Opel Meriva'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='Citroen Berlingo'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='Suzuki Vitara - Softtop'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='Ford Focus Saloon'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='Seat Ibiza'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='Ford Focus H/B'){
	document.booknow.rad[0].disabled=true;
	document.booknow.rad[1].disabled=false;
	}
	
	if (document.booknow.car.value=='Opel Astra'){
	document.booknow.rad[0].disabled=true;
	document.booknow.rad[1].disabled=false;
	}
	
	if (document.booknow.car.value=='Ford Focus S/W'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='Ford Fusion'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='Cirtoen C3'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='Opel Corsa'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=true;
	}
	
	if (document.booknow.car.value=='Ford Fiesta'){
	document.booknow.rad[0].disabled=false;
	document.booknow.rad[1].disabled=false;
	}
}

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

function checkall()
{
var msg="(*)Please enter...\n\n";
if ( document.booknow.name.value.length < 1 ) {
				msg +="- Your name!\n";
				}
				
if ( document.booknow.dob.value.length < 1 ) {
				msg +="- Date of Birth!\n";
				}				

var cemail=document.booknow.email.value.length;
var ctelmob=document.booknow.telmob.value.length;
	
if (cemail < 1 && ctelmob <1 ) {
				msg +="- One of your contact information!\n";
				}

if ( document.booknow.country.value.length < 1 ) {
				msg +="- Country name!\n";
				}
			
if (document.booknow.flightcheck.checked)
	{

if ( document.booknow.airport.value=='Airport') {
				msg +="- Airport!\n";
				}

if ( document.booknow.arflightno.value.length < 1 ) {
				msg +="- Arrival flight no!\n";
				}

if ( document.booknow.ardate.value.length < 1) {
				msg +="- Arrival date!\n";
				}

if ( document.booknow.arhr.value=='hr' ) {
				msg +="- Arrival hour!\n";
				}
				
if ( document.booknow.armin.value=='min') {
				msg +="- Arrival minute!\n";
				}			
}
else
{
if ( document.booknow.pdate.value.length < 1) {
				msg +="- Pick-up date!\n";
				}

if ( document.booknow.ddate.value.length < 1) {
				msg +="- Drop-off date!\n";
				}
}

if ( document.booknow.car.value=='Car type') {
				msg +="- Car type!\n";
				}
else
		{
					
 if ( document.booknow.rad[0].checked==false &&	document.booknow.rad[1].checked==false)
			{
			msg +="- Transmission!\n";		
			}			
				
		}			
			if(msg=="(*)Please enter...\n\n") 
        { 
			return FlightDateCheck();
            
        } 
        else 
        { 
			
            alert(msg); 
            return false; 
        } 		

}
