// JavaScript Document

nTimer = nDelay * 1000;

nCurrentPic = -1;



var bDisableNext = false;

var bDisablePrev = false;



function initAnimation() {

	document.getElementById("diaporama").style.display = "inline";

	document.getElementById("diaporama").style.visibility = "visible";

	if(!bAuto) {

		document.getElementById("prev").onclick = PreviousPic;

		document.getElementById("prev").onmouseover = Handler;

		document.getElementById("prev").onmouseout = Handler;

		document.getElementById("next").onclick = NextPic;

		document.getElementById("next").onmouseover = Handler;

		document.getElementById("next").onmouseout = Handler;
		if(!bContinuous)
			Status("prev","disable");

	}

	if(bShowNext) {

			document.getElementById("prev_img").style.display = "inline";

			document.getElementById("prev_img").style.visibility = "visible";

			document.getElementById("next_img").style.display = "inline";

			document.getElementById("next_img").style.visibility = "visible";

	}

	if(bDoPopup) {

		document.getElementById("diaporama").style.cursor = "pointer";

		document.getElementById("diaporama").onclick = ShowImage;

	}

	NextPic();

}



function ShowImage() {
	strMyImg = arrImages[nCurrentPic];
	strMyImg = strImg.replace("_thumb.jpg",".jpg");
	window.open("popup.php?file="+strPhotoFolder+strMyImg,"popup","toolbar=no, scrollbars=no");

}



function Handler(e) {

	if(navigator.appName == "Microsoft Internet Explorer") {

		//alert("IE" + event.srcElement.id);

		strSourceID = event.srcElement.id;

		strEventType = event.type;

	} else {

		//alert("DA" + e.target.id);

		strSourceID = e.target.id;

		strEventType = e.type;

	}

	if(strEventType == "mouseover") {

		if(strSourceID == "prev") {

				document.getElementById("prev").className = strPrevOverClass;

		} else if (strSourceID == "next") {

				document.getElementById("next").className = strNextOverClass;

		}

	} else if(strEventType == "mouseout") {

		//alert(e.target.id + "-"+e.type);

		if(strSourceID == "prev") {

				document.getElementById("prev").className = strPrevClass;

		} else if (strSourceID == "next") {

				document.getElementById("next").className = strNextClass;

		}

	}

	

}



function NextPic() {

	nCurrentPic++;

	if(!bContinuous && (nCurrentPic+1 >= arrImages.length)) {

		Status("next","disable");

	}

	if(nCurrentPic >= arrImages.length) {

			nCurrentPic = arrImages.length-1;

		if(bContinuous) {

			nCurrentPic = 0;

			DisplayPic(nCurrentPic);

		}

	} else {

		if(!bContinuous && (nCurrentPic-1 >= 0)) {

			Status("prev","enable");

		}

		DisplayPic(nCurrentPic);

	}

	

	if(bAuto && (nCurrentPic < arrImages.length-1 || bContinuous)) {

		setTimeout("NextPic()",nTimer);

	}

}



function PreviousPic() {

	nCurrentPic--;

	if(!bContinuous && (nCurrentPic-1 <0)) {

		Status("prev","disable");

	}

	if(nCurrentPic < 0) {

		nCurrentPic = 0;

		if(bContinuous) {

			nCurrentPic = arrImages.length - 1;

			DisplayPic(nCurrentPic);

		}

	} else {

		if(!bContinuous && (nCurrentPic+1 < arrImages.length)) {

			Status("next","enable");

		}

		DisplayPic(nCurrentPic);

	}

}



function DisplayPic(nb) {

		strImg = arrImages[nb];

		document.getElementById("diaporama").src=strPhotoFolder + strImg;

		if(bShowName) {

			document.getElementById("text").innerHTML = arrImages[nb];

		}

		if(bShowNext) {

			nb_next = nb + 1;

			if(nb_next >= arrImages.length) {

					nb_next = (bContinuous) ? 0 : -1;

			}

			nb_prev = nb - 1;

			if(nb_prev < 0) {

					nb_prev = (bContinuous) ? (arrImages.length - 1) : -1;

			}

			if(nb_next != -1) {

					document.getElementById("next_img").src=strPhotoFolder + arrImages[nb_next].replace(/.jpg/g,"_thumb.jpg");

			} else {

					document.getElementById("next_img").src="photo/no_img.jpg";

			}

			if(nb_prev != -1) {

					document.getElementById("prev_img").src=strPhotoFolder + arrImages[nb_prev].replace(/.jpg/g,"_thumb.jpg");

			} else {

					document.getElementById("prev_img").src="photo/no_img.jpg";

			}

		}

}



function Status(strID, strStatus) {

if(!bAuto) {

	if(strStatus == "disable") {

		document.getElementById(strID).className = strDisabledClass;

		document.getElementById(strID).onclick = vid;

		document.getElementById(strID).onmouseover = vid;

		document.getElementById(strID).onmouseout = vid;

	} else if(strStatus == "enable") {

		if(strID == "prev") {

				document.getElementById(strID).className = "strPrevClass";

				document.getElementById(strID).onclick = PreviousPic;

		} else {

				document.getElementById(strID).className = "strNextClass";

				document.getElementById(strID).onclick = NextPic;

		}

		document.getElementById(strID).onmouseover = Handler

		document.getElementById(strID).onmouseout = Handler;

	}

}

}



function vid() {

	alert("Vid");

}



document.write("<table align='center' height='135' class='"+strMainClass+"'>");

document.write("<tr>");

document.write("<td>");

if(bShowNext) {

	document.write("<img src='' id='prev_img' class='"+strImageClass+"' style='visibility:hidden; display:none'>");

} else {

if(!bAuto) {

	document.write("<div id='prev' class='"+strPrevClass+"' style='float:left;cursor:pointer;' align='left' title='Pr&eacute;c&eacute;dent'><img src='images/charte/arrow_left.jpg' style='margin-bottom:1px'>&nbsp;"+strPrev+"</div>");

}

}

document.write("</td>");

document.write("<td>");

document.write("<img src='' id='diaporama' class='"+strImageClass+"' style='visibility:hidden; display:none'>");

document.write("</td>");

document.write("<td nowrap>");

if(bShowNext) {

	document.write("<img src='' id='next_img' class='"+strImageClass+"' style='visibility:hidden; display:none'>");

} else {

if(!bAuto) {

	document.write("<div id='next' class='"+strNextClass+"' style='float:right;cursor:pointer;' align='right' title='Suivant'>"+strNext+"&nbsp;&nbsp;<img src='images/charte/arrow_right.jpg' style='margin-bottom:1px'></div>");

}

}

document.write("</td>");

document.write("</tr>");

document.write("<tr>");

document.write("<td>");

//if(!bAuto) {

	//document.write("<div id='prev' class='"+strPrevClass+"' style='float:left;cursor:pointer;' align='left'>"+strPrev+"</div>");

//}

document.write("</td>");

document.write("<td>");

if(bShowName) {

	document.write("<br><div id='text'></div>");

}

document.write("</td>");

document.write("<td>");

//if(!bAuto) {

	//document.write("<div id='next' class='"+strNextClass+"' style='float:right;cursor:pointer;' align='right'>"+strNext+"&nbsp;&nbsp;&nbsp;&nbsp;</div>");

//}

document.write("</td>");

document.write("</tr>");

document.write("</table>");


