function initSogo()
{
	
	pickImage('topright_front');
	
	var stretchers = $$('div.holder');
	stretchers.each(function(item){
		item.setStyles({'height': '0', 'overflow': 'hidden'});
	});
	
	var togglers = $$('a.toggler');
	
	////////////////////////////////////////////////////////////
	// Find where the currently opened page in in the menu
	////////////////////////////////////////////////////////////

	display = setPaneToOpen();
	
	
	/////////////////////////////////////////////////////////////
	// Initiate the menu in function of the previous analisys
	/////////////////////////////////////////////////////////////	

	var myAccordion = new Fx.Accordion(togglers, stretchers, { display:display });

	
	if (BrowserDetect.browser != 'Explorer' || BrowserDetect.version >= 7)
	{
		setTimeout("timedFade()",5000);
	}
}

function setPaneToOpen(){

	var currentPage = location.href;
	var display;
	var parent = 0;
	
	
	$ES(".menu a").each(function(elem){
		if(currentPage.indexOf(elem.getProperty("href")) != -1 && elem.getProperty("href") != ""){
			
			var parent = elem.getParent().getParent();

			switch(parent.getAttribute('id')){
				case "sogoholder" 		: display = 0; break;
				case "dojoholder" 		: display = 1; break;
				case "maitresholder" 	: display = 2; break;
				case "artsholder" 		: display = 3;  break;
				default 				: display = 0; 
			}
			
			return display;
		}
	});	
	
	return display;
}

function timedFade()
{
	fadeImage();
	setTimeout("timedFade()",5000);
}

var currentlyShown = 'front';
function fadeImage()
{
	var fx = new Fx.Style('topright_front', 'opacity', { duration: 1000, transition: Fx.Transitions.linear });;
	if (currentlyShown == 'front')
	{
		pickImage('topright_behind');
		fx.start(1,0);
		currentlyShown = 'behind';
	}
	else
	{
		pickImage('topright_front');
		fx.start(0,1);
		currentlyShown = 'front';
	}
}

function pickImage(id)
{
	var index = parseInt(Math.random() * 5);
	var imagediv = document.getElementById(id);
	imagediv.style.backgroundImage = "url(images/bg/" + index + ".png)";
}

function highlight(elem)
{
	//var elem = document.getElementById(elemID);
	if (elem.style.color == "white")
	{
		elem.style.color = "black";
	}
	else
	{
		elem.style.color = "white";
	}
}
