function PopulateLocations(locationContainer) {
	var myOptions = {
		"" : "Choose a location",	//Default state of location select
		"Location1" : "Cape Town",		// "value" & text - Text is displayed in select, value is used in function below to select the tours.
		"Location2" : "Johannesburg",
		"Location3" : "South Africa Safaris",
		"Location4" : "Zambia Safaris"
	}
	$.each(myOptions, function(index,option) {
		$(locationContainer).append(
			$('<option></option>').val(index).html(option)
		);
	});
}

function PopulateTours(location,tourContainer) {
	if (location != "")
	{
		$(tourContainer).attr("disabled",false);
		$(tourContainer).empty();
	
		var myOptions;
	
		switch (location)
		{
			case "Location1":
				myOptions = {
					"" : "Choose a tour/activity",
					"/html/tours/cpt/cape_point.asp" : "Cape Point Tour",
					"/html/tours/cpt/cape_safari.asp" : "Cape Town Safari",
					"/html/tours/cpt/addo2.asp" : "Garden Route Explorer",
					"/html/tours/cpt/addo.asp" : "Garden Route Weekend",
					"/html/tours/cpt/kloofing.asp" : "Kloofing",
					"/html/tours/cpt/paragliding.asp" : "Paragliding",
					"/html/tours/cpt/sandboarding.asp" : "Sandboarding",
					"/html/tours/cpt/skeleton_gorge.asp" : "Skeleton Gorge Hike",
					"/html/tours/cpt/abseil.asp" : "Table Mountain Abseil",
					"/html/tours/cpt/shark_diving.asp" : "Shark Cage Diving",
					"/html/tours/cpt/winelands.asp" : "Winelands Tour"
				}
			break;
			case "Location2":
				myOptions = {
					"" : "Choose a tour/activity",
					"/html/tours/jhb/kruger.asp" : "Kruger National Park",
					"/html/tours/jhb/kruger-budget.asp" : "Kruger National Park (budget)",
					"/html/tours/jhb/pilanesberg.asp" : "Pilanesberg Game Reserve",
					"/html/tours/jhb/soweto.asp" : "Soweto Tour",
					"/html/tours/jhb/sun_city.asp" : "Sun City"
				}
				break;
			case "Location3":
			myOptions = {
					"" : "Choose a tour/activity",
					"/html/safaris/sa/hluhluwe.asp" : "Hluhluwe Game Reserve",
					"/html/safaris/sa/kruger.asp" : "Kruger National Park",
					"/html/safaris/sa/kruger-budget.asp" : "Kruger National Park (budget)",					
					"/html/safaris/sa/pilanesberg.asp" : "Pilanesberg Game Reserve"
				}
				break;
			case "Location4":
			myOptions = {
					"" : "Choose a tour/activity",
					"/html/safaris/zambia/canoe1.asp" : "Canoe Safari, 5 in 1 Zambezi River Run",
					"/html/safaris/zambia/canoe2.asp" : "Canoe Safari, Lower Zambezi 2 night/3 day",
					"/html/safaris/zambia/canoe3.asp" : "Canoe Safari, The Island Trail",					
					"/html/safaris/zambia/chobe1.asp" : "Chobe and Livingstone Budget Safari",
					"/html/safaris/zambia/chobe2.asp" : "Chobe and Victoria Falls Budget Safari",
					"/html/safaris/zambia/chobe3.asp" : "Chobe and Victoria Falls Comfort Safari",
					"/html/safaris/zambia/kafue.asp" : "Kafue National Park 3 night/4 day Safari",
					"/html/safaris/zambia/lower_zambezi.asp" : "Lower Zambezi 3 night/4 day Safari",
					"/html/safaris/zambia/luangwa1.asp" : "Luangwa Deluxe, 5 day all inclusive Safari",
					"/html/safaris/zambia/luangwa2.asp" : "Luangwa Quick and Easy, 3 day all inclusive Safari",
					"/html/safaris/zambia/luangwa3.asp" : "Luangwa Special, 4 day all inclusive Safari",
					"/html/safaris/zambia/luangwa4.asp" : "Taste of Luangwa, 3 day all inclusive Safari"
				}
				break;
		}
		$.each(myOptions, function(index,option) {
			$(tourContainer).append(
			$('<option></option>').val(index).html(option)
			);
		});
	}
	else
	{
		$(tourContainer).attr("disabled",true);
		$(tourContainer).empty();
		$(tourContainer).append($('<option></option>').val("").html("..."));	//Default state of tour select
	}
}

$(document).ready(function() {
   PopulateLocations("#selLocation");
   PopulateTours("","#selTours");

  //Wire up Dropdown change functions
  $("#selLocation").change(function() { PopulateTours($("#selLocation").val(),"#selTours"); });
  $("#selTours").change(function() { if ($("#selTours").val() != "") window.location = $("#selTours").val(); });

});
