﻿//admin login validation
function validate_contactform()
{
	
	
 if(isEmpty(document.getElementById('Name').value))
	{
		alert("Please enter Name of the Passenger.");
		document.getElementById('Name').focus();
		return false;
	}
	/*else if(isEmpty(document.getElementById('EmailAddress').value))
	{
		alert("Please enter your Email Address.");
		document.getElementById('EmailAddress').focus();
		return false;
	}
	else if(!validateEmail(document.getElementById('EmailAddress').value))
	{
		alert("Please enter valid Email Address.");
		document.getElementById('EmailAddress').focus();
		return false;
			
	}*/
	else if(isEmpty(document.getElementById('ContactNumber').value))
	{
		alert("Please enter your Contact Number.");
		document.getElementById('ContactNumber').focus();
		return false;
	}
	
	/*else if (document.getelementbyid("DestinationName").value == 0)
{
    alert('Plese select destinations from dropdown.')
    return false;
}*/

else if (document.getelementbyid("DestinationName").value == '0')
{
    alert('Plese select destinations from dropdown.')
	document.getElementById('DestinationName').focus();
    return false;
}
	
	/*else if(isEmpty(document.getElementById('CellNumber').value))
	{
		alert("Please enter your Contact Number.");
		document.getElementById('CellNumber').focus();
		return false;
	}
	
	else if (document.getelementbyid("select").value == 0)
{
    alert('Plese select value for dropdown')
    return false;
}
	
else if(isEmpty(document.getElementById('Destination').value))
	{
		alert("Please enter your Destination.");
		document.getElementById('Destination').focus();
		return false;
	}
	else if(isEmpty(document.getElementById('DepartureDate').value))
	{
		alert("Please enter your Departure Date.");
		document.getElementById('DepartureDate').focus();
		return false;
	}
	else if(isEmpty(document.getElementById('ArrivalDate').value))
	{
		alert("Please enter your Arrival Date.");
		document.getElementById('ArrivalDate').focus();
		return false;
	}
	else if(isEmpty(document.getElementById('Originating').value))
	{
		alert("Please enter your Originating From.");
		document.getElementById('Originating').focus();
		return false;
	}
	else if(isEmpty(document.getElementById('NumAdults').value))
	{
		alert("Please enter your No. of Adults / Childs / Infants.");
		document.getElementById('NumAdults').focus();
		return false;
	}*/
	else if(isEmpty(document.getElementById('SpecialRequest').value))
	{
		alert("Please enter your Special Request.");
		document.getElementById('SpecialRequest').focus();
		return false;
	}
	
}

function validateEmail(email)
{
	
	if (email == ""){
		return false;
	}
	badStuff = ";:/,' \"\\";
	for (i=0; i<badStuff.length; i++){
		badCheck = badStuff.charAt(i)
		if (email.indexOf(badCheck,0) != -1){
			return false;
		}
	}
	posOfAtSign = email.indexOf("@",1)
	if (posOfAtSign == -1){
		return false;
	}
	if (email.indexOf("@",posOfAtSign+1) != -1){
		return false;
	}
	posOfPeriod = email.indexOf(".", posOfAtSign)
	if (posOfPeriod == -1){
		return false;
	}
	if (posOfPeriod+2 > email.length){
		return false;
	}
	return true
}
function isEmpty(textvalue) 
{
	textvalue=textvalue.replace(/\s/g,"");
	
	if(textvalue.length>0)
	{
		return false;
	}
	else
	{	
		return true;
	}
}


function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
        
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }

