// JavaScript Document

function validate_currency()
{
	for(var k=0;k<document.search.type.length;k++) 
	{
		if(document.search.type[k].checked)
		{
			var radio = document.search.type[k].value;
			//alert(radio);
			if(radio=='Sell') 
			{
				var arr = new Array();
				arr[0] = new Array("Please Select");
				arr[1] = new Array("Any","50000000","250000000","450000000","650000000","850000000",
				"1000000000","3000000000","5000000000");
				arr[2] = new Array("Any","250000","500000","750000","1000000");
				arr[3] = new Array("Any","250000","500000","750000","1000000");
				arr[4] = new Array("Any","250000","500000","750000","1000000");

				var arr_text = new Array();
				arr_text[0] = new Array("Please Select");
				arr_text[1] = new Array("Any","50.000.000","250.000.000","450.000.000","650.000.000","850.000.000",
				"1.000.000.000","3.000.000.000","5.000.000.000");
				arr_text[2] = new Array("Any","250.000","500.000","750.000","1.000.000");
				arr_text[3] = new Array("Any","250.000","500.000","750.000","1.000.000");
				arr_text[4] = new Array("Any","250.000","500.000","750.000","1.000.000");
				
				var comboValue = document.search.Currency.value;
				document.forms["search"].elements["PriceFr"].options.length=0;
				document.forms["search"].elements["PriceTo"].options.length=0;
				
				for (var i=0;i<arr[comboValue].length;i++)
				{
					var option = document.createElement("option");
					//option.setAttribute('value',i+1);
					option.setAttribute('value',arr[comboValue][i]);
					option.innerHTML = arr_text[comboValue][i];
					//alert(option);
					document.forms["search"].elements["PriceFr"].appendChild(option);
				}
				
				for (var i=0;i<arr[comboValue].length;i++)
				{
					var option = document.createElement("option");
					//option.setAttribute('value',i+1);
					option.setAttribute('value',arr[comboValue][i]);
					option.innerHTML = arr_text[comboValue][i];
					document.forms["search"].elements["PriceTo"].appendChild(option);
				}
			}
			else if(radio=='Rent')
			{
				var arr = new Array();
				arr[0] = new Array("Please Select");
				arr[1] = new Array("Any","10000000","25000000","50000000","75000000","100000000");
				arr[2] = new Array("Any","100","300","500","700","1000");
				arr[3] = new Array("Any","100","300","500","700","1000");
				arr[4] = new Array("Any","100","300","500","700","1000");

				var arr_text = new Array();
				arr_text[0] = new Array("Please Select");
				arr_text[1] = new Array("Any","10.000.000","25.000.000","50.000.000","75.000.000","100.000.000");
				arr_text[2] = new Array("Any","100","300","500","700","1.000");
				arr_text[3] = new Array("Any","100","300","500","700","1.000");
				arr_text[4] = new Array("Any","100","300","500","700","1.000");
				
				var comboValue = document.search.Currency.value;
				//alert(comboValue);
				document.forms["search"].elements["PriceFr"].options.length=0;
				document.forms["search"].elements["PriceTo"].options.length=0;
				
				for (var i=0;i<arr[comboValue].length;i++)
				{
					var option = document.createElement("option");
					//option.setAttribute('value',i+1);
					option.setAttribute('value',arr[comboValue][i]);
					option.innerHTML = arr_text[comboValue][i];
					document.forms["search"].elements["PriceFr"].appendChild(option);
				}
				
				for (var i=0;i<arr[comboValue].length;i++)
				{
					var option = document.createElement("option");
					//option.setAttribute('value',i+1);
					option.setAttribute('value',arr[comboValue][i]);
					option.innerHTML = arr_text[comboValue][i];
					document.forms["search"].elements["PriceTo"].appendChild(option);
				}
			}
		}
	}				
}

function submit_searching(form_name)
{
	if (document.forms[form_name].elements["Location"].value == "please type the location" ||  document.forms[form_name].elements["Location"].value == "")
	{
		alert('Please type the location');
		document.forms[form_name].elements["Location"].focus();
		return false;
	}
	else if (document.forms[form_name].elements["Currency"].value == "0" )
	{
		alert('Please select the currency');
		document.forms[form_name].elements["Currency"].focus();
		return false;
	}
	else
	{
		return true;
	}
}
