function setURL(page) {
	document.title = page + title;
}

window.addEvent("domready", function() {
	//get the url
	var url = window.location.href;
	the_location = url.split('#')[1];
	

	
	//case studies
	var found_content = $('found_content');
	var built_content = $('built_content');
	title = " | Case Studies | Property Search and Renovation in the Brighton & Hove Area | Find & Build";
	found = "Found";
	built = "Built";
	
	if(the_location == "built") {
		var hideFound = new Fx.Style('found_content', 'opacity', {duration:0});
		hideFound.set(0);
		setURL(built);
		fx = built_content.effects({duration: 0});
		fx.start({
			'opacity': [0,1]
		});
		$('built_button').addClass('built_current');
	} else {
		var hideBuilt = new Fx.Style('built_content', 'opacity', {duration:0});
		hideBuilt.set(0);
	
		setURL(found);
		fx = found_content.effects({duration: 0});
		fx.start({
			'opacity': [0,1]
		});
		$('found_button').addClass('found_current');
	}
	
	$('built_button').addEvent('click', function(){
		if (built_content.style.opacity != "1") {
			$('found_button').removeClass('found_current');
			fx = found_content.effects({duration: 500});
			fx.start({
				'opacity': [1,0]
			}).chain(function(){
				fadeIn = built_content.effects({duration: 500});
				fadeIn.start.delay(500, fadeIn, { 'opacity': [0,1] });
			});
			$('built_button').addClass('built_current');
			setURL(built);	
		}
	});
	
	$('found_button').addEvent('click', function(){
		if (found_content.style.opacity != "1") {
			setURL(found);
			$('built_button').removeClass('built_current');
			fx = built_content.effects({duration: 500});
			fx.start({
				'opacity': [1,0]
			}).chain(function(){
				fadeIn = found_content.effects({duration: 500});
				fadeIn.start.delay(500, fadeIn, { 'opacity': [0,1] });
			});
			$('found_button').addClass('found_current');
		}
	});
});
