//-----------------------------------------------------------------------------
// Déclaration et initialisation des variables navigateur.
//-----------------------------------------------------------------------------

var ie = (document.all) ? true : false;				// True si le navigateur est IE
var ns4 = (document.layers) ? true : false;			// True si le navigateur est NS version < 6
var ns6 = (document.getElementById) ? true : false; // True si le navigateur est NS version 6

//-----------------------------------------------------------------------------
// Affichage de fenêtres popup
//-----------------------------------------------------------------------------
/* 
* Display a popup window
*	title: titre de la fenêtre windows finale
*	url:   script php (ou autre) à afficher
*/
function DisplayPopUp( title, url, width, height )
{
	option = "width="+width+",height="+height+",toolbar=no,location=no,menubar=no,status=no,scrollbars=no,resizable=no,alwaysRaised=1,dependent=1";
	
	w = window.open(url, title, option);
	w.focus();
}
/* 
* Display a scrollable popup window
*	title: titre de la fenêtre windows finale
*	url:   script php (ou autre) à afficher
*/
function DisplayScrollablePopUp( title, url, width, height )
{

	option = "width="+width+",height="+height+",toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=no,alwaysRaised=1,dependent=1";
	
	w = window.open(url, title, option);
	w.focus();
}
/* 
* Display a scrollable popup window
*	name: nom du script php (ou autre) à afficher
*	title: titre de la fenêtre windows finale
*/
function DisplayScrollableResizablePopUp( name, title, width, height )
{

	option = "width="+width+",height="+height+",toolbar=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=yes,alwaysRaised=1,dependent=1";
	
	w = window.open(title, name, option);
	w.focus();
}

//-----------------------------------------------------------------------------
// Création de layers.
//-----------------------------------------------------------------------------

function newLayer(nomLayer, paramStyle, paramLayer, contenuHtml) {
// Création du layer
// nomLayer -> nom du layer
// paramLayer -> Parametre dans la balise layer (ex: onmouseover)
// contenuHtml -> contenu du layer en code html
	var htmlLayer;
	if(ie)	htmlLayer = '<div id=' + nomLayer + ' style="visibility:hidden; position:absolute" '+ paramStyle + ' ' + paramLayer + '>' + contenuHtml + '</div>';
	else if(ns4) htmlLayer = '<layer name=' + nomLayer + ' ' + paramLayer + '>' + contenuHtml + '</layer>';
	else if(ns6) htmlLayer = '<div id=' + nomLayer + ' style="visibility:hidden; position:absolute" ' + paramLayer + '>' + contenuHtml + '</div>';
	document.write(htmlLayer);
	//alert(htmlLayer);
}

function setDiv(layer, contenuHtml) {
// Change le contenu du layer
// layer -> nom du layer
// contenuHtml -> contenu du layer en code html

   if(ie) document.all[layer].innerHTML = contenuHtml;
   else if(ns4) document.layers[layer].innerHTML = contenuHtml;
   else if(ns6) document.getElementById(layer).innerHTML = contenuHtml;
}

function showLayer(layer) {
// Affiche le layer suivant son état
// layer -> nom du layer
    if(ie) document.all[layer].style.visibility = "visible";
	else if(ns4) document.layers[layer].visibility = "show";
	else if(ns6) document.getElementById(layer).style.visibility = "visible";
}

function portletOpenOrClose( div )
{
    if(ie) {
		document.all[div].style.display = ( document.all[div].style.display == "none" ? "" : "none" );
		document.all[div].style.visibility = ( document.all[div].style.visibility == "hidden" ? "visible" : "hidden" );
	}
	else if(ns4) {
		document.layers[div].style.display = ( document.layers[div].display == "none" ? "" : "none" );
		document.layers[div].style.visibility = ( document.layers[div].visibility == "hidden" ? "visible" : "hidden" );
	}
	else if(ns6) {
		document.getElementById(div).style.display = ( document.getElementById(div).style.display == "none" ? "" : "none" );
		document.getElementById(div).style.visibility = ( document.getElementById(div).style.visibility == "hidden" ? "visible" : "hidden" );
	}
}


// gestion de la position de la souris
var global_mouse_x;
var global_mouse_y;
if (window.dvent && document.captureEvents) {
 	document.captureEvents(Event.MOUSEMOVE);
}

document.onmousemove = getMousePosition;

function getMousePosition(e) {
	if ( !e ) {
		var e = window.event || window.Event;
	}

	if ( e.clientX ) {
		global_mouse_x = e.clientX;
		global_mouse_y = e.clientY;
	} else {
		if ( e.pageX ) {
			global_mouse_x = e.pageX;
			global_mouse_y = e.pageY;
		}
	}
}

function getMouseX(e) {
	return global_mouse_x;
}

function getMouseY(e) {
	return global_mouse_y;
}
