/***********************************************
* CMotion Image Gallery- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for source code
* This copyright notice must stay intact for legal use
* Modified for autowidth and optional starting positions in
* http://www.dynamicdrive.com/forums/showthread.php?t=11839 by jschuer1 8/5/06
***********************************************/

 //1) Set width of the "neutral" area in the center of the gallery.
var restarea=6;
 //2) Set top scroll speed in pixels. Script auto creates a range from 0 to top speed.
var maxspeed=3;
 //3) Set to maximum width for gallery - must be less than the actual length of the image train.
var maxwidth=1000;
 //4) Set to 1 for left start, 0 for right, 2 for center.
var startpos=0;
var startpos2=0;
var startpos3=0;
 //5) Set message to show at end of gallery. Enter "" to disable message.
var endofgallerymsg='';
var endofgallerymsg2='';
var endofgallerymsg3='';

var menuwidth=230;
var menuwidth2=230;


////NO NEED TO EDIT BELOW THIS LINE////////////

// défilement //

var iedom=document.all||document.getElementById, scrollspeed=0, movestate='', actualwidth='230', cross_scroll, ns_scroll, statusdiv, loadedyes=0, lefttime, righttime;

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function showhidediv(what){
if (endofgallerymsg!="") {
statusdiv.style.visibility=what;
}
}

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft: what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function moveleft(){
if (loadedyes){
movestate="left";
if (iedom&&parseInt(cross_scroll.style.left)>(menuwidth-actualwidth)){
cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px";
showhidediv("hidden");
}
else
showhidediv("visible");
}
lefttime=setTimeout("moveleft()",10);
}

function moveright(){
if (loadedyes){
movestate="right";
if (iedom&&parseInt(cross_scroll.style.left)<0){
cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px";
showhidediv("hidden");
}
else
showhidediv("visible");
}
righttime=setTimeout("moveright()",10);
}

function motionengine(e){
var mainobjoffset=getposOffset(crossmain, "left"),
dsocx=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft,
dsocy=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop,
curposy=window.event? event.clientX : e.clientX? e.clientX: "";
curposy-=mainobjoffset-dsocx;
var leftbound=(menuwidth-restarea)/2;
var rightbound=(menuwidth+restarea)/2;
if (curposy>rightbound){
scrollspeed=(curposy-rightbound)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(righttime);
if (movestate!="left") moveleft();
}
else if (curposy<leftbound){
scrollspeed=(leftbound-curposy)/((menuwidth-restarea)/2) * maxspeed;
clearTimeout(lefttime);
if (movestate!="right") moveright();
}
else
scrollspeed=0;
}

function fillup(){
if (iedom){
crossmain=document.getElementById? document.getElementById("motioncontainer") : document.all.motioncontainer;
if(typeof crossmain.style.maxWidth!=='undefined')
crossmain.style.maxWidth=maxwidth+'px';
menuwidth=crossmain.offsetWidth;
cross_scroll=document.getElementById? document.getElementById("motiongallery") : document.all.motiongallery;
actualwidth=document.getElementById? document.getElementById("trueContainer").offsetWidth : document.all['trueContainer'].offsetWidth;
if (startpos)
cross_scroll.style.left=(menuwidth-actualwidth)/startpos+'px';
crossmain.onmousemove=function(e){
motionengine(e);
}

crossmain.onmouseout=function(e){
stopmotion(e);
showhidediv("hidden");
}
}
loadedyes=1
}



//deuxieme
var iedom2=document.all||document.getElementById, scrollspeed2=0, movestate2='', actualwidth2='230', cross_scroll2, ns_scroll2, statusdiv2, loadedyes2=0, lefttime2, righttime2;


function ietruebody2(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function showhidediv2(what2){
if (endofgallerymsg2!="") {
statusdiv2.style.visibility=what2;
}
}

function getposOffset2(what2, offsettype2){
var totaloffset2=(offsettype2=="left")? what2.offsetLeft: what2.offsetTop;
var parentEl2=what2.offsetParent;
while (parentEl2!=null){
totaloffset2=(offsettype2=="left")? totaloffset2+parentEl2.offsetLeft : totaloffset2+parentEl2.offsetTop;
parentEl2=parentEl2.offsetParent;
}
return totaloffset2;
}

function moveleft2(){
if (loadedyes2){
movestate2="left";
if (iedom2&&parseInt(cross_scroll2.style.left)>(230-actualwidth2)){
cross_scroll2.style.left=parseInt(cross_scroll2.style.left)-scrollspeed2+"px";
showhidediv2("hidden");
}
else
showhidediv2("visible");
}
lefttime2=setTimeout("moveleft2()",10);
}


function moveright2(){
if (loadedyes2){
movestate2="right";
if (iedom2&&parseInt(cross_scroll2.style.left)<0){
cross_scroll2.style.left=parseInt(cross_scroll2.style.left)+scrollspeed2+"px";
showhidediv2("hidden");
}
else
showhidediv2("visible");
}
righttime2=setTimeout("moveright2()",10);
}


function motionengine2(e){
var mainobjoffset2=getposOffset2(crossmain2, "left"),
dsocx2=(window.pageXOffset)? pageXOffset: ietruebody2().scrollLeft,
dsocy2=(window.pageYOffset)? pageYOffset : ietruebody2().scrollTop,
curposy2=window.event? event.clientX : e.clientX? e.clientX: "";
curposy2-=mainobjoffset2-dsocx2;
var leftbound2=(menuwidth2-restarea)/2;
var rightbound2=(menuwidth2+restarea)/2;
if (curposy2>rightbound2){
scrollspeed2=(curposy2-rightbound2)/((menuwidth2-restarea)/2) * maxspeed;
clearTimeout(righttime2);
if (movestate2!="left") moveleft2();
}
else if (curposy2<leftbound2){
scrollspeed2=(leftbound2-curposy2)/((menuwidth2-restarea)/2) * maxspeed;
clearTimeout(lefttime2);
if (movestate2!="right") moveright2();
}
else
scrollspeed2=0;
}


function fillup2(){
if (iedom2){
crossmain2=document.getElementById? document.getElementById("motioncontainer2") : document.all.motioncontainer2;
if(typeof crossmain2.style.maxWidth!=='undefined')
crossmain2.style.maxWidth=maxwidth+'px';
menuwidth2=crossmain2.offsetWidth;
cross_scroll2=document.getElementById? document.getElementById("motiongallery2") : document.all.motiongallery2;
actualwidth2=document.getElementById? document.getElementById("trueContainer2").offsetWidth : document.all['trueContainer2'].offsetWidth;
if (startpos2)
cross_scroll2.style.left=(menuwidth2-actualwidth2)/startpos2+'px';
crossmain2.onmousemove=function(e){
motionengine2(e);
}

crossmain2.onmouseout=function(e){
stopmotion2(e);
showhidediv2("hidden");
}
}
loadedyes2=1
}


//troisième
var iedom3=document.all||document.getElementById, scrollspeed3=0, movestate3='', actualwidth3='230', cross_scroll3, ns_scroll3, statusdiv3, loadedyes3=0, lefttime3, righttime3;

function ietruebody3(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function showhidediv3(what3){
if (endofgallerymsg3!="") {
statusdiv3.style.visibility=what3;
}
}

function getposOffset3(what3, offsettype3){
var totaloffset3=(offsettype3=="left")? what3.offsetLeft: what3.offsetTop;
var parentEl3=what3.offsetParent;
while (parentEl3!=null){
totaloffset3=(offsettype3=="left")? totaloffset3+parentEl3.offsetLeft : totaloffset3+parentEl3.offsetTop;
parentEl3=parentEl3.offsetParent;
}
return totaloffset3;
}

function moveleft3(){
if (loadedyes3){
movestate3="left";
if (iedom3&&parseInt(cross_scroll3.style.left)>(menuwidth3-actualwidth3)){
cross_scroll3.style.left=parseInt(cross_scroll3.style.left)-scrollspeed3+"px";
showhidediv3("hidden");
}
else
showhidediv3("visible");
}
lefttime3=setTimeout("moveleft3()",10);
}


function moveright3(){
if (loadedyes3){
movestate3="right";
if (iedom3&&parseInt(cross_scroll3.style.left)<0){
cross_scroll3.style.left=parseInt(cross_scroll3.style.left)+scrollspeed3+"px";
showhidediv3("hidden");
}
else
showhidediv3("visible");
}
righttime3=setTimeout("moveright3()",10);
}


function motionengine3(e){
var mainobjoffset3=getposOffset3(crossmain3, "left"),
dsocx3=(window.pageXOffset)? pageXOffset: ietruebody3().scrollLeft,
dsocy3=(window.pageYOffset)? pageYOffset : ietruebody(3).scrollTop,
curposy3=window.event? event.clientX : e.clientX? e.clientX: "";
curposy3-=mainobjoffset3-dsocx3;
var leftbound3=(menuwidth3-restarea)/2;
var rightbound3=(menuwidth3+restarea)/2;
if (curposy3>rightbound3){
scrollspeed3=(curposy3-rightbound3)/((menuwidth3-restarea)/2) * maxspeed;
clearTimeout(righttime3);
if (movestate3!="left") moveleft3();
}
else if (curposy3<leftbound3){
scrollspeed3=(leftbound3-curposy3)/((menuwidth3-restarea)/2) * maxspeed;
clearTimeout(lefttime3);
if (movestate3!="right") moveright3();
}
else
scrollspeed3=0;
}


function fillup3(){
if (iedom3){
crossmain3=document.getElementById? document.getElementById("motioncontainer3") : document.all.motioncontainer3;
if(typeof crossmain3.style.maxWidth!=='undefined')
crossmain3.style.maxWidth=maxwidth+'px';
menuwidth3=crossmain3.offsetWidth;
cross_scroll3=document.getElementById? document.getElementById("motiongallery3") : document.all.motiongallery3;
actualwidth3=document.getElementById? document.getElementById("trueContainer3").offsetWidth : document.all['trueContainer3'].offsetWidth;
if (startpos3)
cross_scroll3.style.left=(menuwidth3-actualwidth3)/startpos3+'px';
crossmain3.onmousemove=function(e){
motionengine3(e);
}

crossmain3.onmouseout=function(e){
stopmotion3(e);
showhidediv3("hidden");
}
}
loadedyes3=1
}


// défilement + affichage

function displayPics()
{
	var photos = document.getElementById('galerie_mini') ;
	var liens = photos.getElementsByTagName('a') ;
	var big_photo = document.getElementById('big_pict') ;
	var titre_photo = document.getElementById('photo').getElementsByTagName('dt')[0] ;
	
	for (var i = 0 ; i < liens.length ; ++i) {
		liens[i].onclick = function() {
			big_photo.src = this.href;
			big_photo.alt = this.title;
			titre_photo.firstChild.nodeValue = this.title;
			return false;
		};
	}
}

function displayPics2()
{
	var photos = document.getElementById('galerie_mini2') ;
	var liens = photos.getElementsByTagName('a') ;
	var big_photo = document.getElementById('big_pict2') ;
	var titre_photo = document.getElementById('photo2').getElementsByTagName('dt')[0] ;
	
	for (var i = 0 ; i < liens.length ; ++i) {
		liens[i].onclick = function() {
			big_photo.src = this.href;
			big_photo.alt = this.title;
			titre_photo.firstChild.nodeValue = this.title;
			return false;
		};
	}
}

function displayPics3()
{
	var photos = document.getElementById('galerie_mini3') ;
	var liens = photos.getElementsByTagName('a') ;
	var big_photo = document.getElementById('big_pict3') ;
	var titre_photo = document.getElementById('photo3').getElementsByTagName('dt')[0] ;
	
	for (var i = 0 ; i < liens.length ; ++i) {
		liens[i].onclick = function() {
			big_photo.src = this.href;
			big_photo.alt = this.title;
			titre_photo.firstChild.nodeValue = this.title;
			return false;
		};
	}
}



window.onload = function() {

displayPics();
displayPics2();
displayPics3();
fillup();
fillup2();
fillup3();
}




