var country2 = new Object();country2[0] = ["Africa>Gansbaai", "73"];
country2[1] = ["Austria>Kleinwalsertal", "68"];
country2[2] = ["Bulgaria>Black Sea", "36"];
country2[3] = ["Bulgaria>Varna", "83"];
country2[4] = ["Canary Islands>Fuerteventura", "4"];
country2[5] = ["Canary Islands>Gran Canaria", "2"];
country2[6] = ["Canary Islands>La Gomera", "6"];
country2[7] = ["Canary Islands>La Palma", "88"];
country2[8] = ["Canary Islands>Lanzarote", "3"];
country2[9] = ["Canary Islands>Tenerife", "1"];
country2[10] = ["Cape Verde>Sal", "7"];
country2[11] = ["Cape Verde>Santiago", "8"];
country2[12] = ["Cape Verde>Sao Vincent", "9"];
country2[13] = ["Caribbean>ALL", "79"];
country2[14] = ["Caribbean>Bahamas", "76"];
country2[15] = ["Costa Rica>Sabana Norte", "29"];
country2[16] = ["Costa Rica>San Jose", "32"];
country2[17] = ["Costa Rica>Tamarindo", "28"];
country2[18] = ["Costa Rica>Tambor", "27"];
country2[19] = ["Croatia>ALL", "81"];
country2[20] = ["Cuba>ALL", "56"];
country2[21] = ["Cuba>Cayo Largo del Sur", "15"];
country2[22] = ["Cuba>Havana", "16"];
country2[23] = ["Cuba>Varadero", "23"];
country2[24] = ["Cyprus>ALL", "77"];
country2[25] = ["Czech Republic>ALL", "62"];
country2[26] = ["Dominican Republic>All", "17"];
country2[27] = ["Ecuador>Guayas", "33"];
country2[28] = ["Ecuador>Salinas", "34"];
country2[29] = ["France>ALL", "80"];
country2[30] = ["Greece>ALL", "86"];
country2[31] = ["Greece>Crete", "64"];
country2[32] = ["Greece>Rhodes", "78"];
country2[33] = ["Italy>All", "82"];
country2[34] = ["Italy>Naples", "74"];
country2[35] = ["JAMAICA>Saint Ann", "70"];
country2[36] = ["Madeira>All", "75"];
country2[37] = ["Mexico>All", "22"];
country2[38] = ["Morocco>Agadir", "41"];
country2[39] = ["Morocco>Marrakech", "39"];
country2[40] = ["Morocco>Saidia", "40"];
country2[41] = ["Nicaragua>Montelimar", "53"];
country2[42] = ["Nicaragua>Playa Montelimar", "52"];
country2[43] = ["Portugal>Algarve", "42"];
country2[44] = ["Portugal>Lisbon", "46"];
country2[45] = ["Portugal>Madeira", "72"];
country2[46] = ["Spain>ALICANTE", "58"];
country2[47] = ["Spain>Barcelona", "85"];
country2[48] = ["Spain>Cadiz", "66"];
country2[49] = ["Spain>Costa  De Almeria", "21"];
country2[50] = ["Spain>Costa Blanca", "20"];
country2[51] = ["Spain>Costa Brava", "89"];
country2[52] = ["Spain>Costa Calida", "24"];
country2[53] = ["Spain>Costa De Azahar", "87"];
country2[54] = ["Spain>Costa de La luz", "19"];
country2[55] = ["Spain>Costa Del Sol", "18"];
country2[56] = ["Spain>Granada", "50"];
country2[57] = ["Spain>Huesca", "49"];
country2[58] = ["Spain>Ibiza", "25"];
country2[59] = ["Spain>Madrid", "61"];
country2[60] = ["Spain>Majorca", "10"];
country2[61] = ["Spain>Malaga", "71"];
country2[62] = ["Spain>Menorca", "11"];
country2[63] = ["Spain>Murcia", "69"];
country2[64] = ["Spain>San Sebastian", "60"];
country2[65] = ["Spain>Valencia ", "84"];
country2[66] = ["Spain>Vitoria", "59"];
country2[67] = ["Tunisia>Djerba", "14"];
country2[68] = ["Tunisia>Gammarth", "37"];
country2[69] = ["Tunisia>Hammamet", "12"];
country2[70] = ["Tunisia>Mahdia", "48"];
country2[71] = ["Tunisia>Monastir", "47"];
country2[72] = ["Tunisia>Port El Kantaoui", "26"];
country2[73] = ["Tunisia>Skanes", "13"];
country2[74] = ["Tunisia>Tabarka", "54"];
country2[75] = ["Tunisia>Tabarka", "55"];
country2[76] = ["Turkey>Antalya", "38"];
country2[77] = ["Uruquay>Punta De Este", "30"];
country2[78] = ["Uruquay>Salto", "31"];

function selectMe(location) {

	for (i=0;i<country.length;i++) {
	
		if (country[i] == location) {
			document.coun_Sel.countries.selectedIndex = country[i+1];	
		}
	}

}

function init(def) {
	//test if browser can handle delete/create options.
	optionTest = true;
	lgth = document.coun_Sel.regions.options.length - 1;
	//document.coun_Sel.regions.options[lgth] = null;
	if (document.coun_Sel.regions.options[lgth]){ optionTest = false};
	//make select boxes from arrays.
	makeSelect("countries",country2, def);
		if (def != 0){
	//populateRegions();
	 } else {

	}

}

function getAreaHotel(){

	frm = document.forms.coun_Sel;
	regionvalue = frm.elements['countries'].value;

	getAreas(regionvalue);
	getHotelsByRegion(regionvalue);

}

function getAreas(theArea) {
	try{
	url="/getAreas.php?region="+theArea;
	xmlhttp.open("GET",url,true);
	  
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			var area2 = new Function("return "+xmlhttp.responseText)();
			populateAreas(area2);
		}
	}
	
	xmlhttp.setRequestHeader('Accept','message/x-formresult');
	xmlhttp.send(null);
	} catch(e){}
return false;
}

function getHotelsByRegion(theRegion) {
	try{
	url="/getHotels.php?region="+theRegion;
	xmlhttp2.open("GET",url,true);
	  
	xmlhttp2.onreadystatechange=function() {
		if (xmlhttp2.readyState==4) {
			var hotels = new Function("return "+xmlhttp2.responseText)();
			populateHotels(hotels);
		}
	}
	
	xmlhttp2.setRequestHeader('Accept','message/x-formresult');
	xmlhttp2.send(null);
	} catch (e){}
return false;
}

function getHotelsByArea() {
	try{
    	frm = document.coun_Sel;
    } catch(e){
    	frm=document.forms[0];
    }
	url="/getHotelsArea.php?area="+frm.elements['area'].value;
	xmlhttp.open("GET",url,true);
	  
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			var hotels = new Function("return "+xmlhttp.responseText)();
			populateHotels(hotels);
		}
	}
	
	xmlhttp.setRequestHeader('Accept','message/x-formresult');
	xmlhttp.send(null);
return false;
}

function makeSelect(formName,arrayName, def){
	//make select box from a given array and form select name.
	var form = document.coun_Sel.elements[formName];
	form.options.length = 0;
	var x =0;
	var y = 1;
	form.options[0] = new Option('--Select--','');
	//for(i=1;i<arrayName.length;i+=3) {
	//form.options[y] = new Option(arrayName[x],arrayName[x+1])
	//x = x+3;
	//y ++;
	for (index in arrayName){
		form.options[y] = new Option(arrayName[index][0],arrayName[index][1]);
		if (arrayName[index][1] == def) {	
			form.options.selectedIndex=y;
		}
		y++;
	}
}

function makeMultipleSelect(formName,arrayName, searchNo,seletedItem){
	//make a select box from a given array and multiple indexed arrays.
	var form = document.coun_Sel.elements[formName];
	form.options.length = 0;
	var x =1;
	form.options[0] = new Option('--All--','');

	if (typeof(searchNo) == 'object'){
		tempArray1 = new Array();
		tempArray2 = new Array();
		var y = 0;
		for(x=0; x<searchNo.length; x++){
				for (index in arrayName){
					if (arrayName[index][1] == searchNo[x]){
						tempArray1[y] = arrayName[index][0];
						tempArray2[y] = arrayName[index][2];
						y++;
					}
				}
		}
		quicksort(tempArray1, tempArray2);
		y = 1;
		for(x=0; x<tempArray1.length;x++){
			form.options[y] = new Option(tempArray1[x],tempArray2[x]);
			y++;
		}
		
	} else {
		var y = 1;
		for (index in arrayName){
			if (arrayName[index][1] == searchNo || searchNo == 0){
				form.options[y] = new Option(arrayName[index][0], arrayName[index][2]);
				if (arrayName[index][2] == seletedItem){
					form.options.selectedIndex=y;
				}
				y++;
			}	
		}
	}
}

function populateRegions(){
	//if country is selected show only country regions.
	if (!optionTest) return;
	var box = document.coun_Sel.countries;
	var number = box.options[box.selectedIndex].value;
	if (number == 0){
		//init(0);
		var form = document.coun_Sel.elements['regions'];
		form.options.length = 0;
		document.coun_Sel.elements['regions'].options[0] = new Option('--All--','');
		return;
	}else{

	makeMultipleSelect("regions",region2,number,0);
}
}

function populateAreas(areas){

	var form = document.coun_Sel.elements['area'];
	form.options.length = 0;
	
	y = 1;
	form.options[0] = new Option('--All--', '');
	for(x=0; x < areas.length; x++){
		form.options[y] = new Option(areas[x].areaName, areas[x].areaID);
		y++;
	}
}

function populateHotels(hotels){

	var form = document.coun_Sel.elements['regions'];
	form.options.length = 0;
	
	y = 1;
	form.options[0] = new Option('--All--', '');
	for(x=0; x < hotels.length; x++){
		form.options[y] = new Option(hotels[x].hotelName, hotels[x].hotelID);
		y++;
	}
}


function selectOption(location) {

		for (i=0;i<country.length;i++) {
		(country[i] == location) ? document.coun_Sel.country.value = country[i+1] : "";
		}

	
}

function associateLocation() {
//capture data find ids from array indices add them into the hidden field and submit the form
	if (document.coun_Sel.countries.value!=""){
		for (i=0;i<country.length;i++) {
		(country[i] == document.coun_Sel.countries.value) ? document.coun_Sel.country.value = country[i+1] : "";
		}
	}
	
	var regions = document.coun_Sel.regions.value;
	if (regions !=""){
		for (y=1;y<region.length;y++) {
			for (x=0;x<region[y].length;x++) {
			(region[y][x] == regions) ? document.coun_Sel.region.value = region[y][x+1] : "";
			}
		}
	}
	

document.coun_Sel.action = "results.php";
document.coun_Sel.submit();
}



<!--
//function refresh()
//{
//document.coun_Sel.action="";
//document.coun_Sel.submitted.value="false"
//document.coun_Sel.submit();
//}


function SelectOptionInList( lstSelectList, intID ){
	  try
	  {
		   var intIndex = 0;
		   // Loop through all the options
		   for( intIndex = 0; intIndex < lstSelectList.options.length; intIndex++ )
		   {
				// Is this the ID we are looking for?
				if( lstSelectList.options[intIndex].value == intID )
				{
					 // Select it
					 lstSelectList.selectedIndex = intIndex;
					 // Yes, so stop searching
					 break;
				}
		   }
		refresh();
	  }
	  catch( expError )
	  {
		   alert( "ClientUtilities1.js::SelectOptionInList( ).\n" +
					 "Error:" + expError.number + ", " + expError.description );
	  }
} // SelectOptionInList

function setSession()
{
document.currency.submit();
}

function _quicksort (a, a2, lo, hi) {
//  lo is the lower index, hi is the upper index
//  of the region of array a that is to be sorted
   var i=lo, j=hi, h, h2;
   var x=a[Math.floor((lo+hi)/2)];

   //  partition
   do
   {
       while (a[i].toString() < x.toString()) i++;
       while (a[j].toString() > x.toString()) j--;
       if (i<=j)
       {
           h=a[i]; a[i]=a[j]; a[j]=h;
		   h2=a2[i]; a2[i]=a2[j]; a2[j]=h2;
           i++; j--;
       }
   } while (i<=j);

   //  recursion
   if (lo<j) _quicksort(a, a2, lo, j);
   if (i<hi) _quicksort(a, a2, i, hi);
}

function quicksort(a, a2) {
    _quicksort(a, a2, 0, a.length - 1);
}

var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp=false;
  }
 }
@else
 xmlhttp=false
 @end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

var xmlhttp2
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp2=new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
    xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp2=false;
  }
 }
@else
 xmlhttp2=false
 @end @*/
if (!xmlhttp2 && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp2 = new XMLHttpRequest();
	} catch (e) {
		xmlhttp2=false;
	}
}
if (!xmlhttp2 && window.createRequest) {
	try {
		xmlhttp2 = window.createRequest();
	} catch (e) {
		xmlhttp2=false;
	}
}
