/* navigation  switcher */
function changeClass()
{
	var href = document.location.href;
	if(href.indexOf("#") < 0 || href.indexOf("#") == href.length - 1)
	{
		href = href + (href.indexOf("#") != href.length - 1 ? "#salford-quays-apartments" : "salford-quays-apartments");		
	}
	else
	{
		document.location.href = href.substring(0, href.indexOf("#")+1);
	}
				
	linkClick($("a[id]").filter(function(index){return $(this).attr("id").indexOf("link") > -1 && href.indexOf($(this).attr("href")) > -1}).get(0).id);
}

function linkClick(id)
{	
	$("a[id]").filter(function(index){return $(this).attr("id").indexOf("link") > -1}).removeClass("current");	
	$("#" + id).addClass('current');
	
	$("div.page").addClass("jshide");
	$($("#" + id).attr("href")).removeClass("jshide");
	if($("#" + id).attr("href") == '#rental' || $("#" + id).attr("href") == '#rent' || $("#" + id).attr("href") == '#sales' || $("#" + id).attr("href") == '#homebuy'){
		$("div.page#option").removeClass("jshide");
		$("#link4").addClass('current');
		//$("#option").scrollTo( '#homebuy', {axis:'xy'});
		}
	
	$("body").removeClass("home");
	$("body").removeClass("specification");
	$("body").removeClass("location");
	$("body").removeClass("siteplan");
	$("body").removeClass("localarea");
	$("body").removeClass("img-gallery");
	
	if(id == "link1")
	{
		$("body").addClass("home");
	}
	if(id == "link2")
	{
		$("body").addClass("localarea");
	}	
	if(id == "link6")
	{
		$("body").addClass("specification");
	}
	if(id == "link5")
	{
		$("body").addClass("siteplan");
	}
	if(id == "link7")
	{
		$("body").addClass("location");
	}		
	if(id == "link9")
	{
		$("body").addClass("img-gallery");
	}	
	if(id == "link10")
	{
		$("body").addClass("location");
	}	
	return false;
}

jQuery(document).ready(function(){
	$("a").filter(function(index){return $(this).attr("id")!= null && $(this).attr("id").indexOf("link") > -1}).click(function(){linkClick($(this).attr("id")); return false;});
	changeClass();
	$(".content-right").removeClass("jshidden");
	$(".content-right").addClass("jsvisible");
	})