// JavaScript Document

$(document).ready(function()
{
// First we hide all exhibitis
$("#menu ul.section li.section-title").nextAll().hide();

var menuIsClosed = true;

// then the active exhibit is showed
$("#menu ul.section").each(function()
{
	var activeMenu = $(this).find("li.active");
	if (activeMenu.size()) {
		menuIsClosed = false;
	}
	activeMenu.prevAll().nextAll().show();
});

//This is the toggle function

$("#menu ul.section li.section-title").click(function(){
	$(this).nextAll().slideToggle("slow");
});

if (menuIsClosed) {
	if (location.href.match('design')) {
		$('li:contains("design")', 'ul.section').click();
	} else if (location.href.match('architecture'))  {
		$('li:contains("architeture")', 'ul.section').click();
	} else if (location.href.match('profile'))  {
		$('li:contains("profile")', 'ul.section').click();
	}  else if (location.href.match('contact'))  {
		$('li:contains("contact")', 'ul.section').click();
	} else if (location.href.match('awards'))  {
		$('li:contains("awards")', 'ul.section').click();
	}
	
}



// First we hide all exhibitis
$("#menu ul.section li ul.subsection li.subsection-title").nextAll().hide();

var menuIsClosed = true;

// then the active exhibit is showed
$("#menu ul.section li ul.subsection").each(function()
{
	var activeMenu = $(this).find("li.active");
	if (activeMenu.size()) {
		menuIsClosed = false;
	}
	activeMenu.prevAll().nextAll().show();
});

//This is the toggle function

$("#menu ul.section li ul.subsection li.subsection-title").click(function(){
	$(this).nextAll().slideToggle("fast");
});

if (menuIsClosed) {
	if (location.href.match('aethra')) {
		$('li:contains("Aethra")', 'ul.subsection').click();
	} 
	}

if (menuIsClosed) {
	if (location.href.match('avantis')) {
		$('li:contains("Avantis")', 'ul.subsection').click();
	} 
	}

if (menuIsClosed) {
	if (location.href.match('archimede')) {
		$('li:contains("Archimede")', 'ul.subsection').click();
	}  
	}
	
if (menuIsClosed) {
	if (location.href.match('profile')) {
		$('li:contains("profile")', 'ul.subsection').click();
	}  
	}
	
if (menuIsClosed) {
	if (location.href.match('contact')) {
		$('li:contains("contact")', 'ul.subsection').click();
	}  
	}
	
if (menuIsClosed) {
	if (location.href.match('awards')) {
		$('li:contains("awards")', 'ul.subsection').click();
	}  
	}


});



