var CityAreas = new Array ('Albrook', 'Altos Del Golf', 'Amador', 'Balboa Avenue', 'Bella Vista', 'Casco Viejo', 'Clayton', 'Coco Del Mar', 'Condado Del Rey', 'Costa Del Este', 'Costa Sur', 'El Cangrejo', 'El Carmen', 'El Dorado', 'La Cresta', 'La Loma', 'Marbella', 'Obarrio', 'Punta Pacifica', 'Punta Paitilla', 'San Francisco', 'Via Espana');
var CaribbeanAreas = new Array ('Bocas Del Toro', 'Caribbean Coast', 'Costa Abajo', 'La Guaira', 'Maria Chiquita', 'Nombre De Dios', 'Portobello');
var PacificAreas = new Array ('Cambutal', 'Corona', 'Coronado', 'Costa Esmeralda', 'Farallon', 'Gorgona', 'Juan Hombron', 'Las Tablas', 'Pedasi', 'Playa Blanca', 'Punta Barco', 'Punta Chame', 'Rio Mar', 'San Carlos', 'Santa Clara', 'Sea Cliff', 'Tonosi', 'Veracruz', 'Veraguas');
var MountainAreas = new Array ('Boquete', 'Capira', 'Cerro Azul', 'El Valle', 'Santa Fe', 'Sora', 'Volcan');

var ClassList = new Array ('House', 'Condo', 'Condo-hotel', 'Commerical', 'Homes & Condos');

var ExistingBedrooms = new Array ('Studio', '1 Br', '2 Br', '3 Br+');

var BuildingPricesLabel = new Array ('Less than $100K', '$101K-$250K', '$250K-$500K', '$500K-$1M', '$1M+');
var BuildingPricesValue = new Array ('0|100000', '100001|250000', '250001|500000', '500001|1000000', '1000000|10000000');
var LandPricesLabel = new Array ('Less than $100K', '$100K-$250K', '$250K-$500K', '$500K-$1M', '$1M-$5M', '$5M+');
var LandPricesValue = new Array ('0|100000', '100001|250000', '250001|500000', '500001|1000000', '1000000|5000000', '5000000|10000000');

var BuildingSizesLabel = new Array ('Less than 100 M2', '100 M2 TO 200 M2', '200 M2 TO 300 M2', '300 M2 MORE');
var BuildingSizesValue = new Array ('0|100', '100|200', '200|300', '300|40000');
var LandSizesLabel = new Array ('Less than 1 HEC', '1 HEC TO 5 HEC', '5 HEC TO 20 HEC', 'Over 20 HEC');
var LandSizesValue = new Array ('0|0.999', '1|4.999', '5|19.999', '20|40000');
var AllSizesLabel = new Array('Less than 100 M2', '100 M2 TO 200 M2', '200 M2 TO 300 M2', '300 M2 MORE', 'Less than 1 HEC', '1 HEC TO 5 HEC', '5 HEC TO 20 HEC', 'Over 20 HEC');
var AllSizesValue = new Array ('0|100', '100|200', '200|300', '300|40000', '0|0.999', '1|4.999', '5|19.999', '20|40000');

function setLocationArea() {
	var selectedArray = null;
	var idx = -1;
	var AreaList = document.getElementById("LocationAreas");
	var SelectedLocation = document.getElementById("PropertyLocation");
	var SelectedValue = SelectedLocation.options[SelectedLocation.selectedIndex].value;
	AreaList.disabled = false;

	// Remove the previous items
	for (idx = AreaList.options.length - 1; idx > 1; idx--) {
		AreaList.options[idx] = null;
	}

	// Find new items
	switch (SelectedValue) {
		case "Panama City":
			selectedArray = CityAreas;
			break;
		case "Caribbean Beach":
			selectedArray = CaribbeanAreas;
			break;
		case "Pacific Beach":
			selectedArray = PacificAreas;
			break;
		case "Mountain":
			selectedArray = MountainAreas;
			break;
		default:
			selectedArray = new Array();
			AreaList.disabled = true;
			break;
	}

	// Add the new items
	for (idx = 0; idx < selectedArray.length; idx++) {
		AreaList.options[idx + 2] = new Option(selectedArray[idx], selectedArray[idx]);
	}
}

function setClassList() {
	var BuildingList = document.getElementById("BuildingClass");
	var SelectedType = document.getElementById("PropertyType");
	var SelectedValue = SelectedType.options[SelectedType.selectedIndex].value;

	// Remove the previous items
	for (idx = BuildingList.options.length - 1; idx > 1; idx--) {
		BuildingList.options[idx] = null;
	}
	BuildingList.options[0].selected

	// Add the new items
	if (SelectedValue != "Land" && SelectedValue != "All" && SelectedValue != "") {
		BuildingList.disabled = false;
		for (idx = 0; idx < ClassList.length; idx++) {
			BuildingList.options[idx + 2] = new Option(ClassList[idx], ClassList[idx]);
		}
	}
	else
		BuildingList.disabled = true;
}


function setPrices() {
	var PriceList = document.getElementById("PriceRange");
	var SelectedType = document.getElementById("PropertyType");
	var SelectedValue = SelectedType.options[SelectedType.selectedIndex].value;
	var PriceLabel = null;
	var PriceValue = null;
	PriceList.disabled = false;

	// Remove the previous items
	for (idx = PriceList.options.length - 1; idx > 1; idx--) {
		PriceList.options[idx] = null;
	}

	// Add the new items
	switch(SelectedValue) {
		case "Land":
			PriceLabel = LandPricesLabel;
			PriceValue = LandPricesValue;
			break;
		case "All":
			PriceLabel = LandPricesLabel;
			PriceValue = LandPricesValue;
			break;
		case "":
			PriceLabel = new Array ();
			PriceValue = new Array ();
			PriceList.disabled = true;
			break;
		default:
			PriceLabel = BuildingPricesLabel;
			PriceValue = BuildingPricesValue;
			break;
	}

	for (idx = 0; idx < PriceLabel.length; idx++) {
		PriceList.options[idx + 2] = new Option(PriceLabel[idx], PriceValue[idx]);
	}
}


function setSize() {
	var SizeList = document.getElementById("SizeRange");
	var SelectedType = document.getElementById("PropertyType");
	var SelectedValue = SelectedType.options[SelectedType.selectedIndex].value;
	var SizeLabel = null;
	var SizeValue = null;
	SizeList.disabled = false;

	// Remove the previous items
	for (idx = SizeList.options.length - 1; idx > 1; idx--) {
		SizeList.options[idx] = null;
	}

	// Add the new items
	switch(SelectedValue) {
		case "Land":
			SizeLabel = LandSizesLabel;
			SizeValue = LandSizesValue;
			break;
		case "All":
			SizeLabel = AllSizesLabel;
			SizeValue = AllSizesValue;
			break;
		case "":
			SizeLabel = new Array ();
			SizeValue = new Array ();
			SizeList.disabled = true;
			break;
		default:
			SizeLabel = BuildingSizesLabel;
			SizeValue = BuildingSizesValue;
			break;
	}

	for (idx = 0; idx < SizeLabel.length; idx++) {
		SizeList.options[idx + 2] = new Option(SizeLabel[idx], SizeValue[idx]);
	}
}


function setBedrooms() {
	var StartBeds = document.getElementById("StartBeds");
	var SelectedType = document.getElementById("PropertyType");
	var SelectedValue = SelectedType.options[SelectedType.selectedIndex].value;

	// Remove the previous items
	for (idx = StartBeds.options.length - 1; idx > 1; idx--) {
		StartBeds.options[idx] = null;
	}

	// Add the new items
	if (SelectedValue == "Existing Property") {
		StartBeds.disabled = false;
		for (idx = 0; idx < ExistingBedrooms.length; idx++) {
			StartBeds.options[idx + 2] = new Option(ExistingBedrooms[idx], ExistingBedrooms[idx]);
		}
	}
	else {
		StartBeds.disabled = true;
	}
}

function setTypeDropDowns() {
	setClassList();
	setPrices();
	setSize();
	setBedrooms();
}

function sortResults(dropdown) {
	if (dropdown.options[dropdown.selectedIndex].value != "") {
		document.getElementById("sortform").submit();
	}
} 
 
 
