/* modify the php ones too*/
var arr_minprice_options = [0,100000,150000,175000,200000,225000,250000,275000,300000,325000,350000,375000,400000,425000,450000,475000,500000];
var arr_maxprice_options = [0,100000,150000,175000,200000,225000,250000,275000,300000,325000,350000,375000,400000,425000,450000,475000,500000,600000,700000,800000,900000,1000000];	
var arr_price_let_options = [0,400,500,600,800,1000,2000];


$(document).ready(function(){	
	/* search click*/
	$("#r_control_link_search").click( function() {
		
		if ($('#mapdiv').length > 0 && $("input[name='listingtype']:checked").val() == '2')
		{
			 refreshMap();
			 return false;
		}
		
		url = $("input[name='listingtype']:checked").val() == '2' ? '/map/' : '/list/';
		url += $("input[name='saletype']:checked").val() == '2' ? 'properties-to-let/' : 'properties-for-sale/';
		url += $("#min").val() + '/';
		url += $("#max").val() + '/';		
		$(this).attr('href',url);
	});	
});

function switch_price_options(saletype)
{		
	var html_min = '';
	var html_max = '';
	var arr_min = saletype == 1 ? arr_minprice_options : arr_price_let_options;
	var arr_max = saletype == 1 ? arr_maxprice_options : arr_price_let_options;

	$.each( arr_min, function(k, v){
		if (k == 0){
			html_min += "<option value='" + v + "'>All values</option>";
		} else {
			html_min += "<option value='" + v + "'>&pound;" + addCommas(v) +"</option>";
		}
	});
	$("#min").html(html_min);
	
	$.each( arr_max, function(k, v){
		if (k == 0){
			html_max += "<option value='" + v + "'>All values</option>";				
		} else {
			html_max += "<option value='" + v + "'>&pound;" + addCommas(v) +"</option>";			
		}

	});
	$("#max").html(html_max);
}
