function loadLocations() {
	var url = "functions/populate-search-fields.html";
	var params = "type=" + escape($F("type"));
	var ajax = new Ajax.Request(url,{method:"post",parameters:params,onSuccess:populateLocations});
}
function loadPrices() {
	var url = "functions/populate-search-fields.html";
	var params = "type=" + escape($F("type")) + "&location=" + escape($F("location"));
	var ajax = new Ajax.Request(url,{method : "post",parameters:params,onSuccess:populatePrices});	
}
function populateLocations() {
	$("location").options.length = 0;
	$("price").options.length = 0;
	var values = arguments[0].responseText.split(",");
	var options = $("location").options;
	$("location").options[0] = new Option("Select Next","Select Next");
	$("location").options[1] = new Option("All Locations","All Locations");
	for(var i = 0; i < values.length; i++) {
		if(values[i] != '') {
			options[options.length] = new Option(values[i],values[i]);
		}
	}
}
function populatePrices() {
	$("price").options.length = 0;
	var values = arguments[0].responseText.split(",");
	var options = $("price").options;
	$("price").options[0] = new Option("Select Next","Select Next");
	$("price").options[1] = new Option("All Prices","All Prices");
	for(var i = 0; i < values.length; i++) {
		if(values[i] != '') {
			options[options.length] = new Option(values[i],values[i]);
		}
	}
}
function unloadAllOptions() {
	$("location").options.length = 0;
	$("price").options.length = 0;
}
function toggleSubmitValue() {
	if($("type").options.selectedIndex == 1 || $("location").options.selectedIndex == 1 || $("price").options.selectedIndex == 1) {
		$("submit").value = "Search";
	} else {
		$("submit").value = "View";
	}
}
function validateSelections() {
	if($("type").options.selectedIndex == 0) {
		$("search").style.height = "280px";
		$("spotlight").style.height = "280px";
		$("error").innerHTML = "<p class=\"error\">Please select a Type first.</p>";
		return false;
	} else if($("type").options.selectedIndex == 0 && $("location").options.selectedIndex == 0) {
		$("search").style.height = "280px";
		$("spotlight").style.height = "280px";
		$("error").innerHTML = "<p class=\"error\">Please select a Type and Location.</p>";
		return false;
	} else if($("location").options.selectedIndex == 0) {
		$("search").style.height = "280px";
		$("spotlight").style.height = "280px";
		$("error").innerHTML = "<p class=\"error\">Please select a Location.</p>";
		return false;
	} else if($("type").options.selectedIndex == 0 && $("location").options.selectedIndex == 0 && $("price").options.selectedIndex == 0) {
		$("search").style.height = "280px";
		$("spotlight").style.height = "280px";
		$("error").innerHTML = "<p class=\"error\">Please select a Type, Location and Price.</p>";
		return false;
	} else if($("price").options.selectedIndex == 0) {
		$("search").style.height = "280px";
		$("spotlight").style.height = "280px";
		$("error").innerHTML = "<p class=\"error\">Please select a Price.</p>";
		return false;
	}
	return true;
}