var mylocation = window.location;
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

var mydate=new Date()
var year=mydate.getYear()

if (year < 1000)
year+=1900

var day=mydate.getDay()
var month=mydate.getMonth()

var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds

var dateVal = daym + "-" + montharray[month] + "-" + year
var rtflg=true;
var pkflg=true;
var retmn = 0;
var pickmn = 0;

/* -------------------------------------- Validation Functions Begin ---------------------------------------*/

function validateGeneralQry(form)				//Validates General Query
{
	var v=allblanksGeneral(form)
isGeneralQryQuery(form)
isGeneralQryChildren(form)
isGeneralQryAdults(form)
isGeneralQryDaysInHands(form)
isGeneralQryTentArrival(form)
isGeneralQryPhone(form)
isGeneralQryCityCode(form)
isGeneralQryCountryCode(form)
isGeneralQryCountry(form)
isGeneralQryEmail(form)
isGeneralQryName(form)
if( v == true)
	{
		v=confirm("Have You entered \nthe information Correctly !!");
	}
return v;
}

function allblanksGeneral(form) {
if( (isGeneralQryName(form) && isGeneralQryEmail(form)) && (isGeneralQryCountry(form) && isGeneralQryCountryCode(form)) && (isGeneralQryCityCode(form) && isGeneralQryPhone(form)) && (isGeneralQryTentArrival(form)&& isGeneralQryDaysInHands(form)) && ( isGeneralQryAdults(form) && isGeneralQryChildren(form)) && isGeneralQryQuery(form) ) {
 return true ;
}
if( (isGeneralQryName(form) == false) || (isGeneralQryEmail(form) == false) || (isGeneralQryCountry(form) == false) || (isGeneralQryCountryCode(form) == false) || (isGeneralQryCityCode(form) == false) || (isGeneralQryPhone(form) == false) || (isGeneralQryTentArrival(form) == false) || (isGeneralQryDaysInHands(form) == false) || (isGeneralQryAdults(form)== false) || (isGeneralQryChildren(form) == false) || (isGeneralQryQuery(form) == false) ) {
composeGeneral(form);
return false ;
   }
}
function composeGeneral(form) {
var text = " You entered incorrectly or forgot to fill in ::\n"	
if(isGeneralQryName(form) == false) {
text += "\nYour Name -- must be purely alphabetic"
}
if(isGeneralQryEmail(form) == false) {
text += "\nYour E-mail -- improper/incomplete e-mail ID"
}
if(isGeneralQryCountry(form) == false) {
text += "\nYour Country of Residence -- not selected yet"
}
if(isGeneralQryCountryCode(form) == false) {
text += "\nCountry Code for Phone -- should be number or blank"
}
if(isGeneralQryCityCode(form) == false) {
text += "\nArea Code for Phone -- should be a number or blank"
}
if(isGeneralQryPhone(form) == false) {
text += "\nPhone Number -- should be number or blank"
}
if(isGeneralQryTentArrival(form) == false) {
text += "\nTentative Date for Trip -- cannot be earlier than today"
}
if(isGeneralQryDaysInHands(form) == false) {
text += "\nDays in Hand -- should be a number or blank"
}
if(isGeneralQryAdults(form) == false) {
text += "\nNo. of Adults travelling -- should be a number or blank"
}
if(isGeneralQryChildren(form) == false) {
text += "\nNo. of Children travelling -- should be a number or blank"
}
if(isGeneralQryQuery(form) == false) {
text += "\nTopic Comments/Query -- should atleast be a line or blank"
}
alert(text)
}

//FOR NAME
function isGeneralQryName(form) {
if (trim(form.txtName.value) == "") {
form.txtName.focus();
return false;
}
else {
		form.txtName.value=trim(form.txtName.value);
	    if(checkforchar(form.txtName.value)==0)
		   {
			form.txtName.focus();
			return(false);
			}
		return true ;
   }
}

//FOR EMAIL
function isGeneralQryEmail(form) {
if (trim(form.txtEmail.value)== "")
	{
		form.txtEmail.focus();
		return false; // because  it is not optional 
	}
else
	{
		var eid=form.txtEmail.value=trim(form.txtEmail.value);
		if (eid.indexOf(' ')!= -1)
			{
			form.txtEmail.focus();
			return false ; // no spaces
			} 
		if (eid.length < 6 ){
			form.txtEmail.focus();
			return false ; // at least j.a@in
			}
		at=eid.indexOf('@', 0); //check from first position ---- 
		if ( at == -1 || at == 0){ //should not be at first place
			form.txtEmail.focus();
			return false ;
			}
		else
			{
				var at1=eid.indexOf('@', (at + 1)); //looking for another at one place ahead
				if ( at1 == -1 ) // ie only one at is there
				{
					var dot=eid.indexOf('.',(at + 1));//looking for just next value
					if(dot == (at + 1)|| dot== -1){ //if dot is not there or in the next place
						form.txtEmail.focus();
						return false ;	
						}
					else
						{
						 if ( (dot + 2 ) < eid.length )
							return true ;
						 else
						    {
							form.txtEmail.focus();
							return false ;
							}
						}
				}
				else // two @ are there
				{
				form.txtEmail.focus();
				return false;
				}
			}	
	form.txtEmail.focus();
	return false ;
	}		
}

//for country of residence
function isGeneralQryCountry(form)
{
 if(form.selCountry.value == "NA")
	{
	 form.selCountry.focus(); 
	 return false; //presently not used
	} 
 else
   return true;  
 }

//FOR PHONE
function isGeneralQryPhone(form) {
if (trim(form.txtPhone.value) == "") {
form.txtPhone.value=trim(form.txtPhone.value);
return true   //because it is optional
}
else {
			form.txtPhone.value=trim(form.txtPhone.value);
	     if(checkfornum(form.txtPhone.value)==0)
		   {
			form.txtPhone.focus();
			return(false);
			}
return true
   }
}

//FOR CITY CODE OF PHONE

function isGeneralQryCityCode(form) {
if (trim(form.txtCityCode.value) == "") {
form.txtCityCode.value=trim(form.txtCityCode.value);
return true   //because it is optional
}
else {
			form.txtCityCode.value=trim(form.txtCityCode.value);
	     if(checkfornum(form.txtCityCode.value)==0)
		   {
			form.txtCityCode.focus();
			return(false);
			}
return true
   }
}

//for country code of phone
function isGeneralQryCountryCode(form) {
	if (trim(form.txtCityCode.value) == "") {
	form.txtCountryCode.value = trim(form.txtCountryCode.value);
	return true   //because it is optional
	}
	else {
			form.txtCityCode.value=trim(form.txtCityCode.value);
		    if(checkfornum(form.txtCountryCode.value)==0)
			{
				form.txtCountryCode.focus();
				return false;
			}
		return true;
	}
}

//FOR No. of Adults
function isGeneralQryAdults(form) {
if (trim(form.txtAdults.value) == "" || checkforzero(form.txtAdults.value) == 1 ) {
//form.adults.value=trim(form.adults.value);
//form.adults.focus();
return(true);   //because it is optional
}
else {
			//form.adults.value=trim(form.adults.value);
	     if(checkfornum(form.txtAdults.value)==0)
		   {
			form.txtAdults.focus();
			return(false);
			}
return true
   }
}

//FOR No. of Children if any
function isGeneralQryChildren(form) {
if (trim(form.txtChildren.value) == "" ) { //since children are optional so it doesn't include checkforzero
form.txtChildren.value=trim(form.txtChildren.value);
return(true); //because it is optional
}
else {
			form.txtChildren.value=trim(form.txtChildren.value);
	     if(checkfornum(form.txtChildren.value)==0)
		   {
			form.txtChildren.focus();
			return(false);
			}
return true
   }
}

//FOR Days in hands
function isGeneralQryDaysInHands(form) {
if (trim(form.txtDaysInHand.value) == "" || checkforzero(form.txtDaysInHand.value)== 1 ) {
//form.hands.value=trim(form.hands.value);
//form.hands.focus();
return(true);   //because it is optional
}
else {
			form.txtDaysInHand.value=trim(form.txtDaysInHand.value);
	     if(checkfornum(form.txtDaysInHand.value)==0)
		   {
			form.txtDaysInHand.focus();
			return(false);
			}
return true
   }
}

function isGeneralQryTentArrival(form)
{
	if ((form.selTentMonth.value == "NA") || (form.selTentDate.value == "NA") || (form.selTentYear.value == "NA"))
	{
		if(form.selTentMonth.value == "NA")
			form.selTentMonth.focus()
			return false;
		if(form.selTentDate.value == "NA")
			form.selTentDate.focus()
			return false;  
		if(form.selTentYear.value == "NA")
			form.selTentYear.focus()
			return false;
	}
	else{
		if (isGeneralQryTentDate(form)==false)
		{
			return false;
		}
		else
			return true;
	}
}

function isGeneralQryTentDate(form)
{
	for(i=0;i<=montharray.length;i++)
	{
		if (montharray[i]==form.selTentMonth.value)
		{
			dgt=i;
			break;
		}
	}
	//alert(dgt)
if(form.selTentYear.value < year)
{
	//alert("Invalid date. It must be a future date.");
	pkflg = false;
	form.selTentYear.focus(); 
	return false; //presently  used
 } 
 else
	{
		if((form.selTentYear.value == year) && (dgt < month))
		{
			//alert("Invalid date. It must be a future date.");
			pkflg = false;
			form.selTentMonth.focus();
			return false;
		}
		else
		{
			if((form.selTentYear.value == year) && (dgt == month))
			{
				if (form.selTentDate.value < daym)
				{
				//alert("Invalid date. It must be a future date.");
				pkflg = false;
				form.selTentDate.focus();
				return false;
				}
				else
					return true;
			}
		}
	}
 }

 //FOR Query
function isGeneralQryQuery(form) {
form.txaQuery.value=trim(form.txaQuery.value);
if (trim(form.txaQuery.value) == "") {
//form.txaQuery.focus();
return true;
}
else {
			
	     if(checkfornum(form.txaQuery.value)==1)// i. e, it is a pure number that is invalid
		   {
			form.txaQuery.focus();
			return(false);
			}
		qry=trim(form.txaQuery.value);
		if(qry.length <= 6 )// if it is too short
			{
			 form.txaQuery.focus();
			 return(false);
			}	
return true ;
   }
}


function validateAirQry(form)			//Validates Air txaQuery
{
var v=allblanksAir(form)
//isAirQryQuery(form)
isAirQryPax(form)
isAirQryTravel(form)
isAirQryCityTo(form)
isAirQryCountryTo(form)
isAirQryCityFrom(form)
isAirQryCountryFrom(form)
isAirQryPhone(form)
isAirQryCityCode(form)
isAirQryCountryCode(form)
isAirQryCountry(form)
isAirQryEmail(form)
isAirQryName(form)
if( v == true)
	{
		v=confirm("Have You entered \nthe information Correctly !!");
	}
return v;
}

function allblanksAir(form) {
if( (isAirQryName(form) && isAirQryEmail(form)) && ( isAirQryCountry(form) && isAirQryCountryCode(form)) && ( isAirQryCityCode(form) && isAirQryPhone(form)) && ( isAirQryCountryTo(form) && isAirQryCountryFrom(form)) && ( isAirQryCityTo(form) && isAirQryCityFrom(form))  && ( isAirQryTravel(form) && isAirQryPax(form))  &&  isAirQryQuery(form)) {
 return true ;
}
if( (isAirQryName(form) == false ) || ( isAirQryEmail(form) == false || isAirQryCountry(form)==false ) || ( isAirQryCountryCode(form) == false || isAirQryCityCode(form)==false )  || ( isAirQryPhone(form) == false || isAirQryCountryTo(form)==false ) || ( isAirQryCountryFrom(form) == false || isAirQryCityTo(form)==false ) || ( isAirQryCityFrom(form) == false || isAirQryTravel(form)==false ) || ( isAirQryPax(form) == false || isAirQryQuery(form)==false )) {
composeAir(form);
return false ;
   }
}

function composeAir(form) {
var text = " You entered incorrectly or forgot to fill in ::\n"	
if(isAirQryName(form) == false) {
text += "\nYour Name -- must be purely alphabetic"
}
if(isAirQryEmail(form) == false) {
text += "\nYour E-mail -- improper/incomplete e-mail ID"
}
if(isAirQryCountry(form) == false) {
text += "\nYour Country of Residence -- not selected yet"
}
if((isAirQryCountryCode(form) == false) || (isAirQryCityCode(form) == false) || (isAirQryPhone(form) == false) ) {
text += "\nTelephone Number -- should be a number "
}
if(isAirQryCountryFrom(form) == false) {
text += "\nFlying from Country -- not selected yet"
}
if(isAirQryCityFrom(form) == false) {
text += "\nFlying from City -- must be purely alphabetic"
}
if(isAirQryCountryTo(form) == false) {
text += "\nFlying to Country -- not selected yet"
}
if(isAirQryCityTo(form) == false) {
text += "\nFlying to City -- must be purely alphabetic"
}
if(
