//var mdEnableEffects = true;
var mdinit = false;
var mdopen = false;
var mdoktoclose = false;
var mdclose = true;
var mdcurrentid = "";
var mdcurrentida = 0;
var mdcurrenth = 0;
var mdmaxh = 175;
var mdcurrenta = 0;
var mdmaxa = 100;
var mdtimer = -1;
var mdwaitToClose = 300;
function initMediaBox() { 
	if (document.getElementById("mediabox") && document.getElementById("content-wrapper")) { 
		document.getElementById("mediabox").style.overflow = "hidden"; 
		document.getElementById("mediabox").style.height = "0px";
		document.getElementById("content-wrapper").onmouseover = function() { hideMediabox(); };
		mdinit = true;
	}
}
function animMediabox() { 
	if ( mdinit && mdEnableEffects ) {
		if ( mdopen ) { mdopened = false; if ( mdcurrenta < mdmaxa && browser != null && browser != "" ) { mdtimer = mdwaitToClose; mdcurrenta+= (mdmaxa-mdcurrenta)*0.1; if (((mdmaxa-mdcurrenta)*0.3) < 0.1) { mdcurrenta = mdmaxa; } if (browser == "msie") { document.getElementById("mediabox").style.filter = "alpha(opacity="+mdcurrenta+")"; } else if (browser == "netscape") { document.getElementById("mediabox").style.opacity = mdcurrenta/100; } else if (browser == "opera") { document.getElementById("mediabox").style.opacity = mdcurrenta/100; } } if ( mdcurrenth < mdmaxh ) { mdtimer = mdwaitToClose; mdcurrenth+= (mdmaxh-mdcurrenth)*0.3; if (((mdmaxh-mdcurrenth)*0.3) < 0.1) { mdcurrenth = mdmaxh; } document.getElementById("mediabox").style.height = mdcurrenth+"px"; } if ( mdcurrenth == mdmaxh && mdcurrentid != "" && mdcurrentida < mdmaxa && browser != null && browser != "" ) { mdtimer = mdwaitToClose; mdcurrentida+= (mdmaxa-mdcurrentida)*0.1; if (((mdmaxa-mdcurrentida)*0.3) < 0.1) { mdcurrentida = mdmaxa; } if (browser == "msie") { document.getElementById(mdcurrentid).style.filter = "alpha(opacity="+mdcurrentida+")"; } else if (browser == "netscape") { document.getElementById(mdcurrentid).style.opacity = mdcurrentida/100; } else if (browser == "opera") { document.getElementById(mdcurrentid).style.opacity = mdcurrentida/100; } } }
		if ( mdclose ) { if ( mdcurrenta > 0 && browser != null && browser != "" ) { mdtimer = 0; mdcurrenta-= (mdcurrenta)*0.4; if (((mdcurrenta)*0.3) < 0.1) { mdcurrenta = 0; } if (browser == "msie") { document.getElementById("mediabox").style.filter = "alpha(opacity="+mdcurrenta+")"; } else if (browser == "netscape") { document.getElementById("mediabox").style.opacity = mdcurrenta/100; } else if (browser == "opera") { document.getElementById("mediabox").style.opacity = mdcurrenta/100; } } if ( mdcurrenth > 0) { mdcurrenth -= (mdcurrenth)*0.3; if (((mdcurrenth)*0.3) < 0.1) { mdcurrenth = 0; } document.getElementById("mediabox").style.height = mdcurrenth+"px"; } if ( mdcurrenta == 0 && mdcurrenth == 0 && mdtimer != -1 ) { mdtimer = -1; mdclose = false; } } 
		//if ( mdtimer > 0) { mdtimer--; if ( mdtimer == 0 ) { closeMediabox(); } }
	} else if ( mdinit && !mdEnableEffects ) {
		if ( mdopen ) { document.getElementById("mediabox").style.height = mdmaxh+"px"; }
		if ( mdclose ) { document.getElementById("mediabox").style.height = "0px"; mdclose = false; }
		//if ( mdtimer > 0) { mdtimer--; if ( mdtimer == 0 ) { closeMediabox(); } }
	}
}
function closeMediabox() { if ( mdinit ) { mdopen = false; mdcurrentid = ""; mdclose = true; } }
function displayMediabox(id) { if ( mdinit ) { mdopen = true; mdclose = false; mdtimer = mdwaitToClose; 
	if ( mdcurrenth == mdmaxh && mdEnableEffects ) { mdcurrentida = 0; mdcurrentid = "mediabox_"+id; } 
	for (var i=1; i <6; i++) { 
		if (i==id) { 
			document.getElementById("mediabox_"+i).style.display = "block"; 
			if ( mdEnableEffects ) {
				if (mdcurrenth != mdmaxh && browser != null && browser == "msie") { document.getElementById("mediabox_"+i).style.filter = ""; } 
				else if (mdcurrenth == mdmaxh && browser != null && browser == "msie") { document.getElementById("mediabox_"+i).style.filter = "alpha(opacity=0)"; } 
				else if (mdcurrenth != mdmaxh && browser != null && browser == "netscape") { document.getElementById("mediabox_"+i).style.opacity = 1; } 
				else if (mdcurrenth == mdmaxh && browser != null && browser == "netscape") { document.getElementById("mediabox_"+i).style.opacity = 0; } 
				else if (mdcurrenth != mdmaxh && browser != null && browser == "opera") { document.getElementById("mediabox_"+i).style.opacity = 1; } 
				else if (mdcurrenth == mdmaxh && browser != null && browser == "opera") { document.getElementById("mediabox_"+i).style.opacity = 0; }
			}
		} else { document.getElementById("mediabox_"+i).style.display = "none"; } } } }
function hideMediabox() { if (mdopen) { closeMediabox(); } }

window.onload = function () { 
	initMediaBox();
	//displayWarning();
}
window.setInterval('animMediabox()',30);

/*TEMP*/
function displayWarning() {
	var warning = document.createElement('div');
	document.body.appendChild(warning);
	//warning.style="background: #f99; border: 1px solid #f00; position: absolute; padding: 5px; "
	//warning = document.createElement("div");
	warning.style.border = "1px solid #f00";
	warning.style.background = "#f99";
	warning.style.position = "absolute";
	warning.style.padding = "5px";
	warning.style.top = "10px";
	warning.style.left = "10px";
	warning.style.color = "#000";
	warning.innerHTML = "Le site est en cours de maintenance, il sera instable jusqu'&agrave; ce soir.<br/>Merci de votre compr&eacute;hension.";
	
	/**/	
	document.getElementById("wrapper").appendChild(warning);

}
