window.addEvent("domready", function(){
	//var links = $$("a");
	new SmoothScroll();
	new Lightbox();
	
$$(".fadeout").each(function(el){
			new ListItemSelector($(el),{ "fxMin": 1, "fxMax": 0.5 });
		});

var myCarousel = new Carousel($("carousel"), { 
		autoStyle:true,
		idPrevious:$("previousImage"),
		idNext:$("nextImage"),
		visibleItems: 1, //amount that fits in the container
		scrollAmount: 199, //how wide each item is
		scrollInterval: 500, //how quick it should scroll in ms
		fxTransition: Fx.Transitions.quadOut //http://docs.mootools.net/Effects/Fx-Transitions.js <- pick one
	});



	$$(".volatile").each(function(el){
		$(el).addEvent("focus", function(){
			if(this.getValue() == this.getProperty("title")) {
				this.value = "";
			}
		});
	});
	
	$$("a[rel*='external']").each(function(a){ 
		$(a).setProperty("target", "_blank");
	});
	
	if($("letPrices")){
		$("letPrices").setStyle("display","none");
		
		$("type").addEvent("change", function(e){
			if(this.getValue() == 1){
				$("buyPrices").setStyle("display","block");
				$("letPrices").setStyle("display","none");
			} else {
				$("buyPrices").setStyle("display","none");
				$("letPrices").setStyle("display","block");
			}
		});
	}



	if ($("PropertyTypeID")) {
		toggleSearchType()	
		$("PropertyTypeID").addEvent("change", toggleSearchType);
	}

$$(".homeSlideshow").each(function(el){ new Ticker(el, {"interval": 6000}) });














});

function toggleSearchType() {
	
	if ($("PropertyTypeID").value == "2") {
		
		$("label_MinPrice_Lettings").setStyle("display", "block");
		$("MinPrice_Lettings").setStyle("display", "block");
		
		$("label_MaxPrice_Lettings").setStyle("display", "block");
		$("MaxPrice_Lettings").setStyle("display", "block");
		
		$("label_MinPrice").setStyle("display", "none");
		$("MinPrice").setStyle("display", "none");
		
		$("label_MaxPrice").setStyle("display", "none");
		$("MaxPrice").setStyle("display", "none");
		
	} else {
		
		$("label_MinPrice_Lettings").setStyle("display", "none");
		$("MinPrice_Lettings").setStyle("display", "none");
		
		$("label_MaxPrice_Lettings").setStyle("display", "none");
		$("MaxPrice_Lettings").setStyle("display", "none");
		
		$("label_MinPrice").setStyle("display", "block");
		$("MinPrice").setStyle("display", "block");
		
		$("label_MaxPrice").setStyle("display", "block");
		$("MaxPrice").setStyle("display", "block");
		
	}
}

