//Validation for frmItinerary
function flightvalidation(flighttrack)
{
	if(flighttrack.cmbairname.value=="" && flighttrack.txtaircode.value=="")
	{
		alert("Please select the airline or enter the airleine code");
		flighttrack.cmbairname.focus();
		return false;
	}
	
	if(flighttrack.txtflnumber.value=="")
	{
		alert("Please fill the flight number");
		flighttrack.txtflnumber.focus();
		return false;
	}
	if(isNaN(flighttrack.txtflnumber.value))
	{
		alert("Please fill the numeric  flight number");
		flighttrack.txtflnumber.focus();
		return false;
	}
	
	return true;
}


function inte_flight_validation(frmInternationalFlightSearch)
{
	if(frmInternationalFlightSearch.adult.value=="" && frmInternationalFlightSearch.child.value=="" &&  frmInternationalFlightSearch.infant.value=="")
	{
		alert("Please fill the at least one of  number of adult or child or infants number ");
		frmInternationalFlightSearch.adult.focus();
		return false;
	}
	
	//var startmonth=frames["datamain"]; 
	/*frmInternationalFlightSearch.depday.value=document.frames("datamain").document.reservform.day_start.value;
	frmInternationalFlightSearch.retday.value=document.frames("datamain").document.reservform.day_end.value;
	
	frmInternationalFlightSearch.depmonth.value=document.frames("datamain").document.reservform.month_start.value;
	frmInternationalFlightSearch.retmonth.value=document.frames("datamain").document.reservform.month_end.value;*/
	
	frmInternationalFlightSearch.depday.value=document.reservform.day_start.value;
	frmInternationalFlightSearch.retday.value=document.reservform.day_end.value;
	
	frmInternationalFlightSearch.depmonth.value=document.reservform.month_start.value;
	frmInternationalFlightSearch.retmonth.value=document.reservform.month_end.value;
	
	//alert("SDSDS".document.frmInternationalFlightSearch.datamain.value);
	return true;
}


// for text boxes on  frmInternationalFlightSearch form
function inte_flight_valid_text(frmInternationalFlightSearch)
{
	if(frmInternationalFlightSearch.fromcity.value=="")
	{
		alert("Please fill the from city value");
		frmInternationalFlightSearch.fromcity.focus();
		return false;
	}
	
	if(frmInternationalFlightSearch.tocity.value=="")
	{
		alert("Please fill the to city value");
		frmInternationalFlightSearch.tocity.focus();
		return false;
	}
	
	if(frmInternationalFlightSearch.adult.value=="" && frmInternationalFlightSearch.child.value=="" &&  frmInternationalFlightSearch.infant.value=="")
	{
		alert("Please fill the at least one of  number of adult or child or infants number ");
		frmInternationalFlightSearch.adult.focus();
		return false;
	}
	
	//var startmonth=frames["datamain"]; 
	/*frmInternationalFlightSearch.depday.value=document.frames("datamain").document.reservform.day_start.value;
	frmInternationalFlightSearch.retday.value=document.frames("datamain").document.reservform.day_end.value;
	
	frmInternationalFlightSearch.depmonth.value=document.frames("datamain").document.reservform.month_start.value;
	frmInternationalFlightSearch.retmonth.value=document.frames("datamain").document.reservform.month_end.value;*/
	
	frmInternationalFlightSearch.depday.value=document.reservform.day_start.value;
	frmInternationalFlightSearch.retday.value=document.reservform.day_end.value;
	
	frmInternationalFlightSearch.depmonth.value=document.reservform.month_start.value;
	frmInternationalFlightSearch.retmonth.value=document.reservform.month_end.value;
	
	//alert("SDSDS".document.frmInternationalFlightSearch.datamain.value);
	
	return true;
}


function frm_int1_validation(frmsearch)
{

	var sm=frmsearch.smonth.value;
	var sd=frmsearch.sday.value;
	var sy=frmsearch.syear.value;
	var em=frmsearch.endmonth.value;
	var ed=frmsearch.endday.value;
	var ey=frmsearch.endyear.value;
	
	
	
	if(sy > ey )
	{
		alert("Please Check Starting Year");
		frmsearch.syear.focus();
		return false;
	}
	else
	if(sy < ey || sy==ey)
	{		
		if(sm > em )
		{
		alert("Please Check Starting Month");
		frmsearch.smonth.focus();
		return false;
		}
		else
		if(sd > ed )
		{
		alert("Please Check Starting Day");
		frmsearch.sday.focus();
		return false;
		}
	}
	
	frmsearch.depday.value=document.frmsearch.sday.value;
	frmsearch.retday.value=document.frmsearch.endday.value;
	
	frmsearch.depmonth.value=document.frmsearch.smonth.value;
	frmsearch.retmonth.value=document.frmsearch.endmonth.value;
	
	frmsearch.depyear.value=document.frmsearch.syear.value;
	frmsearch.retyear.value=document.frmsearch.endyear.value;
	
	
	
	if(frmsearch.adult.value=="" && frmsearch.child.value=="" &&  frmsearch.infant.value=="")
	{
		alert("Please fill the at least one of  number of adult or child or infants number ");
		frmsearch.adult.focus();
		return false;
	}
	//var startmonth=frames["datamain"]; 
	//alert("SDSDS".document.frmInternationalFlightSearch.datamain.value);
	return true;
}


function frm_int2_valid(frmsearch)
{
	if(frmsearch.fromcity.value=="")
	{
		alert("Please fill the from city value");
		frmsearch.fromcity.focus();
		return false;
	}
	
	if(frmsearch.tocity.value=="")
	{
		alert("Please fill the to city value");
		frmsearch.tocity.focus();
		return false;
	}
	
	if(frmsearch.adult.value=="" && frmsearch.child.value=="" &&  frmsearch.infant.value=="")
	{
		alert("Please fill the at least one of  number of adult or child or infants number ");
		frmsearch.adult.focus();
		return false;
	}
	
	//var startmonth=frames["datamain"]; 
	frmsearch.depday.value=document.frmsearch.sday.value;
	frmsearch.retday.value=document.frmsearch.endday.value;
	
	frmsearch.depmonth.value=document.frmsearch.smonth.value;
	frmsearch.retmonth.value=document.frmsearch.endmonth.value;
	
	frmsearch.depyear.value=document.frmsearch.syear.value;
	frmsearch.retyear.value=document.frmsearch.endyear.value;
	
	//alert("SDSDS".document.frmInternationalFlightSearch.datamain.value);
	
	return true;
}


function frm_dom_validation(AvailRequester)
{
	if(AvailRequester.departureCity.value=="")
	{
		alert("Please select the from city");
		AvailRequester.departureCity.focus();
		return false;
	}
	
	if(AvailRequester.destinationCity.value=="")
	{
		alert("Please select the to city");
		AvailRequester.destinationCity.focus();
		return false;
	}
	
	if(AvailRequester.dom_depdate.value=="")
	{
		alert("Please fill the Dep. date");
		AvailRequester.dom_depdate.focus();
		return false;
	}
	
	if(AvailRequester.dom_retdate.value=="")
	{
		alert("Please fill the Ret. date");
		AvailRequester.dom_retdate.focus();
		return false;
	}
	
	var deptvalue =AvailRequester.dom_depdate.value;
	var retvalue = AvailRequester.dom_retdate.value;
	
	depday = deptvalue.substring(0, 2);
	retday = retvalue.substring(0, 2);
	//alert(depday);
	//alert(retday);
	AvailRequester.departureDay.value=depday;
	AvailRequester.returnDay.value=retday;
	
	
	depmon=deptvalue.substring(3, 5);
	retmon=retvalue.substring(3, 5);
	depmon=depmon-1;
	retmon=retmon-1;
	//alert(depmon);
	//alert(retmon);
	AvailRequester.departureMonth.value=depmon
	AvailRequester.returnMonth.value=retmon;
	
	depyear=deptvalue.substring(6, 10);
	retyear=retvalue.substring(6, 10);
	
	var depDate = new Date(depyear,depmon,depday);
    var retDate = new Date(retyear,retmon,retday);
	
	if(retDate<depDate)
	{
	  alert("Return date shuold be grater than Departure date");
	  AvailRequester.dom_retdate.focus();
	  return false;
	 } 

	if(AvailRequester.adultage.value=="" && AvailRequester.seniorage.value=="" && AvailRequester.infantage.value=="" && AvailRequester.childage.value=="" )
	{
		alert("Please select either adultage or seniorage or infantage or childage");
		AvailRequester.adultage.focus();
		return false;
	}
	return true;
}


// for text boxes on  frmdomestic form
function frm_dom_valid(AvailRequester)
{
	if(AvailRequester.fromcity.value=="")
	{
		alert("Please enter the from city value");
		AvailRequester.fromcity.focus();
		return false;
	}
	
	if(AvailRequester.tocity.value=="")
	{
		alert("Please enter the  to city value");
		AvailRequester.tocity.focus();
		return false;
	}
	
	if(AvailRequester.dom_depdate.value=="")
	{
		alert("Please fill the Dep. date");
		AvailRequester.dom_depdate.focus();
		return false;
	}
	
	if(AvailRequester.dom_retdate.value=="")
	{
		alert("Please fill the Ret. date");
		AvailRequester.dom_retdate.focus();
		return false;
	}
	
	var deptvalue =AvailRequester.dom_depdate.value;
	var retvalue = AvailRequester.dom_retdate.value;
	
	depday = deptvalue.substring(0, 2);
	retday = retvalue.substring(0, 2);
	
	depmon=deptvalue.substring(3, 5);
	retmon=retvalue.substring(3, 5);
	
	depyear=deptvalue.substring(6, 10);
	retyear=retvalue.substring(6, 10);
	
	var depDate = new Date(depyear,depmon,depday);
    var retDate = new Date(retyear,retmon,retday);
	
	if(retDate<depDate)
	{
	  alert("Return date shuold be grater than Departure date");
	  AvailRequester.dom_retdate.focus();
	  return false;
	 } 

	
	if(AvailRequester.adultage.value=="" && AvailRequester.seniorage.value=="" && AvailRequester.infantage.value=="" && AvailRequester.childage.value=="" )
	{
		alert("Please select either adultage or seniorage or infantage or childage");
		AvailRequester.adultage.focus();
		return false;
	}
	//return true;
}

function newslettervalidation(newsletter)
{

	if(newsletter.email.value=="")
	{
		alert("Please enter the email address");
		newsletter.cmbairname.focus();
		return false;
	}
	if(newsletter.email.value!="")
	{
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(newsletter.email.value)))
		{
			alert("Invalid E-mail Address! Please re-enter");
			UserForm.email.select();
			return false;
		}
		
		
	}
		
	return true;
}

function validateIternary(iternary)
{
   var code=document.frmItinerary.pnr.value;
   var name=document.frmItinerary.name.value;
   if(code=="")
	{
		alert("Please fill the code ");
		document.frmItinerary.pnr.focus();
		return false;
	}
	if(name=="")
	{
		alert("Please fill the name ");
		document.frmItinerary.name.focus();
		return false;
	}
   
}

function checkreservationcode(iternary)
{
 
  var code=document.frmItinerary.pnr.value;
 
  if(code.length>6)
  {
    alert("Please enter only 6 characters");
	document.frmItinerary.pnr.select();
	return false;
  }
  else
  {
    for (i=0; i<code.length; i++)
	{
	  if (isDigit(code.charAt(i)))
	  { 
	   alert("Please enter only letters not number");
	   iternarty.pnr.select();
	   return false;
	  }
    }
  }
  return true;
}


function isDigit(num) 
{
	if (num.length>1){return false;}
	var string="1234567890";
	if (string.indexOf(num)!=-1){return true;}
	return false;
}


function noAlpha(obj){
	reg = /[^A-Z a-z]/g;
	obj.value =  obj.value.replace(reg,"");
 }
 
 function check_job_add(jobfrm)
 {
 	if(jobfrm.what.value=="")
	{
		alert("Please select the You are a field");
		jobfrm.what.focus();
		return false;
	}
	 if(jobfrm.name.value=="")
	{
		alert("Please enter your name");
		jobfrm.name.focus();
		return false;
	}
	/*if(jobfrm.email.value=="")
	{
		alert("Please enter the email address");
		jobfrm.email.focus();
		return false;
	}*/
	
	if(jobfrm.email.value!="")
	{
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(jobfrm.email.value)))
		{
			alert("Invalid E-mail Address! Please re-enter");
			jobfrm.email.select();
			return false;
		}
	}
	
	/*if(jobfrm.telephone.value=="")
	{
		alert("Please enter the telephone");
		jobfrm.telephone.focus();
		return false;
	}*/
	
	/*if(jobfrm.telephone.value!="")
	{
		if(isNaN(jobfrm.telephone.value))
		{
		alert("Please enter the numeric telephone");
		jobfrm.telephone.focus();
		return false;
		}
	}*/
	
	if(jobfrm.title.value=="")
	{
		alert("Please enter the job title");
		jobfrm.title.focus();
		return false;
	}
	
	if(jobfrm.message.value=="")
	{
		alert("Please enter the message");
		jobfrm.message.focus();
		return false;
	}
	
	if(jobfrm.img_code.value=="")
	{
		alert("Please enter the image text");
		jobfrm.img_code.focus();
		return false;
	}
		
	if (jobfrm.img_code.value != jobfrm.img_code1.value)
	{
		alert("Please enter the image text properly");
		jobfrm.img_code.focus();
		return false;
	}
	return true;

 }