//' Software by DavidRegier.com. Unauthorized use of this code is prohibited
function ThumbNails(){var arrowLeftSsTnOn=new Image();arrowLeftSsTnOn.src="images/arrowLeftSsTnOn.gif";var arrowRightSsTnOn=new Image();arrowRightSsTnOn.src="images/arrowRightSsTnOn.gif";initImagesArr();this.nImages=Images.length;this.maxIndex=this.nImages-1;for(var i=0;i<this.nImages;i++){var imgTitle=(Images[i][3])?Images[i][3]:"";Images[i][3]=imgTitle.replace(/'/g, "^^" );
checkImgName(Images[i][0]);}
this.initTN=initTN;this.checkTnDim=checkTnDim;this.getImgInfoTN=getImgInfoTN;this.getNewIndex=getNewIndex;this.nextImage=nextImage;this.preloadNext=preloadNext;this.enlarge=enlarge;this.imgBorder=imgBorder;this.kill=kill;this.showNumImages=showNumImages;this.writeConsole=writeConsole;this.updateProgressBar=updateProgressBar;this.reportImgName=reportImgName;this.userIsAdministrator=GetCookie("userWithWritePrivileges");this.writeThumbnails=writeThumbnails;this.setFileSize=setFileSize;this.NextLgImage=null;this.OldImage=null;this.nextImgTimer=0;this.progressBarTimer=0;this.curIndex=-1;this.tnRemainingTN=0;this.TheBody=null;this.TopImage=null;function initTN(){this.showNumImages();this.checkTnDim();}
function getNewIndex(movingForward){if(movingForward)return(this.curIndex<this.maxIndex)?this.curIndex+1:0;else
return(this.curIndex>0)?this.curIndex-1:this.maxIndex;}
function preloadNext(){var newIndex=this.getNewIndex(1);var PreLoadImage=new Image();PreLoadImage.src=Settings.folder+Images[newIndex][0];var nOldImg=(newIndex==0)?Images.length-1:newIndex-1;this.OldImage=new Image();this.OldImage.src=Settings.folder+Images[nOldImg][0];}
function imgBorder(Img,color){if(Img.complete)Img.style.borderColor=color;}
function showNumImages(){if(this.nImages>-1){if(Settings.TN.ProgressBar.hideOnSuccess)document.getElementById("consoleTN").style.visibility="hidden";}}
function writeConsole(){document.write("<div id='consoleTN' style='line-height:14px;' align='"+Settings.TN.align+"'><div>&nbsp; </div><br></div>");}
function updateProgressBar(){var Console=document.getElementById("consoleTN");try{if(this.tnRemainingTN>=0){var dBarWid=(this.nImages-this.tnRemainingTN)*(Settings.TN.ProgressBar.width/this.nImages);var percentLoaded=parseInt(((this.nImages-this.tnRemainingTN)/this.nImages)*100);if(!Settings.TN.ProgressBar.hideOnSuccess){dBarWid=this.nImages/2*(Settings.TN.ProgressBar.width/this.nImages);percentLoaded=50;}
var pBar="<div style='width:"+Settings.TN.ProgressBar.width+"px; background-color:"+Settings.TN.ProgressBar.bgColor+"; text-align:left; z-index:0;'><div style='width:"+dBarWid+"px; background-color:"+Settings.TN.ProgressBar.progressColor+";'>&nbsp;</div></div><div style='position:relative; top:-14px; left:0px; width:"+Settings.TN.ProgressBar.width+"px; text-align:center; z-index:1; font-family:arial,helvetica; font-size:8pt; color:"+Settings.TN.ProgressBar.fontColor+"; font-weight:bold'>Loading Thumbnails "+percentLoaded+"%</div>";Console.innerHTML=pBar;if(!Settings.TN.ProgressBar.hideOnSuccess)clearTimeout(TN.progressBarTimer);else if(this.tnRemainingTN>0)TN.progressBarTimer=setTimeout("TN.updateProgressBar()",250);else if(Settings.TN.ProgressBar.hideOnSuccess)Console.style.visibility="hidden";}}
catch(Err){TN.progressBarTimer=setTimeout("TN.updateProgressBar()",250);}}
function getImgInfoTN(photoCaption,newIndex,addDivs){var count=(newIndex+1)+"/"+(this.maxIndex+1);switch(photoCaption){case "*":photoCaption=Settings.defaultCaption;break;case "_":photoCaption="<span style='font-variant:normal; text-transform:none;'>"+Images[newIndex][0]+"</span>";break;}
if(photoCaption){photoCaption=photoCaption.replace(/\^\^/g, "'" );
photoCaption=photoCaption.replace(/\^/g, "\"" );
if(addDivs)photoCaption=photoCaption.replace(/\[/g, "<div class='dwTitleLine2'>" ).replace(/]/g, "</div>" );}
else
photoCaption="&nbsp; <br>";return[photoCaption,count];}
function kill(){this.NextLgImage=null;clearInterval(this.nextImgTimer);this.nextImgTimer=0;if(this.TopImage){document.body.removeChild(this.TopImage);this.TopImage=null;}}
function nextImage(movingForward){var ImageDW=document.getElementById("ImageDW");if(ImageDW){var newIndex=this.getNewIndex(movingForward);if(!this.NextLgImage){this.NextLgImage=new Image();this.NextLgImage.src=Settings.folder+Images[newIndex][0];}
if(this.NextLgImage.complete&&this.OldImage.complete){if(!document.getElementById("dwOverlay"))DW.addOverlay();ImageDW.onload=null;var imgWidNew=Images[newIndex][1];var imgHgtNew=Images[newIndex][2];var imgWidReal=this.NextLgImage.width;var imgHgtReal=this.NextLgImage.height;if(imgWidReal>1&&imgHgtReal>1&&(imgWidReal!=imgWidNew||imgHgtReal!=imgHgtNew)){var eMsg="\""+Images[newIndex][0]+"\" has incorrect dimensions: \n  1) "+imgWidNew+" x "+imgHgtNew+" are the errant values \n  2) "+imgWidReal+" x "+imgHgtReal+" are the true values";alert(eMsg);}
if(!TN.TopImage){TN.TopImage=document.createElement("IMG");TN.TopImage.id="TopImage";TN.TopImage.style.top=(imgHgtNew*-2)+"px";TN.TopImage.style.left=(imgWidNew*-2)+"px";TN.TopImage.style.zIndex=10001;TN.TopImage.style.position="absolute";TN.TopImage.style.cursor="pointer";TN.TopImage.oncontextmenu=function(){if(Settings.disableContextImgMenu)return false;}
TN.TopImage.onclick=function(){TN.nextImage(1);this.title="";document.getElementById("ImageDW").title="";}
document.body.appendChild(TN.TopImage);}
if(winIE)TN.TopImage.style.visibility="hidden";else if(MZ)TN.TopImage.style.MozOpacity=0;else TN.TopImage.style.opacity=0;TN.TopImage.src=this.NextLgImage.src;TN.TopImage.style.height=imgHgtNew+"px";TN.TopImage.style.width=imgWidNew+"px";var Win=document.getElementById("dWinID");var PhotoInfo=this.getImgInfoTN(Images[newIndex][3],newIndex,1);document.getElementById("dwTitleLeft").innerHTML=PhotoInfo[1];document.getElementById("SsTnTitle").innerHTML=PhotoInfo[0];var imgWidOld=Images[this.curIndex][1];var imgHgtOld=Images[this.curIndex][2];var marLeft=Math.round((imgWidNew-imgWidOld)/2);var marTop=Math.round((imgHgtNew-imgHgtOld)/2);ImageDW.parentNode.style.marginLeft=marLeft+"px";ImageDW.parentNode.style.marginTop=marTop+"px";ImageDW.parentNode.parentNode.style.overflow="hidden";ImageDW.src=this.OldImage.src;ImageDW.style.width=imgWidOld+"px";ImageDW.style.height=imgHgtOld+"px";ImageDW.parentNode.parentNode.style.height=imgHgtNew+"px";Win.style.width=imgWidNew+"px";DW.reCenter(Win);DW.moveTopImage();this.NextLgImage=null;clearInterval(this.nextImgTimer);this.nextImgTimer=0;this.curIndex=(movingForward)?this.curIndex+1:this.curIndex-1;if(this.curIndex>this.maxIndex)this.curIndex=0;else if(this.curIndex<0)this.curIndex=this.maxIndex;this.preloadNext();startFade(TN.TopImage,Settings.IeTransNum,Settings.transDur,0);}
else{if(this.nextImgTimer==0){eval("this.nextImgTimer = setInterval( 'TN.nextImage( "+movingForward+" )', 250 );");document.getElementById("SsTnTitle").innerHTML="<span style='font-variant:normal;'>Downloading Image...</span>";}}}
else this.kill();}
function enlarge(cap,wid,hgt,imageNum){if(window.SS)SS.kill();this.TheBody=(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body;if(window.Images==null){RequestData=getAjaxRequest();if(RequestData){RequestData.onreadystatechange=function(){try{if(RequestData.readyState==4){if(RequestData.status==200){eval(RequestData.responseText);initImagesArr();subEnlarge();}
else
alert("AJAX error retrieving file \""+dataFile+"\" at TN.enlarge");}}
catch(Err){var eMsg="AJAX exception at TN.enlarge\n\n";for(var i in Err)eMsg+=i+": "+Err[i]+"\n";try{alert(eMsg);} catch(Err){}}}
RequestData.open("GET",dataFile,true);RequestData.send(null);}}
else
subEnlarge();function subEnlarge(){var PhotoInfo=TN.getImgInfoTN(Images[imageNum][3],imageNum,0);var photoCaption=PhotoInfo[0];DW.createWindow([photoCaption,"imgSrc="+Settings.folder+Images[imageNum][0]],[0,wid,hgt],null,null,0,[4,0,0],"TN");var TdCount=document.getElementById("dwTitleLeft");TdCount.innerHTML=PhotoInfo[1];}
return false;}
function writeThumbnails(){if(dataFile){this.tnRemainingTN=this.nImages;var htm="";var tnNum=0;thePageTitle=Settings.TN.pageTitle;thePageTitle=thePageTitle.replace(/\^\^/g, "&#39;" );
thePageTitle=thePageTitle.replace(/\^/g, "&#34;" );
if(thePageTitle)htm+="<div class='tnTitle' align='center'>"+thePageTitle+"</div>";htm+="<table align='center' border=0 cellpadding=0 cellspacing=0>";var nRows=Math.floor(this.nImages/Settings.TN.nImagesRow)+1;for(var row=0;row<nRows;row++){htm+="<tr align='"+Settings.TN.align+"' valign='middle'><td align=center nowrap>";for(var i=0;i<Settings.TN.nImagesRow;i++){var thisTnImgData='';var writeTN=(tnNum<this.nImages)?true:false;if(writeTN){var lgImageName=Images[tnNum][0],tnImageName="";lastDotPos=lgImageName.lastIndexOf(".");var fileExt="TN"+lgImageName.substring(lastDotPos,lgImageName.length);tnImageName=(Images[tnNum][6])?Images[tnNum][6]:lgImageName.split(".")[0]+fileExt;var lgWid=Images[tnNum][1];var lgHgt=Images[tnNum][2];var imgTitle=Images[tnNum][3];imgTitle=imgTitle.replace(/\"/g, "^" );
if(imgTitle=="*")imgTitle=Settings.defaultCaption;else if(imgTitle=="_")imgTitle=lgImageName;var toolTip=imgTitle.replace(/<.*?>/g, "" );
toolTip=toolTip.replace(/\^\^/g, "&#39;" ).replace(/\^/g, "&#34;" );
toolTip=toolTip.replace(/\[.*\]/g, "" );
var tn=Settings.folder+tnImageName;tnNum++;}
var imageNum=row*Settings.TN.nImagesRow+i+1;if(writeTN){var lgImgName=Images[tnNum-1][0];var toolTipColon=(toolTip)?": ":"";toolTip=imageNum+" of "+this.nImages+toolTipColon+toolTip;htm+="<a href='javascript:void(0);' title=\""+toolTip+"\" onClick='if( window.DW ) { TN.curIndex = "+(imageNum-1)+"; this.blur(); return TN.enlarge( \""+imgTitle+"\", "+lgWid+", "+lgHgt+", "+(imageNum-1)+" ); }' onContextMenu='return TN.reportImgName( this, "+imageNum+", event );'><img src='"+tn+"' border='0' hspace='2' vspace='2' width='"+Settings.TN.width+"' HEIGHT='"+Settings.TN.height+", ' title=\""+toolTip+"\" style='border:1px solid "+Settings.TN.bordColOff+";' onMouseover='if( window.TN ) TN.imgBorder(this,Settings.TN.bordColOn);' onMouseout='if( window.TN ) TN.imgBorder(this,Settings.TN.bordColOff);' onAbort='this.src=this.src;' onLoad='TN.tnRemainingTN--;' onContextMenu='"+((Settings.disableContextImgMenu)?"return false;":"return true;")+"' id='TN_"+imageNum+"'></a>";}}
htm+="</td></tr>";}
htm+="</table>";document.write(htm);}}
function reportImgName(Link,imageNum,evt){if(this.userIsAdministrator){var Img=Images[imageNum-1];var ImgTN=Link.firstChild;var wid=Img[1],hgt=Img[2];var shape=(wid>hgt)?"horizontal":((wid<hgt)?"vertical":"square");var htm="<table align='left' border='0' cellspacing='0' cellpadding='0'><tr><td align=center valign=top><img src='"+ImgTN.src+"' width='"+ImgTN.width+"' height='"+ImgTN.height+"'></td><td align=center valign=top style='padding:4px;'><table align='center' border='0' cellspacing='0' cellpadding='0' class='dwText'><tr><td align=right>Name:&nbsp;</td><td align=left>"+Img[0]+"</td></tr><tr><td align=right>Number:&nbsp;</td><td align=left>"+imageNum+" of "+TN.nImages+"</td></tr><tr><td align=right>Dimensions:&nbsp;</td><td align=left>"+wid+" &times; "+hgt+" px; "+shape+"</td></tr><tr><td align=right>File Size:&nbsp;</td><td id='fileSizeTN' align=left></td></tr><tr><td align=right valign=top>Caption:&nbsp;</td><td align=left>"+Img[3]+"</td></tr></table></td></table>";if(window.DW){DW.createWindow(["Enlargement Properties",htm],[0,500,0],Link,evt);this.setFileSize(imageNum);}
return false;}}
function setFileSize(imageNum){this.Request=getAjaxRequest();if(this.Request){this.Request.onreadystatechange=function(){try{if(TN.Request.readyState==4){if(TN.Request.status==200){var fileSize=parseInt(TN.Request.getResponseHeader("Content-Length"))/1024;document.getElementById("fileSizeTN").innerHTML=Math.round(fileSize)+" KB";}
else
alert("Error retrieving photo at method TN.setFileSize");}}
catch(Err){var eMsg="Exception at method TN.setFileSize\n\n";for(var i in Err)eMsg+=i+": "+Err[i]+"\n";try{alert(eMsg);} catch(Err){}}}
this.Request.open("GET",Settings.folder+Images[imageNum-1][0],true);this.Request.send(null);}}
this.checkTN=1;this.checkTnTimer=0;this.TnReal=null;this.TnSizeErr="";function checkTnDim(){if(this.userIsAdministrator||local){if(this.TnReal==null){var TN=document.getElementById("TN_"+this.checkTN);if(TN){TnReal=new Image();TnReal.src=TN.src;}
else{TnReal=null;clearTimeout(this.checkTnTimer);if(this.TnSizeErr)DW.createWindow(["Thumbnail Dimension Error","<div style='margin:0px 0px 4px 0px;' class='dwText'>Thumbnails must be "+Settings.TN.width+" x "+Settings.TN.height+" pixels:</div>"+this.TnSizeErr],[0,400,0],null,null,6,[4,0,0]);}}
if(TnReal&&TnReal.complete){var realWid=TnReal.width,realHgt=TnReal.height;if(realWid>1&&realHgt>1&&(realWid!=Settings.TN.width||realHgt!=Settings.TN.height)){var FileComponents=TnReal.src.split("/");var fileName=FileComponents[FileComponents.length-1];this.TnSizeErr+="<div style='margin:0px 0px 0px 8px;'>#"+this.checkTN+" "+fileName+" is "+realWid+" x "+realHgt+"</div>";}
this.checkTN++;this.checkTnTimer=setTimeout("TN.checkTnDim();",100);}}}} 
