function openCaseStudy(casestudy_name)
{
	var casestudy_link = $(casestudy_name);
	var casestudy_full = $(casestudy_link.identify() + "casestudy");
	var children = $('casestudies').descendants();
	children.each(function(item) 
	{
	  	if ((item.hasClassName('casestudy_expanded')) && (item.identify() != casestudy_full.identify()))
		{
			new Effect.Fade(item.identify());
		}
		
		if((item.hasClassName('casestudy')) && (item.identify() != casestudy_link.identify()))
		{
			new Effect.Appear(item.identify());
		}
	});
	
	new Effect.Fade(casestudy_link.identify());
	new Effect.Appear(casestudy_full.identify());
}

function closeCaseStudy(casestudy_name)
{
	var casestudy_link = $(casestudy_name);
	var casestudy_full = $(casestudy_link.identify() + "casestudy");
	new Effect.Appear(casestudy_link.identify());
	new Effect.Fade(casestudy_full.identify());
}

// new PeriodicalExecuter(function CheckForHash()
// {
// 	if(document.location.hash)
// 	{
// 		var HashLocationName = document.location.hash;
// 		HashLocationName = HashLocationName.gsub('#','');
// 		$(HashLocationName).show();
// 		
// 		var children = $('services_container').descendants();
// 		children.each(function(item) 
// 		{
// 			if(HashLocationName != item.identify())
// 			{
// 				item.hide();
// 			}
// 			
// 		});
// 	}
// 	else
// 	{
// 		var children = $('services_container').descendants();
// 		children.each(function(item) 
// 		{
// 			if(HashLocationName != item.identify())
// 			{
// 				item.hide();
// 			}
// 			
// 		});
// 	}
// }, 0.5);

function CheckForHash()
{
	if(document.location.hash)
	{
		var HashLocationName = document.location.hash;
		HashLocationName = HashLocationName.gsub('#','');
		
		var children = $('services_container').descendants();
		children.each(function(item) 
		{
			if((HashLocationName != item.identify()) && item.hasClassName('service_text'))
			{
				// item.hide();
				new Effect.Fade(item.identify());
				new Effect.BlindUp(item.identify());
			}
			
		});
		
		// $(HashLocationName).show();
		new Effect.Appear(HashLocationName);
		new Effect.BlindDown(HashLocationName);
	}
	
	else
	{
		var children = $('services_container').descendants();
		children.each(function(item) 
		{
			if((HashLocationName != item.identify()) && item.hasClassName('service_text'))
			{
				// item.hide();
				new Effect.Fade(item.identify());
				new Effect.BlindUp(item.identify());
			}
			
		});
	}
}
 		
function RenameAnchor(anchorid, anchorname)
{
	$(anchorid).writeAttribute('name', anchorname); //this renames the anchor
}

function RedirectLocation(anchorid, anchorname, HashName)
{
	RenameAnchor(anchorid, anchorname);
	document.location = HashName;
	CheckForHash();
}

window.onload = CheckForHash;		