var IE7 = false, IE8  = false, IE9 = false;
var strUserAgent = navigator.userAgent;

if(strUserAgent.indexOf("MSIE 7") != -1)
    IE7 = true;
else if(strUserAgent.indexOf("MSIE 8") != -1)
    IE8 = true;
else if(strUserAgent.indexOf("MSIE 9") != -1)
    IE9 = true;

Array.prototype.has=function(v){
	for (i=0;i<this.length;i++){
		if (this[i]==v) return i;
		}
	return false;
}

onload=function(){
	if (document.getElementsByClassName == undefined) {
		document.getElementsByClassName = function(className)
		{
			var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
			var allElements = document.getElementsByTagName("*");
			var results = [];

			var element;
			for (var i = 0; (element = allElements[i]) != null; i++) {
				var elementClass = element.className;
				if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
					results.push(element);
			}

			return results;
		}
	}
}////////////////////////////////////////getElementsByClassName/////////////////////////////////

///////////////////////////////////////AJAX requester///////////////////////////////////////////////
function getXMLHttpRequest() {
	var xhr = null;
	
	if (window.XMLHttpRequest || window.ActiveXObject) {
		if (window.ActiveXObject) {
			try {
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
		} else {
			xhr = new XMLHttpRequest(); 
		}
	} else {
		alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
		return null;
	}
	
	return xhr;
}
///////////////////////////////////////AJAX requester///////////////////////////////////////////////



//Section Tabs Up/////////////////////////////////////////////////////////////////////////////
var steps = new Array (14,13,11,8,6,4,2,1);
var stpNb = steps.length;

var ongletsLiMarginTop=3;
var ongletsLiHeight=21;

function lancement_up(){
	var onglets = document.getElementsByTagName('li');
	for (var i=0; i<onglets.length; i++){
		if((onglets[i].className).search(/active/)!=-1){
			onglets[i].id='ongletActif';
			onglets[i].style.position='relative';
			setTimeout(
			(function(arg){return function(){moveUp(arg);};})(onglets[i])
			,750);
		}
	}
}

function moveUp(elt){
	if (stpNb>0){
			elt.style.top = -steps[stpNb - 1] + 'px'; 
			elt.style.height= ongletsLiHeight + steps[stpNb-1] + 'px';
			stpNb-=1;
			setTimeout(function(){moveUp(elt);},30);
	}
}
//Section Tabs Up/////////////////////////////////////////////////////////////////////////////


//Section Tabs Down/////////////////////////////////////////////////////////////////////////////
window.onunload = function()
{
var onglets = document.getElementsByTagName('li');
for (var i = 0; i < onglets.length; i++)
	{if (onglets[i].className == 'active')
	onglets[i].id = 'ongletActif';}
execute();
}

function execute()
{
var oa = document.getElementById('ongletActif');
if (parseInt(oa.style.marginTop)<4){
	oa.style.marginTop=parseInt(oa.style.marginTop)+1+'px';
	setTimeout(function() {execute();},15);
	}
}
//Section Tabs Down/////////////////////////////////////////////////////////////////////////////

//Section Progressive Appear///////////////////////////////////////////////////////////////////
function d2h(d){
	if (d<10)
		var h='0'+d.toString(16);
	else
		var h=d.toString(16);
	return (h);
	}
function h2d(h){
	var d=parseInt(h,16);
	return (d);
	}
function hex2rgb(hex){//requires the #ffffff strin and turns into 3 ints
	var hexcolor=new Array(hex.slice(1,3),hex.slice(3,5),hex.slice(5,7));
	var rgbcolor=new Array(h2d(hexcolor[0]),h2d(hexcolor[1]),h2d(hexcolor[2]));
	return (rgbcolor);}
function rgb2hex(rgb){//Requires 3int and turns into a str
	var hexcolor='#'+String(d2h(rgb[0]))+String(d2h(rgb[1]))+String(d2h(rgb[2]));
	return hexcolor;}

function make_elt_visible(elt){
	if (typeof elt=="string")
		var elt=document.getElementById(elt);
	elt.style.display="block";
	elt.visToggle=1;}
function make_elt_invisible(elt){
	if (typeof elt=="string")
		var elt=document.getElementById(elt);
	elt.style.display="none";
	elt.visToggle=0;}	

function increment_alpha_elt(elt,target){
if (window.getComputedStyle)
	{var opacity=parseFloat(window.getComputedStyle(elt,null).getPropertyValue("opacity"));}
else
	{var opacity=0;
	make_elt_invisible(elt);
	return null;}
if (elt.inc==1)
	{if (opacity < target)
		{elt.style.opacity= opacity + 0.05;

		opacity=Math.round(100*opacity)/100;

		elt.style.filter = "alpha(opacity='" + Math.round(opacity*100) + "')";
		//alert(window.getComputedStyle(elt,null).getPropertyValue("opacity"));
		elt.TOIncr=setTimeout(function(){increment_alpha_elt(elt,target);},25);
		elt.TODecr=false;}
	else
	{	elt.style.filter = "alpha(opacity='100')";
		//alert("id: "+elt.id+"\nopacity: "+opacity);
		return null;}
	}
}
function decrement_alpha_elt(elt,target){
if (window.getComputedStyle)
	{var opacity=parseFloat(window.getComputedStyle(elt,null).getPropertyValue("opacity"));
	/* alert(opacity); */}
else
	{var opacity=1;}
if (elt.inc==0)
	{if (opacity > target)
		{elt.style.opacity= opacity - 0.05;
		elt.style.filter = "alpha(opacity='" + opacity*100 + "')";
		elt.TODecr=setTimeout(function(){decrement_alpha_elt(elt,target);},40);
		elt.TOIncr=false;}
	else
		{if (elt.visToggle==0)
			{make_elt_invisible(elt);}
		return null;}
	}
}

function make_id_appear(id,targetAlpha){
	if (!targetAlpha) targetAlpha=1.0;
	if (typeof id=="string")
		var id=document.getElementById(id);
	id.inc=1;
	make_elt_visible(id);
	increment_alpha_elt(id,targetAlpha);
}
function make_id_disappear(id){
	if (typeof id=="string")
		var id=document.getElementById(id);
	if (!id) return;
	id.inc=0;
	id.visToggle=0;
	decrement_alpha_elt(id,0.0);
}

function delayed_opacity_increase(elt,target,delay){
	elt.style.opacity="0";
	setTimeout(function(){increment_alpha_elt(elt,target);},delay);
	}

function chgcolor(id,rate,steps,r,g,b,dr,dg,db,init){
	if (init==steps)
		return null;
	else
		{var rt=r+dr/steps;
		var gt=g+dg/steps;
		var bt=b+db/steps;
		id.style.color='rgb('+String((r+(dr/steps)).toFixed())+','+String((g+(dg/steps)).toFixed())+','+String((b+(db/steps)).toFixed())+')';
		var color=id.style.color;
		var colors=new Array(parseInt(color.slice(4,50).split(',')[0]),parseInt(color.slice(4,50).split(',')[1]),parseInt(color.slice(4,50).split(',')[2]));
		setTimeout(function(){chgcolor(id,rate,steps,rt,gt,bt,dr,dg,db,(init+1));},rate);}
}
function chgtxtcolor(elt,delay,rate,steps,r0,g0,b0,r,g,b){
	var elt=document.getElementById(elt);
	elt.style.color="rgb("+r0+","+g0+","+b0+")";
	var dr=r-r0;
	var dg=g-g0;
	var db=b-b0;
	setTimeout(function(){chgcolor(elt,rate,steps,r0,g0,b0,dr,dg,db,0);},1000*delay);
}
function delaychgtxtcolor(elt,delay,rate,steps,r0,g0,b0,r,g,b){
	setTimeout(function(){chgtxtcolor(elt,0,rate,steps,r0,g0,b0,r,g,b);},(1000*delay));}

function appdisapp(elt,delay,pause,rate,steps,r0,g0,b0,r,g,b){
	setTimeout(function(){chgtxtcolor(elt,0,rate,steps,r0,g0,b0,r,g,b);},(1000*delay));
	setTimeout(function(){chgtxtcolor(elt,0,rate,steps,r,g,b,r0,g0,b0);},(1000*delay+(steps*rate)+1000*pause));}
	
function getColor(id){
	var elt=document.getElementById(id);
	var clr=window.getComputedStyle(elt,null).getPropertyValue("color");
	clr=clr.split(',');
	clr=[clr[0].slice(4),parseInt(clr[1],10),parseInt(clr[2],10)];
	return(clr);
	}
//Section Progressive Appear///////////////////////////////////////////////////////////////////////////////

//Section Pulsating Links//////////////////////////////////////////////////////////////////////////////////
var startRGB = new Array(136, 136, 136);
var targetRGB = new Array(210, 210, 210);

function lancement_links(){
    var links = document.getElementsByTagName('a');
    for(var i = 0; i < links.length; i++)
    {
        if(links[i].className == 'trans')
        {
            links[i].id = 'trans' + i;
            links[i].curRGB = new Array(startRGB[0], startRGB[1], startRGB[2]); // 2
            links[i].onmouseover = doTrans;
            links[i].t_act = false;
            links[i].onmouseout = clTrans;
            links[i].t_desact = false;
        }
    }
}

function doTrans(){
 	id=this.id;
    if(this.t_desact){
        clearInterval(this.t_desact);
        this.t_desact = false;
    }
    if (this.t_act) return null;
    this.t_act = setInterval(function(){rgbTrans(id,targetRGB[0],targetRGB[1],targetRGB[2]);},25);
}

function clTrans(){
	id=this.id;
    if(this.t_act){
        clearInterval(this.t_act);
        this.t_act = false;
    }
    if (this.t_desact) return null;
    this.t_desact = setInterval(function(){rgbTrans(id,startRGB[0],startRGB[1],startRGB[2]);},25);
}

function rgbTrans(id, r, g, b){
	var link = document.getElementById(id);
    var i = 10; // the step of the modifications
    var curRGB = new Array(link.curRGB[0],link.curRGB[1],link.curRGB[2]);
    var destRGB = new Array(parseInt(r),parseInt(g),parseInt(b));
    if(curRGB[0] == destRGB[0] && curRGB[1] == destRGB[1] && curRGB[2] == destRGB[2])
    {
        if(link.t_act)
        {
            clearInterval(link.t_act);
            link.t_act = false;
        }
        if(link.t_desact)
        {
            clearInterval(link.t_desact);
            link.t_desact = false;
        }
        return null;
    }
    for(var j = 0; j < 3; j++)
    {
        if(curRGB[j] > destRGB[j])
        {
            curRGB[j] = curRGB[j]-i > destRGB[j] ? curRGB[j]-i : destRGB[j];
        }
        else if(curRGB[j] < destRGB[j])
        {
            curRGB[j] = curRGB[j]+i < destRGB[j] ? curRGB[j]+i : destRGB[j];
        }
    }
    link.curRGB = curRGB;
    link.style.color = 'rgb('+curRGB[0]+','+curRGB[1]+','+curRGB[2]+')';
}
//Section Pulsating Links///////////////////////////////////////////////////////////////////////////////////////////////////////


//Section Preload Imgs///////////////////////////////////////////////////////////////////////////////////////////////////////
function preload(url){
	var myImage = new Image();
	myImage.src = url;
}

function preloads(urls){
	for (a=0;a<urls.length;a++)
	{	var myImage = new Image();
		myImage.src = urls[a];}
}
//Section Preload Imgs///////////////////////////////////////////////////////////////////////////////////////////////////////

/*
	Developed by Robert Nyman, http://www.robertnyman.com
	Code/licensing: http://code.google.com/p/getelementsbyclassname/
*/
var getElementsByClassName = function (className, tag, elm){
	if (document.getElementsByClassName) {
		getElementsByClassName = function (className, tag, elm) {
			elm = elm || document;
			var elements = elm.getElementsByClassName(className),
				nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
				returnElements = [],
				current;
			for(var i=0, il=elements.length; i<il; i+=1){
				current = elements[i];
				if(!nodeName || nodeName.test(current.nodeName)) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	else if (document.evaluate) {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = "",
				xhtmlNamespace = "http://www.w3.org/1999/xhtml",
				namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
				returnElements = [],
				elements,
				node;
			for(var j=0, jl=classes.length; j<jl; j+=1){
				classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
			}
			try	{
				elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
			}
			catch (e) {
				elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
			}
			while ((node = elements.iterateNext())) {
				returnElements.push(node);
			}
			return returnElements;
		};
	}
	else {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = [],
				elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
				current,
				returnElements = [],
				match;
			for(var k=0, kl=classes.length; k<kl; k+=1){
				classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
			}
			for(var l=0, ll=elements.length; l<ll; l+=1){
				current = elements[l];
				match = false;
				for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
					match = classesToCheck[m].test(current.className);
					if (!match) {
						break;
					}
				}
				if (match) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	return getElementsByClassName(className, tag, elm);
};///////////////////////////////////////////////////////////////gEBCN

/////////////////////////////////////////////////////////////////////getComputedStyle for IE
if (!window.getComputedStyle) {
	window.getComputedStyle = function(el, pseudo) {
		this.el = el;
		this.getPropertyValue = function(prop) {
			var re = /(\-([a-z]){1})/g;
			if (prop == 'float') prop = 'styleFloat';
			if (re.test(prop)) {
				prop = prop.replace(re, function () {
				return arguments[2].toUpperCase();
				});

			}
			return el.currentStyle[prop] ? el.currentStyle[prop] : null;
		}
		return this;
	}
}
/////////////////////////////////////////////////////////////////////getComputedStyle for IE


//Section Display JS Active///////////////////////////////////////////////////////////////////////////////////////////////////////
function displayClass(className){
	var elts=getElementsByClassName(className);
	for (elt in elts){
		if (elts[elt]=='HTMLParagraphElement'){
		elts[elt].style.display="block";}
	}
}
//Section Display JS Active///////////////////////////////////////////////////////////////////////////////////////////////////////


//Section Blendinout Visite///////////////////////////////////////////////////////////////////////////////////////////////////////////
function increment_alpha(id){

if (id.style.opacity!='undefined')  var opacity = parseFloat(id.style.opacity, 10);
else if (id.filters.alpha.opacity!='undefined') var opacity =id.filters.alpha.opacity/100;

if ( opacity < 1)
	{id.style.opacity= opacity + 0.1;
	id.style.filter = "alpha(opacity='" + opacity*100 + 10 + "')";
	setTimeout(function(){increment_alpha(id);},40);}
else
	return null;
}

function decrement_alpha(id){
var opacity = parseFloat(id.style.opacity, 10);
if ( opacity >0)
	{id.style.opacity= opacity - 0.1;
	setTimeout(function(){decrement_alpha(id);},40);}
else
		return null;
}

function bringon_references(){
	var trs=document.getElementsByTagName('td');
	for (elt in trs){
		if (trs[elt]=='[object HTMLTableCellElement]'){
/* 		alert(trs[elt]);*/
		trs[elt].style.opacity=0;
 		for (j=0;j<trs.length;j++){
		setTimeout(
			(function(indice){
			return function(){
			increment_alpha(trs[indice]);};
			})(j),
			750+j*70);
			}
		}
	}
	//setTimeout(function(){increment_alpha(trs[1]);},2500);
}
function bringon_1er(imgLoc,arg){
	var browser=window.navigator.appName;			//Hack MSIE6
	if (browser=='Microsoft Internet Explorer')		//Hack MSIE6
		{arg=(arg-1)/2;}							//Hack MSIE6
	var ppimg_1er=document.getElementById('pPlan1erImg');
	var pp_1er=document.getElementById('pPlan1er');
	var expose_1er=document.getElementById('expose1er');

	ppimg_1er.src=imgLoc;

	var salles_1er=expose_1er.childNodes;				//on fait apparaitre seulement le paragraphe qu'il nous faut.
	if (browser=='Microsoft Internet Explorer')		//Hack MSIE6
		{for (var i=0;i<salles_1er.length;i+=1)			//
		{salles_1er[i].style.display='none';}}
	else
		for (var i=1;i<salles_1er.length;i+=2)			//
		{salles_1er[i].style.display='none';}	

	var actif_1er=salles_1er[arg];
	actif_1er.liste=new Array;
	actif_1er.liste=actif_1er.getElementsByTagName('*');
	actif_1er.liste2= new Array;
	for (i=0;i<actif_1er.liste.length;i++)
		{if (actif_1er.liste[i]=='[object HTMLParagraphElement]' || actif_1er.liste[i]=='[object HTMLHeadingElement]' || actif_1er.liste[i]=='[object HTMLImageElement]')
			{actif_1er.liste2.push(actif_1er.liste[i]);}
				}
	actif_1er.liste=actif_1er.liste2;

	expose_1er.style.visibility= "visible";//
	expose_1er.style.opacity="0";//
	pp_1er.style.opacity="0";//

	actif_1er.style.opacity='1';
	actif_1er.style.display='inline';

	for (i=0;i< actif_1er.liste.length;i++)
		{actif_1er.liste[i].style.opacity='0';}		//On rend transparent tous les elements contenus dans la balise contenu actif

	timer_in_pp_1er=setTimeout(function(){increment_alpha(pp_1er);},0);
	timer_in_exp_1er=setTimeout(function(){increment_alpha(expose_1er);},100);

	for (j=0;j<actif_1er.liste.length;j++){
		actif_1er.liste[j].style.display="block";
	//setTimeout(function(){increment_alpha(actif_1er.liste[j]);},500+j*75);} pose des tas de problemes
	//setTimeout(increment_alpha,500+j*75,actif_1er.liste[j]);} aussi !
		setTimeout(
			(function(indice){
			return function(){
			increment_alpha(actif_1er.liste[indice]);};
			})(j),
			500+j*75
		);
	}
}

function bringon_Rdc(imgLoc,arg){
	var browser=window.navigator.appName;			//Hack MSIE6
	if (browser=='Microsoft Internet Explorer')		//Hack MSIE6
		{arg=(arg-1)/2;}							//Hack MSIE6
	var ppimg_Rdc=document.getElementById('pPlanRdcImg');
	var pp_Rdc=document.getElementById('pPlanRdc');
	var expose_Rdc=document.getElementById('exposeRdc');

	ppimg_Rdc.src=imgLoc;

	salles_Rdc=expose_Rdc.childNodes;				//on fait disparaitre tous les paragraphes
	if (browser=='Microsoft Internet Explorer')		//Hack MSIE6
		{for (var i=0;i<salles_Rdc.length;i+=1)			//
		{salles_Rdc[i].style.display='none';}}
	else
		for (var i=1;i<salles_Rdc.length;i+=2)			//
		{salles_Rdc[i].style.display='none';}	
	actif_Rdc=salles_Rdc[arg];
	actif_Rdc.liste=new Array;
	actif_Rdc.liste=actif_Rdc.getElementsByTagName('*');
	actif_Rdc.liste2= new Array;
	for (i=0;i<actif_Rdc.liste.length;i++)
		{if (actif_Rdc.liste[i]!='[object HTMLBRElement]')
			{actif_Rdc.liste2.push(actif_Rdc.liste[i]);}
				}
	actif_Rdc.liste=actif_Rdc.liste2;

	expose_Rdc.style.visibility= "visible";//
	expose_Rdc.style.opacity="0";//
	pp_Rdc.style.opacity="0";//

	actif_Rdc.style.opacity='1';
	actif_Rdc.style.display='inline';

	for (i=0;i< actif_Rdc.liste.length;i++)
		{actif_Rdc.liste[i].style.opacity='0';}		//On rend transparent tous les elements contenus dans la balise contenu actif

	timer_in_pp_Rdc=setTimeout(function(){increment_alpha(pp_Rdc);},0);
	timer_in_exp_Rdc=setTimeout(function(){increment_alpha(expose_Rdc);},100);

	for (j=0;j<actif_Rdc.liste.length;j++){
		actif_Rdc.liste[j].style.display="block";
		//setTimeout(function(){increment_alpha(actif_Rdc.liste[j]);},500+j*75);} pose des tas de problemes !
		//setTimeout(increment_alpha,500+j*75,actif_Rdc.liste[j]);} aussi!
		setTimeout(
			(function(indice){
			return function(){
			increment_alpha(actif_Rdc.liste[indice]);};
			})(j),
			500+j*75
		);
	}
}

function bringoff_Rdc(){
	var pp_Rdc=document.getElementById('pPlanRdc');
	var expose_Rdc=document.getElementById('exposeRdc');
	var ppimg_Rdc=document.getElementById('pPlanRdcImg');

	ppimg_Rdc.src="ressources/visite/plan_empty.png";
	pp_Rdc.style.opacity='0';
	expose_Rdc.style.opacity='0';
	expose_Rdc.style.visibility= "hidden";
}

function bringoff_1er(){
	var pp_1er=document.getElementById('pPlan1er');
	var expose_1er=document.getElementById('expose1er');
	var ppimg_1er=document.getElementById('pPlan1erImg');

	ppimg_1er.src="ressources/visite/plan_empty.png";
	pp_1er.style.opacity='0';
	expose_1er.style.opacity='0';
	expose_1er.style.visibility= "hidden";
}
//Section Blendinout Visite///////////////////////////////////////////////////////////////////////////////////////////////////////////



//Section Galerie Eye Candy////////////////////////////////////////////////////////////////////////////////////////////////////
function test(){
	alert('test');} //For debugging

thumbHWidth=150;
thumbVWidth=93;
thumbHMargin=-77;
thumbVMargin=-52;

//fr ou en ?
var adresse= window.location.toString();
if (adresse.search(/fr/)>-1){
	Strnext='suiv';
	Strprev='prec';}
else
	{Strnext='next';
	Strprev='prev';}

function minimiseThumbs(list){
	test();
	for (var i=1;i<list.length;i++){
		if (list[i].horizontal){
			list[i].width=Math.min(800/(list.length/2),140);}
		if (!list[i].horizontal){
			list[i].width=Math.min(500/(list.length/2),93);
			list[i].style.left=5+40/(list.length)+'px';}
		}
	var gal=document.getElementById('galerie');
	gal.style.marginLeft=-4*list.length+'px';
}

function list_thumbs(){
	var imgs=document.getElementsByTagName("img");
	var list=[];
		for (var i=0;i<imgs.length;i++){
			if (imgs[i].getAttribute("class")=="thumbimgh"||imgs[i].getAttribute("className")=="thumbimgh")
			{list[i]=imgs[i];
			list[i].id="thumb"+i
			list[i].horizontal=true;
			list[i].curWidth=thumbHWidth;
			list[i].smallWidth=thumbHWidth;
			list[i].bigWidth=thumbHWidth+18;
			list[i].curMargin=thumbHMargin;
			list[i].curBlur=0;
			list[i].enl=false;
			list[i].res=false
			if (IE7==false) ///Redimensionnement foire sous IE7
			{	list[i].onmouseover=enlarge;
				list[i].onmouseout=resize;}
			};

			if (imgs[i].getAttribute("class")=="thumbimgv"||imgs[i].getAttribute("className")=="thumbimgv")
			{list[i]=imgs[i];
			list[i].id="thumb"+i
			list[i].horizontal=false;
			list[i].curWidth=thumbVWidth;
			list[i].smallWidth=thumbVWidth;
			list[i].bigWidth=thumbVWidth+10;
			list[i].curMargin=thumbVMargin;
			list[i].curBlur=0;
			list[i].enl=false;
			list[i].res=false
			if (IE7==false)
			{	list[i].onmouseover=enlarge;
				list[i].onmouseout=resize;}
			};
		};
	return(list);
}

function enlarge(){
	var thisThumb =this.id;
	var thisThumbBigWidth =this.bigWidth;
	
	if (this.res)
	{
		clearInterval(this.res);
		this.res=false;
	}
	if (this.enl) return null;
	this.enl=setInterval(function(){changeWidthMargin(thisThumb,thisThumbBigWidth);},15);
}

function resize(){
	var thisThumb =this.id;
	var thisThumbSmallWidth =this.smallWidth;

	if (this.enl)
	{
		clearInterval(this.enl);
		this.enl=false;
	}
	if (this.res) return null;
	this.res=setInterval(function(){changeWidthMargin(thisThumb,thisThumbSmallWidth);},25);
}

function changeWidthMargin(id,goal,margin){
	var elt=document.getElementById(id);

	var curWidth=elt.curWidth;
	var curMargin=elt.curMargin;
	var amount=goal-curWidth;
	var curBlur=elt.curBlur;
	if (curWidth==goal)
	{
		if (elt.enl)
		{	clearInterval(elt.enl);
			elt.enl=false;}
		if (elt.res)
		{	clearInterval(elt.res);
			elt.res=false;}
		return null;
	}
	if (amount!=0)
	{	curBlur=curBlur+(2*amount/Math.abs(amount));
		curWidth=curWidth+(2*amount/Math.abs(amount));
		curMargin=curMargin-(1*amount/Math.abs(amount));
	}
	elt.curBlur=curBlur;
	elt.curWidth=curWidth;
	elt.curMargin=curMargin;
	elt.style.WebkitBoxShadow= "0px "+curBlur/8+"px "+curBlur+"px #aaaaaa";
 	elt.style.MozBoxShadow= "0px "+curBlur/8+"px "+curBlur+"px #aaaaaa";
	elt.style.width=curWidth+"px";
	elt.style.marginLeft=curMargin+"px";}

function scrollRight(){
	var gal=document.getElementById("galerie");
	cancelScrollLeft();
	if (gal.ScroRi) return null;
	gal.scroRi=setInterval(function(){scrollR(gal);},25);
	var bt=document.getElementById('bouton_'+Strnext);
	bt.src="ressources/"+Strnext+"_hover.jpg";
}

function scrollR(elt){
	var mLeft=parseInt(window.getComputedStyle(elt,null).getPropertyValue("margin-left"));
	var galWidth=parseInt(window.getComputedStyle(elt,null).getPropertyValue("width"));
	if (mLeft<-(galWidth-850)) return null;
	elt.style.marginLeft=(mLeft-7)+"px";
}

function cancelScrollRight(){
	var gal=document.getElementById("galerie");
	if (gal.scroRi)
	{	clearInterval(gal.scroRi);
		gal.scroRi=false;}
	var bt=document.getElementById('bouton_'+Strnext);
	bt.src="ressources/"+Strnext+".gif";
}

function scrollLeft(){
	var gal=document.getElementById("galerie");
	cancelScrollRight();
	if (gal.ScroLe) return null;
	gal.scroLe=setInterval(function(){scrollL(gal);},25);
	var bt=document.getElementById('bouton_'+Strprev);
	bt.src="ressources/"+Strprev+"_hover.jpg";
}

function scrollL(elt){
	var mLeft=parseInt(window.getComputedStyle(elt,null).getPropertyValue("margin-left"));
	if (mLeft>10) return null;
	elt.style.marginLeft=(mLeft+7)+"px";
}

function cancelScrollLeft(){
	var gal=document.getElementById("galerie");
	if (gal.scroLe)
	{	clearInterval(gal.scroLe);
		gal.scroLe=false;}
	var bt=document.getElementById('bouton_'+Strprev);
	bt.src="ressources/"+Strprev+".gif";
}

function initGalleryWidth(){
	list=list_thumbs();
	var gal=document.getElementById("galerie");
	if (window.getComputedStyle){
		if (gal.amount)
			gal.style.width=parseInt(Math.floor((gal.amount+1)/2))*200+'px';
		else 
			gal.style.width=parseInt(list.length/2)*200+'px';}
	else //IE: ne supporte pas overflow correctement. On redimensionne les thumbs plutot.
	{
	minimiseThumbs(list_thumbs());}
}

function initGalleryScroll(){
	var gal=document.getElementById("galerie");
	gal.scroRi=false;
	gal.scroLe=false;
	var prev=document.getElementById('bouton_'+Strprev);
	prev.onmouseover=scrollLeft;
	prev.onmouseout=cancelScrollLeft;
	var next=document.getElementById('bouton_'+Strnext);
	next.onmouseover=scrollRight;
	next.onmouseout=cancelScrollRight;

	var maskL=document.getElementById("maskL");
	maskL.onmouseover=scrollLeft;
	maskL.onmouseout=cancelScrollLeft;
	var maskR=document.getElementById("maskR");
	maskR.onmouseover=scrollRight;
	maskR.onmouseout=cancelScrollRight;	//alert(list);
}
//Section Galerie Eye Candy////////////////////////////////////////////////////////////////////////////////////////////////////


//Section Video
function launchVideo(href){
	var secCen=document.getElementById('section_centrale');
	var video=document.createElement('div');

	video.id="video";

	var videoContent='<object type="video/quicktime" style="width: 640px; height: 376px;" data="'+href+'">';
	videoContent+='<param name="src" value="'+href+'"/>';
	videoContent+='</object>';
	videoContent+='<div src="ressources/boutons/close.jpg" id="closeButton" onClick="closeVideo();"></div>';
	video.innerHTML=videoContent;
	secCen.appendChild(video);
}
	
function closeVideo(){
	var video=document.getElementById('video');
	var secCen=document.getElementById('section_centrale');
	secCen.removeChild(video);}

//Section Lancement Onload////////////////////////////////////////////////////////////////////////////////////////////////////
var adresse= window.location.toString();

function addEvent(obj, event, fct) {
	if (obj.attachEvent) //Est-ce IE ?
		obj.attachEvent("on" + event, fct); //Ne pas oublier le "on"
	else
		obj.addEventListener(event, fct, true);
}
function lancer(fct) {
    addEvent(window, "load", fct);
}

if (document.styleSheets[0].cssRules)
lancer(lancement_links);

lancer(lancement_up);

function galerie(){
if (document.getElementById('galerie'))
	{	list_thumbs();
		initGalleryScroll();}
}

if ((adresse.search(/galerie/)>-1) || (adresse.search(/references/)>-1))
	lancer(galerie);
if (adresse.search(/references/)>-1)
	lancer(bringon_references);
//Section Lancement Onload////////////////////////////////////////////////////////////////////////////////////////////////////
