//dynamic navigation
initNav = function() {
	if (typeof document.body.style.maxHeight == 'undefined') {
		var nav = document.getElementById("espace");
		var lis = nav.getElementsByTagName("div");
		for (var i=0; i<lis.length; i++)
		{
			lis[i].onmouseover = function()
			{
				this.className += " hover";
			}
			lis[i].onmouseout = function()
			{
				this.className = this.className.replace(" hover", "");
			}
		}
	}
}

if (document.all && !window.opera)
	attachEvent("onload", initNav);

function detectSafari(){
if (navigator.appVersion.indexOf("Safari") != -1)
   document.body.className += " safari";
}

if (window.addEventListener)
   window.addEventListener("load", detectSafari, false);


function fixLayout()
{
	var cont = document.getElementById("main");
	var contHeight = cont.offsetHeight;
	wHeight = window.innerHeight;	

	if (document.all && !window.opera) {
		wHeight = document.documentElement.clientHeight;
	}
		var temp = wHeight - contHeight;
		if (temp > 0)
	{
		cont.style.marginTop = (wHeight - contHeight) / 2 + "px";
	}
	else {
		cont.style.marginTop = "0px";
	}
}

var _items = [];
var _item_active = 0;
var _scroll = null;
var _prev = null;
var _next = null;

function initScroll() {
	_scroll = document.getElementById("scroll");
	_prev = document.getElementById("button-prev");
	_next = document.getElementById("button-next");
	if (_scroll && _prev && _next) {
		_items = _scroll.getElementsByTagName("li");
		
		revertItems();
		_prev.onclick = function() {
			_item_active = _item_active - 1;
			if (_item_active < 0)
			{
				_item_active = _items.length - 1;
			}
			revertItems();
			return false;
		}
		_next.onclick = function() {
			_item_active++;
			if (_item_active > _items.length-1)
			{
				_item_active = 0;
			}
			revertItems();
			return false;
		}
	}
}

function revertItems() {
	for (i = 0; i < _items.length; i++)
		{
			if (i == _item_active)
			{
				_items[i].style.display = "block";
			}
			else
			{
				_items[i].style.display = "none";
			}
		}
}

if (window.addEventListener){
	window.addEventListener("resize", fixLayout, false);
	window.addEventListener("load", fixLayout, false);
	window.addEventListener("load", initScroll, false);
}
else if (window.attachEvent){
	window.attachEvent("onresize", fixLayout);
	window.attachEvent("onload", fixLayout);
	window.attachEvent("onload", initScroll);
}
