//***********************************************
// Dynamic Population of Select Objects
// Author: Randy L. Taylor
// Copyright 2005
//
// May be freely used
//***********************************************

var COUNTRY = new Array
(
 {"value" : "0", "innerText" : "Select Country"},
 {"value" : "1", "innerText" : "Argentina"},
 {"value" : "Australi", "innerText" : "Australia"},
 {"value" : "Brazi", "innerText" : "Brazil"},
 {"value" : "Czech Republi", "innerText" : "Czech Republic"},
 {"value" : "Franc", "innerText" : "France"},
 {"value" : "Ital", "innerText" : "Italy"},
 {"value" : "25", "innerText" : "India"}
 );
 
var CURRENCY = new Array
(
 {"value" : "AUD", "innerText" : "Australian Dollar"},
 {"value" : "BRL", "innerText" : "Brazilian Real"},
 {"value" : "CAD", "innerText" : "Canadian Dollar"},
 {"value" : "CZK", "innerText" : "Czech Koruna"},
 {"value" : "DKK", "innerText" : "Danish Krone"},
 {"value" : "EUR", "innerText" : "Euro"},
 {"value" : "HKD", "innerText" : "Hong Kong Dollar"},
 {"value" : "CAD", "innerText" : "Canadian Dollar"},
 {"value" : "INR", "innerText" : "Indian Rupee"},
 {"value" : "USD", "innerText" : "USD - US Dollar"},
 {"value" : "KRW", "innerText" : "KRW - Won"}
);

var PRICE = new Array
(
 {"value" : "-1", "innerText" : "No maximum"},
 {"value" : "100,000", "innerText" : "100,000"},
 {"value" : "300,000", "innerText" : "300,000"},
 {"value" : "500,000", "innerText" : "500,000"},
 {"value" : "700,000", "innerText" : "700,000"},
 {"value" : "1,000,000", "innerText" : "1,000,000"},
 {"value" : "3,000,000", "innerText" : "3,000,000"},
 {"value" : "5,000,000", "innerText" : "5,000,000"},
 {"value" : "7,000,000", "innerText" : "7,000,000"},
 {"value" : "10,000,000", "innerText" : "10,000,000"},
 {"value" : "15,000,000", "innerText" : "15,000,000"},
 {"value" : "20,000,000", "innerText" : "20,000,000"}
);
 


 
//put category arrays here - can be created manually
//or server-side, the name is important and must match
//the option values in the main drop down
var Argentin= new Array
(
 {"value" : "0", "innerText" : "Select City"},
 {"value" : "Buenos Aires", "innerText" : "Buenos Aires"},
 {"value" : "Chubut", "innerText" : "Chubut"},
 {"value" : "Córdoba", "innerText" : "Córdoba"},
 {"value" : "Cosquin", "innerText" : "Cosquin"},
 {"value" : "La Plata", "innerText" : "La Plata"},
 {"value" : "Mar del Plata", "innerText" : "Mar del Plata"}
);

 var Ital = new Array
(
 {"value" : "0", "innerText" : "Select City"},
 {"value" : "Chieti", "innerText" : "Chieti"},
 {"value" : "L'Aquila", "innerText" : "L'Aquila"},
 {"value" : "Pescara", "innerText" : "Pescara"},
 {"value" : "Teramo", "innerText" : "Teramo"}
  
);

var Franc = new Array
(
 {"value" : "0", "innerText" : "Select City"},
 {"value" : "Bordeaux", "innerText" : "Bordeaux"},
 {"value" : "Brest", "innerText" : "Brest"},
 {"value" : "Cannes", "innerText" : "Cannes"},
 {"value" : "Dijon", "innerText" : "Dijon"},
 {"value" : "Le Havre", "innerText" : "Le Havre"}
  
);

var Brazi = new Array
(
 {"value" : "0", "innerText" : "Select City"},
 {"value" : "Belo Horizonte", "innerText" : "Belo Horizonte"},
 {"value" : "Brasília", "innerText" : "Brasília"},
 {"value" : "Fortaleza", "innerText" : "Fortaleza"},
 {"value" : "Goiânia", "innerText" : "Goiânia"},
 {"value" : "Guarulhos", "innerText" : "Guarulhos"}
);

var Australi = new Array
(
 {"value" : "0", "innerText" : "Select City"},
 {"value" : "Albury", "innerText" : "Albury"},
 {"value" : "Newcastle", "innerText" : "Newcastle"},
 {"value" : "Sydney", "innerText" : "Sydney"},
 {"value" : "Wollongong", "innerText" : "Wollongong"},
 {"value" : "Blue Mountains", "innerText" : "Blue Mountains"},
 {"value" : "Broken Hill", "innerText" : "Broken Hill"}
);


//populates the target sub drop down using the array
//with the input name
function wpc_ww_setSubDropDown(targetSubDropDownID, chosenCategoryArrayName){
	var targetSubDropDown = document.getElementById(targetSubDropDownID);
	
	 if (chosenCategoryArrayName != ""){
   		eval("var categoryArray = " + chosenCategoryArrayName);
   		wpc_ww_populateDropDown(targetSubDropDownID, categoryArray);
 	}
 	else{
   		targetSubDropDown.options.length = 0;
 	}
}

//populates the target drop down using the input array
function wpc_ww_populateDropDown(targetDropDownID, optionsArray){
	var targetDropDown = document.getElementById(targetDropDownID);
	 //clear out any current options
 	targetDropDown.options.length = 0;
	 //add new options using the values in the arraydr
 	for (var i = 0; i < optionsArray.length; i++) {
   		var newOption = document.createElement("OPTION");
			var newOption = document.createElement('option');
			
		try { //Mozilla
			newOption.value = optionsArray[i].value;
			newOption.text = optionsArray[i].innerText;
			targetDropDown.add(newOption, null); 
		}
	  	catch(ex) {  //IE
			targetDropDown.options.add(newOption);
			newOption.value = optionsArray[i].value;
			newOption.innerText = optionsArray[i].innerText;
		  }
		  
   		//targetDropDown.options.add(newOption);
   		//newOption.value = optionsArray[i].value;
   		//newOption.innerText = optionsArray[i].innerText;
 	}
}


function wpc_ww_listingSrc()
{
	
	
	var f = document.forms['frmwpcww']; 
	if(!f ) 
	{   
		alert("Unable to find the required form on property search widget");
	} 
	if(f) 
	{   
	
		//Need to put in Js validations for - Country selection, state selection.
		var falsCt = 0;
		var r = f.elements["ddCountry"];
		if(!r)
		{
			alert("Unable to find Country element in search form");
			falsCt += 1;
		}
		else
		{
			if(r.selectedIndex == "")
			{
				alert("Please select country");
				r.focus();
				falsCt += 1;
			}
		}

		var rc = f.elements["ddCity"];
		if(!rc)
		{
			alert("Unable to find City element in search form");
			falsCt += 1;
		}
 
         

		if(falsCt == 0)
		{
			document.getElementById('COUNTRY1').value = document.frmwpcww.ddCountry.options[document.frmwpcww.ddCountry.selectedIndex].value
			document.getElementById('CITY1').value = document.frmwpcww.ddCity.options[document.frmwpcww.ddCity.selectedIndex].value
			document.getElementById('LANGUAGE1').value = document.frmwpcww.ddLanguage.options[document.frmwpcww.ddLanguage.selectedIndex].value
			f.action = "http://192.168.1.11/TRCWidegets.aspx";
			f.method = "post";
			f.target = "_blank";
			f.submit();
		}
	} 
	
}
  
 

 
 