	function load()
	{
		
		var cnt = document.all.Country.value;
		var arp = document.all.hAirport.value;
		var dst = document.all.hDestination.value;
		fillAirports(cnt);
		document.all.Airport.value=arp;
		fillDestinations(arp);
		document.all.Destination.value=dst;
	}

	function fillAirports(cnt)
	{
		var cnt1=cnt
		var i=1;
		document.all.Airport.options.length=1;
		for(var counter=0; counter<document.all.AirportTemplate.options.length; counter++)
		{
			if(document.all.AirportTemplate.options[counter].getAttribute("CountryID")==cnt)
			{
				document.all.Airport.options[i] = new Option();
				document.all.Airport.options[i].setAttribute("text",document.all.AirportTemplate.options[counter].getAttribute("text"));
				document.all.Airport.options[i].setAttribute("value",document.all.AirportTemplate.options[counter].getAttribute("value"));
				document.all.Airport.options[i].setAttribute("CountryID",cnt);
				i+=1;
			}
		}
		cleanPrice()
	}
function fillDestinations(arp)
	{
		if(document.all.hAirport)
			document.all.hAirport.value=arp;
		var arp1=arp;
		var i=1;
		document.all.Destination.options.length=1;
		for(var counter=0; counter<document.all.DestinationTemplate.options.length; counter++)
		{
			if(document.all.DestinationTemplate.options[counter].getAttribute("AirportID")==arp)
			{
				
				document.all.Destination.options[i] = new Option();
				document.all.Destination.options[i].setAttribute("text",document.all.DestinationTemplate.options[counter].getAttribute("text"));
				document.all.Destination.options[i].setAttribute("value",document.all.DestinationTemplate.options[counter].getAttribute("value"));
				document.all.Destination.options[i].setAttribute("AirportID",arp);
				i+=1;
			}
		}
		cleanPrice();
	}
function setDestination(dst)
{
	document.all.hDestination.value=dst;
	cleanPrice()
}
function cleanPrice()
{
	if(document.all.getPrice)
	{
		document.all.getPrice.disabled=false;
		document.all.Price.value="-1";
	}
}


function isValidDate(dateStr) {
// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
// Also separates date into month, day, and year variables
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

// To require a 4 digit year entry, use this line instead:
// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null) {
//alert("Date is not in a valid format.")
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if(new Date(year,month,day)<new Date())
	return false;
if (month < 1 || month > 12) { // check month range
//alert("Month must be between 1 and 12.");
return false;
}
if (day < 1 || day > 31) {
//alert("Day must be between 1 and 31.");
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
//alert("Month "+month+" doesn't have 31 days!")
return false
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
//alert("February " + year + " doesn't have " + day + " days!");
return false;
   }
}
return true;  // date is valid
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}

function ValidPhone(aphone)
{
// declare valid variable as a string with all valid characters (digits from 0 to 9 )
    var valid = "0123456789-";
        
         for (var i=0; i < aphone.length; i++)
         {
         //put in temp variable each character, one at a time.
         temp = "" + aphone.substring(i, i+1);

         if (valid.indexOf(temp) == "-1") 
         {
          return false;
         }
    }
    //if all conditions are passed, then return true
    return true
}

function InvalidText(atext)
{
// declare valid variable as a string with all valid characters (digits from 0 to 9 )
    var invalid = "<>%";
        
         for (var i=0; i < atext.length; i++)
         {
         //put in temp variable each character, one at a time.
         temp = "" + atext.substring(i, i+1);

         if (invalid.indexOf(temp) != "-1") 
         {
          return false;
         }
    }
    //if all conditions are passed, then return true
    return true
}

