// -------------------------------------------------------------------// Image Thumbnail Viewer II- By Dynamic Drive, available at: http://www.dynamicdrive.com// Last updated: Feb 5th, 2007// -------------------------------------------------------------------var thumbnailviewer2={enableTitle: false, //Should "title" attribute of link be used as description?enableTransition: false, //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 stringiefiltercapable: document.compatMode && window.createPopup? true : false, //Detect browser support for IE filterspreloadedimages:[], //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.onloadloadimage:function(linkobj){var imagepath=linkobj.getAttribute("href") //Get URL to enlarged imagevar showcontainer=document.getElementById(linkobj.getAttribute("rev").split("::")[0]) //Reference container on page to show enlarged image invar dest=linkobj.getAttribute("rev").split("::")[1] //Get URL enlarged image should be linked to, if anyvar description=(thumbnailviewer2.enableTitle && linkobj.getAttribute("title"))? linkobj.getAttribute("title") : "" //Get title attrvar imageHTML='<img src="'+imagepath+'" style="border-width: 0" />' //Construct HTML for enlarged imageif (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 />'+descriptionif (this.iefiltercapable){ //Is this an IE browser that supports filters?showcontainer.style.filter=this.iefilterstringshowcontainer.filters[0].Apply()}showcontainer.innerHTML=imageHTMLthis.featureImage=showcontainer.getElementsByTagName("img")[0] //Reference enlarged image itselfthis.featureImage.onload=function(){ //When enlarged image has completely loadedif (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 showif (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 inshowcontainer.innerHTML=""},cleanup:function(){ //Clean up routine on page unloadif (this.featureImage){this.featureImage.onload=null; this.featureImage.onerror=null; this.featureImage=null}this.showcontainer=nullfor (var i=0; i<this.targetlinks.length; i++){this.targetlinks[i].onclick=nullthis.targetlinks[i].onmouseover=nullthis.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"+tasktypeif (target.addEventListener)target.addEventListener(tasktype, functionref, false)else if (target.attachEvent)target.attachEvent(tasktype, functionref)},init:function(){ //Initialize thumbnail viewer scriptthis.iefiltercapable=(this.iefiltercapable && this.enableTransition) //True or false: IE filters supported and is enabled by uservar pagelinks=document.getElementsByTagName("a")for (var i=0; i<pagelinks.length; i++){ //BEGIN FOR LOOPif (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 displaythis.preloadedimages[this.preloadedimages.length]=new Image()this.preloadedimages[this.preloadedimages.length-1].src=pagelinks[i].hrefpagelinks[i]["onclick"]=function(){ //Cancel default click actionreturn false}}pagelinks[i]["on"+initType]=function(){ //Load enlarged image based on the specified display type (event)thumbnailviewer2.loadimage(this) //Load imagereturn false}if (this.hideimgmouseout)pagelinks[i]["onmouseout"]=function(){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 initthumbnailviewer2.addEvent(document, function(){thumbnailviewer2.alreadyrunflag=1; thumbnailviewer2.init()}, "DOMContentLoaded") //Initialize script on page loadelse if (document.all && document.getElementsByTagName("a").length>0){ //Take advantage of "defer" attr inside SCRIPT tag in IE for instant initthumbnailviewer2.alreadyrunflag=1thumbnailviewer2.init()}thumbnailviewer2.addEvent(window, function(){if (!thumbnailviewer2.alreadyrunflag) thumbnailviewer2.init()}, "load") //Default init method: window.onloadthumbnailviewer2.addEvent(window, function(){thumbnailviewer2.cleanup()}, "unload")
