window.addEvent('domready', function() {
	var rotater = new Rotater('.slide1',{
		slideInterval:3000,
		transitionDuration:1000
	});
	
	var rentarray = new Array(0,250,400,500,600,700,800,1000);
	var salearray = new Array(0,100,150,200,250,300,400,500,750,1000,2000,5000);

	var selectedrad = ($('radiosale').getProperty('checked'));
	
	if (!selectedrad) poprent();
	
	function poprent() {
		$('minprice').empty();
		$('maxprice').empty();
		var opt = new Element('option',{value: '',text:'Minimum Price'});
		opt.inject($('minprice'));
		rentarray.each(function(item,i) {
			if (i<rentarray.length-1) {
				var opt = new Element('option',{
					value: item,
					text : '£' + item + ' PW'
				});
				opt.inject($('minprice'));
			}
		});
		var opt = new Element('option',{value: '',text:'Maximum Price'});
		opt.inject($('maxprice'));
		rentarray.each(function(item,i) {
			var plus = (i==rentarray.length-1) ? "+":"";
			var val = (i==salearray.length-1) ? "":item;
			if (i>0) {
				var opt = new Element('option',{
					value: val,
					text : '£' + item + ' PW' + plus
				});
				opt.inject($('maxprice'));
			}
		});
	}
	
	function popsale() {
		$('minprice').empty();
		$('maxprice').empty();
		var opt = new Element('option',{value: '',text:'Minimum Price'});
		opt.inject($('minprice'));
		salearray.each(function(item,i) {
			var mills = (item >= 1000) ? item/1000 + "M" : item + "K";
			if (i<salearray.length-1) {
				var opt = new Element('option',{
					value: item + '000',
					text : '£' + mills
				});
				opt.inject($('minprice'));
			}
		});
		var opt = new Element('option',{value: '',text:'Maximum Price'});
		opt.inject($('maxprice'));
		salearray.each(function(item,i) {
			var plus = (i==salearray.length-1) ? "+":"";
			var val = (i==salearray.length-1) ? "":item + '000';
			var mills = (item >= 1000) ? item/1000 + "M" : item + "K";
			if (i>0) {
				var opt = new Element('option',{
					value: val,
					text : '£' + mills + plus
				});
				opt.inject($('maxprice'));
			}
		});
	}
	

	$$('.rad').addEvent('click',function() {
		(this.getProperty('id')=='radiosale') ? popsale():poprent();
	});
	
});