// -------------------------------------------------------------------
// Image Thumbnail Viewer II- By Dynamic Drive, available at: http://www.dynamicdrive.com
// Last updated: Feb 5th, 2007
// -------------------------------------------------------------------

var thumbnailviewer2={
enableTitle: true, //Should "title" attribute of link be used as description?
enableTransition: true, //Enable fading transition in IE?
hideimgmouseout: false, //Hide enlarged image when mouse moves out of anchor link? (if enlarged image is hyperlinked, always set to false!)

/////////////No need to edit beyond here/////////////////////////

iefilterstring: 'progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=0.7)', //IE specific multimedia filter string
iefiltercapable: document.compatMode && window.createPopup? true : false, //Detect browser support for IE filters
preloadedimages:[], //array to preload enlarged images (ones set to display "onmouseover"
targetlinks:[], //array to hold participating links (those with rel="enlargeimage:initType")
alreadyrunflag: false, //flag to indicate whether init() function has been run already come window.onload

loadimage:function(linkobj){ 

// Fonction de dtection de la position de l'objet (la petite image) dans la fentre:
function FindPos(AObject,option)
{
	var largeur;
	var hauteur;
	largeur = screen.width;
	hauteur = screen.height;

	var posX = 0, posY = 0;
    do
    {
        posX += AObject.offsetLeft;
        posY += AObject.offsetTop;
        AObject = AObject.offsetParent;
    }
    while( AObject != null );

	var pos = [];
    pos['X'] = posX; posX=posX-310;						// A partir la gauche de l'cran (on enlve la largeur de l'image)
    pos['Y'] = posY; 				 					// A partir du haut de l'cran
	
	if (posY <= hauteur)
		{ posY = (hauteur/4) + 200; }
	else
		{ temp = (posY / hauteur) + 200; }
	
   if (option=='X_left') return (posX + "px");
   if (option=='Y_top') return (posY + "px");
   
}
// FindPos(this,option);
// Fin de la fonction de dtection de la position de l'objet (la petite image) dans la fentre.

var imagepath=linkobj.getAttribute("href") //Get URL to enlarged image
var showcontainer=document.getElementById(linkobj.getAttribute("rev").split("::")[0]) //Reference container on page to show enlarged image in

/*
var position='top:'+FindPos(linkobj,'Y_top')+'; '+'left:'+FindPos(linkobj,'X_left') +'; '
showcontainer.setAttribute('position','absolute'); // *** HZ ****
showcontainer.setAttribute('style',position); // *** HZ ****
*/

var dest=linkobj.getAttribute("rev").split("::")[1] //Get URL enlarged image should be linked to, if any

var description=(thumbnailviewer2.enableTitle && linkobj.getAttribute("title"))? linkobj.getAttribute("title") : "" //Get title attr
var imageHTML='<img src="'+imagepath+'" style="border-width: 0" />' //Construct HTML for enlarged image
if (typeof dest!="undefined") //Hyperlink the enlarged image?
imageHTML='<a href="'+dest+'" >'+imageHTML+'</a>'

if (description!="") //Use title attr of the link as description?
imageHTML+='<br />'+description
if (this.iefiltercapable){ //Is this an IE browser that supports filters?
showcontainer.style.filter=this.iefilterstring
showcontainer.filters[0].Apply()
}

myPicture_source = search_source(imageHTML);
myPicture_target = search_target(imageHTML);
myString = "<a href=\""+myPicture_target+"\" rel=\"lightbox[0]\" title=\""+description+"\"> <img src=\""+myPicture_source+"\" title=\"cliquez pour agrandir\" border=\"0\" /> </a> ";
showcontainer.innerHTML=myString ;

this.featureImage=showcontainer.getElementsByTagName("img")[0] //Reference enlarged image itself
this.featureImage.onload=function(){ //When enlarged image has completely loaded
if (thumbnailviewer2.iefiltercapable) //Is this an IE browser that supports filters?
showcontainer.filters[0].Play()
}
this.featureImage.onerror=function(){ //If an error has occurred while loading the image to show
if (thumbnailviewer2.iefiltercapable) //Is this an IE browser that supports filters?
showcontainer.filters[0].Stop()
}
},

hideimage:function(linkobj){
	
var showcontainer=document.getElementById(linkobj.getAttribute("rev").split("::")[0]) //Reference container on page to show enlarged image in
showcontainer.innerHTML="";

},


cleanup:function(){ //Clean up routine on page unload
if (this.featureImage){this.featureImage.onload=null; this.featureImage.onerror=null; this.featureImage=null}
this.showcontainer=null
for (var i=0; i<this.targetlinks.length; i++){
this.targetlinks[i].onclick=null
this.targetlinks[i].onmouseover=null
this.targetlinks[i].onmouseout=null

}
},

addEvent:function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
},

init:function(){ //Initialize thumbnail viewer script
this.iefiltercapable=(this.iefiltercapable && this.enableTransition) //True or false: IE filters supported and is enabled by user
var pagelinks=document.getElementsByTagName("a")
for (var i=0; i<pagelinks.length; i++){ //BEGIN FOR LOOP
if (pagelinks[i].getAttribute("rel") && /enlargeimage:/i.test(pagelinks[i].getAttribute("rel"))){ //Begin if statement: Test for rel="enlargeimage"
var initType=pagelinks[i].getAttribute("rel").split("::")[1] //Get display type of enlarged image ("click" or "mouseover")
if (initType=="mouseover"){ 
//If type is "mouseover", preload the enlarged image for quicker display
this.preloadedimages[this.preloadedimages.length]=new Image()
this.preloadedimages[this.preloadedimages.length-1].src=pagelinks[i].href
pagelinks[i]["onclick"]=function(){ //Cancel default click action
return false
}
}

pagelinks[i]["on"+initType]=function()
{ //Load enlarged image based on the specified display type (event)
	
	/*
				var IE6 = false, IE7 = false,
				 FIREFOX2  = false, FIREFOX  = false,
				 NETSCAPE7 = false, NETSCAPE = false, 
				 OPERA9 = false, OPERA = false, 
				 AUTRE = false;
				var strChUserAgent = navigator.userAgent;
				var intSplitStart = strChUserAgent.indexOf("(",0);
				var intSplitEnd = strChUserAgent.indexOf(")",0);
				var strChStart = strChUserAgent.substring(0,intSplitStart);
				var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
				var strChEnd = strChUserAgent.substring(strChEnd);
				if(strChMid.indexOf("MSIE 7") != -1)
				 IE7 = true;
				else if(strChMid.indexOf("MSIE 6") != -1)
				 IE6 = true;
				else if(strChEnd.indexOf("Firefox/2") != -1)
				 FIREFOX2 = true;
				else if(strChEnd.indexOf("Firefox") != -1)
				 FIREFOX = true;
				else if(strChEnd.indexOf("Netscape/7") != -1)
				 NETSCAPE7 = true;
				else if(strChEnd.indexOf("Netscape") != -1)
				 NETSCAPE = true;
				else if(strChStart.indexOf("Opera/9") != -1)
				 OPERA9 = true;
				else if(strChStart.indexOf("Opera") != -1)
				 OPERA = true;
				else
				 AUTRE = true;
				 
				affiche='';
				if (IE6) affiche+=" IE6";
				if (IE7) affiche+=" IE7";
				if (FIREFOX) affiche+=" FIREFOX";
				if (FIREFOX2) affiche+=" FIREFOX2";
				if (NETSCAPE7) affiche+=" NETSCAPE7";
				if (NETSCAPE) affiche+=" NETSCAPE";
				if (OPERA9) affiche+=" OPERA9";
				if (OPERA) affiche+=" OPERA";
				if (AUTRE) affiche+=" AUTRE";
				
				// alert(affiche);

				var Coordx = 0; 
				var Coordy = 0;
				
				if (IE7)
					{	e=window.event;
						function IEcoord(e)
							{Coordx = IEmousex(); 
							Coordy = IEmousey();
							// alert(Coordx+":"+Coordy);
							}		
						function IEmousex(e)
							{return event.clientX;}
						function IEmousey(e)
							{return event.clientY;}
						IEcoord(e);
					}
				else 
					{	e=pagelinks[i].event;
						function mousex(e)
							{return e.x;}
						function mousey(e)
							{return e.y;}
						function coord(e)
							{Coordx = mousex(); 
							Coordy = mousey();
								// alert(Coordx+":"+Coordy);
							}	
						coord(e);
					}
	
	*/
	
thumbnailviewer2.loadimage(this) //Load image

return false
}

if (this.hideimgmouseout)
pagelinks[i]["onmouseout"]=function(){
// HZ thumbnailviewer2.hideimage(this)
}

this.targetlinks[this.targetlinks.length]=pagelinks[i] //store reference to target link
} //end if statement

} //END FOR LOOP


} //END init() function

}


if (document.addEventListener) //Take advantage of "DOMContentLoaded" event in select Mozilla/ Opera browsers for faster init
thumbnailviewer2.addEvent(document, function(){thumbnailviewer2.alreadyrunflag=1; thumbnailviewer2.init()}, "DOMContentLoaded") //Initialize script on page load
else if (document.all && document.getElementsByTagName("a").length>0){ //Take advantage of "defer" attr inside SCRIPT tag in IE for instant init
thumbnailviewer2.alreadyrunflag=1
thumbnailviewer2.init()
}
thumbnailviewer2.addEvent(window, function(){if (!thumbnailviewer2.alreadyrunflag) thumbnailviewer2.init()}, "load") //Default init method: window.onload
thumbnailviewer2.addEvent(window, function(){thumbnailviewer2.cleanup()}, "unload")

function search_source(tmp)
{
	pos = tmp.indexOf("photos/",0);
	name = tmp.substring(pos,pos+14);
 	return (name);
}

function search_target(tmp)
{
	name = tmp.substring(pos,pos+9);
	name += "l.jpg";
	return (name);
}
