document.onmouseover = doOver;
document.onmouseout  = doOut;
document.onmousedown = doDown;
document.onmouseup   = doUp;


var tempWin;
var NamePopUP;

if ((document.all)&&(navigator.appVersion.indexOf("MSIE")!=-1)){
	var start = navigator.appVersion.indexOf("MSIE");
	var end = navigator.appVersion.indexOf(".",start);
	IE6 = (parseInt(navigator.appVersion.substring(start+5,end)))>=6
}

if (IE6){
var oToolTip = window.createPopup();
var oToolTipBody = oToolTip.document.body;
oToolTipBody.style.backgroundColor='infobackground'
oToolTipBody.style.fontFamily ='Arial'
oToolTipBody.style.fontSize = '8pt'
}

function ToolTip(i, image)
{
  oToolTipBody.innerHTML =	"<DIV style='width:100%; height:100%; border: 1 solid #000000;'> " +
							"<TABLE border=0 width=100% cellspacing=0 cellpadding=2><TR><TD align='right'><font size=1 face='verdana' onclick='parent.oToolTip.hide()' style='cursor:hand'><B>X</B></font></TD></TR></TABLE> " +
							"<P style='margin: 3'>" + tips(0, i) + "</P></DIV>";
  oToolTip.show(5, 5, tips(1, i), tips(2, i), image);
}

//Fonction qui génère un popUp selon les caractéristiques passées en paramètre
function popUp3()
{	
		/*
		arguments[0] //URL
		arguments[1] //width ("half", "full", 200, 300)
		arguments[2] //height ("half", "full", 200, 300)
		arguments[3] //left ("center", "left", 200, 300)
		arguments[4] //top ("center", "top", 200, 300)
		arguments[5] //status (0, 1)
		arguments[6] //resizable (0, 1)
		arguments[7] //scrollbars(0, 1)
		arguments[8] //location(0, 1)
		arguments[9] //toolbar(0, 1)
		arguments[10] //menubar(0, 1)
		*/
		var Hauteur, Largeur, PosX, PosY, status, resizable, scrollbars, location, toolbar, menubar   //Défini les variables
		//Tout les paramètres ne sont pas requis, donc si un paramètre est omis une valeur par défaut lui est attribuée
		if (typeof(arguments[1]) == "undefined") {Largeur = screen.width/2;}	//Défini la largeur
		if (typeof(arguments[2]) == "undefined") {Hauteur = screen.height/2;}   //Défini la hauteur 
		if (typeof(arguments[3]) == "undefined") {PosX = (screen.width/2) - (Largeur/2);}	//Défini la position horizontale
		if (typeof(arguments[4]) == "undefined") {PosY = (screen.height/2) - (Hauteur/2);}	//Défini la position verticale

		if (typeof(arguments[5]) == "undefined") //Défini la présence de la barre de status en dessous de la fenêtre
			{status=1;}	
		else
			{status=arguments[5];}
			
		if (typeof(arguments[6]) == "undefined")//Défini si la fenêtre est redimensionnable
			{resizable=1;}	
		else
			{resizable=arguments[6];}
			
		if (typeof(arguments[7]) == "undefined")//Défini la présence des barres déroulantes
			{scrollbars=1;}	
		else
			{scrollbars=arguments[7];}
			
		if (typeof(arguments[8]) == "undefined")//Défini la présence de la barre d'adresse
			{location=0;}
		else
			{location=arguments[8];}
		
		if (typeof(arguments[9]) == "undefined")//Défini la présence de la barre d'outils
			{toolbar=0;}
		else
			{toolbar=arguments[9];}
			
		if (typeof(arguments[10]) == "undefined")//Défini la présence de la barre de menu
			{menubar=0;}
		else
			{menubar=arguments[10];}
		
		if (typeof(arguments[1]) != "undefined") {
		//Vérifie et attributs les valeurs requises si l'utilisateur a entrée des constantes prédéfinies en paramètres
		//Pour la largeur
		switch (arguments[1]){
			case "half": 
				Largeur = screen.width/2;
				PosX = (screen.width/2) - (Largeur/2);
				Hauteur = screen.height/2;
				PosY = (screen.height/2) - (Hauteur/2);				
				break;				
			case "full":
				Largeur = screen.width-10;
				PosX = 1;
				Hauteur = screen.height-85;
				PosY = 1;				
				break;				
			default: 
				Largeur = arguments[1];
				PosX = (screen.width/2) - (Largeur/2);
				if (typeof(arguments[2]) != "undefined")
				{
					Hauteur = arguments[2];
					PosY = (screen.height/2) - (Hauteur/2);					
				}								
		}
		}
		
		if (typeof(arguments[2]) != "undefined") {
		//Vérifie et attributs les valeurs requises si l'utilisateur a entrée des constantes prédéfinies en paramètres
		//Pour la hauteur
		switch (arguments[2]){
			case "half":
				Hauteur = screen.height/2;
				PosY = (screen.height/2) - (Hauteur/2);
				break;
			case "full":
				Hauteur = screen.height-85;
				PosY = 1;
				break;				
			default: 
				Hauteur = arguments[2];
				PosY = (screen.height/2) - (Hauteur/2);
		}
		}
		
		if (typeof(arguments[3]) != "undefined") {
		//Vérifie et attributs les valeurs requises si l'utilisateur a entrée des constantes prédéfinies en paramètres
		//Pour la position horizontale
		switch (arguments[3]){
			case "center": 
				PosX = (screen.width/2) - (Largeur/2);
				break;				
			case "left":
				PosX = 1;
				break;				
			default: 
				PosX = arguments[3];
		}
		}

		if (typeof(arguments[4]) != "undefined") {
		//Vérifie et attributs les valeurs requises si l'utilisateur a entrée des constantes prédéfinies en paramètres
		//Pour la position verticale
		switch (arguments[4]){
			case "center": 
				PosY = (screen.height/2) - (Hauteur/2);
				break;				
			case "top":
				PosY = 1;
				break;				
			default: 
				PosY = arguments[4];
		}
		}
		
		//Concatène les paramètres de la nouvelle fenêtre					
		FEATURES = "status="+status+",resizable="+resizable+",scrollbars="+scrollbars+",location="+location+",toolbar="+toolbar+",menubar="+menubar;
		FEATURES = FEATURES + ",width=" + Largeur + ",height=" + Hauteur;
		FEATURES = FEATURES + ",screenX=" + PosX + ",screenY=" + PosY + ",left=" + PosX + ",top=" + PosY;				
		//Si une fenêtre portant le même nom est déjà ouvert, il la ferme pour ensuite ouvrir le nouveau popUp
		if (typeof(tempWin) != "undefined" && tempWin.closed == false)
		{
			tempWin.close();
		}
		tmpTitle = Math.round(Math.random( ) * 100000).toString();	//Donne un nom random pour éviter les noms identiques
		tempWin= window.open(arguments[0],  'titre' + tmpTitle, FEATURES, 0);	//Ouvre le popUp
		NamePopUP = 'titre' + tmpTitle;	//Set le noubeau nom du popUp
}


function doOver() {
	var toEl = getReal(window.event.toElement, "className", "coolButton");
	var fromEl = getReal(window.event.fromElement, "className", "coolButton");
	if (toEl == fromEl) return;
	var el = toEl;
	
//	alert(el);
	
//	var cDisabled = el.getAttribute("cDisabled");
	var cDisabled = el.cDisabled;
//	alert(cDisabled);
	cDisabled = (cDisabled != null); // If CDISABLED atribute is present
	
	if (el.className == "coolButton")
		el.onselectstart = new Function("return false");
	
	if ((el.className == "coolButton") && !cDisabled) {
		makeRaised(el);
		makeGray(el,false);
	}
}

function doOut() {
	var toEl = getReal(window.event.toElement, "className", "coolButton");
	var fromEl = getReal(window.event.fromElement, "className", "coolButton");
	if (toEl == fromEl) return;
	var el = fromEl;

//	var cDisabled = el.getAttribute("cDisabled");
	var cDisabled = el.cDisabled;
	cDisabled = (cDisabled != null); // If CDISABLED atribute is present

	var cToggle = el.cToggle;
	toggle_disabled = (cToggle != null); // If CTOGGLE atribute is present

	if (cToggle && el.value) {
		makePressed(el);
		makeGray(el,true);
	}
	else if ((el.className == "coolButton") && !cDisabled) {
		makeFlat(el);
		makeGray(el,true);
	}

}

function doDown() {
	el = getReal(window.event.srcElement, "className", "coolButton");
	
	var cDisabled = el.cDisabled;
	cDisabled = (cDisabled != null); // If CDISABLED atribute is present
	
	if ((el.className == "coolButton") && !cDisabled) {
		makePressed(el)
	}
}

function doUp() {
	el = getReal(window.event.srcElement, "className", "coolButton");
	
	var cDisabled = el.cDisabled;
	cDisabled = (cDisabled != null); // If CDISABLED atribute is present
	
	if ((el.className == "coolButton") && !cDisabled) {
		makeRaised(el);
	}
}


function getReal(el, type, value) {
	temp = el;
	while ((temp != null) && (temp.tagName != "BODY")) {
		if (eval("temp." + type) == value) {
			el = temp;
			return el;
		}
		temp = temp.parentElement;
	}
	return el;
}

function findChildren(el, type, value) {
	var children = el.children;
	var tmp = new Array();
	var j=0;
	
	for (var i=0; i<children.length; i++) {
		if (eval("children[i]." + type + "==\"" + value + "\"")) {
			tmp[tmp.length] = children[i];
		}
		tmp = tmp.concat(findChildren(children[i], type, value));
	}
	
	return tmp;
}

function disable(el) {

	if (document.readyState != "complete") {
		window.setTimeout("disable(" + el.id + ")", 100);	// If document not finished rendered try later.
		return;
	}
	
	var cDisabled = el.cDisabled;
	
	cDisabled = (cDisabled != null); // If CDISABLED atribute is present

	if (!cDisabled) {
		el.cDisabled = true;
		
		el.innerHTML = '<span style="background: buttonshadow; width: 100%; height: 100%; text-align: center;">' +
						'<span style="filter:Mask(Color=buttonface) DropShadow(Color=buttonhighlight, OffX=1, OffY=1, Positive=0); height: 100%; width: 100%%; text-align: center;">' +
						el.innerHTML +
						'</span>' +
						'</span>';

		if (el.onclick != null) {
			el.cDisabled_onclick = el.onclick;
			el.onclick = null;
		}
	}
}

function enable(el) {
	var cDisabled = el.cDisabled;
	
	cDisabled = (cDisabled != null); // If CDISABLED atribute is present
	
	if (cDisabled) {
		el.cDisabled = null;
		el.innerHTML = el.children[0].children[0].innerHTML;

		if (el.cDisabled_onclick != null) {
			el.onclick = el.cDisabled_onclick;
			el.cDisabled_onclick = null;
		}
	}
}

function addToggle(el) {
	var cDisabled = el.cDisabled;
	
	cDisabled = (cDisabled != null); // If CDISABLED atribute is present
	
	var cToggle = el.cToggle;
	
	cToggle = (cToggle != null); // If CTOGGLE atribute is present

	if (!cToggle && !cDisabled) {
		el.cToggle = true;
		
		if (el.value == null)
			el.value = 0;		// Start as not pressed down
		
		if (el.onclick != null)
			el.cToggle_onclick = el.onclick;	// Backup the onclick
		else 
			el.cToggle_onclick = "";

		el.onclick = new Function("toggle(" + el.id +"); " + el.id + ".cToggle_onclick();");
	}
}

function removeToggle(el) {
	var cDisabled = el.cDisabled;
	
	cDisabled = (cDisabled != null); // If CDISABLED atribute is present
	
	var cToggle = el.cToggle;
	
	cToggle = (cToggle != null); // If CTOGGLE atribute is present
	
	if (cToggle && !cDisabled) {
		el.cToggle = null;

		if (el.value) {
			toggle(el);
		}

		makeFlat(el);
		
		if (el.cToggle_onclick != null) {
			el.onclick = el.cToggle_onclick;
			el.cToggle_onclick = null;
		}
	}
}

function toggle(el) {
	el.value = !el.value;
	
	if (el.value)
		el.style.background = "URL(/images/tileback.gif)";
	else
		el.style.backgroundImage = "";

//	doOut(el);	
}


function makeFlat(el) {
	with (el.style) {
		background = "";
		border = "1px solid buttonface";
		padding      = "1px";
	}
}

function makeRaised(el) {
	with (el.style) {
		borderLeft   = "1px solid buttonhighlight";
		borderRight  = "1px solid buttonshadow";
		borderTop    = "1px solid buttonhighlight";
		borderBottom = "1px solid buttonshadow";
		padding      = "1px";
	}
}

function makePressed(el) {
	with (el.style) {
		borderLeft   = "1px solid buttonshadow";
		borderRight  = "1px solid buttonhighlight";
		borderTop    = "1px solid buttonshadow";
		borderBottom = "1px solid buttonhighlight";
		paddingTop    = "2px";
		paddingLeft   = "2px";
		paddingBottom = "0px";
		paddingRight  = "0px";
	}
}

function makeGray(el,b) {
	var filtval;
	
	if (b)
		filtval = "gray()";
	else
		filtval = "";

	var imgs = findChildren(el, "tagName", "IMG");
		
	for (var i=0; i<imgs.length; i++) {
		imgs[i].style.filter = filtval;
	}

}
	

document.write("<style>");
document.write(".coolBar	{background: buttonface;border-top: 1px solid buttonhighlight;	border-left: 1px solid buttonhighlight;	border-bottom: 1px solid buttonshadow; border-right: 1px solid buttonshadow; padding: 1px; font: menu;}");
document.write(".coolButton {border: 1px solid buttonface; padding: 1px; text-align: center; cursor: default;}");
document.write(".coolButton IMG	{filter: gray();}");
document.write("</style>");
