if(!window.SVFX_panel) SVFX_panel = new Object();



//Paramètres des panneaux par defaut

var panelBackgroundColor = '#AAAAAA';

var panelTextColor = '#000000';

var panelBorder = '1px Solid #CCCCCC';

var panelAlpha = 50;

var speed = 9;



//Ne pas modifier

var animationRunning = false;

var listDiv = Array();

var memVars = Array();



var isIE = false;

if(navigator.appName.indexOf("Microsoft Internet Explorer") != -1) isIE = true;





//Ajoute un panneau

SVFX_panel.addPanel = function(containerId,panelId){

	

	if(document.getElementById(containerId) != undefined){

		listDiv[containerId] = Array();

		listDiv[containerId]['panel'] = panelId;

		listDiv[containerId]['state'] = 'OFF';

		

		//Applique le style nécessaire au container

		var container = document.getElementById(containerId);

		container.style.position = 'relative';

		var containerHeight = container.offsetHeight;



		//Applique le style nécessaire au panneau

		var panel = document.getElementById(panelId);

			//Texte en trop caché

		panel.style.overflow = 'hidden';

			//Position absolue

		panel.style.position = 'absolute';		

			//Couleur de fond du panneau

		if(panelBackgroundColor != false) panel.style.backgroundColor = panelBackgroundColor;

			//Couleur du texte du panneau

		if(panelTextColor != false) panel.style.color = panelTextColor;

			//Bodure du panneau

		if(panelBorder != false) panel.style.border = panelBorder;

			//Transparence du panneau

		if(panelAlpha != false){

			if(isIE) panel.style.filter = "alpha(opacity=" + panelAlpha + ")";

			else{

				var opacite = (panelAlpha / 100);

				panel.style.setProperty( "-moz-opacity",opacite , "");

				panel.style.setProperty( "-khtml-opacity", opacite, "");

				panel.style.setProperty( "opacity",opacite , "");

			}

		}

			//Calcul la position relevée

		if(panel.style.marginBottom == '' || panel.style.marginBottom == undefined) var marginBottom = 0;

		else marginBottom = parseInt(panel.style.marginBottom);

		if(panel.style.paddingBottom == '' || panel.style.paddingBottom == undefined) var paddingBottom = 0;

		else paddingBottom = parseInt(panel.style.paddingBottom);

		if(panel.style.paddingTop == '' || panel.style.paddingTop == undefined) var paddingTop = 0;

		else paddingTop = parseInt(panel.style.paddingTop);

		

		var padding = parseInt(paddingTop) + parseInt(paddingBottom);

		var maxHeight = parseInt(panel.offsetHeight) - padding + 12;

		

		panel.style.height = '2px';

		panel.style.top = (parseInt(container.offsetHeight) - marginBottom - parseInt(panel.offsetHeight)) + 'px';

			//Masque le panneau

		panel.style.visibility = 'hidden';

			//Mémorise la position relevée

		memVars[containerId] = Array();

		memVars[containerId]['maxHeight'] = maxHeight;

		memVars[containerId]['marginBottom'] = marginBottom;

		memVars[containerId]['padding'] = padding;

		

		//Gestion des actions

		container.onmouseover = function () { SVFX_panel.panelOver(this); }

		container.onmouseout = function () { SVFX_panel.panelOut(this); }

	}

}



SVFX_panel.setStyle = function(panelId,bgColor,color,border,alpha){

	if(document.getElementById(panelId) != undefined){

		var panel = document.getElementById(panelId);

		

		if(bgColor == false) panel.style.backgroundColor = 'none';

		else if(bgColor != null) panel.style.backgroundColor = bgColor;

			//Couleur du texte du panneau

		if(color == false) panel.style.color = 'none';

		else if(color != null) panel.style.color = color;

			//Bodure du panneau

		if(border == false) panel.style.border = '0px';

		else if(border != null) panel.style.border = border;

			//Transparence du panneau

		if(alpha != null){

			if(isIE) panel.style.filter = "alpha(opacity=" + alpha + ")";

			else{

				var opacite = (alpha / 100);

				panel.style.setProperty( "-moz-opacity",opacite , "");

				panel.style.setProperty( "-khtml-opacity", opacite, "");

				panel.style.setProperty( "opacity",opacite , "");

			}

		}

	}

}



SVFX_panel.panelOver = function(container){

	listDiv[container.id]['state'] = 'UP';

	if(animationRunning == false) SVFX_panel.runAnimation();

}





SVFX_panel.panelOut = function(container){

	listDiv[container.id]['state'] = 'DOWN';

	if(animationRunning == false) SVFX_panel.runAnimation();

}



SVFX_panel.runAnimation = function(){

	var running = false;



	for(containerId in listDiv){

		var panel = document.getElementById(listDiv[containerId]['panel']);

		var container = document.getElementById(containerId);

		

		if(listDiv[containerId]['state'] == 'UP'){

			

			panel.style.visibility = 'visible';

			var newH = parseInt(panel.style.height) + speed;



			if(newH < memVars[containerId]['maxHeight']){

				panel.style.height = newH+'px';

				var posY = parseInt(container.offsetHeight) - memVars[containerId]['marginBottom'] - parseInt(panel.offsetHeight);

				panel.style.top = posY+'px';

				running = true;

			}

			else listDiv[containerId]['state'] = 'OFF';

		}

		else if(listDiv[containerId]['state'] == 'DOWN'){

			

			panel.style.visibility = 'visible';

			var newH = parseInt(panel.style.height) - speed;

			

			if(newH > 0){	

				panel.style.height = newH+'px';

				var posY = parseInt(container.offsetHeight) - memVars[containerId]['marginBottom'] - parseInt(panel.offsetHeight);

				panel.style.top = posY+'px';

				running = true;

			}

			else{

				listDiv[containerId]['state'] = 'OFF';

				panel.style.visibility = 'hidden';

			}

		}

	}

	

	animationRunning = running;

	if(running == true) setTimeout("SVFX_panel.runAnimation()",15);

}
