// <![CDATA[
// Begin Ad Muncher helper script
// Do not remove without removing all references to this in the below page (eg: everything containing "ywz" or "ywb")
// Retrieved from: 72.167.97.91:80
function ywzn(){return false;};function ywzbHelp(a,b){ywzYgp(a);ywzYbn();return;};function ywzb(a,b,c,d){ywzYgp(a);ywzYbn();return ywzYfw(b);};function ywzYpp(a){ywzYppa=a;if(a)ywzYorgsti("ywzYppa=0;",500);};function ywzbtePopup(a,b,c,d,e,f){ywzYgp();ywzYbn();return ywzYfw();};function ywzbModalDialog(a,b,c){ywzYgp(a);ywzYbn();return ywzYfw();};function ywzYj(m,u,l){if(ywzYolp){ywzYqn=ywzYqnbu;ywzYolp=0;};return true;};function ywzbModelessDialog(a,b,c){ywzYgp(a);ywzYbn();return ywzYfw();};function ywzYpl(a,b,c){while(a.indexOf(b)!=-1)a=a.replace(b,c);return a;};function ywzYtry(a,z){if(ywzYtryk())eval("try{"+a+"}catch(e){};");else eval(a);};function ywzc(){ywzYqn=ywzYqnbu=10;ywzYorgsti("ywzYqn=ywzYqnbu=0;",500);return;};function ywzY__amscript_addonload(a){ywzY_ams_onload[ywzY_ams_onload_i++]=(typeof(a)=="function")?a:new Function(a);};function ywzY__amscript_addonunload(a){ywzY_ams_onunload[ywzY_ams_onunload_i++]=(typeof(a)=="function")?a:new Function(a);};function ywzYfcs(z){ywzYfcsr=0;if(z){ywzYfcsrz=z;ywzYtry("ywzYfcsr=ywzYfcsd();");};return ywzYfcsr;};function ywzYfc(a,z){for(var i=0;i<a.length;i++)if(a[i].name==z||ywzYfc(a[i].frames,z))return 1;return 0;};function ywb(z){if(typeof(z.location)!="undefined"||typeof(z.blur)=="undefined")return false;return z.blur();};function ywzf(z){if(typeof(z.location)!="undefined"||typeof(z.focus)=="undefined")return false;return z.focus();};function ywzYHelp(a,b){if(ywzYck(a))return;if(ywzYqn)ywzYqn-=1;if(b)return showHelp(a,b);else return showHelp(a);};function ywzTimeout(a,b){if(((!ywzYqn&&!ywzYa)||ywzYppa||ywzYul)&&typeof(a)=="string")return ywzYorgsti("ywzYpp(1);"+a+";ywzYpp(0);",b);return ywzYorgsti(a,b);};function ywzInterval(a,b){if(((!ywzYqn&&!ywzYa)||ywzYppa||ywzYul)&&typeof(a)=="string")return ywzYorgsin("ywzYpp(1);"+a+";ywzYpp(0);",b);return ywzYorgsin(a,b);};function ywzYbn(){if(ywzYd&&ywzYm){if(ywzYb){ywzYc="s";ywzYb+=", "+ywzYm;}else{ywzYc="";ywzYb=ywzYm;};ywzYi="Popup"+ywzYc+" on page blocked by Ad Muncher: "+ywzYb;ywzYu();};};function ywzYox(){var x;for(var i=0;i<ywzY_ams_onunload.length;i++){if(typeof(ywzY_ams_onunload[i])=="function")ywzY_ams_onunload[i]();};if(typeof(ywzYffad)!="undefined"&&!ywzYffadd){if(ywzYkou)ywzYul=1;ywzYffadd=1;if(typeof(ywzYffad)=="function")x=ywzYffad();else eval(ywzYffad);ywzYul=0;};return x;};function ywzYModalDialog(a,b,c){if(ywzYck(a,b))return ywzYfw();if(ywzYqn)ywzYqn-=1;if(c)return showModalDialog(a,b,c);else if(b)return showModalDialog(a,b);else return showModalDialog(a);};function ywzYs(a){if((typeof(a.target)!="undefined"&&typeof(a.action)!="undefined"&&a.target&&ywzYnw(a.target)&&ywzYck(a.action))||typeof(a.submit)=="undefined")return false;return a.submit();};function ywzYt(a){if((ywzYqn||ywzYa)&&!ywzYppa&&!ywzYul){if(ywzYqn)ywzYqn-=1;return alert(a);};if(a&&ywzYd){ywzYi="Alert message blocked by Ad Muncher: "+ywzYpl(a,"\n"," ");ywzYu();};return false;};function ywzYModelessDialog(a,b,c){if(ywzYck(a,b))return ywzYfw();if(ywzYqn)ywzYqn-=1;if(c)return showModelessDialog(a,b,c);else if(b)return showModelessDialog(a,b);else return showModelessDialog(a);};function ywzYsp(a,z){if(a.split)return a.split(z);var j,c,s,n,b,e;j=b=0;c=on.length;s=new Array();a+=z;n=a.length;while(b<n){e=z?a.indexOf(z,b):b+1;s[j++]=a.substring(b,e);b=e+c;};return s.length=j,s;};function ywzYu(a){ywzYi=ywzYpl(ywzYpl(ywzYi.substring(0,1024),'"',"<~am~`"),"<~am~`",'\\"');ywzYir='defaultStatus="'+ywzYi+'";';if(!ywzYss){ywzYss=1;ywzYorgsin("eval(ywzYir);",3000);};ywzYorgsti("eval(ywzYir);",1000);};function ywzYe(){ywzYa=0;ywzYqnbu=ywzYqn;ywzYqn=0;ywzYolp=1;ywzYorgsti("ywzYa=1;",1000);if(!ywzYffd){ywzYffd=1;for(var i=0;i<ywzY_ams_onload.length;i++){if(typeof(ywzY_ams_onload[i])=="function")ywzY_ams_onload[i]();};if(typeof(ywzYff)!="undefined"){if(typeof(ywzYff)=="function")ywzYff();else eval(ywzYff);};};ywzYqn=ywzYqnbu;ywzYolp=0;ywzYx();};function ywzYnw(a){ywzYagt=navigator.userAgent.toLowerCase();if(a!="_self"&&a!="_top"&&a!="_main"&&a!="_parent"&&!ywzYfcs(a)&&((ywzYagt.indexOf("msie")==-1||ywzYagt.indexOf("opera")!=-1)||(a!="_search"&&a!="_media")))return 1;return 0;};function ywzYobx(){var x;if(typeof(ywzYffreunload)!="undefined"&&!ywzYffreunloadd){if(ywzYkou)ywzYul=1;ywzYffreunloadd=1;if(typeof(ywzYffreunload)=="function")x=ywzYffreunload();else eval(ywzYffreunload);ywzYffreunloadd=0;ywzYul=0;};return x;};function ywzYtryk(){var b=navigator.userAgent.toLowerCase();var c=parseInt(navigator.appVersion);if((b.indexOf("mozilla")!=-1&&b.indexOf("compatible")== -1&&c>=5)||(b.indexOf("opera")!=-1&&c>=6)||(b.indexOf("msie")!=-1&&c>=4))return 1;return 0;};function ywzYfcsd(){var v=self;if(ywzYfc(v.frames,ywzYfcsrz)||(typeof(v.name)!="undefined"&&v.name==ywzYfcsrz))return 1;while(v!=v.parent){v=v.parent;if(ywzYfc(v.frames,ywzYfcsrz)||(typeof(v.name)!="undefined"&&v.name==ywzYfcsrz))return 1;};return 0;};function ywzYtePopup(a,b,c,d,e,f){if(ywzYck())return ywzYfw();if(ywzYqn)ywzYqn-=1;if(f)return createPopup(a,b,c,d,e,f);else if(e)return createPopup(a,b,c,d,e);else if(d)return createPopup(a,b,c,d);else if(c)return createPopup(a,b,c);else if(b)return createPopup(a,b);else return createPopup(a);};function ywzYmc(){if(typeof(document.layers)!="undefined")document.captureEvents(Event.KeyDown|Event.MouseUp|Event.Blur|Event.KeyPress|Event.Move|Event.Click|Event.KeyUp|Event.Reset|Event.Change|Event.Load|Event.Resize|Event.DblClick|Event.MouseDown|Event.Select|Event.DragDrop|Event.MouseMove|Event.Submit|Event.Error|Event.MouseOut|Event.Unload|Event.Focus|Event.MouseOver);document.onmousedown=ywzYr;return 0;};function ywzYck(a,b){if(!ywzYul&&!ywzYppa&&(ywzYro||ywzYqn||ywzYa||(b&&!ywzYnw(b)))){return 0;};ywzYgp(a);var l,s,c;for(var i=0;i<ywzYpmx.length;i++){l=0;s=ywzYsp(ywzYpmx[i],"*");for(var z=0;z<s.length;z++){c=ywzYn.indexOf(s[z],l);if(c==-1){l=0;break;};l=c;};if(l)return 0;};ywzYbn();if(ywzYrp){ywzYrpi5=ywzYrpi4;ywzYrpi4=ywzYrpi3;ywzYrpi3=ywzYrpi2;ywzYrpi2=ywzYrpi1;ywzYrpi1=new Image();var ywzYzn;ywzYtry("ywzYzn=document.referrer");ywzYrpi1.src="http://www.admuncher.com/cgi-bin/pr.pl?p="+escape(ywzYm)+"&s="+escape(document.location.href)+"&r="+escape(ywzYzn)+"&v=4.71.28140&l=1711";};return 1;};function ywzYr(e){if((e&&e.which==1)||(typeof(window.event)!="undefined"&&window.event.button==1)){ywzYqn=ywzYqnbu=10;ywzYorgsti("ywzYqn=ywzYqnbu=0;",500);if(typeof(document.ywzYusedown)!="undefined"){if(typeof(document.ywzYusedown)=="function")return document.ywzYusedown(e);else return eval(document.ywzYusedown);};};if(typeof(document.ywzYusedown)!="undefined"){if(e||typeof(window.event)!="undefined"){if(typeof(document.ywzYusedown)=="function"){ywzYpp(0);var ywzYtn=document.ywzYusedown(e);ywzYpp(1);return ywzYtn;}else return eval("ywzYpp(1);"+document.ywzYusedown+";ywzYpp(0);");};if(typeof(document.ywzYusedown)=="function")return document.ywzYusedown(e);else return eval(document.ywzYusedown);};return true;};function ywzYx(){ywzYtry('if(typeof(window.onload)=="undefined")window.onload=ywzYe;else{ywzYq=""+window.onload;if(!window.onload||!ywzYq||ywzYq.indexOf("ywzYe")!=-1)window.onload=ywzYe;};if(typeof(window.onunload)=="undefined")window.onunload=ywzYox;else{ywzYq=""+window.onunload;if(!window.onunload||!ywzYq||ywzYq.indexOf("ywzYox")!=-1)window.onunload=ywzYox;};if(typeof(window.onbeforeunload)=="undefined")window.onbeforeunload=ywzYobx;else{ywzYq=""+window.onbeforeunload;if(!window.onbeforeunload||!ywzYq||ywzYq.indexOf("ywzYobx")!=-1)window.onbeforeunload=ywzYobx;};if(typeof(window.onmousedown)=="undefined")ywzYmc();else{ywzYq=""+document.onmousedown;if(!window.onmousedown||!ywzYq||ywzYq.indexOf("ywzYr")!=-1){ywzYmc();};};');};function ywzYgp(a){if(a){var ywzYckjs=/[A-Za-z]+:/;if(a.search(ywzYckjs)!=-1){if(a.substring(0,5).toLowerCase()!="http:"){ywzYm="(No URL)";ywzYn=a.toLowerCase()+" "+document.URL.toLowerCase();return;};};ywzYp="/admuncherpopcheck&"+Math.random()+"&"+document.URL;ywzYmi3=ywzYmi2;ywzYmi2=ywzYmi1;ywzYmi1=new Image();ywzYn=a;ywzYnn=ywzYn.indexOf("#");if(ywzYnn!=-1)ywzYn=ywzYn.substring(0,ywzYnn);ywzYmi1.src=ywzYn+ywzYp;ywzYnn=ywzYmi1.src.indexOf(ywzYp);if(ywzYnn!=-1)ywzYm=ywzYmi1.src.substring(0,ywzYnn);ywzYn=ywzYm.toLowerCase()+" "+document.URL.toLowerCase();}else{ywzYm="(No URL)";ywzYn=document.URL.toLowerCase();ywzYp="/admuncherpopchecknourl&"+Math.random();ywzYmi3=ywzYmi2;ywzYmi2=ywzYmi1;ywzYmi1=new Image();ywzYmi1.src=document.URL+ywzYp;};};function ywzY(a,b,c,d){if(ywzYck(a,b))return ywzYfw(b);if(ywzYqn)ywzYqn-=1;if(!a)a="";if(typeof(c)=="string"){c=ywzYpl(c.toLowerCase()," ","");if(ywzYw){c=ywzYpl(c,"height=","xxx=");c=ywzYpl(c,"width=","xxx=");c=ywzYpl(c,"top=","xxx=");c=ywzYpl(c,"left=","xxx=");c=ywzYpl(c,"screenx=","xxx=");c=ywzYpl(c,"screeny=","xxx=");};if(ywzYy){c=ywzYpl(c,"location=","xxx=");c=ywzYpl(c,"toolbar=","xxx=");c=ywzYpl(c,"menubar=","xxx=");c=ywzYpl(c,"resizable=","xxx=");c=ywzYpl(c,"scrollbars=","xxx=");c=ywzYpl(c,"status=","xxx=");c=ywzYpl(c,"titlebar=","xxx=");c=ywzYpl(c,"fullscreen=","xxx=");c=ywzYpl(c,"directories=","xxx=");};};if(ywzYy){if(typeof(c)=="string")c+=",";else c="";c+="location,toolbar,menubar,resizable,scrollbars,status,titlebar,directories";};if(d)return ywzYorgo(a,b,c,d);else if(c)return ywzYorgo(a,b,c);else if(b)return ywzYorgo(a,b);else return ywzYorgo(a);};function ywzYso(c,a){if(typeof(a)=="string"&&a.substring(0,11)=="javascript:"){a=a.substring(11,a.length);};if(typeof(ywzYsod[c])=="undefined"||!ywzYsod[c]){ywzYsod[c]=1;var x=new Array('quot22','amp26','lt3C','gt3E','nbspA0','iexclA1','centA2','poundA3','yenA5','brvbarA6','sectA7','umlA8','copyA9','ordfAA','laquoAB','notAC','shyAD','regAE','macrAF','degB0','plusmnB1','sup2B2','sup3B3','acuteB4','microB5','paraB6','middotB7','cedilB8','sup1B9','ordmBA','raquoBB','frac14BC','frac12BD','frac34BE','iquestBF','AgraveC0','AacuteC1','AcircC2','AtildeC3','AumlC4','AringC5','AEligC6','CcedilC7','EgraveC8','EacuteC9','EcircCA','EumlCB','IgraveCC','IacuteCD','IcircCE','IumlCF','ETHD0','NtildeD1','OgraveD2','OacuteD3','OcircD4','OtildeD5','OumlD6','timesD7','OslashD8','UgraveD9','UacuteDA','UcircDB','UumlDC','YacuteDD','THORNDE','szligDF','agraveE0','aacuteE1','acircE2','atildeE3','aumlE4','aringE5','aeligE6','ccedilE7','egraveE8','eacuteE9','ecircEA','eumlEB','igraveEC','iacuteED','icircEE','iumlEF','ethF0','ntildeF1','ograveF2','oacuteF3','ocircF4','otildeF5','oumlF6','divideF7','oslashF8','ugraveF9','uacuteFA','ucircFB','uumlFC','yacuteFD','thornFE','yumlFF');var l,m;for(var i=0;i<x.length;i++){if (typeof(x[i])=="string"){l=x[i].length;m="&"+x[i].substring(0,(l-2))+";";a=ywzYpl(a,m,unescape("%"+x[i].substring((l-2),l)));};};if(c==1)ywzYff=new Function(a);if(c==2)ywzYffad=new Function(a);if(c==3)ywzYffreunload=new Function(a);};};function ywzYfw(b){var r=new Object();for(i in window)r[i]=window[i];var v=new Array("scrollBy","getSelection","scrollByLines","scrollByPages","sizeToContent","dump","setTimeout","setInterval","clearTimeout","clearInterval","setResizable","captureEvents","releaseEvents","routeEvent","enableExternalCapture","disableExternalCapture","prompt","open","openDialog","find","alert","confirm","focus","blur","back","forward","home","stop","print","moveTo","moveBy","resizeTo","resizeBy","scroll","close","show","updateCommands","escape","unescape","atob","btoa","addEventListener","removeEventListener","dispatchEvent","getComputedStyle");for(var i=0;i<v.length;i++)r[v[i]]=ywzn;v=new Array("captureEvents","close","open","releaseEvents","clear","writeln","getElementById","getElementsByName","elementFromPoint","createEvent","getSelection","write","createElement","createElementNS","createDocumentFragment","createTextNode","createComment","createAttribute","getElementsByTagName","importNode","attachEvent","detachEvent","hasAttributes","addEventListener","removeEventListener","dispatchEvent","contains","insertBefore","replaceChild","removeChild","appendChild","hasChildNodes","isSupported","normalize","cloneNode");r.document=new Object();for(var i=0;i<v.length;i++)r.document[v[i]]=ywzn;r.document.body=new Object();r.document.body.style=new Object();r.name=b;r.amwin="a";r.location=new Object(ywzYm);r.location.href=ywzYm;r.location.hash=window.location.hash;r.location.host=window.location.host;r.location.hostname=window.location.hostname;r.location.pathname=window.location.pathname;r.location.port=window.location.port;r.location.protocol=window.location.protocol;r.location.search=window.location.search;ywzYclct+=1;eval("ywzYpc["+ywzYclct+"]=r;ywzYorgsti(\"ywzYpc["+ywzYclct+"].closed=true;\",1500);");return r;};if(typeof(self.ywzYinited)=="undefined"){var ywzYinited=1;var ywzYa,ywzYb,ywzYc,ywzYd,ywzYi,ywzYir,ywzYk,ywzYm,ywzYmi1,ywzYmi2,ywzYmi3,ywzYn,ywzYnn,ywzYp,ywzYq,ywzYss,ywzYv,ywzYw,ywzYy,ywzYro,ywzYolp,ywzYqn,ywzYqnbu,ywzYplt,ywzYagt,ywzYtz,ywzYti,ywzYsa,ywzYeb,ywzYrp,ywzYrpi1,ywzYrpi2,ywzYrpi3,ywzYrpi4,ywzYrpi5,ywzYppa,ywzYffd,ywzYorgo,ywzYorgsin,ywzYorgsti,ywzYul,ywzYkou,ywzYffreunloadd,ywzYffadd,ywzYfcsr,ywzYfcsrz;var ywzY_ams_onload_i=0;var ywzY_ams_onload=new Array();var ywzY_ams_onunload_i=0;var ywzY_ams_onunload=new Array();var ywzYsod=new Array();for(var ywzYvin="";ywzYvin!="aaaaaaaaaaaaaaaaaaaa";ywzYvin+="a")eval("var AdMch"+ywzYvin+";");var ywzYclct=0;var ywzYpc=new Array();ywzYk=1;ywzYd=1;ywzYw=0;ywzYy=0;ywzYro=0;ywzYi="";ywzYtz=0;ywzYti=0;ywzYrp=0;ywzYkou=1;var ywzYpmx=new Array('.gov/funzone/','/apps/mediaplayer/','/home/loaded.php?room=','/online/popup.html?','/playradionow.jsp?','/portalcookiecheck.aspx?site=','/private.php?','/privmsg.php?','/public/logon.do','/radio/launchradio.','/reviews_viewer.php?object=','/site/olspage.jsp?id=','/spurl.php?v=','/video/partners/','/vspot/player.','/watch_fullscreen?','isapi.dll?picture','launch.yahoo.*/play/','music.yahoo.','skinbase.org/files/','webmessenger.msn.com');ywzYorgo=open;ywzYorgsti=setTimeout;ywzYorgsin=setInterval;ywzYx();if(ywzYk)ywzYtry("window.onerror=ywzYj;");var ywzYz;ywzYtry("ywzYz=document.referrer");if(!ywzYz){if(ywzYti){if(ywzYtz)ywzYz=location.protocol+"//"+location.host+"/";else ywzYz="http://www.admuncher.com/";};}else if(ywzYz.substring(0,7)=="http://"){ywzYsa=ywzYz;ywzYsa=ywzYsa.substring(7,1024);if(ywzYsa.indexOf("/")!=-1)ywzYsa=ywzYsa.substring(0,ywzYsa.indexOf("/"));if(ywzYsa!=location.host){if(ywzYtz)ywzYz=location.protocol+"//"+location.host+"/";else ywzYz="http://www.admuncher.com/";};};};
// End Ad Muncher helper script
// ]]>

// -----------------------------------------------------------------------------------
//
//	Lightbox v2.02
//	by Lokesh Dhakar - http://www.huddletogether.com
//	3/31/06
//
//	For more information on this script, visit:
//	http://huddletogether.com/projects/lightbox2/
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//	
//	Credit also due to those who have helped, inspired, and made their code available to the public.
//	Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.org), Thomas Fuchs(mir.aculo.us), and others.
//
//
// -----------------------------------------------------------------------------------
/*

	Table of Contents
	-----------------
	Configuration
	Global Variables

	Extending Built-in Objects	
	- Object.extend(Element)
	- Array.prototype.removeDuplicates()
	- Array.prototype.empty()

	Lightbox Class Declaration
	- initialize()
	- start()
	- changeImage()
	- resizeImageContainer()
	- showImage()
	- updateDetails()
	- updateNav()
	- enableKeyboardNav()
	- disableKeyboardNav()
	- keyboardAction()
	- preloadNeighborImages()
	- end()
	
	Miscellaneous Functions
	- getPageScroll()
	- getPageSize()
	- getKey()
	- listenKey()
	- showSelectBoxes()
	- hideSelectBoxes()
	- pause()
	- initLightbox()
	
	Function Calls
	- addLoadEvent(initLightbox)
	
*/
// -----------------------------------------------------------------------------------

//
//	Configuration
//
var fileLoadingImage = "includes/templates/template_default/images/lightbox/loading.gif";		
var fileBottomNavCloseImage = "includes/templates/template_default/images/lightbox/closelabel.gif";

var resizeSpeed = 7;	// controls the speed of the image resizing (1=slowest and 10=fastest)

var borderSize = 10;	//if you adjust the padding in the CSS, you will need to update this variable

// -----------------------------------------------------------------------------------

//
//	Global Variables
//
var imageArray = new Array;
var activeImage;

if(resizeSpeed > 10){ resizeSpeed = 10;}
if(resizeSpeed < 1){ resizeSpeed = 1;}
resizeDuration = (11 - resizeSpeed) * 0.15;

// -----------------------------------------------------------------------------------

//
//	Additional methods for Element added by SU, Couloir
//	- further additions by Lokesh Dhakar (huddletogether.com)
//
Object.extend(Element, {
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
	   	element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   		element = $(element);
    	element.style.height = h +"px";
	},
	setTop: function(element,t) {
	   	element = $(element);
    	element.style.top = t +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

// -----------------------------------------------------------------------------------

//
//	Extending built-in Array object
//	- array.removeDuplicates()
//	- array.empty()
//
Array.prototype.removeDuplicates = function () {
	for(i = 1; i < this.length; i++){
		if(this[i][0] == this[i-1][0]){
			this.splice(i,1);
		}
	}
}

// -----------------------------------------------------------------------------------

Array.prototype.empty = function () {
	for(i = 0; i <= this.length; i++){
		this.shift();
	}
}

// -----------------------------------------------------------------------------------

//
//	Lightbox Class Declaration
//	- initialize()
//	- start()
//	- changeImage()
//	- resizeImageContainer()
//	- showImage()
//	- updateDetails()
//	- updateNav()
//	- enableKeyboardNav()
//	- disableKeyboardNav()
//	- keyboardNavAction()
//	- preloadNeighborImages()
//	- end()
//
//	Structuring of code inspired by Scott Upton (http://www.uptonic.com/)
//
var Lightbox = Class.create();

Lightbox.prototype = {
	
	// initialize()
	// Constructor runs on completion of the DOM loading. Loops through anchor tags looking for 
	// 'lightbox' references and applies onclick events to appropriate links. The 2nd section of
	// the function inserts html at the bottom of the page which is used to display the shadow 
	// overlay and the image container.
	//
	initialize: function() {	
		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');

		// loop through all anchor tags
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			
			var relAttribute = String(anchor.getAttribute('rel'));
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				anchor.onclick = function () {myLightbox.start(this); return false;}
			}
		}

		// The rest of this code inserts html at the bottom of the page that looks similar to this:
		//
		//	<div id="overlay"></div>
		//	<div id="lightbox">
		//		<div id="outerImageContainer">
		//			<div id="imageContainer">
		//				<img id="lightboxImage">
		//				<div style="" id="hoverNav">
		//					<a href="#" id="prevLink"></a>
		//					<a href="#" id="nextLink"></a>
		//				</div>
		//				<div id="loading">
		//					<a href="#" id="loadingLink">
		//						<img src="images/loading.gif">
		//					</a>
		//				</div>
		//			</div>
		//		</div>
		//		<div id="imageDataContainer">
		//			<div id="imageData">
		//				<div id="imageDetails">
		//					<span id="caption"></span>
		//					<span id="numberDisplay"></span>
		//				</div>
		//				<div id="bottomNav">
		//					<a href="#" id="bottomNavClose">
		//						<img src="images/close.gif">
		//					</a>
		//				</div>
		//			</div>
		//		</div>
		//	</div>


		var objBody = document.getElementsByTagName("body").item(0);
		
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.display = 'none';
		objOverlay.onclick = function() { myLightbox.end(); return false; }
		objBody.appendChild(objOverlay);
		
		var objLightbox = document.createElement("div");
		objLightbox.setAttribute('id','lightbox');
		objLightbox.style.display = 'none';
		objBody.appendChild(objLightbox);
	
		var objOuterImageContainer = document.createElement("div");
		objOuterImageContainer.setAttribute('id','outerImageContainer');
		objLightbox.appendChild(objOuterImageContainer);

		var objImageContainer = document.createElement("div");
		objImageContainer.setAttribute('id','imageContainer');
		objOuterImageContainer.appendChild(objImageContainer);
	
		var objLightboxImage = document.createElement("img");
		objLightboxImage.setAttribute('id','lightboxImage');
		objImageContainer.appendChild(objLightboxImage);
		// begin zen lightbox v1.2 aclarke 2006-09-07
		objLightboxImage.onclick = function() { myLightbox.end(); return false; }
		// end zen lightbox v1.2 aclarke 2006-09-07
	
		var objHoverNav = document.createElement("div");
		objHoverNav.setAttribute('id','hoverNav');
		objImageContainer.appendChild(objHoverNav);
	
		var objPrevLink = document.createElement("a");
		objPrevLink.setAttribute('id','prevLink');
		objPrevLink.setAttribute('href','#');
		objHoverNav.appendChild(objPrevLink);
		
		var objNextLink = document.createElement("a");
		objNextLink.setAttribute('id','nextLink');
		objNextLink.setAttribute('href','#');
		objHoverNav.appendChild(objNextLink);
	
		var objLoading = document.createElement("div");
		objLoading.setAttribute('id','loading');
		objImageContainer.appendChild(objLoading);
	
		var objLoadingLink = document.createElement("a");
		objLoadingLink.setAttribute('id','loadingLink');
		objLoadingLink.setAttribute('href','#');
		objLoadingLink.onclick = function() { myLightbox.end(); return false; }
		objLoading.appendChild(objLoadingLink);
	
		var objLoadingImage = document.createElement("img");
		objLoadingImage.setAttribute('src', fileLoadingImage);
		objLoadingLink.appendChild(objLoadingImage);

		var objImageDataContainer = document.createElement("div");
		objImageDataContainer.setAttribute('id','imageDataContainer');
		objImageDataContainer.className = 'clearfix';
		objLightbox.appendChild(objImageDataContainer);

		var objImageData = document.createElement("div");
		objImageData.setAttribute('id','imageData');
		objImageDataContainer.appendChild(objImageData);
	
		var objImageDetails = document.createElement("div");
		objImageDetails.setAttribute('id','imageDetails');
		objImageData.appendChild(objImageDetails);
	
		var objCaption = document.createElement("span");
		objCaption.setAttribute('id','caption');
		objImageDetails.appendChild(objCaption);
	
		var objNumberDisplay = document.createElement("span");
		objNumberDisplay.setAttribute('id','numberDisplay');
		objImageDetails.appendChild(objNumberDisplay);
		
		var objBottomNav = document.createElement("div");
		objBottomNav.setAttribute('id','bottomNav');
		objImageData.appendChild(objBottomNav);
	
		var objBottomNavCloseLink = document.createElement("a");
		objBottomNavCloseLink.setAttribute('id','bottomNavClose');
		objBottomNavCloseLink.setAttribute('href','#');
		objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; }
		objBottomNav.appendChild(objBottomNavCloseLink);
	
		var objBottomNavCloseImage = document.createElement("img");
		objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage);
		objBottomNavCloseLink.appendChild(objBottomNavCloseImage);
	},
	
	//
	//	start()
	//	Display overlay and lightbox. If image is part of a set, add siblings to imageArray.
	//
	start: function(imageLink) {	

		hideSelectBoxes();

		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		Element.setHeight('overlay', arrayPageSize[1]);
		new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8 });

		imageArray = [];
		imageNum = 0;		

		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');

		// if image is NOT part of a set..
		if((imageLink.getAttribute('rel') == 'lightbox')){
			// add single image to imageArray
			imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title')));			
		} else {
		// if image is part of a set..

			// loop through anchors, find other images in set, and add them to imageArray
			for (var i=0; i<anchors.length; i++){
				var anchor = anchors[i];
				if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){
					imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
				}
			}
			imageArray.removeDuplicates();
			while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
		}

		// calculate top offset for the lightbox and display 
		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 15);

		Element.setTop('lightbox', lightboxTop);
		Element.show('lightbox');
		
		this.changeImage(imageNum);
	},

	//
	//	changeImage()
	//	Hide most elements and preload image in preparation for resizing image container.
	//
	changeImage: function(imageNum) {	
		
		activeImage = imageNum;	// update global var

		// hide elements during transition
		Element.show('loading');
		Element.hide('lightboxImage');
		Element.hide('hoverNav');
		Element.hide('prevLink');
		Element.hide('nextLink');
		Element.hide('imageDataContainer');
		Element.hide('numberDisplay');		
		
		imgPreloader = new Image();
		
		// once image is preloaded, resize image container
		imgPreloader.onload=function(){
			Element.setSrc('lightboxImage', imageArray[activeImage][0]);
			myLightbox.resizeImageContainer(imgPreloader.width, imgPreloader.height);
		}
		imgPreloader.src = imageArray[activeImage][0];
	},

	//
	//	resizeImageContainer()
	//
	resizeImageContainer: function( imgWidth, imgHeight) {

		// get current height and width
		this.wCur = Element.getWidth('outerImageContainer');
		this.hCur = Element.getHeight('outerImageContainer');

		// scalars based on change from old to new
		this.xScale = ((imgWidth  + (borderSize * 2)) / this.wCur) * 100;
		this.yScale = ((imgHeight  + (borderSize * 2)) / this.hCur) * 100;

		// calculate size difference between new and old image, and resize if necessary
		wDiff = (this.wCur - borderSize * 2) - imgWidth;
		hDiff = (this.hCur - borderSize * 2) - imgHeight;

		if(!( hDiff == 0)){ new Effect.Scale('outerImageContainer', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); }
		if(!( wDiff == 0)){ new Effect.Scale('outerImageContainer', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); }

		// if new and old image are same size and no scaling transition is necessary, 
		// do a quick pause to prevent image flicker.
		if((hDiff == 0) && (wDiff == 0)){
			if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} 
		}

		Element.setHeight('prevLink', imgHeight);
		Element.setHeight('nextLink', imgHeight);
		Element.setWidth( 'imageDataContainer', imgWidth + (borderSize * 2));

		this.showImage();
	},
	
	//
	//	showImage()
	//	Display image and begin preloading neighbors.
	//
	showImage: function(){
		Element.hide('loading');
		new Effect.Appear('lightboxImage', { duration: 0.5, queue: 'end', afterFinish: function(){	myLightbox.updateDetails(); } });
		this.preloadNeighborImages();
	},

	//
	//	updateDetails()
	//	Display caption, image number, and bottom nav.
	//
	updateDetails: function() {
	
		Element.show('caption');
		Element.setInnerHTML( 'caption', imageArray[activeImage][1]);
		
		// if image is part of set display 'Image x of x' 
		if(imageArray.length > 1){
			Element.show('numberDisplay');
			Element.setInnerHTML( 'numberDisplay', "Image " + eval(activeImage + 1) + " of " + imageArray.length);
		}

		new Effect.Parallel(
			[ new Effect.SlideDown( 'imageDataContainer', { sync: true, duration: resizeDuration + 0.25, from: 0.0, to: 1.0 }), 
			  new Effect.Appear('imageDataContainer', { sync: true, duration: 1.0 }) ], 
			{ duration: 0.65, afterFinish: function() { myLightbox.updateNav();} } 
		);
	},

	//
	//	updateNav()
	//	Display appropriate previous and next hover navigation.
	//
	updateNav: function() {

		Element.show('hoverNav');				

		// if not first image in set, display prev image button
		if(activeImage != 0){
			Element.show('prevLink');
			document.getElementById('prevLink').onclick = function() {
				myLightbox.changeImage(activeImage - 1); return false;
			}
		}

		// if not last image in set, display next image button
		if(activeImage != (imageArray.length - 1)){
			Element.show('nextLink');
			document.getElementById('nextLink').onclick = function() {
				myLightbox.changeImage(activeImage + 1); return false;
			}
		}
		
		this.enableKeyboardNav();
	},

	//
	//	enableKeyboardNav()
	//
	enableKeyboardNav: function() {
		document.onkeydown = this.keyboardAction; 
	},

	//
	//	disableKeyboardNav()
	//
	disableKeyboardNav: function() {
		document.onkeydown = '';
	},

	//
	//	keyboardAction()
	//
	keyboardAction: function(e) {
		if (e == null) { // ie
			keycode = event.keyCode;
		} else { // mozilla
			keycode = e.which;
		}

		key = String.fromCharCode(keycode).toLowerCase();
		
		if((key == 'x') || (key == 'o') || (key == 'c')){	// close lightbox
			myLightbox.end();
		} else if(key == 'p'){	// display previous image
			if(activeImage != 0){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage - 1);
			}
		} else if(key == 'n'){	// display next image
			if(activeImage != (imageArray.length - 1)){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage + 1);
			}
		}


	},

	//
	//	preloadNeighborImages()
	//	Preload previous and next images.
	//
	preloadNeighborImages: function(){

		if((imageArray.length - 1) > activeImage){
			preloadNextImage = new Image();
			preloadNextImage.src = imageArray[activeImage + 1][0];
		}
		if(activeImage > 0){
			preloadPrevImage = new Image();
			preloadPrevImage.src = imageArray[activeImage - 1][0];
		}
	
	},

	//
	//	end()
	//
	end: function() {
		this.disableKeyboardNav();
		Element.hide('lightbox');
		new Effect.Fade('overlay', { duration: 0.2});
		showSelectBoxes();
	}
}

// -----------------------------------------------------------------------------------

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

// -----------------------------------------------------------------------------------

//
// getKey(key)
// Gets keycode. If 'x' is pressed then it hides the lightbox.
//
function getKey(e){
	if (e == null) { // ie
		keycode = event.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){
	}
}

// -----------------------------------------------------------------------------------

//
// listenKey()
//
function listenKey () {	document.onkeypress = getKey; }
	
// ---------------------------------------------------

function showSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
// begin zen lightbox v1.2 aclarke 2006-09-07
	flashObjects = document.getElementsByClassName('flash')
	flashObjects.each(function(object){
	Element.show(object);
	})
// end zen lightbox v1.2 aclarke 2006-09-07
}

// ---------------------------------------------------

function hideSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
// begin zen lightbox v1.2 aclarke 2006-09-07
	flashObjects = document.getElementsByClassName('flash')
	flashObjects.each(function(object){
	Element.hide(object);
	})
// end zen lightbox v1.2 aclarke 2006-09-07
}

// ---------------------------------------------------

//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
//
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

// ---------------------------------------------------



function initLightbox() { myLightbox = new Lightbox(); }
Event.observe(window, 'load', initLightbox, false);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      