document.observe('dom:loaded', initPropertyAlert);

function initPropertyAlert(evt)
{
	loadPropertyAlertValues();
	$('property_alert_interested_in').observe('change', loadPropertyAlertValues);
}

function loadPropertyAlertValues()
{
	var typeVal = $('property_alert_interested_in').getValue();
	new Ajax.Request('/index.php/ajax/getPriceList', {
		method: 'post',
		requestHeaders: {Accept: 'application/json'},
		parameters: { type: typeVal },
		onSuccess: function(transport, json) {
			var responses = json;
			var resSize = responses.length;
			
			
			$('property_alert_min_price').options.length = 0;
			$('property_alert_max_price').options.length = 0;
			
			
			for( var i = 0; i < resSize; i++)
			{
				var val = responses[i];
				if(i < (resSize -1)) {
					$('property_alert_min_price').options[i] = new Option(val, val);
				}
				$('property_alert_max_price').options[i] = new Option(val, val);
			}
			
		}
	});

}
