window.addEvent("load", function(){

	// CSS styling to keep the page useable without JS	
	
	$$('.galleryItems').each(function(el){
		el.setStyles({
			'height': '203px'
		});
	});
	
	$$('#galleryInner').each(function(el){
		el.setStyles({
			'height': '203px'
		});
	});
		
	$$('.tabheading').each(function(el){
		el.setStyles({
			'display': 'none'
		});
	});
	
	$$('.imageCounter, #tabsContainer').each(function(el){
		el.setStyles({
			'display': 'block'
		});
	});

	$$('.galleryImage').each(function(el){
		el.setStyles({
			'padding': '0'
		});
	});
		
	$$('#propertyContentContainer').each(function(el){
		el.setStyles({
			'margin': '-5px 0 0 0'
		});
	});

});

window.addEvent("domready", function(){

	if($("galleryContainer")){
		new SlideItMoo({
					gallery: 'galleryContainer',
					overallContainer: 'galleryOuter',
					elementScrolled: 'galleryInner',
					thumbsContainer: 'galleryItems',		
					itemsVisible:1,
					itemsSelector: '.galleryImage',
					itemWidth: 267,
					showControls:1
		});
	}

	if($("tabsContainer")){
		var myAccordion = new Accordion($$('#tabsContainer li a'), $$('.propertyContent'), {
			display: 0,
			alwaysHide: false,
			opacity: true,
			
			onActive: function(togglers){
				togglers.addClass('selected');
				
			},
			onBackground: function(togglers){
				togglers.removeClass('selected');
			}
		});
		
		$$("#tabsContainer li a").each(function(el){
				el.addEvent("click", function(e){
				new Event(e).stop();
			});
		});
	}
		
	// Configure all socialize links

	var addthis_pub = "";

	$$(".socialize").each(function(el){
			el.addEvent("click", function(e){
			new Event(e).stop();
			addthis_url = location.href;
			addthis_title = document.title;
			addthis_click(this);
		});
	});

	new SmoothScroll({}, $(document.body));

	$$(".volatile").each(function(el){
		$(el).addEvent("focus", function(){
			if(this.get("value") == this.get("title")) {
				this.value = "";
			}
		});
	});
	
	$$("a[rel*='external']").each(function(a){ 
		$(a).setProperty("target", "_blank");
	});

	$$("#content .textfield, #content select, #content textarea").addEvents({
		"focus": function(){ this.setStyle("border-color","#757575"); },
		"blur": function(){ this.setStyle("border-color","#B1B1B1"); }
	});
	
	$$("#planner tr").addEvents({
		"mouseover": function(){ this.setStyle("background","#f2f2f2"); },
		"mouseout": function(){ this.setStyle("background","#ffffff"); }
	});

});
