
/* EVENEMENTS JAVASCRIPT :

onmouseup = Le bouton de la souris est relaché
onmouseover =  Le curseur de la souris entre sur le layer
onmouseout = Le curseur de la souris sort du layer

*/

//***   *************** AJOUT DE CaYuS *************** ***//

// *** Des PopUps aux normes, et qui marchent ***

var newWindow = null;

function closeWin()
{
	if (newWindow != null)
	{
		if(!newWindow.closed)
		{
			newWindow.close();
		}
	}
}

function popUpWin(url, type, strWidth, strHeight)
{
	closeWin();

	if (type == "fullScreen")
	{
		strWidth = screen.availWidth - 10;
		strHeight = screen.availHeight - 160;
	}
	else
	{
		strWidth = strWidth + 37;
		strHeight = strHeight + 75;
	}

	var tools="";

	if (type == "standard" || type == "fullScreen")
	{
		tools = "resizable,toolbar=no,location=no,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	}

	if (type == "console")
	{
		tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=0,top=0";
	}

	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

//***   *************** FIN *************** ***//


// *** GetPageName ***
// Ecrit le nom de la page courante

function GetPageName()
{
	document.write(document.title);
}


// *** SwapImage ***
// sLayerName = Nom du layer dont on veut "swapper" l'image
// iImageIndex = index (entier) de l'image alternative (le nom de l'image doit être : NOMDEBASE + O + index) 
//			Exemple : 	image de base = bouilledegris_gribouillage.gif
//					image alternative 1 = bouilledegris_gribouillageO1.gif
//					image alternative 2 = bouilledegris_gribouillageO2.gif... etc

function SwapImage(sLayerName, iImageIndex)
{
	var CurDiv = document.getElementById(sLayerName);
	if(CurDiv != null)
	{
		var aCurBG = CurDiv.style.background.split(".");
		var newBG = aCurBG[0] + "O" + iImageIndex + "." +  aCurBG[1];
		CurDiv.style.background = newBG;
	}
}

// *** UnswapImage ***
// sLayerName = Nom du layer dont on veut faire revenir l'image originale
// Voir SwapImage

function UnswapImage(sLayerName)
{
	var CurDiv = document.getElementById(sLayerName);
	if(CurDiv != null)
	{
		var aCurBG = CurDiv.style.background.split(".");
		CurDiv.style.background = aCurBG[0].substring(0,aCurBG[0].length - 2) + "." + aCurBG[1];
	}
}

// *** ChangeImage ***
// sLayerName = Nom du layer dont on veut changer l'image
// sImagePath  = Nouveau chemin d'image

function ChangeImage(sLayerName, sImagePath)
{
	var CurDiv = document.getElementById(sLayerName);
	if(CurDiv != null)
	{
		CurDiv.style.background = "url(" + sImagePath + ")";
	}
}

// *** HideLayer ***
// sLayerName = Nom du layer que l'on veut cacher

function HideLayer(sLayerName)
{
	toggleBox(sLayerName, 0);
}

// *** ShowLayer ***
// sLayerName = Nom du layer que l'on veut montrer

function ShowLayer(sLayerName)
{
	toggleBox(sLayerName, 1);
}

// *** PopUp ***
// sPath = chemin de la page html à montrer dans la popup
// sName = Nom de la popup

function PopUp(sPath, sName)
{
	window.open (sPath, sName, 'toolbar=no,scrollbars=YES, WIDTH=840 ,height=800');
}

// *** HELPERS ***

function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}

