function validate() {
	i_errfound =false;
	validate_init("txt_reddark_xs");
	var formcity=$("#cityfromDomestic").val();
	var tocity=$("#citytoDomestic").val();
	if (!gjfValidLength(document.regform.cityfromDomestic.value, 1))
		gjferror_div("cityfromDomestic","_err", error_airsearch_missing_departure_city);

	if (!gjfValidLength(document.regform.citytoDomestic.value, 1))
		gjferror_div("citytoDomestic","_err", error_airsearch_missing_destination_city);			
		
	if(gjfValidLength(document.regform.cityfromDomestic.value, 1) && gjfValidLength(document.regform.citytoDomestic.value, 1))
	   if (document.regform.cityfromDomestic.value == document.regform.citytoDomestic.value)
		  gjferror_div("citytoDomestic","_err", error_airsearch_duplicate_city_name);

	if(!checkCityPair)
		gjferror_div("citytoDomestic","_err1", error_airsearch_no_sell);

	var departureDate = document.getElementById('datefrom').value;	
	departureDate = departureDate.replace(/-/g,"/");
	var fromDate = nowday;//new Date();
	fromDate = Date.parse(departureDate);
					var arrivalDate = document.getElementById('dateto').value;		
					arrivalDate = arrivalDate.replace(/-/g,"/");
					var toDate =nowday;// new Date();
					toDate = Date.parse(arrivalDate);

	var today=nowday;//new Date();
	today = Date.parse((today.getYear())+"/"+(today.getMonth()+1)+"/"+today.getDate());
	if (document.regform.datefrom.value == "yyyy-mm-dd") 
		gjferror_div("leftmonth","_err", error_airsearch_missing_departure_date);

	if (fromDate < today)
		gjferror_div("leftmonth","_err",error_airsearch_departure_date_too_early);		
	
	if (!gjfValidfulldate2(document.regform.datefrom.value) && document.regform.datefrom.value != "yyyy-mm-dd") {
		gjferror_div("leftmonth","_err", error_airsearch_invalid_departure_date_format);
		document.regform.datefrom.value = "yyyy-mm-dd";
	}
	
	if (document.regform.tripType[1].selected) {
		document.regform.dateto.disabled=false;
		if (document.regform.dateto.value == "yyyy-mm-dd") 
			gjferror_div("backmonth","_err", error_airsearch_missing_return_date);		
		
		if (!gjfValidfulldate2(document.regform.dateto.value) && document.regform.dateto.value != "yyyy-mm-dd") {
			document.regform.dateto.value = "yyyy-mm-dd";
			gjferror_div("backmonth","_err", error_airsearch_invalid_return_date_format);
			
		}
		
		var arrivalDate = document.getElementById('dateto').value;		
		arrivalDate = arrivalDate.replace(/-/g,"/");
		var toDate =nowday;// new Date();
		toDate = Date.parse(arrivalDate);
		if (fromDate > toDate) {
			gjferror_div("backmonth","_err",error_airsearch_invalid_date_range);
		}
	}
	if (document.regform.tripType[0].selected) {
		/*
		document.regform.dateto.value="yyyy-mm-dd";
		if (document.regform.dateto.value != "yyyy-mm-dd") 
			gjferror_div("backmonth","_err", error_airsearch_oneway_return_date);	   
		*/
		document.regform.dateto.disabled=true;
	}else{
		if (fromDate > toDate) {
			gjferror_div("backmonth","_err",error_airsearch_invalid_date_range);
		}
	}
	var numOfAdult = document.getElementById('adult').value;
	var numOfChild = document.getElementById('child').value;
	var total = parseInt(numOfAdult) + parseInt(numOfChild);
	if (total == 0) {
		gjferror(document.regform.numOfAdult, error_airsearch_zero_passenger);
	} else if (total > 9) {
		gjferror_div("numOfAdult","_err",error_airsearch_too_many_passengers);
	}
	return !i_errfound;
}

function validateHotel() {
	i_errfound =false;	
	validate_init("txt_reddark_xs");
	if (!gjfValidLength(document.regform.destinationCity.value, 1) || !gjfValidLength(document.regform.city.value, 1))
		gjferror_div("destinationCity","_err", error_hotsearch_missing_departure_city);
	if (document.regform.datefrom.value == "yyyy-mm-dd") 
		gjferror_div("datefrom","_err", error_hotsearch_missing_departure_date);

	if(document.regform.incHotel.checked==false && document.regform.incApr.checked==false){
		gjferror_div("incHotel","_err", error_hotsearch_include_hotel_or_aprt);
	}
	return !i_errfound;
}

function submitItHotel(){
	if (validateHotel()){
		var days=document.getElementById('days').value;
		var checkindate=document.getElementById('datefrom').value;
		if(checkindate!="" && checkindate!="yyyy-mm-dd" ) {
			checkindate=checkindate.replace(/-/g,"/");
			var stardate=new Date(checkindate);
			var time=Math.floor(days * 1000 * 60 * 60 * 24);
			var enddate=new Date(stardate.getTime()+time);
			var checkoutdate="";
			if(enddate.getMonth()+1<10) {
				checkoutdate=enddate.getFullYear()+"-0"+(enddate.getMonth()+1);
			} else {
				checkoutdate=enddate.getFullYear()+"-"+(enddate.getMonth()+1);
			}
			if(enddate.getDate()<10) {
				checkoutdate=checkoutdate+"-0"+enddate.getDate();
			} else {
				checkoutdate=checkoutdate+"-"+enddate.getDate();
			}
			document.getElementById('dateto').value=checkoutdate;
		}
			
		document.regform.action = "hotelLoading.php";		
		document.regform.submit();
	}
}

function validateMem() {
	validate_init("txt_reddark_xs");	
	var username=document.getElementById("user_name").value;
	if(username == ""){
		gjferror_div("user_name","_err",error_memberlogin_missing_loginid);
	}	
	
	var password=document.getElementById("pass_word").value;
	if(password == ""){
		gjferror_div("pass_word","_err",error_memberlogin_missing_password);
		document.getElementById("pass_word").value="";
}

return !i_errfound;
}

function submitIt(url){	
	document.getElementById("datefrom").value=document.getElementById("leftmonth").value+"-"+(document.getElementById("leftdate").value<10?"0"+document.getElementById("leftdate").value:document.getElementById("leftdate").value);
	document.getElementById("dateto").value=document.getElementById("backmonth").value+"-"+(document.getElementById("backdate").value<10?"0"+document.getElementById("backdate").value:document.getElementById("backdate").value);
	if (validate()){
		document.regform.action =url;
		document.regform.submit();
	}
}
/********* new index start************/
function validatefl() {
	i_errfound =false;
	validate_init("txt_reddark_xs");
	var formcity=$("#cityfromDomestic").val();
	var tocity=$("#citytoDomestic").val();
	if (!gjfValidLength(document.regformfl.cityfromDomestic.value, 1))
		gjferror_div("cityfromDomestic","_err", error_airsearch_missing_departure_city);

	if (!gjfValidLength(document.regformfl.citytoDomestic.value, 1))
		gjferror_div("citytoDomestic","_err", error_airsearch_missing_destination_city);			
		
	if(gjfValidLength(document.regformfl.cityfromDomestic.value, 1) && gjfValidLength(document.regformfl.citytoDomestic.value, 1))
	   if (document.regformfl.cityfromDomestic.value == document.regformfl.citytoDomestic.value)
		  gjferror_div("citytoDomestic","_err", error_airsearch_duplicate_city_name);

	if(!checkCityPair)
		gjferror_div("citytoDomestic","_err1", error_airsearch_no_sell);
	var departureDate = document.regformfl.datefrom.value;
	departureDate = departureDate.replace(/-/g,"/");
	var fromDate = nowday;//new Date();
	fromDate = Date.parse(departureDate);
	var today=nowday;//new Date();
	today = Date.parse((today.getYear())+"/"+(today.getMonth()+1)+"/"+today.getDate());
	if (document.regformfl.datefrom.value == "yyyy-mm-dd") 
		gjferror_div("leftmonth","_err", error_airsearch_missing_departure_date);

	if (fromDate < today)
		gjferror_div("leftmonth","_err",error_airsearch_departure_date_too_early);
			
	if (!gjfValidfulldate2(document.regformfl.datefrom.value) && document.regformfl.datefrom.value != "yyyy-mm-dd") {
		gjferror_div("leftmonth","_err", error_airsearch_invalid_departure_date_format);
		document.regformfl.datefrom.value = "yyyy-mm-dd";
	}
	
	if (document.regformfl.tripType[0].checked) {
		document.regformfl.dateto.disabled=false;
		if (document.regformfl.dateto.value == "yyyy-mm-dd") 
			gjferror_div("backmonth","_err", error_airsearch_missing_return_date);
			
		if (!gjfValidfulldate2(document.regformfl.dateto.value) && document.regformfl.dateto.value != "yyyy-mm-dd") {
			gjferror_div("backmonth","_err", error_airsearch_invalid_return_date_format);
			document.regformfl.dateto.value = "yyyy-mm-dd";
		}
		
		var arrivalDate = document.regformfl.dateto.value;		
		arrivalDate = arrivalDate.replace(/-/g,"/");
		var toDate = nowday;//new Date();
		toDate = Date.parse(arrivalDate);
		if (fromDate > toDate) {
			gjferror_div("backmonth","_err",error_airsearch_invalid_date_range);
		}
	}
	if (document.regformfl.tripType[1].checked) {
		//document.regformfl.dateto.value="yyyy-mm-dd";
		//if (document.regformfl.dateto.value != "yyyy-mm-dd") 
		//	gjferror_div("backmonth","_err", error_airsearch_oneway_return_date);   
		document.regformfl.dateto.disabled=true;
	}
	var numOfAdult = document.getElementById('adult').value;
	var numOfChild = document.getElementById('child').value;
	var total = parseInt(numOfAdult) + parseInt(numOfChild);
	if (total == 0) {
		gjferror(document.regformfl.numOfAdult, error_airsearch_zero_passenger);
	} else if (total > 9) {
		gjferror_div("numOfAdult","_err",error_airsearch_too_many_passengers);
	}
	return !i_errfound;
}
function submitItfl(url){
		document.regformfl.datefrom.value=document.regformfl.leftmonth.value+"-"+(document.regformfl.leftdate.value<10?"0"+document.regformfl.leftdate.value:document.regformfl.leftdate.value);
		document.regformfl.dateto.value=document.regformfl.backmonth.value+"-"+(document.regformfl.backdate.value<10?"0"+document.regformfl.backdate.value:document.regformfl.backdate.value);
	if (validatefl()){		
		document.regformfl.action =url;
		document.regformfl.submit();
	}
}
/********* new index end************/


/************ Bruce start*************/
  var issub=false;
  function isSubmit(){
  	if(window.ActiveXObject){
	   if(event.keyCode==13&&issub==false){
			return false;
	   }else{
		   issub=false;
	   }
  	}
  }
  function changeform(){
	  issub=true;
  }
/************ Bruce end*************/