// JavaScript Document
function validForm() {
	var frmObj 	= document.frm;
	var msg_err = '';	

	//Check First Name
	if( typeof(frmObj.cli_FName) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_FName.focus();
		}
		if(!validateEmptyName(frmObj.cli_FName)) {
			msg_err = msg_err + "Enter First Name." + '\n';
		}
		else if( !validateName(frmObj.cli_FName) ) {
			msg_err = msg_err + "Enter valid First Name. Allows only 0-9 a-z A-Z Dot Apostrophe Space." + '\n';
		}
	}
	
	//Check Last Name
	if( typeof(frmObj.cli_LName) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_LName.focus();
		}
		if(!validateEmptyName(frmObj.cli_LName)) {
			msg_err = msg_err + "Enter Last Name." + '\n';
		}
		else if( !validateName(frmObj.cli_LName) ) {
			msg_err = msg_err + "Enter valid Last Name. Allows only 0-9 a-z A-Z Dot Apostrophe Space." + '\n';
		}
	}
	//Check Address
	if( typeof(frmObj.cli_Address) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_Address.focus();
		}
		if(!validateEmptyName(frmObj.cli_Address)) {
			msg_err = msg_err + "Enter Address" + '\n';
		}
		else if( !validateName(frmObj.cli_Address) ) {
			msg_err = msg_err + "Enter valid Address. Allows only 0-9 a-z A-Z Dot Apostrophe Space." + '\n';
		}
	}
	
	//Check City
	if( typeof(frmObj.cli_city) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_city.focus();
		}
		if(!validateEmptyName(frmObj.cli_city)) {
			msg_err = msg_err + "Enter City" + '\n';
		}
		else if( !validateName(frmObj.cli_city) ) {
			msg_err = msg_err + "Enter valid City Name. Allows only 0-9 a-z A-Z Dot Apostrophe Space." + '\n';
		}
	}
	//Check State
	if( typeof(frmObj.cli_State) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_State.focus();
		}
		if(!validateEmptyName(frmObj.cli_State)) {
			msg_err = msg_err + "Enter State" + '\n';
		}
		else if( !validateName(frmObj.cli_State) ) {
			msg_err = msg_err + "Enter valid State Name. Allows only 0-9 a-z A-Z Dot Apostrophe Space." + '\n';
		}
	}
	
	//Check Postal Code
	if( typeof(frmObj.cli_Zip) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_Zip.focus();
		}
		if(!validateEmptyName(frmObj.cli_Zip)) {
			msg_err = msg_err +  "Enter Postal Code." + '\n';
		} 
		else if (!validatePhone(frmObj.cli_Zip)) {
			msg_err = msg_err +  "Enter valid Postal Code. Allow only 0-9 ( ) + - Space." + '\n';
		}
	}
	
	//Check Country
	if( typeof(frmObj.cli_country) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_country.focus();
		}
		if(!validateEmptyName(frmObj.cli_country)) {
			msg_err = msg_err + "Enter Country" + '\n';
		}
		else if( !validateName(frmObj.cli_country) ) {
			msg_err = msg_err + "Enter valid Country Name. Allows only 0-9 a-z A-Z Dot Apostrophe Space." + '\n';
		}
	}
	
	
	// Check Home Phone
	if( typeof(frmObj.cli_HomePhone) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_HomePhone.focus();
		}
		if(!validateEmptyName(frmObj.cli_HomePhone)) {
			msg_err = msg_err +  "Enter Home Phone." + '\n';
		} 
		else if (!validatePhone(frmObj.cli_HomePhone)) {
			msg_err = msg_err +  "Enter valid Home Phone. Allow only 0-9 ( ) + - Space." + '\n';
		}
	}
	
		
	//Check Email
	if( typeof(frmObj.cli_email) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_email.focus();
		}
		if(!validateEmptyName(frmObj.cli_email)) {
			msg_err = msg_err + "Enter Email Id." + '\n';
		}
		else if( !validateEmail(frmObj.cli_email) ) {
			msg_err = msg_err + "Enter valid Email Id." + '\n';
		}
	}
	
	//For Billing Address:
	
	//Check Billing Address
	if( typeof(frmObj.cli_creditcardname) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_creditcardname.focus();
		}
		if(!validateEmptyName(frmObj.cli_creditcardname)) {
			msg_err = msg_err + "Enter Name as on Credit Card" + '\n';
		}
		else if( !validateName(frmObj.cli_creditcardname) ) {
			msg_err = msg_err + "Enter valid Name as on Credit Card. Allows only 0-9 a-z A-Z Dot Apostrophe Space." + '\n';
		}
	}
	
	if( typeof(frmObj.cli_creditcardaddr) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_creditcardaddr.focus();
		}
		if(!validateEmptyName(frmObj.cli_creditcardaddr)) {
			msg_err = msg_err + "Enter Billing Address" + '\n';
		}
		else if( !validateName(frmObj.cli_creditcardaddr) ) {
			msg_err = msg_err + "Enter valid Billing Address. Allows only 0-9 a-z A-Z Dot Apostrophe Space." + '\n';
		}
	}
	
	//Check City
	if( typeof(frmObj.cli_creditcardcity) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_creditcardcity.focus();
		}
		if(!validateEmptyName(frmObj.cli_creditcardcity)) {
			msg_err = msg_err + "Enter Billing City" + '\n';
		}
		else if( !validateName(frmObj.cli_creditcardcity) ) {
			msg_err = msg_err + "Enter valid Billing City Name. Allows only 0-9 a-z A-Z Dot Apostrophe Space." + '\n';
		}
	}
	//Check State
	if( typeof(frmObj.cli_creditcardstate) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_creditcardstate.focus();
		}
		if(!validateEmptyName(frmObj.cli_creditcardstate)) {
			msg_err = msg_err + "Enter Billing State" + '\n';
		}
		else if( !validateName(frmObj.cli_creditcardstate) ) {
			msg_err = msg_err + "Enter valid Billing State Name. Allows only 0-9 a-z A-Z Dot Apostrophe Space." + '\n';
		}
	}
	
	//Check Postal Code
	if( typeof(frmObj.cli_creditcardzip) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_creditcardzip.focus();
		}
		if(!validateEmptyName(frmObj.cli_creditcardzip)) {
			msg_err = msg_err +  "Enter Zip Code." + '\n';
		} 
		else if (!validatePhone(frmObj.cli_creditcardzip)) {
			msg_err = msg_err +  "Enter valid Zip Code. Allow only 0-9 ( ) + - Space." + '\n';
		}
	}
	
	//Check Country
	if( typeof(frmObj.cli_creditcardcountry) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cli_creditcardcountry.focus();
		}
		if(!validateEmptyName(frmObj.cli_creditcardcountry)) {
			msg_err = msg_err + "Enter Country" + '\n';
		}
		else if( !validateName(frmObj.cli_creditcardcountry) ) {
			msg_err = msg_err + "Enter valid Country Name. Allows only 0-9 a-z A-Z Dot Apostrophe Space." + '\n';
		}
	}
	//Billing Address ends here
	
	// Check Credit Card Type
	if (frmObj.cmbCCType.value == "Not Selected") {
		if(msg_err == ''){
		frmObj.cmbCCType.focus();
		}
			msg_err = msg_err +  "Select Credit Card type." + '\n';
	}	
	// Check Credit Card Number
	if( typeof(frmObj.txtCCNumber) != "undefined" ) {
		if(msg_err == ''){
			frmObj.txtCCNumber.focus();
		}
		if(!validateEmptyName(frmObj.txtCCNumber)) {
			msg_err = msg_err +  "Enter Credit Card Number." + '\n';
		} 
	}
	// Check Credit Card Type
	if (frmObj.cmbMonth.value == "Not selected") {
		if(msg_err == ''){
		frmObj.cmbMonth.focus();
		}
			msg_err = msg_err +  "Select Exp. Month." + '\n';
	}	
	// Check Credit Card Type
	if (frmObj.cmbYear.value == "Not selected") {
		if(msg_err == ''){
		frmObj.cmbYear.focus();
		}
			msg_err = msg_err +  "Select Exp. Year." + '\n';
	}	
	
	if( typeof(frmObj.cvv) != "undefined" ) {
		if(msg_err == ''){
			frmObj.cvv.focus();
		}
		if(!validateEmptyName(frmObj.cvv)) {
			msg_err = msg_err +  "Enter CVV Code." + '\n';
		} 
		/*else if (!validateCaptcha(frmObj.captcha)) {
			msg_err = msg_err +  "Security Code did not match !'";
		}*/
	}
	if( typeof(frmObj.captcha) != "undefined" ) {
		if(msg_err == ''){
			frmObj.captcha.focus();
		}
		if(!validateEmptyName(frmObj.captcha)) {
			msg_err = msg_err +  "Enter Security Code." + '\n';
		} 
		/*else if (!validateCaptcha(frmObj.captcha)) {
			msg_err = msg_err +  "Security Code did not match !'";
		}*/
	}
	
	
	if ( msg_err.length > 0 ) {
		displayMsg(msg_err);
		return false;
	}
	return true;
}


function displayMsg(msg_err){
		msg_err="Please provide detail(s) mentioned below for processing your request:\n\n"+msg_err;
		alert(msg_err);
}

function validatemyform()
{
	var frmObj 	= document.frm;
	var msg_err = '';	
	if(!validateEmptyName(frmObj.ArrivalDate)) {
			msg_err = msg_err + "Please Enter Arrival Date." + '\n';
		}
	if(!validateEmptyName(frmObj.ArrivalTime)&&!validateEmptyName(frmObj.ArrivalTime2)) {
			msg_err = msg_err + "Please Enter Arrival Time." + '\n';
		}
	if(!validateEmptyName(frmObj.ArrivalAirline)) {
			msg_err = msg_err + "Please Enter Arrival Airline/Train or Bus Depot." + '\n';
		}
		
	if(!validateEmptyName(frmObj.FlightNumber)) {
			msg_err = msg_err + "Please Enter Flight/Bus or Train Number." + '\n';
		}
	
	if(!validateEmptyName(frmObj.paxname)) {
			msg_err = msg_err + "Please Enter PaxName." + '\n';
		}
		
		if (!alphanumeric(frmObj.FlightNumber.value)) {
			msg_err = msg_err +  "Enter valid Flight/Bus or Please Input only Alphanumberic characters." + '\n';
		}
		
	 if ( msg_err.length > 0 ) {
		displayMsg(msg_err);
		return false;
	}
	return true;
}


function validatemyform_hotel()
{
	var frmObj 	= document.frm;
	var msg_err = '';	
	if(!validateEmptyName(frmObj.ArrivalDate)) {
			msg_err = msg_err + "Please Enter Arrival Date." + '\n';
		}
	
		
	 if ( msg_err.length > 0 ) {
		displayMsg(msg_err);
		return false;
	}
	return true;
}
function validatemyform_eco(frm1)
{
	//var frmObj 	= document.frm;
	var frmObj 	= frm1;
	var msg_err = '';
	if(frmObj.name=='frm1')
	{
		if(!validateEmptyName(frmObj.a_date1)) {
			msg_err = msg_err + "Please Appointment Date." + '\n';
		}	
	}
	else
	{
		if(!validateEmptyName(frmObj.a_date)) {
			msg_err = msg_err + "Please Appointment Date." + '\n';
		}
		if(frmObj.name=='frmlake')
		{
		if(frmObj.appointment_time1=='Select Time')
		msg_err = msg_err + "Please Select Appointment Time." + '\n';
		
		if(frmObj.appointment_time3=='Select Time')
		msg_err = msg_err + "Please Select Appointment Time." + '\n';
		}
	}
	
	

	 if ( msg_err.length > 0 ) {
		displayMsg(msg_err);
		return false;
	}
	

	
	return true;
}

function theChecker()
	{
		if(document.frm.chkbilling.checked==true)
		{
			document.frm.cli_creditcardname.disabled=true;
			document.frm.cli_creditcardaddr.disabled=true;
			document.frm.cli_creditcardcity.disabled=true;
			document.frm.cli_creditcardstate.disabled=true;
			document.frm.cli_creditcardzip.disabled=true;
			document.frm.cli_creditcardcountry.disabled=true;
			
			document.frm.cli_creditcardname.value=document.frm.cli_FName.value+' '+document.frm.cli_LName.value;
			document.frm.cli_creditcardaddr.value=document.frm.cli_Address.value+'  '+document.frm.cli_Address1.value;
			document.frm.cli_creditcardcity.value=document.frm.cli_city.value;
			document.frm.cli_creditcardstate.value=document.frm.cli_State.value;
			document.frm.cli_creditcardzip.value=document.frm.cli_Zip.value;
			document.frm.cli_creditcardcountry.value=document.frm.cli_country.value;
			
		}
		else
		{
			document.frm.cli_creditcardname.disabled=false;
			document.frm.cli_creditcardaddr.disabled=false;
			document.frm.cli_creditcardcity.disabled=false;
			document.frm.cli_creditcardstate.disabled=false;
			document.frm.cli_creditcardzip.disabled=false;
			document.frm.cli_creditcardcountry.disabled=false;
			
			document.frm.cli_creditcardname.value='';
			document.frm.cli_creditcardaddr.value='';
			document.frm.cli_creditcardcity.value='';
			document.frm.cli_creditcardstate.value='';
			document.frm.cli_creditcardzip.value='';
			document.frm.cli_creditcardcountry.value='';
		}
	}

function validatemyform1(frm1)
{
	var frmObj 	= frm1;
	var msg_err = '';
	if(!validateEmptyName(frmObj.a_date1)) {
		msg_err = msg_err + "Please select Appointment Date." + '\n';
	}	
	if ( msg_err.length > 0 ) {
		displayMsg(msg_err);
		return false;
	}
	return true;
}

function validatemyform2(frm1)
{
	var frmObj 	= frm1;
	var msg_err = '';
	if(!validateEmptyName(frmObj.a_date2)) {
		msg_err = msg_err + "Please select Appointment Date." + '\n';
	}	
	if ( msg_err.length > 0 ) {
		displayMsg(msg_err);
		return false;
	}
	return true;
}