//-----------valodation for admin email start----------------------//

function checkemail(f)
{
		var alertMsg = "";
	
	if(f.email.value == ""){
		alertMsg += "Email is Mandatory.\n";
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  alertMsg += "Email address is incorrect.\n";
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 alertMsg += "Email address contains illegal characters.\n";
		 }
		
		
	}
	
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		//f.submit();
		return true;
	}

}

//-----------valodation for Change password start----------------------//

function checkpass(f)
{
		var alertMsg = "";
	if(f.old.value == ""){
		alertMsg += "Old Password is Mandatory.\n";
	}
	if(f.newp.value == ""){
		alertMsg += "New Password is Mandatory.\n";
	}
	if(f.conf_pass.value == ""){
		alertMsg += "Confirm Password is Mandatory.\n";
	}
	else
	{
		if(f.conf_pass.value != f.newp.value){
		alertMsg += "Password & Confirm Password didnot matched.\n";
		}	
	}
	
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		//f.submit();
		return true;
	}

}

                  
//-----------valodation for route----------------------//

function checkgrtroute(f)
{
	
	var alertMsg = "";
	
	var radio0=f.wheretowhere[0].checked;
	var radio1=f.wheretowhere[1].checked;
	var radio2=f.wheretowhere[2].checked;
	var radio3=f.wheretowhere[3].checked;
	
	if (!radio0 && !radio1 && !radio2 && !radio3) 
	{
		
		alertMsg += "Please select the route.\n";
	}
	else
	{
		var radiovalue0=f.wheretowhere[0].checked;
		var radiovalue1=f.wheretowhere[1].checked;
		var radiovalue2=f.wheretowhere[2].checked;
		var radiovalue3=f.wheretowhere[3].checked;
		
		if(radiovalue0 == true)
			var from = f.fromat.value;
		if(radiovalue1 == true)
			var from = f.fromta.value;
		if(radiovalue2 == true)
			var from = f.fromaa.value;
		if(radiovalue3 == true)
			var from = f.fromtt.value;
		
		if(from == "")
		{
			alertMsg += "Please select the Departure.\n";
		}
		else
		{
			if(f.to.value == "")
			{
				alertMsg += "Please select the arrival.\n";
			}
			else
			{
				if(!checkcar1())
				{
					alertMsg += "Please select car.\n";
				}
			}

		}
	}
	
	
	
	
	
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}

function checkcar1()
{
	var carlength = document.form1.cartype.length;
	for(i=0;i<carlength;i++)
	{
		
		if (document.form1.cartype[i].checked == false) 
		{
			
			msg = 0;
		}
		else
		{
			return(true);
			
		}
		
		
		
	}
	
	if(msg == 0)
	{
		//alert("Please select car.");
	
	}
	return(false);
}


//-----------valodation for news start----------------------//

function checkbooking(f)
{
	

	var alertMsg = "";
	if(f.title.value == ""){
		alertMsg += "Passenger Tittle is Mandatory.\n";
	}
	if(f.fname.value == ""){
		alertMsg += "Passenger First Name is Mandatory.\n";
	}
	if(f.lname.value == ""){
		alertMsg += "Passenger Last Name is Mandatory.\n";
	}
	if(f.email.value == ""){
		alertMsg += "Email is Mandatory.\n";
	}
	else
	{
		var f1=f.email.value;
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(f1))) 
		{ 
		  alertMsg += "Email address is incorrect.\n";
		}
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		 if (f1.match(illegalChars)) 
		 {
			 alertMsg += "Email address contains illegal characters.\n";
		 }
		
		
	}
	if(f.address.value == ""){
		alertMsg += "Address  is Mandatory.\n";
	}
	if(f.hr.value == "" || f.minu.value == ""){
		alertMsg += "Pick up time is Mandatory.\n";
	}
	
	
	
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}



//-----------valodation for  credit card starts----------------------//

function cardcheck(f)
{
		var alertMsg = "";
	
	if(f.holder_name.value == ""){
		alertMsg += "Holder Name is Mandatory.\n";
	}
	if(f.credit_no.value == ""){
		
		alertMsg += "Cerdit Card Number is Mandatory.\n";
	}
	if(f.credit_no.value.length > 16){
		
		alertMsg += "Cerdit Card Number  must be less than sixteen.\n";
	}
	
	if(f.security_code.value == ""){
		alertMsg += "Security Code is Mandatory.\n";
	}
	if(f.security_code.value.length > 4){
		alertMsg += "Security Code must be less than four.\n";
	}
	if(f.exp_date.value == ""){
		alertMsg += "Expire Date is Mandatory.\n";
	}
	if(f.fname.value == ""){
		alertMsg += "First Name is Mandatory.\n";
	}
	if(f.lname.value == ""){
		alertMsg += "Last Name is Mandatory.\n";
	}
	if(f.address.value == ""){
		alertMsg += "Address  is Mandatory.\n";
	}
	if(f.postcode.value == ""){
		alertMsg += "Postcode  is Mandatory.\n";
	}
	if(f.city.value == ""){
		alertMsg += "City  is Mandatory.\n";
	}
	if(f.county.value == ""){
		alertMsg += "County  is Mandatory.\n";
	}
	
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}
function checksearch(f)
{
	

	var alertMsg = "";
	if(f.from.value == ""){
		alertMsg += "From date is Mandatory.\n";
	}
	if(f.to.value == ""){
		alertMsg += "To date is Mandatory.\n";
	}
		
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}

function checkairport(f)
{
	

	var alertMsg = "";
	if(f.airport.value == ""){
		alertMsg += "Airport Name is Mandatory.\n";
	}
	
		
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}

function checktown(f)
{
	

	var alertMsg = "";
	if(f.town.value == ""){
		alertMsg += "Town Name is Mandatory.\n";
	}
	
		
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}
function checkcar(f)
{
	

	var alertMsg = "";
	if(f.cartype.value == ""){
		alertMsg += "Car Type is Mandatory.\n";
	}
	if(f.seat.value == ""){
		alertMsg += "Seat is Mandatory.\n";
	}
	if(f.lugg.value == ""){
		alertMsg += "Lugguage is Mandatory.\n";
	}
	
	
		
		
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}

function checkrate(f)
{
	

	var alertMsg = "";
	if(f.from.value == ""){
		alertMsg += "Departure is Mandatory.\n";
	}
	if(f.to.value == ""){
		alertMsg += "Arrival is Mandatory.\n";
	}
			
	if(alertMsg!=""){
		alert(alertMsg);
		return(false);
	}else{
		return true;
	}

}

function checkqty(f)
{
	var qty = document.getElementsByName('price[]');

	
	for(i=0;i<qty.length;i++)
	{
		if(qty[i].value == 0)
		{
			return(false);
		}
		else
		{
			return true;
		}
		bool=qty[i].value.match("^[0-9]{1,2}$");
		if((!bool)||isNaN(qty[i].value)||(qty[i].value.indexOf(".")!=-1))
		{
		return(false);
		
		}
		else
		{
			return true;
		}
	}
		
	

}









