   
   var WayPointLog =  new Array();
   var CountryIndex = -1;
   var LocationIndex = -1;
   
	
	function LoadWaypointPullDowns(WayPointLogIN){
		WayPointLog = WayPointLogIN;
		//alert(WayPointLog);
		var OutText = "<form name=\"WayPointform\" id=\"WayPointform\">";
		
		OutText =  OutText + CreateWayPointCountryPullDown();
		
		OutText =  OutText + " </form>\n";
		document.getElementById("WayPointData").innerHTML = OutText;
	}
	
	function CreateWayPointCountryPullDown(){
		var OutText = "";
		
			OutText = "<font face=\"Verdana,Arial,Helvetica,sans-serif\" size=\"2\" color=\"ffffff\"><B>Display Waypoints:</B></font><select name=\"Countries\" onchange=\"SelectCountry(this)\">\n";
			OutText = OutText + "<option";
			if(CountryIndex == 0 ){ 
				OutText = OutText + " SELECTED";
			}
			OutText = OutText + " value=\"-1\">Select a Country ....</option>\n";
			for(var i = 0;i<=WayPointLog.length-1;i++){
			
				OutText = OutText + "<option";
				if(CountryIndex == i){ 
					OutText = OutText + " SELECTED";
				}
				OutText = OutText + " value=\"" + i + "\">" + WayPointLog[i][0] + "</option>\n" + i + "\n";
			}
			OutText = OutText + "</select>\n";
		
		return OutText;
	}


function SelectCountry(SelectList){

	//alert(SelectList[SelectList.selectedIndex].value);
	var NewArray = new Array();
	LocationIndex = -1 // Set the location back to nothing 
	CountryIndex = SelectList[SelectList.selectedIndex].value;
	var OutText = "<form name=\"WayPointform\" id=\"WayPointform\">";
		
	OutText =  OutText + CreateWayPointCountryPullDown();
	if(CountryIndex >= 0 ){
		NewArray = WayPointLog[CountryIndex][1];
	
		OutText =  OutText + CreateWayPointLocationPullDown(NewArray);
	}
	//alert(OutText);
	OutText =  OutText + " </form>\n";
	
	document.getElementById("WayPointData").innerHTML = OutText;
	document.getElementById("WayPointList").innerHTML = "";	
}

function CreateWayPointLocationPullDown(LoctionArray){
		var OutText = "";
		
			OutText = "<select name=\"Locations\" onchange=\"SelectLocation(this)\">\n";
			OutText = OutText + "<option";
			if(LocationIndex == 0 ){ 
				OutText = OutText + " SELECTED";
			}
			OutText = OutText + " value=\"-1\">Select a Location ....</option>\n";
			
			for(var i = 0;i<=LoctionArray.length-1;i = i+2){
			
				OutText = OutText + "<option";
				if(LocationIndex == i){ 
					OutText = OutText + " SELECTED";
				}
				OutText = OutText + " value=\"" + i + "\">" + LoctionArray[i] + "</option>\n" + i + "\n";
			}
			OutText = OutText + "<option";
			if(LocationIndex == "ALL" ){ 
				OutText = OutText + " SELECTED";
			}
			OutText = OutText + " value=\"ALL\">Display all areas on a single page ....</option>\n";
			OutText = OutText + "</select>\n";
		
		return OutText;
}

