// JavaScript Document
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById('conteneur').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
			}
			else {
				footerElement.style.top = '0px';
			}
		}
	}
}

//on calcule la taille pour le div des expo
function setExpo() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			
			var tailleElement = 353;
			var tailleAutre = 398;
			var element = $('div.bloc-gauche');
			var elementHeight = ( windowHeight - tailleAutre );
			
			if (elementHeight > tailleElement) {
				$('div.jScrollPaneContainer').height(elementHeight);
				$('div.jScrollPaneTrack').height(elementHeight);
			}
			
			//Init Scrollbar
			$('#pane').jScrollPane({showArrows:true});
			$('#pane-2').jScrollPane({showArrows:true});
			$('#pane-3').jScrollPane({showArrows:true});
			
			setFooter();
			
		}
	}
}

function addEvent(obj, event, fct) {
    if (obj.attachEvent) //Est-ce IE ?
        obj.attachEvent("on" + event, fct); //Ne pas oublier le "on"
    else
        obj.addEventListener(event, fct, true);
}

addEvent(window , "load", setExpo); //On les lance toutes les deux au chargement de la page
addEvent(window , "load", setFooter);

addEvent(window , "resize", setExpo); //On les lance toutes les deux au resize de la page
addEvent(window , "resize", setFooter);

// la fonction qui lance les autres
function lancer(fct) {
    addEvent(window, "load", fct);
}