
// JavaScript Document
/* 
* Author: Er. Rajan Maharjan
* Date : 8th June, 2009
* Reason : Implementing of jquery and stylish error display

*/	
var numericExpression = /^[0-9]+$/;
var numericExpression1 = /^[0-9+]+$/;
function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function displayStyleErr(idTodisplay, errorMsg){		
	if(errorMsg!=''){		
		inlineMsg(idTodisplay,errorMsg,2);				//alert(errorMsg);
		$(idTodisplay).focus();
		$(idTodisplay).select();
		return false;
	}
	else
		return true;
	}
	
function displayStyleErr1(idError,idTodisplay, errorMsg){		
	if(errorMsg!=''){		
		inlineMsg(idError,errorMsg,2);				//alert(errorMsg);
		$(idTodisplay).focus();
		$(idTodisplay).select();
		return false;
	}
	else
		return true;
	}


function isValidPhone(phoneString){	
	phoneString=trim(phoneString);	
	if(phoneString=='')
		return false;
	if(isNaN(phoneString) || phoneString<0){
		var plusSign=phoneString.substring(0,1);
		var numbers='';
		var returnValue=1;
		if(plusSign=="+"){
			numbers=trim(phoneString.substring(1,phoneString.length));
			}
		else
			numbers=phoneString;
		
		
		
		for(var i=0;i<numbers.length;i++){			
				if((isNaN(numbers[i]) && trim(numbers[i])!='') || numbers[i]<0 || numbers[i]=='+'){
					returnValue=0;
					break;
				}				
			}
		
		if(returnValue==0)
			return false;
	}
	return true;
	}
	
	
function isNumber(myNumber){
	if(myNumber=='' || isNaN(myNumber))
		return false;
	else
		return true;
}

function isValidURL(theurl) {	
    var urlMatchOne= /(http|https):\/\/www\.[A-Za-z0-9\.-]{3,}\.[A-Za-z]{2,}/;	
	if(urlMatchOne.test(theurl)){     
         return true;     
		}
     else      
         return false;  
}


function isValidEmail(strEmail){	
	strEmail=strEmail.toLowerCase();
	var myregEmail=/^([_a-z0-9-])+(\.[a-z0-9-]+)*@([a-z0-9-])+(\.[a-z0-9-]{1,})*\.([a-z]{2,}){1}/;
	return myregEmail.test(strEmail);
 
}


function validate(field,form)
{
	
	try
	{
	valiclass=field.getAttribute("valiclass");	
	valimessage=field.getAttribute("valimessage");
	idOfField=field.getAttribute("id");	
	if(valiclass=="required"){
	req=field.getAttribute("req");
	pattern="\\w{"+req+",}";
	if(!field.value.match(pattern)){			
		return displayStyleErr(idOfField,valimessage);	
		}
	}
	
	else if(valiclass=="txtarea" && field.value==''){		
		return displayStyleErr(idOfField,valimessage);	
		}	
	else if(valiclass=="urllink")
	{
		req=field.getAttribute("req");
		if(req==1){
		if(!isValidURL(field.value))
		{
		return displayStyleErr(idOfField,valimessage);	
		}
		}
		else{
			if(!isValidURL(field.value) && trim(document.getElementById(idOfField).value)!='')
				return displayStyleErr(idOfField,valimessage);	
			}
	}
	
	else if(valiclass=="email")
	{
		
		if(isValidEmail(field.value)==0)
		{
		return displayStyleErr(idOfField,valimessage);	
		}
	}
	
	else if(valiclass=="dePhone")
	{
		
		if(isValidPhone(field.value)==false)
		{
		return displayStyleErr(idOfField,valimessage);	
		}
	}
	
	
	else if(valiclass=="checkbox")
	{
		//!document.frmsignup.chkAccept.checked
		if(!field.checked)
		{
			return displayStyleErr(idOfField,valimessage);	
		}
	
	}
	else if(valiclass=="number")
	{
		
	if(isNumber(field.value)==false)
	{
	return displayStyleErr(idOfField,valimessage);	
	}
		
	}

	else if(valiclass=="PIN")
	{
	pattern="[0-9]{13}$";
	if((field.value.length!=13) || (!field.value.match(pattern)))
	{
	return displayStyleErr(idOfField,valimessage);	
	}
	
	}
	else if(valiclass=="zip")
	{
	pattern="[0-9]{5}$";
	//if(!field.value.match(pattern))
	if((field.value.length!=5) || (!field.value.match(pattern)))
	{
		return displayStyleErr(idOfField,valimessage);	
	}
	
	}
	
	else if(valiclass == "pass")
	{	
	if((field.value.length<5))
	{
	return displayStyleErr(idOfField,valimessage);	
	}
	}
	else if(valiclass == "cpass")
	{	
		
		if(form.password.value != form.cpassword.value)
			{
				return displayStyleErr(idOfField,valimessage);	
			}
	}
	else if(valiclass == "cemail")
	{	
		if(form.email.value != form.cemail.value)
			{
				return displayStyleErr(idOfField,valimessage);				
			}
	}
	
	
	else if(valiclass=="select")
	{
	if(field.value=="0")
	{
	return displayStyleErr(idOfField,valimessage);				
	}
	}
return true;
}
catch(ex)
{
alert(ex.message);
return true;
}
}

function call_validate(form,from,to)
{

for(counter=from;counter<to;counter++)
{
bool=validate(form[counter],form);
if(!bool)
{
return false;
break;
}
}
return true;
//form.submit();
}

<!--ADDED BY RAZAN -->

<!-- START INDEX	-->
function populateElements(selector, defvalue)	
{
	$(selector).each(function(){
			if($.trim(this.value) == "")
			{
				this.value = defvalue;
			}
	});
	
	$(selector).focus(function(){
				if(this.value == defvalue)   
				{
					this.value = "";
				}
	});
	$(selector).blur(function(){
		if($.trim(this.value) == "")
		{
				this.value = defvalue;
		}
	});
}

$(function() {          
          $("#center_home img").lazyload({ 
			placeholder : globalJSLiveURL+"/images/grey.gif",
			effect : "fadeIn"
			});
      });
<!-- END INDEX		-->
<!-- START TRIP SEARCH	-->

function trimAll( strValue ) {
	var objRegExp = /^(\s*)$/;
		if(objRegExp.test(strValue)) {
		   strValue = strValue.replace(objRegExp, '');
		   if( strValue.length == 0)
			  return strValue;
		}
	   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
	   if(objRegExp.test(strValue)) {
		   strValue = strValue.replace(objRegExp, '$2');
		}
	  return strValue;
}
function getSubCategory(funcName, catId, subCatId){
	$.ajax({
				type:"POST",
				url:globalJSLiveURL+"/ajaxpages.php",
				data:{catId:catId, funcName:funcName, subCatId:subCatId},
									
				success: function(msg){
										
					if(trimAll(msg)!="error"){
						
						$('#subCatDiv').show();					
						$('#subCatDiv').html(msg);	
					}
					else{
						
						$('#subCatDiv').hide();
						$('#subCatDiv').html('');	
					}
				}
      });	

}

function getPackAllCat(funcName, country_id, catId){
	$.ajax({
				type:"POST",
				url:globalJSLiveURL+"/ajaxpages.php",
				data:{country_id:country_id, funcName:funcName, catId:catId},
									
				success: function(msg){
					
					$('#category-foreign').html(msg);	
					
				}
      });	
}

function getPackNepali(funcName, country_id, catId){
	$.ajax({
				type:"POST",
				url:globalJSLiveURL+"/ajaxpages.php",
				data:{country_id:country_id, funcName:funcName, catId:catId},
									
				success: function(msg){
					
					$('#category-nepali').html(msg);	
					
				}
      });	
}

function getNepaliCat(value){
	
	if(value	==	'96'){
		$("#category-india").show();
		$("#category-nepali").hide();
		$("#category-foreign").hide();
		$("#category-other").hide();
	}
	else if(value == '146'){
		$("#category-india").hide();
		$("#category-nepali").show();
		$("#category-foreign").hide();
		$("#category-other").hide();
	}
	else{
		
		$("#category-india").hide();
		$("#category-nepali").hide();
		$("#category-foreign").hide();
		$("#category-other").show();
	}
}

function setRadioVal(value){
	$("#radioVal").val(value);
	if($("#radioVal").val() == '1'){
		$("#country-nepali").hide();
		$("#country-foreign").show();
		$("#catDiv").show();
		$("#price-foreign").show();
		$("#price-nepali").hide();
		$("#category-foreign").show();
		$("#category-nepali").hide();
		$("#category-india").hide();
		$("#category-other").hide();
		
		
	}
	else if($("#radioVal").val() == '0')
	{	
		$("#country-foreign").hide();
		$("#country-nepali").show();		
		$("#package_country option[value='-1']").attr('selected', 'selected');		
		$("#catDiv").hide();
		$("#price-foreign").hide();
		$("#price-nepali").show();		
		$("#category-foreign").hide();		
		$("#category-nepali").show();		
		
	}
}

function showHideTrek(value){
	if(value == 'Trekking'){
		$('#trekDiv').show();
		$('#tourSubDiv').hide();
	}
	else if(value =='Tour')
	{
		$('#trekDiv').hide();	
		$('#tourSubDiv').show();
	}
	else{
		$('#trekDiv').hide();	
		$('#tourSubDiv').hide();
	}
}
<!-- END TRIP SEARCH-->

<!-- START HOTEL, FLIGHT & CAR SEARCH	-->

function validateFlight(){
	if($("#city_from").val()=='-1'){
		alert('Select from option');
		$("#city_from").focus();
		return false;
		
	}
	if($("#city_to").val()=='-1'){
		alert('Select to option');
		$("#city_to").focus();
		return false;
		
	}
	if($("#departTime").val()==''){
		alert('Select depart time');
		$("#departTime").focus();
		return false;
		
	
	}
	
	if($("#trip_type_value").val()=='1'){
		if($("#arrivalTime").val()==''){
			alert('Select arrival time');
			$("#arrivalTime").focus();
			return false;
			
		}
	}	
	flightReservation(globalJSLiveURL+'/flight-reservation/');
}
function getCityList(funcName, country_id, status, city_id){	
	$.ajax({
				type:"POST",
				url:globalJSLiveURL+"/ajaxpages.php",
				data:{funcName:funcName, country_id:country_id, status:status, city_id:city_id},							
				success: function(msg){
					if(status=='from')
						$('#flight_from_dd').html(msg);
					else if(status=='to')
						$('#flight_to_dd').html(msg);
					
				},
				error: function(XMLHttpRequest, textStatus, errorThrown){
					alert(XMLHttpRequest.responseText)
				}
				
      });	
}
function changeType(val){
	if(val=='1'){
		$("#domesticFlight").hide();
		$("#domesticBtn").hide();
		$("#internationalFlight").show();
		$("#intlBtn").show();
		$("#class").show();
		$("#domestic-note").hide();
		$("#international-note").show();   
		$("#domesticClass").hide();
		$("#intlClass").show();
	}
	else if(val=='0'){
		$("#domesticFlight").show();
		$("#domesticBtn").show();
		$("#internationalFlight").hide();
		$("#intlBtn").hide();
		$("#class").hide();
		$("#domestic-note").show();
		$("#international-note").hide(); 
		$("#domesticClass").show();
		$("#intlClass").hide();
				
	}
}

function changeTrip(val){
	if(val=='1'){		
		$("#arrivalTime").datepicker(  "enable"  );
		$("#arrivalTime").removeClass("disabled");
		$("#arrivalTimeIntl").datepicker(  "enable"  );
		$("#arrivalTimeIntl").removeClass("disabled");
	}
	else if(val=='0'){
		$("#arrivalTime").datepicker(  "disable"  );	
		$("#arrivalTime").addClass("disabled");
		$("#arrivalTimeIntl").datepicker(  "disable"  );	
		$("#arrivalTimeIntl").addClass("disabled");
		
	}
}

function changeTypeValue(typeVal){
	
	$("#flight_type_value").val(typeVal);	
}
function changeTripValue(typeVal){
	$("#trip_type_value").val(typeVal);	
}

function refreshCityList(funcName){
	$.ajax({
				type:"POST",
				url:globalJSLiveURL+"/ajaxpages.php",
				data:{funcName:funcName},
							
				success: function(msg){
					msgArray=msg.split("|");
					$('#flight_from_dd').html(msgArray[0]);
					$('#flight_to_dd').html(msgArray[1]);	
					$('#country_from_dd').html(msgArray[2]);
					$('#country_to_dd').html(msgArray[3]);	
					 
				}
      });	
}

function performSearch(){
	if($('#flight_type_value').val()=='0'){
		searchFlight('searchFlight',$('#flight_type_value').val(),$('#flight_from').val(),$('#flight_to').val(), '0', '0');
	}
	else if($('#flight_type_value').val()=='1'){
		
		searchFlight('searchFlight',$('#flight_type_value').val(),$('#flight_from').val(),$('#flight_to').val(),$('#country_from').val(),$('#country_to').val());
	}
}
function searchFlight(funcName, flight_type, flight_from, flight_to, countryFrom, countryTo){
	
	$.ajax({
				type:"POST",
				url:globalJSLiveURL+"/ajaxpages.php",
				data:{funcName:funcName,flight_type:flight_type, flight_from:flight_from, flight_to:flight_to, countryFrom:countryFrom, countryTo:countryTo},
							
				success: function(msg){					
					$('#flight-search-result').html(msg);							 
				}
      });	
}

function domesticSearch(action_url){
	document.flightForm.action	=	action_url;
}

function flightReservation(action_url){
	document.flightForm.action	=	action_url;
}

$().ready(function(){
	$('#departTime').datepicker({
		minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
	}); 
	
	$('#arrivalTime').datepicker({ 
			minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut,
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
	});  
	
	$('#departTimeIntl').datepicker({
		minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
	}); 
	
	$('#arrivalTimeIntl').datepicker({ 
			minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut,
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
	}); 
	
	$('#check_in').datepicker({ 
		minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
	}); 
	
	$('#check_out').datepicker({ 
		minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
	}); 
			

});

function showHideFlightCar(type){
	if(type=='flight'){
		$("#car-div").hide();
		$("#flight-div").show();
	}
	else if(type=='car'){
		$("#car-div").show();
		$("#flight-div").hide();
				
		$('#pickup-date').datepicker({
			minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true });
						
		$('#dropoff-date').datepicker({
			minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true  });
 
		$("#pickup-time").clockpick({
			starthour : 0,
			endhour : 23,
			showminutes : true
		}); 
		
		$("#dropoff-time").clockpick({
			starthour : 0,
			endhour : 23,
			showminutes : true
		}); 
	

	}
}

function limitCheckOut(dateText) {
      $('#check_out_date').datepicker('option', 'minDate', $(this).datepicker('getDate') || 0);
}

function showHideCity(type){
	if(type =='airport'){
		$("#cityDiv").hide();
	}
	else if(type =='city'){
		$("#cityDiv").show();
	}
}


function showNepalHotel(){
	
	$("#hotel-nepali").show();
	$("#nepal").attr("checked", true); 
}

function refreshCity(){
	$('#hotelName').attr("disabled", "");
	$('#hotelName').val('');
	$("#change_city").hide();
}

function refreshCityFrom(){
	$('#intl_city_from').attr("disabled", "");
	$('#intl_city_from').val('');
	$("#change_city_from").hide();
	$("#intl_city_from").removeClass("disabled");
}

function refreshCityTo(){
	$('#intl_city_to').attr("disabled", "");
	$('#intl_city_to').val('');
	$("#change_city_to").hide();
	$("#intl_city_to").removeClass("disabled");
}

function refreshFlightFrom(){
	$('#flight_from').attr("disabled", "");
	$('#flight_from').val('');
	$("#change_flight_from").hide();
	$("#flight_from").removeClass("disabled");
}

function refreshFlightTo(){
	$('#flight_to').attr("disabled", "");
	$('#flight_to').val('');
	$("#change_flight_to").hide();
	$("#flight_to").removeClass("disabled");
}


function showHideRoom(value,type){
	if(type=='nepali'){
		if(value	==	'1'){
			$('#room2').hide();
			$('#room3').hide();
			
		}
		else if(value	==	'2'){
			$('#room2').show();
			$('#room3').hide();			
		}
		else if(value	==	'3'){
			$('#room2').show();
			$('#room3').show();			
		}
	}
	else if(type=='world'){
		if(value	==	'1'){
			$('#room2-world').hide();
			$('#room3-world').hide();			
		}
		else if(value	==	'2'){
			$('#room2-world').show();
			$('#room3-world').hide();			
		}
		else if(value	==	'3'){
			$('#room2-world').show();
			$('#room3-world').show();
		}	
	}
}
function getCityList(funcName, country_id, status, city_id){	
	$.ajax({
				type:"POST",
				url:globalJSLiveURL+"/ajaxpages.php",
				data:{funcName:funcName, country_id:country_id, status:status, city_id:city_id},							
				success: function(msg){
					if(status=='from')
						$('#flight_from_dd').html(msg);
					else if(status=='to')
						$('#flight_to_dd').html(msg);
					
				},
				error: function(XMLHttpRequest, textStatus, errorThrown){
					alert(XMLHttpRequest.responseText)
				}
				
      });	
}

function getHotelGrade(funcName, region_id){
	$.ajax({
				type:"POST",
				url:globalJSLiveURL+"/ajaxpages.php",
				data:{funcName:funcName, region_id:region_id},	
				beforeSend:function(){
				
					$('#eventUl').html("<img src='"+globalJSLiveURL+"images/ajax-loader.gif'>");
				},
				success: function(msg){
					$('#gradeDiv').html(msg);
					
				},
				error: function(XMLHttpRequest, textStatus, errorThrown){
					alert(XMLHttpRequest.responseText)
				}
				
      });	
	
}

function performHotelSearch(funcName){
	hotelName			=	$('#hotelName').val();
	hotelRegionId		=	$('#hotel_region').val();
	hotelRating			=	$('#hotel_rating').val();
	
	$.ajax({
				type:"POST",
				url:globalJSLiveURL+"/ajaxpages.php",
				data:{funcName:funcName,hotelRegionId:hotelRegionId, hotelRating:hotelRating, hotelName:hotelName},
							
				success: function(msg){
					alert(msg);
					$('#hotelListing').html(msg);				
					 
				}
      });	
}

function changeHotelType(type){
	if(type =="world"){
		$("#hotel-nepali").hide();
		$("#hotel-world").show();
		$('#check_in_world').datepicker({ 
			minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
		}); 
	
		$('#check_out_world').datepicker({ 
			minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
		}); 
	}
	else if(type =="nepali"){
		$("#hotel-nepali").show();
		$("#hotel-world").hide();		
	}

}

<!-- END HOTEL, FLIGHT & CAR SEARCH	-->

<!--START TAILOR MADE -->
$(document).ready(function(){
	$('#arrival_date').datepicker({
			minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true });
});

function showHideCountry(radVal){
	
	if(radVal=='0'){
		$("#destination-foreign").hide();
		$("#destination-nepali").slideDown('fast');
	}
	else if(radVal=='1'){
		$("#destination-foreign").slideDown('fast');
		$("#destination-nepali").hide();
	}
}

function validateTailorMade(){
	if($("#travel_to").val()=='-1'){
		alert('Select Destination');
		$("#travel_to").focus();
		return false;
		
	}
	if($("#arrival_date").val()==''){
		alert('Choose Arrival Date');
		$("#arrival_date").focus();
		return false;
		
	}	
	if($("#duration").val()=='-1'){
		alert('Select Duration');
		$("#duration").focus();
		return false;
		
	}
	if($("#budget").val()=='-1'){
		alert('Select Budget Type');
		$("#budget").focus();
		return false;
		
	}
	if($('#no_people').val()!=''){
		if(!$('#no_people').val().match(numericExpression)){
			alert("Enter valid number of people");
			$('#no_people').focus();
			return false;
		}
	}
	if($("#tailor_name").val()=='' || $("#tailor_name").val()=='Full Name'){
		alert('Enter name');
		$("#tailor_name").focus();
		return false;
		
	}
	if($("#tailor_email").val()=='' || $("#tailor_name").val()=='Email'){
		alert('Enter email');
		$("#tailor_email").focus();
		return false;
		
	}
	if(isValidEmail($("#tailor_email").val())==0){
		alert("Enter Valid Email Address");
		$('#tailor_email').focus();
		return false;
	}
	if(trimAll($('#country_code').val())==''){
		alert("Enter Country Code");
		$('#country_code').focus();
		return false;
	
	}
	else if(!$('#country_code').val().match(numericExpression) || $('#country_code').val().length < '2'){
		alert("Enter valid Country Code/Country Code should be of min 2 digits");
		$('#country_code').focus();
		return false;
	}
	if($("#tailor_phone").val()=='' || $("#tailor_phone").val()=='Phone No'){
		alert('Enter phone');
		$("#tailor_phone").focus();
		return false;
		
	}	
	else if(!$('#tailor_phone').val().match(numericExpression) || $('#tailor_phone').val().length < '7'){
		alert("Enter valid Phone Number/Phone Number should be of min 7 digits");
		$('#tailor_phone').focus();
		return false;
	}
	else if(!$('#tailor_phone').val().match(numericExpression) || $('#tailor_phone').val().length < '6'){
		alert("Enter valid phone number/Phone number should be of min 6 chars");
		$('#tailor_phone').focus();
		return false;
	}
	if($("#tailor_country").val()=='-1'){
		alert('Select a country');
		$("#tailor_country").focus();
		return false;
		
	}
	
	if(trimAll($('#trip_security_code').val())==''){
		alert("Enter Code");
		$('#trip_security_code').focus();
		return false;	
	}
	
}
<!--END TAILOR MADE  -->
<!--Hotel Reservation -->
function validateIntlHotel(){
	if(trimAll($('#firstname').val())==''){
		alert("Enter First Name");
		$('#firstname').focus();
		return false;
	
	}
	
	if(trimAll($('#surname').val())==''){
		alert("Enter Surname");
		$('#surname').focus();
		return false;
	
	}
	
	if(trimAll($('#country_code').val())==''){
		alert("Enter Country code");
		$('#country_code').focus();
		return false;
	
	}
	
	else if(!$('#country_code').val().match(numericExpression1) || $('#country_code').val().length < '2'){
		alert("Enter valid country code/Country code should be of min 2 digits");
		$('#country_code').focus();
		return false;
	}
	
	if(trimAll($('#phone_no').val())==''){
		alert("Enter Phone Number");
		$('#phone_no').focus();
		return false;
	
	}
	
	else if(!$('#phone_no').val().match(numericExpression) || $('#phone_no').val().length < '7'){
		alert("Enter valid phone number/Phone number should be of min 7 digits");
		$('#phone_no').focus();
		return false;
	}

	if(isValidEmail($("#email_address").val())==0){
		alert("Enter Valid Email Address");
		$('#email_address').focus();
		return false;
	}	
}

$(document).ready(function () {	
	$('#check_in_w').datepicker({ 
			minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
		}); 
	
	$('#check_out_w').datepicker({ 
			minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
		}); 
	
});

function showHideResRoom(value){
			
		if(value	==	'1'){
			$('#room2-w').hide();
			$('#room3-w').hide();
			
		}
		else if(value	==	'2'){
			$('#room2-w').show();
			$('#room3-w').hide();
			
		}
		else if(value	==	'3'){
			$('#room2-w').show();
			$('#room3-w').show();
			
		
	}	

}

//Domestic Starts

function validateDomesticHotel(){
	if(trimAll($('#firstname').val())==''){
		alert("Enter First Name");
		$('#firstname').focus();
		return false;
	
	}
	
	if(trimAll($('#surname').val())==''){
		alert("Enter Surname");
		$('#surname').focus();
		return false;
	
	}
	
	if(trimAll($('#country_code').val())==''){
		alert("Enter Country code");
		$('#country_code').focus();
		return false;
	
	}
	
	else if(!$('#country_code').val().match(numericExpression1) || $('#country_code').val().length < '2'){
		alert("Enter valid country code/Country code should be of min 2 digits");
		$('#country_code').focus();
		return false;
	}
	
	if(trimAll($('#phone_no').val())==''){
		alert("Enter Phone Number");
		$('#phone_no').focus();
		return false;
	
	}
	
	else if(!$('#phone_no').val().match(numericExpression) || $('#phone_no').val().length < '7'){
		alert("Enter valid phone number/Phone number should be of min 7 digit");
		$('#phone_no').focus();
		return false;
	}

	if(isValidEmail($("#email_address").val())==0){
		alert("Enter Valid Email Address");
		$('#email_address').focus();
		return false;
	}	
	
	if(trimAll($('#trip_security_code').val())==''){
		alert("Enter Code");
		$('#trip_security_code').focus();
		return false;	
	}
}

$(document).ready(function () {	
	$('#check_in_w').datepicker({ 
		minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
	}); 
	
	$('#check_out_w').datepicker({ 
		minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
	});	
});

function showHideResRoom(value){
		//alert(value);
	
		if(value	==	'1'){
			$('#room2-w').hide();
			$('#room3-w').hide();
			
		}
		else if(value	==	'2'){
			$('#room2-w').show();
			$('#room3-w').hide();
			
		}
		else if(value	==	'3'){
			$('#room2-w').show();
			$('#room3-w').show();
			
		
	}	

}
<!--End Hotel Reservation -->
<!-- Car -->
function validateCar(){
	if(trimAll($('#firstname').val())==''){
		alert("Enter First Name");
		$('#firstname').focus();
		return false;
	
	}
	
	if(trimAll($('#surname').val())==''){
		alert("Enter Surname");
		$('#surname').focus();
		return false;
	
	}
	
	if(trimAll($('#country_code').val())==''){
		alert("Enter Country code");
		$('#country_code').focus();
		return false;
	
	}
	
	else if(!$('#country_code').val().match(numericExpression1) || $('#country_code').val().length < '2'){
		alert("Enter valid country code/Country code should be of min 2 digits");
		$('#country_code').focus();
		return false;
	}
	if(trimAll($('#phone_no').val())==''){
		alert("Enter Phone Number");
		$('#phone_no').focus();
		return false;
	
	}
	
	else if(!$('#phone_no').val().match(numericExpression) || $('#phone_no').val().length < '7'){
		alert("Enter valid phone number/Phone number should be of min 7 digits");
		$('#phone_no').focus();
		return false;
	}

	if(isValidEmail($("#email_address").val())==0){
		alert("Enter Valid Email Address");
		$('#email_address').focus();
		return false;
	}	
	if(trimAll($('#trip_security_code').val())==''){
		alert("Enter Code");
		$('#trip_security_code').focus();
		return false;	
	}
}

$(document).ready(function () {	
	
	$('#pickup-date-res').datepicker({
			minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut,			
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true });
		
		
		/*$('#dropoff-date').datepicker({ 
			
		}); */
		
		$('#dropoff-date-res').datepicker({
			minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut,			
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true  });
 
		$("#pickup-time-res").clockpick({
			starthour : 0,
			endhour : 23,
			showminutes : true
		}); 
		
		$("#dropoff-time-res").clockpick({
			starthour : 0,
			endhour : 23,
			showminutes : true
		}); 

	

	
});
<!-- END cAR-->

function validateNewsletter(){
	if(isValidEmail($("#newsletter_email").val())==0){
		alert("Enter Valid Email Address");
		$('#newsletter_email').focus();
		return false;
	}	
	
	$.ajax({
				type:"POST",
				url:globalJSLiveURL+"/ajaxpages.php",
				data:{funcName:'newsletterAction', emailAddress:$("#newsletter_email").val()},							
				success: function(msg){
					msgArr	=	msg.split('|')
					if(msgArr['1'] == "1"){
						
						$("#status").html(msgArr['0']);	
						$('#newletterDiv').hide();				
					}
					else if(msgArr['1'] == "2"){
						alert(trimAll(msgArr['0']));	
						//$("#status").html(msgArr['0']);					
					}
				},
				error: function(XMLHttpRequest, textStatus, errorThrown){
					
					alert(XMLHttpRequest.responseText)
				}
      });	
		
}

$().ready(function(){
	$('#check_in_w').datepicker({ 
		minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
	}); 
	
	$('#check_out_w').datepicker({ 
		minDate: 0, 
			maxDate: new Date(2011, 12-1, 31),
      		onSelect: limitCheckOut, 
			showOn: "both", 
			buttonImage: globalJSLiveURL+"/images/calendar.gif", 
			buttonImageOnly: true 
	}); 
});

$(document).ready(function () {
	
	//$("#datepicker").datepicker();
	$('#checkindate').datepicker({ 
		beforeShowDay: noSunday, 
		showOn: "both", 
		buttonImage: globalJSLiveURL+"images/calendar.gif", 
		buttonImageOnly: true 
	}); 
  
	$('#checkoutdate').datepicker({ 
		beforeShowDay: noSunday, 
		showOn: "both", 
		buttonImage: globalJSLiveURL+"images/calendar.gif", 
		buttonImageOnly: true 
	}); 
  function noSunday(date){ 
	  var day = date.getDay(); 
				  return [(day >-1), '']; 
  }; 
	
});

function validateReservation(){
if($("#name").val()==''){
	alert("Enter your name");
	$('#name').focus();
	return false;
}
if($("#nationionality").val()==''){
	alert("Enter Nationality");
	$('#nationionality').focus();
	return false;
}

if($("#address").val()==''){
	alert("Enter address");
	$('#address').focus();
	return false;
}
if(isValidEmail($("#email").val())==0){
	alert("Enter Valid Email Address");
	$('#email').focus();
	return false;
}
if($("#nroom").val()==''){
	alert("Enter number of room");
	$('#address').focus();
	return false;
}
if($("#checkindate").val()==''){
	alert("Enter check in date");
	$('#address').focus();
	return false;
}
if($("#checkoutdate").val()==''){
	alert("Enter check out date");
	$('#checkoutdate').focus();
	return false;
}
if($("#checkindate").val() >= $("#checkoutdate").val()){
	alert("Check out date must be greater than check in date");
	$('#checkoutdate').focus();
	return false;
}

}

function showHideResRoom(value){
			
		if(value	==	'1'){
			$('#room2-w').hide();
			$('#room3-w').hide();
			
		}
		else if(value	==	'2'){
			$('#room2-w').show();
			$('#room3-w').hide();
			
		}
		else if(value	==	'3'){
			$('#room2-w').show();
			$('#room3-w').show();
			
		
	}	

}

function validateDomesticFlight(){
	var numericExpression = /^[0-9]+$/;
	var numericExpression1 = /^[0-9+]+$/;
	if(trimAll($('#firstname').val())==''){
		alert("Enter First Name");
		$('#firstname').focus();
		return false;
	
	}
	
	if(trimAll($('#surname').val())==''){
		alert("Enter Surname");
		$('#surname').focus();
		return false;
	
	}
	
	if(trimAll($('#country_code').val())==''){
		alert("Enter Country code");
		$('#country_code').focus();
		return false;
	
	}
	
	if(!$('#country_code').val().match(numericExpression) || $('#country_code').val().length < '2'){
		alert("Enter valid country code/Country code should be of min 2 digit");
		$('#country_code').focus();
		return false;
	}
	
	if(trimAll($('#phone_no').val())==''){
		alert("Enter Phone Number");
		$('#phone_no').focus();
		return false;
	
	}
	
	else if(!$('#phone_no').val().match(numericExpression) || $('#phone_no').val().length < '6'){
		alert("Enter valid phone number/Phone number should be of min 6 chars");
		$('#phone_no').focus();
		return false;
	}

	if(isValidEmail($("#email_address").val())==0){
		alert("Enter Valid Email Address");
		$('#email_address').focus();
		return false;
	}	
	
	if(trimAll($('#trip_security_code').val())==''){
		alert("Enter Code");
		$('#trip_security_code').focus();
		return false;	
	}
}

function validateInternationalFlight(){
	
	var numericExpression = /^[0-9+]+$/;
	if(trimAll($('#firstname').val())==''){
		alert("Enter First Name");
		$('#firstname').focus();
		return false;
	
	}
	
	if(trimAll($('#surname').val())==''){
		alert("Enter Surname");
		$('#surname').focus();
		return false;
	
	}
	if(trimAll($('#country_code').val())==''){
		alert("Enter Country Code");
		$('#country_code').focus();
		return false;
	
	}
	else if(!$('#country_code').val().match(numericExpression) || $('#country_code').val().length < '2'){
		alert("Enter valid Country Code/Country Code should be of min 2 digits");
		$('#country_code').focus();
		return false;
	}
	if(trimAll($('#phone_no').val())==''){
		alert("Enter Phone Number");
		$('#phone_no').focus();
		return false;
	
	}
	else if(!$('#phone_no').val().match(numericExpression) || $('#phone_no').val().length < '7'){
		alert("Enter valid phone number/Phone number should be of min 7 digits");
		$('#phone_no').focus();
		return false;
	}
	if(isValidEmail($("#email_address").val())==0){
		alert("Enter Valid Email Address");
		$('#email_address').focus();
		return false;
	}	
	
	if(trimAll($('#trip_security_code').val())==''){
		alert("Enter Code");
		$('#trip_security_code').focus();
		return false;	
	}
}

function changePriceContent(funcName, fieldName, packageId, currentId){
	$.ajax({
				type:"POST",
				cache: true,
				url:globalJSLiveURL+"/ajaxpages.php",
				data:{funcName:funcName, fieldName:fieldName, packageId:packageId},
									
				success: function(msg){
					$(".price-tab").removeClass("currentprice");
					$("#"+currentId).addClass("currentprice");
					$('#priceId').html(msg);	
					
				}
      });	
}

function validateMember(){
	if(trimAll($("#first_name").val())==''){
		alert('Enter First Name');
		$("#first_name").focus();
		return false;
		
	}
	if(trimAll($("#last_name").val())==''){
		alert('Enter Last Name');
		$("#last_name").focus();
		return false;
		
	}
	if(trimAll($("#dob").val())==''){
		alert('Enter Date of Birth');
		$("#dob").focus();
		return false;
		
	}
	if(trimAll($("#email_address").val())=='' || $("#email_address").val()=='Email'){
		alert('Enter email');
		$("#email_address").focus();
		return false;
		
	}
	if(isValidEmail($("#email_address").val())==0){
		alert("Enter Valid Email Address");
		$('#email_address').focus();
		return false;
	}
	
	if($("#country_id").val()=='-1'){
		alert('Select Country');
		$("#country_id").focus();
		return false;
		
	}
	
	if(trimAll($("#address").val())==''){
		alert('Enter Address');
		$("#address").focus();
		return false;
		
	}
	
	if(trimAll($('#country_code').val())==''){
		alert("Enter Country Code");
		$('#country_code').focus();
		return false;
	
	}
	else if(!$('#country_code').val().match(numericExpression) || $('#country_code').val().length < '2'){
		alert("Enter valid Country Code/Country Code should be of min 2 digits");
		$('#country_code').focus();
		return false;
	}
	
	if($("#phone_number").val()=='' || $("#phone_number").val()=='Phone No'){
		alert('Enter phone');
		$("#phone_number").focus();
		return false;
		
	}	
	else if(!$('#phone_number').val().match(numericExpression) || $('#phone_number').val().length < '7'){
		alert("Enter valid Phone Number/Phone Number should be of min 7 digits");
		$('#phone_number').focus();
		return false;
	}
		
	if(trimAll($('#trip_security_code').val())==''){
		alert("Enter Code");
		$('#trip_security_code').focus();
		return false;	
	}
	
}

function changeFlghtTo(funcName, cityFromId){
	$.ajax({
				type:"POST",
				url:globalJSLiveURL+"/ajaxpages.php",
				data:{funcName:funcName, cityFromId:cityFromId},
									
				success: function(msg){
					$("#flightTo").html(msg);					
				}
      });	

}
<!--END BY RAZAN -->
