


function getWindowTop()
{
	
	if(document.documentElement)
	{
		var top = document.documentElement.scrollTop;
	}
	else
		var top = document.body.pageYOffset;
	
		return top;
}




/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////
/////////////////////////////////////////////////		Scripts pour la LTBox
/////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

function prechargimg() 
{
	var doc=document;
	if(doc.images)
	{ 
		if(!doc.precharg)
			doc.precharg=new Array();
		var i,j=doc.precharg.length,x=prechargimg.arguments; 
		for(i=0; i<x.length; i++)
			if (x[i].indexOf("#")!=0)
			{ 
				doc.precharg[j]=new Image;
				doc.precharg[j++].src=x[i];
			}
	}
}


function hideLtBox()
{
	document.body.removeChild(document.getElementById('LTBackground')); 
	document.body.removeChild(document.getElementById('LTCadre'));  	
	if(!isIe6())
		document.body.style.overflow = "auto";
		
	if(isIe6())
	{
		allSelect = document.getElementsByTagName('select');
		for(var i=0; i<allSelect.length; i++)
			allSelect[i].style.visibility = allSelect[i].oldVisibility;
	}
}

prechargimg('image/corner-top-right.png','image/corner-top-left.png','image/corner-bottom-right.png','image/corner-bottom-left.png');





function showLtBoxFrame(url,options)
{
	
	if(!options)
		options = {};
	
	var frameWidth = (options.width)?options.width:500;
	var frameHeight = (options.height)?options.height:350;
	
	options.width = frameWidth;
	options.height = frameHeight;
	
	showLtBox
	(
		'<iframe frameborder="0" src="'+url+'" width="100%" height="'+frameHeight+'"></iframe>',options
	);	
	
}


function isIe6()
{
	var IE6 = false; 

	var strChUserAgent = navigator.userAgent;
	var intSplitStart = strChUserAgent.indexOf("(",0);
	var intSplitEnd = strChUserAgent.indexOf(")",0);
	var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
	
	if(strChMid.indexOf("MSIE 6") != -1) IE6 = true;

	return IE6;
}



function showLtBox(content, options)
{

	if(!options)
		options = {};
	
	var backgroundOpacity = (options.backgroundOpacity)?options.backgroundOpacity:80;
	var backgroundColor = (options.backgroundColor)?options.backgroundColor:'#000';
	var contentOpacity = (options.contentOpacity)?options.contentOpacity:100; 
	var after = options.after;
 
	
	var width = (options.width)?options.width:500;
	var height = (options.height)?options.height:350;
	var display_title = (options.display_title)?options.display_title:false;
	
	
	
	if(isIe6())
	{
		allSelect = document.getElementsByTagName('select');
		for(var i=0; i<allSelect.length; i++)
		{
			allSelect[i].oldVisibility = allSelect[i].style.visibility;
			allSelect[i].style.visibility = "hidden";
		}
	}
	
	
	if(!document.getElementById("LTBackground"))
	{
		var LTBackground = document.createElement("div");
		LTBackground.id = "LTBackground";
		LTBackground.style.top = getWindowTop()+'px';
		LTBackground.style.left = "-5px";
		LTBackground.style.padding = "10px";
		LTBackground.style.width = "99%";
		if(isIe6())			
			LTBackground.style.height = screen.availHeight+'px';
		else
			LTBackground.style.height = "98%";
			

		LTBackground.style.position = "absolute";
		LTBackground.style.display = "none";
		LTBackground.onclick = function()
		{
			hideLtBox();
			//document.getElementById("LTBackground").style.display = "none";
			//document.getElementById("LTContent").style.display = "none";
		};		
		//LTBackground.style.opacity = "0.7";
		LTBackground.style.zIndex = "98";
		LTBackground.style.backgroundColor = backgroundColor;
		
	
		
		document.body.appendChild(LTBackground);
	}
	
	if(!isIe6())
		document.body.style.overflow = "hidden";
	

	if(!document.getElementById("LTContent"))
	{
		var LtContentTop = document.createElement('div');
		LtContentTop.style.height = '14px';
		LtContentTop.style.width = width+'px';
		
		var LtContentTopLeft = document.createElement('span');
		LtContentTopLeft.style.height = '14px';
		LtContentTopLeft.style.width = '16px';
		LtContentTopLeft.style.display = 'inline-block';
		LtContentTopLeft.style.backgroundImage = 'url(/image/corner-top-left.png)';
		
		var LtContentTopCenter = document.createElement('span');
		LtContentTopCenter.style.height = '14px';
		LtContentTopCenter.style.width = (width-32)+'px';
		LtContentTopCenter.style.display = 'inline-block';
		LtContentTopCenter.style.backgroundColor = '#FFF';
		
		var LtContentTopRight = document.createElement('span');
		LtContentTopRight.style.height = '14px';
		LtContentTopRight.style.width = '16px';
		LtContentTopRight.style.display = 'inline-block';
		LtContentTopRight.style.backgroundImage = 'url(/image/corner-top-right.png)';
		
		LtContentTop.appendChild(LtContentTopLeft);
		LtContentTop.appendChild(LtContentTopCenter);
		LtContentTop.appendChild(LtContentTopRight);
		

		var LTCadre = document.createElement("div");
		LTCadre.id = "LTCadre";
		LTCadre.style.marginLeft = "50%";
		LTCadre.style.left = "-"+(width/2)+"px";
		LTCadre.style.top = (getWindowTop()+50)+'px';
		//LTCadre.style.padding = "10px";
		LTCadre.style.width = width+"px";
		LTCadre.style.zIndex = "99";
		LTCadre.style.fontFamily = "calibri, arial";
		LTCadre.style.fontSize = "12px";
		LTCadre.style.overflow = "visible";
		LTCadre.style.position = "absolute";
		//LTCadre.style.border = "solid 2px #666";
		//LTCadre.style.backgroundColor = "#FFF";


		var LTContent = document.createElement("div");
		LTContent.id = "LTContent";
		//LTContent.style.border = "solid 2px #666";
		LTContent.style.padding = "10px";
		LTContent.style.minHeight = height+'px';
		LTContent.style.backgroundColor = "#FFF";
	
		
	
	
	
	
		var LtContentBottom = document.createElement('div');
		LtContentBottom.style.height = '14px';
		LtContentBottom.style.width = width+'px';
		
		var LtContentBottomLeft = document.createElement('span');
		LtContentBottomLeft.style.height = '14px';
		LtContentBottomLeft.style.width = '16px';
		LtContentBottomLeft.style.display = 'inline-block';
		LtContentBottomLeft.style.backgroundImage = 'url(/image/corner-bottom-left.png)';
		
		var LtContentBottomCenter = document.createElement('span');
		LtContentBottomCenter.style.height = '14px';
		LtContentBottomCenter.style.width = (width-32)+'px';
		LtContentBottomCenter.style.display = 'inline-block';
		LtContentBottomCenter.style.backgroundColor = '#FFF';
		
		var LtContentBottomRight = document.createElement('span');
		LtContentBottomRight.style.height = '14px';
		LtContentBottomRight.style.width = '16px';
		LtContentBottomRight.style.display = 'inline-block';
		LtContentBottomRight.style.backgroundImage = 'url(/image/corner-bottom-right.png)';
	
		LtContentBottom.appendChild(LtContentBottomLeft);
		LtContentBottom.appendChild(LtContentBottomCenter);
		LtContentBottom.appendChild(LtContentBottomRight);
	

		
		LTCadre.appendChild(LtContentTop);
		LTCadre.appendChild(LTContent);
		LTCadre.appendChild(LtContentBottom);
		
		
		

		var LTClose = document.createElement("div");
		LTClose.id = "LTClose";
		LTClose.style.right = "4px";
		LTClose.style.top = "4px";
		LTClose.style.width = "67px";
		LTClose.style.height = "22px";
		LTClose.style.padding = "3px";
		LTClose.style.fontWeight = "bold";
		LTClose.style.color = "#343434";
		LTClose.style.zIndex = "99";
		LTClose.style.position = "absolute";
		LTClose.onmouseover = function()
		{
			this.style.color = "#000";
		}
		LTClose.onmouseout = function()
		{
			this.style.color = "#343434";
		}
		
		LTClose.style.fontSize = "17px";
		LTClose.style.backgroundImage = 'url(/image/close.jpg)';
		LTClose.style.backgroundRepeat = "no-repeat";
		LTClose.style.cursor = "pointer";
		LTClose.onclick = function()
		{
			hideLtBox();
		};		



	
		LTCadre.style.display = "none";
		document.body.appendChild(LTCadre); 
	}
	

	

	
	
	document.getElementById("LTBackground").style.display = "block";

	
	
	changeOpacity
	(
		'LTBackground',
		0,
		backgroundOpacity,
		10,
		function()
		{
			document.getElementById('LTCadre').style.display = "block";
			changeOpacity
			(
			 	'LTCadre',
				0,
				contentOpacity,
				5,
				function()
				{

					document.getElementById("LTContent").innerHTML = content;
					document.getElementById("LTContent").appendChild(LTClose); 	
					if(after)
						after();
				}			
			);
			
			
		
		
		}
	);
	
	window.onscroll = function()
	{
		document.getElementById('LTBackground').style.top = getWindowTop()+'px';
		document.getElementById('LTCadre').style.top = (getWindowTop()+50)+'px';	
		
	}
	
	
	

	
	
	//document.getElementById("LTContent").style.display = "block";

	
}





/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////
/////////////////////////////////////////////////		Scripts pour le panel
/////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////





//// CHANGEMENT D'OPACITE DUNE DIV

function changeOpacity(divid,begin,end,speed,after)
{

	if(!speed)
		speed = 1;
	var opacity = 0;
	
	var div = document.getElementById(divid)
	
	div.isChangingOpacity = 1;
	opacity = begin;		
	
	
	if(begin<end)
		var sens = 1;
	else
		var sens = 0

	
	if(sens == 1)
		opacity = opacity + speed;
	else
		opacity = opacity - speed;
		
	if(opacity > 100)
		opacity = 100;
	if(opacity < 0)
		opacity = 0;
	
	var style = div.style
	
	style.opacity = (opacity / 100);
    style.MozOpacity = (opacity / 100);
    style.KhtmlOpacity = (opacity / 100);
    style.filter = "alpha(opacity=" + opacity + ")";

	if(opacity != end)
	{
		var timeout = function()
		{
			changeOpacity(divid,opacity,end,speed,after)
		}
		setTimeout(timeout,1);	
	}
	else
	{
		div.isChangingOpacity = 0;
		if(after)
			after();
		
	}
}


