//#
/*
function ImagePop(sPopupTitle,sImageTag,sImageWidth,sImageHeight,sRedirectionUrl)
	{
		var width	= sImageWidth ;
		var height	= sImageHeight ;
		var left	= (screen.width/2) - width/2 ;
		var top		= (screen.height/2) - height/2 ;
		var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=no, width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',screenX=' + left + ',screenY=' + top;

		var msgWindow	= window.open('','pop', styleStr);
		var head		=	'<head><title>' + sPopupTitle + '</title>';

		if(sRedirectionUrl == '')
			{
			// si pas d'url spécifiée, on se content de fermer
			sRedirection = '<a href="#" onclick="window.close();">' + sImageTag + '</a>' ;
			}
			else
			{
			sRedirection = '<a href="#" onclick="window.opener.location.href=\'' + sRedirectionUrl + '\'; window.close()">' + sImageTag + '</a>' ;
			}
		
		//var msg	= '<' + 'script language=javascript><' + '/script>';
		
		//var body = '<center>'+msg+'<br><p><form><input type="button" value="   close   " onClick="self.close()"></form>';
		var body = '<body style="padding:0;margin:0;spacing:0">' + sRedirection + '</body>' ;
		
		var popupwindow;
		msgWindow.document.write(head + body);
	}

function ContentPop(sPopupTitle,sPopupContent,sDirectory,width,height)
	{
	// attribution de taille par défaut si pas spécifiée
		if (width == '')	width	= 300 ;
		if (height == '')	height	= 200 ;
		var left	= (screen.width/3) - width/2 ;
		var top		= (screen.height/3) - height/2 ;
		var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=no, width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',screenX=' + left + ',screenY=' + top ;
		
		if(msgWindow) msgWindow.close();
		
		var msgWindow	= window.open('','pop', styleStr) ;
		var head		=	'<head><title>' + sPopupTitle + '</title>' ;
			head		+=	'<' + 'script type="text/javascript" src="/' + sDirectory + '/js/pop.js"><' + '/script>' ;
			head		+=	'<' + 'link rel="stylesheet" type="text/css" href="/' + sDirectory + '/css/imagine.css"><' + '/script>' ;
			//head		+=	'<' + 'script language="javascript">test(\'' + sPopupTitle + '\')<' + '/script>' ;
			head		+=	'</head>' ;

			sRedirection = sPopupContent ;
		
		//var body = '<center>'+msg+'<br><p><form><input type="button" value="   close   " onClick="self.close()"></form>';
		var body = '<body style="padding:0;margin:0;spacing:0;background-color:#FFFFFF;">' + sRedirection + '</body>';
		msgWindow.document.write(head + body);

	}
	
function insertImagePopup(sPopupTitle,sImageTag,sImageWidth,sImageHeight,sRedirectionUrl)
	{
	if (document.getElementById)
		{
		var oImage = new Image;
		
		document.write('<div id="popup" style="z-index:200;position:absolute;width:' + oImage.width + ';height:' + oImage.height + '"><a href="' + sRedirectionUrl + '" target=_blank>' + sImageTag + '</a></div><div id="shadow" style="z-index:100;position:absolute;width:' + oImage.width + ';height:' + oImage.height + ';background:#000000;filter:alpha(opacity=40); -moz-opacity: .4;"></a></div>');
		var screenx;
		var screeny;
		
		screenx = document.body.clientWidth ;
		screeny = document.body.clientHeight ;
		
		document.getElementById("popup").style.top		= (screeny - oImage.height / 2 - 30);
		document.getElementById("popup").style.left		= (screenx - oImage.width / 2 - 30);
		document.getElementById("shadow").style.top		= (screeny - oImage.height / 2 - 25);
		document.getElementById("shadow").style.left	= (screenx - oImage.width / 2 - 25);
		}
	}
function loadpopup()
	{
	if (document.getElementById)
		{
		w2 = document.body.scrollTop ;
		document.getElementById("popup").style.top		= (w2 + screeny - oImage.height / 2 - 30);
		document.getElementById("shadow").style.top		= (w2 + screeny - oImage.height / 2 - 25);
		setTimeout("loadpopup()",1);
		}
	}
*/

//***** gestion DHTML *******
//#
var deactivate;
var SWF ;

function openImagePopup()
{
	// SWF = true si l'extension du fichier = swf
	SWF = (imagePath.split('.')[1].toLowerCase() == 'swf') ? true : false ;
	

	document.getElementById("popcontainer").style.display = 'none';
	document.getElementById("popshadow").style.width = imageWidth;
	document.getElementById("popshadow").style.height = imageHeight;

	if (!isOpened) window.clearTimeout(deactivate) ;
	
	document.getElementById("popup").style.top	= yPosition;
	document.getElementById("popup").style.left	= xPosition;
	document.getElementById("popshadow").style.top	= yPosition+3;
	document.getElementById("popshadow").style.left	= xPosition+3;
	

	if(SWF)
		{ // traitement pour les animations Flash
		
		document.getElementById("popup").innerHTML	= '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" id="pop" ALIGN="" width="' + imageWidth + '" height="' + imageHeight + '"><PARAM NAME=movie VALUE="' + imagePath + '"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="' + imagePath + '" quality=high bgcolor=#FFFFFF NAME="pop" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" width="' + imageWidth + '" height="' + imageHeight + '"></EMBED></OBJECT>';
		}
		else
		{ // traitement pour les images
		
		document.getElementById("popshadow").style.width = oImage.width;
		document.getElementById("popshadow").style.height = oImage.height;
		var target;
			if (sRedirection.indexOf('http') != -1){target = '_blank'} else {target = '_self' } ;
		
		document.getElementById("popup").innerHTML	= '<a href="' + sRedirection + '" target="' + target + '" onclick="closeImagePopup()"><img src="' + oImage.src + '" border="0"></a>';
		}
	
	if ( xPosition < 200 )
		{
		xPosition = xPosition + 50;
		yPosition = yPosition + 3;
		activate = setTimeout("openImagePopup()",10);
		}
		else
		{
		document.getElementById("popcontainer").style.top	= yPosition ;
		
		if(SWF)
		{
			document.getElementById("popcontainer").style.left	= xPosition + imageWidth ;
		}
		else
		{
			document.getElementById("popcontainer").style.left	= xPosition + imageWidth - 13;
		}
		
		document.getElementById("popcontainer").style.display = 'block';
		document.getElementById("opening").style.display = 'none';
		deactivate = setTimeout("closeImagePopup()",20000);
		}
}

function closeImagePopup()
{

	//fastCloseImagePopup(); isOpened = 'false';
	document.getElementById("popcontainer").style.display = 'none';
	isOpened = 'true' ;
	window.clearTimeout(activate) ;
	document.getElementById("popup").style.top	= yPosition ;
	document.getElementById("popup").style.left	= xPosition ;
	
	document.getElementById("popshadow").style.top	= yPosition + 3;
	document.getElementById("popshadow").style.left	= xPosition + 3;
	
	document.getElementById("popcontainer").style.top	= yPosition;
	document.getElementById("popcontainer").style.left	= xPosition + imageWidth;
	
	if ( xPosition > negImageWidth-30 )
		{
		xPosition = xPosition - 60 ;
		yPosition = yPosition + 3 ;
		deactivate = setTimeout("closeImagePopup()",5) ;
		}
		else
		{
		activate = setTimeout("openImagePopup()",600000) ;
		}
}

function fastCloseImagePopup()
{
	document.getElementById("popupwindow").style.display = 'none';

}

// gestion des cookies
function GetCookie(name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
		{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
		}
	return 'null';
}

function getCookieVal (offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}