/**

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.island.options.length - 1;
  document.coun_Sel.island.options[lgth] = null;
  if(document.coun_Sel.island.options[lgth]) optionTest = false;
  
  generateIslands();
  
  return true;
/**
	//make select boxes from arrays.
	makeSelect("countries",country2, def);
		if(def != 0) {
  	populateRegions();
  	populateAreas();
  } else {
  	  	makeMultipleSelect("islands","islands", 0, 0);
  	makeMultipleSelect("areas","areas", 0, 0);
	}
	**/
}

function generateIslands() {
  var island= document.coun_Sel.elements["island"];
  island.options[0]= new Option('Any', '0', true);
island.options[1]= new Option('Tenerife', '1', false);
  generateAreas();
}

var arrArea= new Array();

arrArea[0]= ["Callao Salvaje", "75", "1"];
arrArea[1]= ["Fañabe", "57", "1"];
arrArea[2]= ["Las Americas", "61", "1"];
arrArea[3]= ["Los Cristianos", "49", "1"];
arrArea[4]= ["San Eugenio", "59", "1"];
arrArea[5]= ["San Eugenio Alto", "68", "1"];
arrArea[6]= ["Torviscas", "55", "1"];
arrArea[7]= ["Torviscas Alto", "24", "1"];

function generateAreas() {
  var selectedIndex = document.coun_Sel.island.selectedIndex;

  var selected= document.coun_Sel.island.options[selectedIndex].value;

	document.coun_Sel.area.options.length= 0;
	area= document.coun_Sel.elements["area"];

	var areaSelected= 0;

	var j= 0;  // number of option element

  area.options[j]= new Option('Any','0', (areaSelected== 0 ? true : false));
  for(i= 0; i< arrArea.length; i++) {
    if(selected== arrArea[i][2]) {
      j++;
      area.options[j]= new Option(arrArea[i][0],arrArea[i][1], (areaSelected== arrArea[i][1] ? true : 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('--All--','');
	//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);
		return;
	}
	//if (!number) return;
	//var list = region[number];
	makeMultipleSelect("regions",region2,number,0);
}

function populateAreas(){
	//if country or country and region selected populate areas.
	if (!optionTest) return;
	var box = document.coun_Sel.countries;
	var number = box.options[box.selectedIndex].value;
	var box2 = document.coun_Sel.regions;
	var number2 = box2.options[box2.selectedIndex].value;
	
	if (number == ''){
		makeMultipleSelect("regions",region2, 0);
		makeMultipleSelect("areas",area2, 0);
	} else if (number2 == '' && number != ''){
		
		//var box3 = document.coun_Sel.areas
		//box3.options.length = 0;
		//box3.options[0] = new Option('--All--','');
		var y = 0;
		var regionsArray = new Array();
		for (index in region2){
			if (region2[index][1] == number){
				regionsArray[y] = region2[index][2];
				y++;	
			}
		}
		makeMultipleSelect("areas",area2,regionsArray,0);
	} else {
		makeMultipleSelect("areas", area2, number2,0);
	}	
	
}



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] : "";
			}
		}
	}
	
	var areas = document.coun_Sel.areas.value;
	if (areas !=""){
		for (y=1;y<area.length;y++) {
			for (x=0;x<area[y].length;x++) {
			(area[y][x] == areas) ? document.coun_Sel.area.value = area[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);
}

**/