function frenchDateToDateObject(originalvalue) // en entree date au format  jj/mm/aaaa hh:ii
{
	var date_day = originalvalue.substring(0,2);
	if(date_day.charAt(0) == '0')
		date_day = date_day.charAt(1);
	date_day = parseInt(date_day);
	
	
	var date_month = originalvalue.substring(3,5);
	if(date_month.charAt(0) == '0')
		date_month = date_month.charAt(1);
	date_month = parseInt(date_month)-1;
	
	
	var date_year = parseInt(originalvalue.substring(6,10));
	
	var date_hour = originalvalue.substring(11,13);
	if(date_hour.charAt(0) == '0')
		date_hour = date_hour.charAt(1);
	date_hour = parseInt(date_hour);
	
	date_min = originalvalue.substring(14,16);
	if(date_min.charAt(0) == '0')
		date_min = date_min.charAt(1);
	date_min = parseInt(date_min);
	
	var date = new Date(date_year,date_month,date_day,date_hour,date_min,0);
	
	return date;
	
}



function showAndHide(id)
{
	var elem = document.getElementById(id);
	
	if(!elem.showAndHide_marker)
	{
		if(elem.clientHeight && elem.clientWidth)
			elem.showAndHide_marker = 'visible';
		else
			elem.showAndHide_marker = 'hidden';
	}
	if(elem.showAndHide_marker == 'hidden')
	{
		elem.showAndHide_marker = "visible";
		elem.style.display = "block";
	}
	else if(elem.showAndHide_marker == 'visible')
	{
		elem.showAndHide_marker = "hidden";
		elem.style.display = "none";
	}
}

function show(div)
{
	
	document.getElementById(div).style.display = 'block';
	
}

function hide(div)
{
	document.getElementById(div).style.display = 'none';	
}

function LtCaroussel(divId)
{
	this.speed = 1;
	this.position = 0;
	LtCarousselObject = this;
	
	this.init = function()
	{
		this.caroussel = document.getElementById(divId);
		this.carousselWidth = this.caroussel.clientWidth;
		this.maxLeft = this.carousselWidth - this.caroussel.parentNode.clientWidth;
	}
	
	
	this.goLeft = function()
	{
		this.init();
		this.position = this.position+this.speed;
		
		if(this.position > 0)
		{
			this.stop();
			return null;
		}
		this.caroussel.style.left = this.position+"px";
		
		clearTimeout(this.timeout);
		this.timeout = setTimeout(function(){LtCarousselObject.goLeft();},2);
		
	}
	
	this.goRight = function()
	{
		if(this.position < this.maxLeft*-1)
		{
			this.stop();
			return null;
		}
		this.init();
		this.position  = this.position-this.speed;
		this.caroussel.style.left = this.position+"px";
		
		
		clearTimeout(this.timeout);
		this.timeout = setTimeout(function(){LtCarousselObject.goRight();},2);
		
	}
	
	
	this.stop = function()
	{
		clearTimeout(this.timeout);	
	}
}


function loadUrlInDiv(url,blockdest,options)
{
	if(options)
	{
		var parameters = options.parameters;
		var onSuccess2 = options.onSuccess;
	}
	
	url = url.replace('\#','');




	new Ajax.Request
	(	
		url,
		{
			method : "POST",
			parameters : parameters,
			onSuccess : function(transport)
			{
				var retour = transport.responseText;
				document.getElementById(blockdest).innerHTML  = transport.responseText;
				
				
				if(onSuccess2)
					onSuccess2();
				
			}
		}
	);	
}



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 ajaxInsert(url,after)
{
	new Ajax.Request(url, {
					 method:'post', onSuccess : after
					
					 });				
	return false;
}



// DETECTION DE FLASH

function detectFlash()
{
	if( navigator.mimeTypes.length > 0 )
		return navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin != null;
	else if( window.ActiveXObject )
	{
		try
		{
			new ActiveXObject( "ShockwaveFlash.ShockwaveFlash" );
			return true;
		}
		catch( oError )
		{
			return false;
		}
	}
	else
		return false;
}

function hideAllFlash()
{
	var allFlash = document.getElementsByTagName('OBJECT');
	for(var i=0; i<allFlash.length; i++)
	{
		allFlash[i].originalVisibility = allFlash[i].style.visibility;
		allFlash[i].style.visibility = "hidden";
		
	}
}

function showAllFlash()
{
	var allFlash = document.getElementsByTagName('OBJECT');
	for(var i=0; i<allFlash.length; i++)
	{
		if(allFlash[i].originalVisibility)
			allFlash[i].style.visibility = allFlash[i].originalVisibility;
		else
			allFlash[i].style.visibility = '';
	}
	
}




// DETECTION DE LA PRESSION D'UNE TOUCHE


function  DetecteTouche(e, touche)
{
	var EnterKey;
	
	
	if(document.all) 
	{
		ev = window.event;
		EnterKey = ev.keyCode;
	}
	else
	{        
		EnterKey = e.keyCode;
	}
	
	//showForDev(EnterKey);
	
	return  (EnterKey == touche) 
	
}


// SIMPLIFICATION DU INNERHTML




function setBaliseContent(id,content)
{
	if(document.getElementById(id))
		document.getElementById(id).innerHTML = content;
	
}

function addBaliseContent(id,content)
{
	if(document.getElementById(id))
		document.getElementById(id).innerHTML += content;
	
}
function getBaliseContent(id)
{

	
	if(document.getElementById(id))
	{

		return document.getElementById(id).innerHTML;
	}
	else
		return '';
}


 
function getFieldValue(idfield,form)
{

	if(form)
	{
		var doc = document.getElementById(form);
		if(!doc)
			doc = document.forms[form];
		var field = doc.elements[idfield];
	}
	else
	{
		doc = document;
			var field = doc.getElementById(idfield);
	}
	


	

	if(field)
		var type = field.tagName;
	var value = '';
	

	if(type == 'SELECT')
		value = field.options[field.selectedIndex].value
	else if(type == 'INPUT' && field.type.toUpperCase() == 'CHECKBOX')
	{
		value = (field.checked)?'1':'0';
	}
	else if(field)
		value = field.value;
		
	return value;
}


function setFieldValue(idfield,value)
{
	if(typeof(idfield) =='object')
	{
		var field = idfield;
		idfield = field.id;
	}
	else
		var field = document.getElementById(idfield);
	
	
	if(document.getElementById(idfield+'_id'))
	{
		document.getElementById(idfield+'_id').value = value;
	}
	
	

	var type = field.tagName;
	

	
	if(type == 'INPUT' && field.type.toUpperCase() == 'CHECKBOX')
	{
		field.checked = (value && value!='0')?true:false;
	}
	else
		field.value = value;
		
	
}

function addToOnchange(idfield,onchange2)
{
	if(document.getElementById("chk"+idfield))
		addEvent(document.getElementById('chk'+idfield),'click',onchange2,false);
	else
		addEvent(document.getElementById(idfield),'change',onchange2,false);
	
}




function addEvent(obj,evType,fn,capt){ 

  if(!obj)
  	return null;

  if(obj.addEventListener){

    obj.addEventListener(evType,fn,capt);return true;} // NS6+ 

  else if(obj.attachEvent)obj.attachEvent("on"+evType,fn) // IE 5+ 

  else {

   return false;

  } 

} 

// ajout d'un evenement sur le onload

function addOnLoad(functiontolaunch)
{
	addEvent(window,"load",functiontolaunch,false);
}


function getElementsByClass(className,idparent)
{
/*	
	if(window.location.href.match("intra.gkm"))
		alert(className);
	*/
	if(idparent)
	{
		if(typeof(idparent) == 'string')
			var doc = document.getElementById(idparent);
		else
			var doc = idparent;
	}
	else
		var doc = document;
	elements = new Array();
	var allElements = doc.getElementsByTagName('*');
	
	
	
	if(allElements.length)
	{
		for(var i=0; i<allElements.length; i++)
		{
			if(allElements[i].className.match(className))
				elements.push(allElements[i]);
			
		}
	}
	

	return elements;

}

function getElementByClass(className,idparent)
{
	var list = getElementsByClass(className,idparent);
	if(list.length)
		return list[0];
	
}


// INFOS FENETRE


function getWindowHeight()
{
	
	
	if(window.innerHeight)
	{
		var haut = (window.innerHeight);
	}
	else if ( document.documentElement)
	{
			var haut = document.documentElement.clientHeight;
	}
	
	return haut;

}


function getWindowWidth()
{
	if (window.innerWidth)
	{
		var larg = (window.innerWidth);
		
	}
	else if(document.body)
	{
		var larg = (document.body.clientWidth);
	}
	return larg;

}



function getWindowTop()
{
	if(document.body.scrollTop) // google chrome
		var top = document.body.scrollTop;
	else if(document.documentElement) // ie 
		var top = document.documentElement.scrollTop;
	else // firefox
		var top = document.body.pageYOffset;
	
	return top;
}




// perchargement

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 setOuterHtml(node,html)
{
			
	var idnode = node.id;
	
	var parent = node.parentNode;
	
	var htmlNode = document.createElement('div');
	htmlNode.innerHTML = html;
	parent.replaceChild(htmlNode,node);
	
	var newNode = document.getElementById(idnode);

	parent.insertBefore(newNode,htmlNode);
	parent.removeChild(htmlNode);
	
	
}


function LtDiaporama()
{	
	this.images = new Array();
	this.descriptions = new Array();
	this.currentImageNumber = 0;
	
	this.options = {};
	
	var diapoObj = this;

	
	this.launch = function(firstImage)
	{
		if(!firstImage)
			firstImage = 1;
		document.body.style.overflow = "hidden";
		
		this.backgroundOpacity = (this.options.backgroundOpacity)?this.options.backgroundOpacity:60;
		this.backgroundColor = (this.options.backgroundColor)?this.options.backgroundColor:'#000';
		this.borderColor = (this.options.borderColor)?this.options.borderColor:'#FFF';
		this.contentOpacity = (this.options.contentOpacity)?this.options.contentOpacity:100; 
		this.top = (this.options.top)?this.options.top:100;
		
		hideAllFlash();
		
		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(this.images.length > 1)
			this.showFleches();
		this.showBackgroundAndFirstPicture(firstImage);
	}
	
	this.quit = function()
	{
		
		document.body.style.overflow = "";
		document.body.removeChild(this.LTBackground);
		document.body.removeChild(this.LTImage);
		if(document.getElementById('LTDescription'))
			document.body.removeChild(document.getElementById('LTDescription'));
		document.body.removeChild(this.LTClose);
		document.body.removeChild(this.fleche_left);
		document.body.removeChild(this.fleche_right);
		this.LTBackground = null;
		this.LTDescription = null;
		this.LTImage = null;
		this.LTClose = null;
		this.fleche_left = null;
		this.fleche_right = null;
		
		window.onscroll = null;
		
		if(!isIe6())
			document.body.style.overflow = "auto";
		
		showAllFlash();
		
		if(isIe6())
		{
			allSelect = document.getElementsByTagName('select');
			for(var i=0; i<allSelect.length; i++)
				allSelect[i].style.visibility = allSelect[i].oldVisibility;
		}
		
		this.currentImageNumber = 0;
	}
	
	this.next = function()
	{
		if(this.currentImageNumber == this.images.length)
			var nextImageNumber = 1;
		else
			var nextImageNumber = this.currentImageNumber + 1;
			
		this.hideCurrentImage(function(){diapoObj.showImage(diapoObj.images[nextImageNumber-1],diapoObj.descriptions[nextImageNumber-1]);});
		this.currentImageNumber = nextImageNumber;
	}
	
	this.previous = function()
	{
		if(this.currentImageNumber == 1)
			var previousImageNumber = this.images.length;
		else
			var previousImageNumber = this.currentImageNumber - 1;
		
		this.hideCurrentImage(function(){diapoObj.showImage(diapoObj.images[previousImageNumber-1],diapoObj.descriptions[previousImageNumber-1]);});
		
		this.currentImageNumber = previousImageNumber;
	}
	
	this.addImage = function(imageSrc,description)
	{
		var imagepreload =new Image;
		imagepreload.src = imageSrc;
		
		this.descriptions.push(description);
		this.images.push(imageSrc);	
	}
	
	
	this.showFleches = function()
	{
		this.fleche_left = document.createElement('img');
		this.fleche_left.src = 'http://images.lucas-tordeux.com/mini_left1.png';
		this.fleche_left.style.position = "absolute";
		this.fleche_left.style.top= getWindowTop()+20+'px';
		//this.fleche_left.style.top= getWindowTop()+(document.body.clientHeight/4)+'px';
		this.fleche_left.style.marginLeft = "50%";
		this.fleche_left.style.left = '-20px';
		this.fleche_left.style.cursor = "pointer";
		this.fleche_left.style.zIndex = '99';
		this.fleche_left.onclick = function(){ diapoObj.previous(); };
		
		document.body.appendChild(this.fleche_left);
		
		this.fleche_right = document.createElement('img');
		this.fleche_right.src = 'http://images.lucas-tordeux.com/mini_right1.png';
		this.fleche_right.style.position = "absolute";
		this.fleche_right.style.top= getWindowTop()+20+'px';
		//this.fleche_left.style.top= getWindowTop()+(document.body.clientHeight/4)+'px';
		this.fleche_right.style.marginLeft = "50%";
		this.fleche_right.style.left = '20px';
		this.fleche_right.style.cursor = "pointer";
		this.fleche_right.style.zIndex = '99';
		this.fleche_right.onclick = function(){ diapoObj.next(); };
		
		document.body.appendChild(this.fleche_right);
	}
	
	this.showBackgroundAndFirstPicture = function(firstImage)
	{
		
		
		this.LTBackground = document.createElement("div");
		this.LTBackground.id = "LTBackground";
		this.LTBackground.ltDiapo = this;
		this.LTBackground.style.top = getWindowTop()+'px';
		this.LTBackground.style.left = "-5px";
		this.LTBackground.style.padding = "10px";
		this.LTBackground.style.width = "99%";
		if(isIe6())			
			this.LTBackground.style.height = screen.availHeight+'px';
		else
			this.LTBackground.style.height = "98%";
			

		this.LTBackground.style.position = "absolute";
		this.LTBackground.style.display = "none";
		this.LTBackground.onclick = function()
		{
			this.ltDiapo.quit();
		};		
		//this.LTBackground.style.opacity = "0.7";
		this.LTBackground.style.zIndex = "98";
		this.LTBackground.style.backgroundColor = this.backgroundColor;
		
	
		
		document.body.appendChild(this.LTBackground);
		
		this.LTBackground.style.display = "block";
		
		
		
		
		
		
		
		changeOpacity
		(
			'LTBackground',
			0,
			diapoObj.backgroundOpacity,
			10,
			function()
			{
				
				if(!diapoObj.images.length)
					return false;
				
				image1 = diapoObj.images[firstImage-1];
				description1 = diapoObj.descriptions[firstImage-1];
				diapoObj.currentImageNumber = 1;
				
				diapoObj.showImage(image1,description1);
			}
			
		);
		
		
		window.onscroll = function()
		{
		
			if(diapoObj.LTBackground) diapoObj.LTBackground.style.top = getWindowTop()+'px';
			if(diapoObj.LTImage) diapoObj.LTImage.style.top = (getWindowTop()+50)+'px';	
			
		}
	}
	
	this.hideCurrentImage = function(after)
	{
		document.body.removeChild(diapoObj.LTClose);
		diapoObj.LTClose = null;
		changeOpacity
		(
			'LTCadre',
			diapoObj.contentOpacity,
			0,
			5,
			function()
			{
				document.body.removeChild(diapoObj.LTImage);
				diapoObj.LTImage = null;
				
				after();
			}
		);
		
		if(document.getElementById('LTDescription'))
		{
			changeOpacity
			(
				'LTDescription',
				100,
				0,
				5,
				function()
				{
					document.body.removeChild(document.getElementById('LTDescription'));
					diapoObj.LTDescription = null;
					
				}
			);
		}
	}
	
	this.showImage = function(src,description)
	{
		
		
		var image = new Image();
		image.src = src;
						
		while(!image.width || !image.height)
		{
		 	setTimeout(function(){diapoObj.showImage(src,description);},100);
			return null;
			
		}
		
		
		var imageWidth = image.width;
		var imageHeight = image.height;
		
		if(imageWidth > getWindowWidth())
		{
			imageWidth = getWindowWidth()-100;
			imageHeight = (imageWidth*image.height)/image.width;		
			
		}
		if(imageHeight > getWindowHeight())
		{
			imageHeight = getWindowHeight()-150;
			imageWidth = (imageHeight*image.width)/image.height;		
		}
		
		this.LTImage = document.createElement('img');
		
		this.LTImage.id = "LTCadre";
		this.LTImage.style.backgroundColor = '#FFF';
		this.LTImage.style.marginLeft = "50%";
		this.LTImage.style.width = imageWidth+"px";
		this.LTImage.style.height = imageHeight+"px";
		this.LTImage.src = src;
		if(description)
		{
			this.LTImage.alt = description;
			this.LTImage.title = description;
			
		}
		this.LTImage.style.left = "-"+(imageWidth/2)+"px";
		this.LTImage.style.top = (getWindowTop()+this.top)+'px';
		this.LTImage.style.border = 'solid 10px '+this.borderColor;
		this.LTImage.style.zIndex = "98";
		this.LTImage.style.overflow = "visible";
		this.LTImage.style.display = 'none';
		this.LTImage.style.position = "absolute";
		//LTCadre.style.border = "solid 2px #666";
		//LTCadre.style.backgroundColor = "#FFF";
		
		
		document.body.appendChild(this.LTImage);

		if(description)
		{
			
			this.LTDescription = document.createElement('div');
			this.LTDescription.id = "LTDescription";
			this.LTDescription.style.backgroundColor = '#FFF';
			this.LTDescription.style.position = "absolute";
			this.LTDescription.style.color = "#777";
			this.LTDescription.style.width = imageWidth+6+"px";
			this.LTDescription.style.zIndex = "99";
			this.LTDescription.style.padding = "7px";
			this.LTDescription.style.fontFamily = "century gothic";
			this.LTDescription.style.display = "none";
			this.LTDescription.style.marginLeft = "50%";
			this.LTDescription.style.left = "-"+((imageWidth/2))+"px";
			this.LTDescription.style.top = (imageHeight+20+getWindowTop()+this.top)+'px';
		
			this.LTDescription.innerHTML = description;
			
			document.body.appendChild(this.LTDescription);
			
		}
		
		this.LTClose = document.createElement("img");
		this.LTClose.id = "LTClose";
		this.LTClose.src = "images/close_button_mini.png";
		
		this.LTClose.ltDiapo = this;
		this.LTClose.style.marginLeft = "50%";
		this.LTClose.style.display = "none";
		this.LTClose.style.backgroundColor = "#666";
		this.LTClose.style.left = ((imageWidth/2)*-1)-10+imageWidth+'px';
		this.LTClose.style.top = (getWindowTop()+this.top)+15+'px';
		
		/*
		this.LTClose.style.padding = "3px";
		this.LTClose.style.fontWeight = "bold";
		this.LTClose.style.fontFamily = "arial";
		this.LTClose.style.color = "#343434";
		this.LTClose.style.fontSize = "12px";
		*/
		this.LTClose.style.zIndex = "99";
		this.LTClose.style.position = "absolute";
		this.LTClose.style.cursor = "pointer";
		this.LTImage.style.display = "block";
		
		this.LTClose.onmouseover = function()
		{
			this.style.color = "#000";
		}
		this.LTClose.onmouseout = function()
		{
			this.style.color = "#343434";
		}
		
		
		this.LTClose.onclick = function()
		{
			this.ltDiapo.quit();
		};		
		
		
		changeOpacity
		(
			'LTCadre',
			0,
			diapoObj.contentOpacity,
			5,
			function()
			{
				diapoObj.LTClose.style.display = "";
			}
			
		);
		
		if(description)
		{
			diapoObj.LTDescription.style.display = "";
		
			changeOpacity
			(
				'LTDescription',
				0,
				100,
				5
			);
		}
		document.body.appendChild(this.LTClose); 
		
		
	}
	
	
	if(LtDiaporama.arguments.length)
		for(var j=0;j<LtDiaporama.arguments.length; j++)
			this.addImage(LtDiaporama.arguments[j]);

	
}


var Loader = new Loader();

function Loader()
{

	
	this.show = function()
	{
		if(this.running)
			return false;
		if(!document.getElementById("loaderDiv"))
		{
			
			var loaderDiv = document.createElement("div");
			loaderDiv.id = "loaderDiv";
			loaderDiv.style.top = getWindowTop()+'px';
			loaderDiv.style.left = "-5px";
			loaderDiv.style.padding = "10px";
			loaderDiv.style.width = "99%";
			loaderDiv.style.height = "98%";
			loaderDiv.style.position = "absolute";
			loaderDiv.style.display = "none";
			loaderDiv.style.zIndex = "98";
			loaderDiv.style.backgroundColor = "#000";






			
			
			var loader = document.createElement("img");
			loader.src = "images/ajax-loader.gif";
			loader.id = "loader";
			loader.style.top = "300px";
			loader.style.marginLeft = "50%";
			loader.style.left = "-50px";
			loader.style.position = "absolute";
			loader.style.display = "none";
			loader.style.zIndex = "99";
			
			loaderDiv.appendChild(loader);
			
			
			
			document.body.appendChild(loaderDiv);
			document.body.appendChild(loader);
			
			
		}
		
		document.getElementById("loaderDiv").style.display = "block";
		document.getElementById("loader").style.display = "block";
		
		this.running = 1;
		
		changeOpacity('loaderDiv',0,80,10);
		changeOpacity('loader',0,80,10);
		
		window.onscroll = function()
		{
			document.getElementById('loaderDiv').style.top = getWindowTop()+'px';
			document.getElementById('loader').style.top = (getWindowTop()+50)+'px';	
			
		}
		
	
	}

	this.hide = function()
	{
		
		document.getElementById("loaderDiv").style.display = "none";
		document.getElementById("loader").style.display = "none";
		this.running = 0;
	}
}




















var mouseLoader = new mouseLoader();

function mouseLoader()
{
	this.show = function()
	{
		if(this.running)
			return false;
		if(!document.getElementById("loaderDiv"))
		{
			
			var loaderDiv = document.createElement("div");
			loaderDiv.id = "mouseloaderDiv";
			loaderDiv.style.top = getWindowTop()+'px';
			loaderDiv.style.left = "-5px";
			loaderDiv.style.padding = "10px";
			loaderDiv.style.width = "99%";
			loaderDiv.style.height = "98%";
			loaderDiv.style.position = "absolute";
			loaderDiv.style.display = "none";
			loaderDiv.style.zIndex = "98";
			loaderDiv.style.cursor = "wait";

			
			
			var loader = document.createElement("img");
			loader.src = "images/ajax-loader2.gif";
			loader.id = "mouseloader";
			loader.style.top = "10px";
			loader.style.left = "10px";
			loader.style.position = "absolute";
			loader.style.display = "none";
			loader.style.zIndex = "99";
			
		
			
			
			
			document.body.appendChild(loaderDiv);
			document.body.appendChild(loader);
			
	
		}
		
		document.getElementById("mouseloaderDiv").style.display = "block";
		document.getElementById("mouseloader").style.display = "block";
		
		this.running = 1;
		window.onscroll = function()
		{
			document.getElementById('mouseloaderDiv').style.top = getWindowTop()+'px';
			document.getElementById('mouseloader').style.top = getWindowTop()+10+'px';
		}
	}
	this.hide = function()
	{
		document.getElementById("mouseloaderDiv").style.display = "none";
		document.getElementById("mouseloader").style.display = "none";
		this.running = 0;
	}
}



















/////// VERSION PLUS EFFICACE 


function fermetureProgressive(divid,options)
{
	if(!options)
		var options = {};
	options.sens = 'down';
	
	if(!options.startHeight)
	{
		options.startHeight = document.getElementById(divid).offsetHeight;
	}
	
	if(!options.height)
		options.height = 0;
	
	ouvertureProgressive(divid,options);
}
function ouvertureProgressive(divid,options)
{

	if(!options)
		options = {};
		
	var speed = (options.speed)?options.speed:5;
	var height = options.height;
	var startHeight = (options.startHeight)?options.startHeight:'0';
	var after = options.after;
	var div = document.getElementById(divid);
	
	
	if(!height && options.sens != 'down')
	{
		
		div.style.display = "block";
		var autoHeight = div.offsetHeight;
		div.style.display = "none";
		
		height = autoHeight;
		options.height = height;
		
	}
	
	
	
	if(!options.sens)
	{
		if(height > startHeight)
			options.sens = 'up';
		else
			options.sens = 'down';		
	}
	
	var sens = options.sens;
	
	
	if(!div.isOpeningInDegrade)
	{
		div.style.overflow = 'hidden';
		div.style.height = startHeight+'px';
		div.style.display = 'block';
	}
	
		
	div.isOpeningInDegrade = 1;
	
	
	var currentHeight = parseInt(div.style.height);
	if(sens == 'up')
		var newHeight = (currentHeight+speed)+'px';
	else
		var newHeight = (currentHeight-speed)+'px';

	div.style.height = newHeight;

	var currentValue = parseInt(newHeight);
	var finalValue = height;




	if( ( sens == 'up' && currentValue < finalValue) || ( sens == 'down' && currentValue > finalValue ) )
	{
		var timeout = function()
		{
			ouvertureProgressive(divid,options)
		}
		setTimeout(timeout,1);	
	}
	else
	{
		div.isOpeningInDegrade = 0;
		if(sens == 'up')
			div.style.overflow = '';
		else
			div.style.display = 'none';
			
		div.isOpen = 1;
		div.style.height = '';
		if(after)
			after();
	}
	

}













//// 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();
		
	}
}


function changeImageSrc(idimage,newSrc)
{

	
	
	
	changeOpacity
	(
		idimage,
		100,
		0,
		5,
		function()
		{
			document.getElementById(idimage).onload = function()
			{
				changeOpacity(idimage,0,100,5);
			}
			document.getElementById(idimage).src= newSrc;
			
		}		  
	)
	
}



































function LtBox(options)
{	
	this.content = '';
	
	if(options)
		this.options = options;
	else
		this.options = {};
	var ltBoxObj = this;

	
	this.backgroundOpacity = (this.options.backgroundOpacity)?this.options.backgroundOpacity:60;
	this.backgroundColor = (this.options.backgroundColor)?this.options.backgroundColor:'#000';
	this.borderColor = (this.options.borderColor)?this.options.borderColor:'#FFF';
	this.contentOpacity = (this.options.contentOpacity)?this.options.contentOpacity:100; 
	this.top = (this.options.top)?this.options.top:50;
	this.width = (this.options.width)?this.options.width:500;
	this.height = (this.options.height)?this.options.height:500;
	
	this.show = function(content)
	{
		document.body.style.overflow = "hidden";
		
		
		hideAllFlash();
		
		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";
			}
		}
	
		this.LTBackground = document.createElement("div");
		this.LTBackground.id = "LTBackground";
		this.LTBackground.ltBox = this;
		this.LTBackground.style.top = getWindowTop()+'px';
		this.LTBackground.style.left = "-5px";
		this.LTBackground.style.padding = "10px";
		this.LTBackground.style.width = "99%";
		if(isIe6())			
			this.LTBackground.style.height = screen.availHeight+'px';
		else
			this.LTBackground.style.height = "98%";
			

		this.LTBackground.style.position = "absolute";
		this.LTBackground.style.display = "none";
		this.LTBackground.onclick = function()
		{
			this.ltBox.quit();
		};		
		//this.LTBackground.style.opacity = "0.7";
		this.LTBackground.style.zIndex = "98";
		this.LTBackground.style.backgroundColor = this.backgroundColor;
		
	
		
		document.body.appendChild(this.LTBackground);
		
		this.LTBackground.style.display = "block";
		
		
		
		
		
		
		
		changeOpacity
		(
			'LTBackground',
			0,
			ltBoxObj.backgroundOpacity,
			10,
			function()
			{
				
				
				
				
				
				ltBoxObj.showContent(content);
			}
			
		);
		
		
		window.onscroll = function()
		{
		
			if(ltBoxObj.LTBackground) ltBoxObj.LTBackground.style.top = getWindowTop()+'px';
			if(ltBoxObj.LTContent) ltBoxObj.LTContent.style.top = (getWindowTop()+50)+'px';	
			
		}
		
	}
	
	this.quit = function()
	{
		
		document.body.style.overflow = "";
		document.body.removeChild(this.LTBackground);
		document.body.removeChild(this.LTContent);
		document.body.removeChild(this.LTClose);
		
		this.LTBackground = null;
		this.LTContent = null;
		this.LTClose = null;
		
		window.onscroll = null;
		
		if(!isIe6())
			document.body.style.overflow = "auto";
		
		showAllFlash();
		
		if(isIe6())
		{
			allSelect = document.getElementsByTagName('select');
			for(var i=0; i<allSelect.length; i++)
				allSelect[i].style.visibility = allSelect[i].oldVisibility;
		}
		
		
	}
		
	this.showPage = function(href)
	{
		var frame = document.createElement('iframe');
		frame.height = this.height;
		frame.frameBorder = "0";
		frame.width = this.width;
		frame.src = href;
		frame.id = 'frameBox';
		
		this.show(frame);
	}
	

	this.showVideo = function(file)
	{
		
		var player = document.createElement('a');
		player.style.display = "block";
		player.style.height = this.height+"px";
		player.style.width = this.width+"px";
		player.href = file;
		player.id = 'playerBox';
		
		
		this.afterload = function(){flowplayer("playerBox", "/lib/flowplayer/flowplayer-3.2.7.swf");}; 
		this.show(player);
		
		
		
		
		
		
		
	}
	

	this.showContent = function(content)
	{
		
		
		
		
		
		
		this.LTContent = document.createElement('div');
		
		this.LTContent.id = "LTContent";
		this.LTContent.style.backgroundColor = '#FFF';
		this.LTContent.style.marginLeft = "50%";
		this.LTContent.style.width = this.width+"px";
		this.LTContent.style.height = this.height+"px";
		if(typeof(content) == 'object')
			this.LTContent.appendChild(content);	
		else
			this.LTContent.innerHTML = content;
		this.LTContent.style.left = "-"+(this.width/2)+"px";
		this.LTContent.style.top = (getWindowTop()+this.top)+'px';
		this.LTContent.style.border = 'solid 10px '+this.borderColor;
		this.LTContent.style.zIndex = "98";
		this.LTContent.style.overflow = "visible";
		this.LTContent.style.display = 'none';
		this.LTContent.style.position = "absolute";
		//LTCadre.style.border = "solid 2px #666";
		//LTCadre.style.backgroundColor = "#FFF";
		
		
		document.body.appendChild(this.LTContent);
		
		
		this.LTClose = document.createElement("div");
		this.LTClose.id = "LTClose";
		this.LTClose.innerHTML = "Fermer";
		this.LTClose.style.width = "64px";
		this.LTClose.style.padding = "3px";
		this.LTClose.style.textAlign = "center";
		this.LTClose.style.height = "24px";
		this.LTClose.style.fontFamily = "century gothic";
		this.LTClose.style.backgroundColor = "#FFFFFF";
		//this.LTClose.src = "images/close_button_mini.png";
		this.LTClose.ltBox = this;
		this.LTClose.style.marginLeft = "50%";
		this.LTClose.style.cursor = "pointer";
		this.LTClose.style.display = "none";
		this.LTClose.style.left = ((this.width/2)*-1)-50+this.width+'px';
		this.LTClose.style.top = (getWindowTop()+this.top)-20+'px';
		
		/*
		this.LTClose.style.padding = "3px";
		this.LTClose.style.fontWeight = "bold";
		this.LTClose.style.fontFamily = "arial";
		this.LTClose.style.color = "#343434";
		this.LTClose.style.fontSize = "12px";
		*/
		this.LTClose.style.zIndex = "99";
		this.LTClose.style.position = "absolute";
		this.LTClose.style.cursor = "pointer";
		this.LTContent.style.display = "block";
		
		this.LTClose.onmouseover = function()
		{
			this.style.color = "#000";
		}
		this.LTClose.onmouseout = function()
		{
			this.style.color = "#343434";
		}
		
		
		this.LTClose.onclick = function()
		{
			this.ltBox.quit();
		};		
		
		
		changeOpacity
		(
			'LTContent',
			0,
			ltBoxObj.contentOpacity,
			5,
			function()
			{
				ltBoxObj.LTClose.style.display = "";
				if(ltBoxObj.afterload)
					ltBoxObj.afterload();
			
			}
			
		);
		
		
		
		document.body.appendChild(this.LTClose); 
		
		
	}
	
	
	
}


function diapo(divid)
{
	this.divid = divid;
	this.images = new Array();
	this.fading = 1;
	this.delai = 1200;
	this.currentImage = 1;
	var obj_diap = this;
	
	this.add = function(src,description)
	{
		var img = new Image();
		img.src = src;
		if(description)
		{
			img.alt = description;
			img.title = description;
		}
		img.style.position = "absolute";
		img.id = divid+'_diapo_img_'+(this.images.length+1);
		this.images.push(img);
		
	}
	
	this.changeImage = function()
	{
		var imgToRemove = divid+'_diapo_img_'+this.currentImage;
		
		changeOpacity
		(
			imgToRemove,
			100,
			0,
			this.fading,
			function()
			{
				obj_diap.div.removeChild(document.getElementById(imgToRemove));
			}
		);	
		
		
		
		if(this.currentImage == this.images.length)
			this.currentImage = 1;
		else
			this.currentImage++;
		

		
		this.div.appendChild(this.images[this.currentImage-1]);
		
		changeOpacity
		(
		 	divid+'_diapo_img_'+this.currentImage,
			0,
			100,
			this.fading
		);
		
	}
					 
	
	this.start = function()
	{
		if(!this.div)
		{
			this.div = document.getElementById(this.divid);
			this.div.style.position = "relative";
			this.div.appendChild(this.images[this.currentImage-1]);
		}
		else
		{
			this.changeImage();	
		}
		
		
		setTimeout(function(){obj_diap.start();},this.delai);
		
	}		
}




function LtLoupe()
{
	// Parametres requis  resizedImageId, imagePath, zoomBoxId
	
	
	
	var ltLoupeObject = this;
	
	this.loupeWidth = 90;
	this.loupeHeight = 50;

	this.zoomBox = document.createElement("div");
	this.zoomBox.id = "LtLoupeZoomBox";
	this.zoomBox.style.overflow = "hidden";	
	this.zoomBox.style.position = "relative";

	this.setZoomContainer = function(id)
	{
		this.zoomBoxContainerId = id;
		this.zoomBoxContainer = document.getElementById(id);	
		
	}


	

	this.createLoupe = function(e)
	{
		if(document.getElementById('LtLoupeDiv'))
			document.body.removeChild(document.getElementById('LtLoupeDiv'));
		this.loupeDiv = document.createElement('div');
		this.loupeDiv.id = "LtLoupeDiv";
		this.loupeDiv.style.position = "absolute";
		this.loupeDiv.style.zIndex = "40";
		this.loupeDiv.style.width = this.loupeWidth+"px";
		this.loupeDiv.style.height = this.loupeHeight+"px";
		this.loupeDiv.style.border = "solid 1px #000";
		this.loupeDiv.style.display = "block";
		this.loupeDiv.onmousemove = function(e){ltLoupeObject.setLoupePosition(e);};
		this.loupeDiv.onmouseout = function(e){ltLoupeObject.deleteLoupe()};
		document.body.appendChild(this.loupeDiv);
	}
	
	this.setLoupePosition = function(e)
	{
		var curseurPos = getCursorPosition(e);
		var resizedImagePosition = getElementPosition(this.resizedImage);
		this.loupeDiv.style.top = (curseurPos['y'] - ( ltLoupeObject.loupeHeight / 2) )+'px';
		this.loupeDiv.style.left = (curseurPos['x'] - ( ltLoupeObject.loupeWidth / 2) )+'px';
		
		if(curseurPos['y'] < resizedImagePosition['y'] || curseurPos['y'] > (resizedImagePosition['y']+this.resizedImage.height) || curseurPos['x'] < resizedImagePosition['x'] || curseurPos['x'] > (resizedImagePosition['x']+this.resizedImage.width) )
		{
			this.deleteLoupe();
		}
		else
		{
			this.showZoom(e);
		}
	}
	
	this.deleteLoupe = function()
	{
		document.body.removeChild(this.loupeDiv);
		this.hideZoom();
	}
	
	this.showZoom = function(e)
	{
		this.zoomRatio = this.fullSizeImage.width / this.resizedImage.width;
		this.zoomWidth = Math.round(this.zoomRatio *  this.loupeWidth);
		this.zoomHeight = Math.round(this.zoomRatio *  this.loupeHeight);
		
		
		this.zoomBox.style.width = this.zoomWidth+"px"; 
		this.zoomBox.style.height = this.zoomHeight+"px";
		this.zoomBox.style.position = "relative";
		this.zoomBox.innerHTML = "";
		this.zoomBox.appendChild(this.fullSizeImage);
		
		
		this.zoomBoxContainer.style.display = "block";
		
		this.zoomBoxContainer = document.getElementById(this.zoomBoxContainerId );
		this.zoomBoxContainer.appendChild(this.zoomBox);
		
		var curseurPos = getCursorPosition(e);
		var resizedImagePosition = getElementPosition(this.resizedImage);
		
		var top = Math.round( ( (curseurPos['y'] - ( this.loupeHeight / 2) ) - resizedImagePosition['y'] ) * this.zoomRatio * -1 );
		var left = Math.round( ( ( curseurPos['x'] - ( this.loupeWidth / 2) ) - resizedImagePosition['x'] ) * this.zoomRatio * -1 );
		
		this.fullSizeImage.style.left = left+"px";
		this.fullSizeImage.style.top = top+"px";
		
	}
	
	this.hideZoom = function()
	{
		
		this.zoomBoxContainer.style.display = "none";
		this.zoomBoxContainer.innerHTML = "";
		
		
	}
	
	this.setResizedImageId = function(id)
	{
		this.resizedImageId = id;
		this.resizedImage = document.getElementById(this.resizedImageId);
		this.resizedImage.onmousemove = function(e)
		{
			ltLoupeObject.createLoupe();
			ltLoupeObject.setLoupePosition(e);
		}
		
	}
	
	this.setFullSizeImagePath = function(path)
	{
		this.imagePath = path;
		this.fullSizeImage = new Image();
		this.fullSizeImage.src = this.imagePath;
		this.fullSizeImage.style.position = "absolute";

	
	}

	

	
		

	
}



	function getCursorPosition(e)
	{
		var cursorPos = new Array();
		cursorPos['x'] = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
		cursorPos['y'] = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
		return cursorPos;
	
	}
	
	function getElementPosition(element)
	{
		if(typeof(element) == 'object')
			var e = element;
		else		
			var e = document.getElementById(element);		  
		
		var left = 0;
		var top = 0;
		/*On récupère l'élément*/
		/*Tant que l'on a un élément parent*/
		while (e.offsetParent != undefined && e.offsetParent != null)
		{
			/*On ajoute la position de l'élément parent*/
			left += e.offsetLeft + (e.clientLeft != null ? e.clientLeft : 0);
			top += e.offsetTop + (e.clientTop != null ? e.clientTop : 0);
			e = e.offsetParent;
		}
		
		
		
		var elementPos = new Array();
		elementPos['x'] = left;
		elementPos['y'] = top;
		
		return elementPos;
		
	}
	





