				function GetMin()
        {
            /*
             * Extracts the min from the Query String, if given
             */
 
            var args = getQueryString();
            if (args['min'] != undefined)
            {
                return args['min'];
            } else {
                return 0;
            }
        }
        
        function GetMax()
        {
            /*
             * Extracts the max from the Query String, if given
             */

            var args = getQueryString();
            if (args['max'] != undefined)
            {
                return args['max'];
            } else {
                return 0;
            }
        } 

        function getQueryString() 
        {
            /*
             * Gets the Query String parameters as an array of key/value pairs
             */
             
            var args = new Object();
            var query = location.search.substring(1);
            var pairs = query.split("&");
            
            for (var i = 0; i < pairs.length; i++) 
            {
                var pos = pairs[i].indexOf('=');
                if (pos == -1) continue;
                    var argname = pairs[i].substring(0,pos);
                    var value = pairs[i].substring(pos+1);
                args[argname] = unescape(value);
            }            
            return args;
        }


function posted_back() {
	// DEBUGGING
	strForm = '';
	for(i=0; i<document.post_back_form.elements.length; i++)	{
		strForm = strForm + 'The field name is: ' + document.post_back_form.elements[i].name + ' and it's value is: ' + document.post_back_form.elements[i].value + '\n';
	}
	alert(strForm); 
	return true;
}
function airport_changed() {
/* DEPARTURE AIRPORT CHANGED. POPULATE POST BACK FROM WITH DEPARTURE AIRPORT ID AND 
   SUBMIT BACK TO THIS SCRIPT. */
	if (document.forms.search_form.airportID.selectedIndex > 0) {	

		document.forms.post_back_form.airportID.value = document.forms.search_form.airportID.value;

document.forms.post_back_form.action = "index.asp?min=" + GetMin() + "&max=" + GetMax();

		document.forms.post_back_form.submit();
	}
}
function country_changed() {
/* DESTINATION CHANGED. POPULATE POST BACK FROM WITH COUNTRY ID AND 
   SUBMIT BACK TO THIS SCRIPT. */
	if (document.forms.search_form.countryID.selectedIndex > 0) {
		document.forms.post_back_form.countryID.value = document.forms.search_form.countryID.value;
document.forms.post_back_form.action = "index.asp?min=" + GetMin() + "&max=" + GetMax();
		//posted_back();
		document.forms.post_back_form.submit();
	}
	else {

	}

}
function region_changed() {
/* REGION CHANGED. POPULATE POST BACK FROM WITH REGION ID AND 
 SUBMIT BACK TO THIS SCRIPT. */
	if (document.forms.search_form.regionID.selectedIndex > 0) {
		document.forms.post_back_form.countryID.value = document.forms.search_form.countryID.value;
		document.forms.post_back_form.regionID.value = document.forms.search_form.regionID.value;
document.forms.post_back_form.action = "index.asp?min=" + GetMin() + "&max=" + GetMax();
		//posted_back();
		document.forms.post_back_form.submit();
	}
}
function search_form_valid() {
/*	CONFIGURE SEARCES, CHECK VALUES, REMOVE FORM FIELD THAT WOULD INTERFERE WITH SUBMITTED POST TO HD WBESITE
	ONLINE SEARCH ENGINE. */
	


	// ENSURE A REGION HAS BEEN SELECTED.
	if ((document.forms.search_form.regionID.value == '') || (document.forms.search_form.depair.value == '')) {
	alert("Please complete all fields:\nTo, Region and From")
		return false;
	}

	// Determine whether to use the region's airport code or the country's airport code.
	// Currently defaults to region above as its compulsory.
	//
	if (document.forms.search_form.regionID.value != '') {		
		// Region was selected. Set 'destair' to the region's airport code.
		var arrTemp = document.forms.search_form.regionID.value.split('|');
		document.forms.search_form.destair.value = arrTemp[0];
	}
	else {
		// NO REGION WAS SELECTED. USE Country.
		
		document.forms.search_form.destair.value = document.forms.search_form.countryID.value;		
	}
	
	// GET RID OF UNREQUIRED FORM FIELDS NOT RELEVANT TO SEARCH ENGINE
	document.forms.search_form.countryID.disabled = true;
	document.forms.search_form.regionID.disabled = true;
	SetDepDateMonthYear();
	// DEBUGGING
	strForm = '';
	for(i=0; i<document.search_form.elements.length; i++)	{
		strForm = strForm + 'The field name is: ' + document.search_form.elements[i].name + ' and it's value is: ' + document.search_form.elements[i].value + '\n';
	}
	//alert(strForm); 
	//return false;

	// SUBMIT TO SEARCH ENGINE
	
/*	if (document.forms.search_form.destair.value == '') {
	alert("Please select a destination")
	}
	else if (document.forms.search_form.depair.value == '') {
	alert("Please select a departure point")
	}
	else if (document.forms.search_form.regionID.value == '') {
	alert("Please select a region")	*/
	
	return true;
}

	//This function was written to store the departure date in depday
    //and to store the month and year to depmonthyear
    //This is done so that the calendar control does not change the
    //way the pages that use the date were working before adding the calendar control
    function SetDepDateMonthYear()
    {                                                
        var SelectedDate = document.getElementById('txtCalendarCtrl').value;
        var depday = SelectedDate.substring(0,2);
        document.getElementById('depday').value = depday;
        var depmonthyear = SelectedDate.substring(3,SelectedDate.length);                                            
        depmonthyear = depmonthyear.replace('/','_');
        document.getElementById('depmonthyear').value = depmonthyear;
    }