function setupSearchForm() 
{
	clearOptions();
	populateCountryBox(countryString);
	populateRegionBox(0);
	populateInspirationBox(his);
}

function chosenCountry(selectBox)
{
	document.getElementById("regionlist").length = 0;
	populateRegionBox(selectBox.selectedIndex);
}

function populateCountryBox() 
{
	//Populates country dropdown with choices
	var countryArray = countryString.split("%")
	var countrySelectBox = document.getElementById("countrylist");
	
	//A default "any country" choice
	var newOption = document.createElement("option");
	newOption.value = "X";
	newOption.text = "Any country";
	try{countrySelectBox.add(newOption, null);}catch(ex){countrySelectBox.add(newOption);}//NB IE fix

	//Now go through each choice and add
	for(i=0; i<(countryArray.length-1); i++)
	{
		var thisOptionArray = countryArray[i].split("|");
		var newOption = document.createElement("option");
		newOption.value = thisOptionArray[1];
		newOption.text = thisOptionArray[0];
		try{countrySelectBox.add(newOption, null);}catch(ex){countrySelectBox.add(newOption);}//NB IE fix
	}
}

function populateRegionBox(newSelectedIndex)
{
	//Populates region dropdown with choices appropriate for the current selection
	var regionArray = regionString.split("#")
	var regionSelectBox = document.getElementById("regionlist");
	
	//A default "any region" choice
	var newOption = document.createElement("option");
	newOption.value = "X";
	newOption.text = "Any region";
	try{regionSelectBox.add(newOption, null);}catch(ex){regionSelectBox.add(newOption);}//NB IE fix

	if(newSelectedIndex != 0)	//If choice was zero then there are definitely no subregions
	{
		//Find regions to match this country
		for(i=0; i<regionArray.length; i++)
		{
			var thisCountriesRegions = regionArray[i].split("~");
			if(thisCountriesRegions[0] == newSelectedIndex)
			{
				var subRegions = thisCountriesRegions[1].split("%");
				for(c=0; c<(subRegions.length-1); c++)
				{
					var thisOptionArray = subRegions[c].split("|");
					var newOption = document.createElement("option");
					if(thisOptionArray[0]=="XXXX") break; //Abort if this region doesnt have a name
					newOption.value = thisOptionArray[1];
					newOption.text = thisOptionArray[0];
					try{regionSelectBox.add(newOption, null);}catch(ex){regionSelectBox.add(newOption);}//NB IE fix
				}
			} 
			else 
			{ 
				continue;
			}
		}
	}
}

function populateInspirationBox(isChoice) 
{
	//Populates inspiration/holidat type dropdown with choices
	var inspirationArray = isChoice.split("%")
	var inspirationSelectBox = document.getElementById("inspirationlist");
	inspirationSelectBox .length = 0;	

	//A default "any type" choice
	var newOption = document.createElement("option");
	newOption.value = "X";
	newOption.text = "Any type";
	try{inspirationSelectBox.add(newOption, null);}catch(ex){inspirationSelectBox.add(newOption);}//NB IE fix

	//Now go through each choice and add
	for(i=0; i<(inspirationArray.length-1); i++)
	{
		var thisOptionArray = inspirationArray[i].split("|");
		var newOption = document.createElement("option");
		newOption.value = thisOptionArray[1];
		newOption.text = thisOptionArray[0];
		try{inspirationSelectBox.add(newOption, null);}catch(ex){inspirationSelectBox.add(newOption);}//NB IE fix
	}
}

function clearOptions() 
{
	//Clears drop down lists of any options
	document.getElementById("countrylist").length = 0;
	document.getElementById("regionlist").length = 0;
	document.getElementById("inspirationlist").length = 0;
}

function submitOrderForm()
{
	document.resultsorderform.submit();
}

//Cheating: i need this on a few pages and know this JS is always included
function showPrint(url) {
	var openForm = window.open(url,'print', 'height=480,width=640,resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=no,status=no,directories=no');
	if(window.focus) openForm.focus();
}