// <![CDATA[
// Begin Ad Muncher helper script
// Do not remove without removing all references to this in the below page (eg: everything containing "XzW" or "Xzb")
// Retrieved from: 208.113.197.139:80
function XzWn(){return false;};function XzWbHelp(a,b){XzWZgp(a);XzWZbn();return;};function XzWb(a,b,c,d){XzWZgp(a);XzWZbn();return XzWZfw(b);};function XzWZpp(a){XzWZppa=a;if(a)XzWZorgsti("XzWZppa=0;",500);};function XzWbtePopup(a,b,c,d,e,f){XzWZgp();XzWZbn();return XzWZfw();};function XzWbModalDialog(a,b,c){XzWZgp(a);XzWZbn();return XzWZfw();};function XzWZj(m,u,l){if(XzWZolp){XzWZqn=XzWZqnbu;XzWZolp=0;};return true;};function XzWbModelessDialog(a,b,c){XzWZgp(a);XzWZbn();return XzWZfw();};function XzWZpl(a,b,c){while(a.indexOf(b)!=-1)a=a.replace(b,c);return a;};function XzWZtry(a,z){if(XzWZtryk())eval("try{"+a+"}catch(e){};");else eval(a);};function XzWc(){XzWZqn=XzWZqnbu=10;XzWZorgsti("XzWZqn=XzWZqnbu=0;",500);return;};function XzWZ__amscript_addonload(a){XzWZ_ams_onload[XzWZ_ams_onload_i++]=(typeof(a)=="function")?a:new Function(a);};function XzWZ__amscript_addonunload(a){XzWZ_ams_onunload[XzWZ_ams_onunload_i++]=(typeof(a)=="function")?a:new Function(a);};function XzWZfcs(z){XzWZfcsr=0;if(z){XzWZfcsrz=z;XzWZtry("XzWZfcsr=XzWZfcsd();");};return XzWZfcsr;};function XzWZfc(a,z){for(var i=0;i<a.length;i++)if(a[i].name==z||XzWZfc(a[i].frames,z))return 1;return 0;};function Xzb(z){if(typeof(z.location)!="undefined"||typeof(z.blur)=="undefined")return false;return z.blur();};function XzWf(z){if(typeof(z.location)!="undefined"||typeof(z.focus)=="undefined")return false;return z.focus();};function XzWZHelp(a,b){if(XzWZck(a))return;if(XzWZqn)XzWZqn-=1;if(b)return showHelp(a,b);else return showHelp(a);};function XzWTimeout(a,b){if(((!XzWZqn&&!XzWZa)||XzWZppa||XzWZul)&&typeof(a)=="string")return XzWZorgsti("XzWZpp(1);"+a+";XzWZpp(0);",b);return XzWZorgsti(a,b);};function XzWInterval(a,b){if(((!XzWZqn&&!XzWZa)||XzWZppa||XzWZul)&&typeof(a)=="string")return XzWZorgsin("XzWZpp(1);"+a+";XzWZpp(0);",b);return XzWZorgsin(a,b);};function XzWZbn(){if(XzWZd&&XzWZm){if(XzWZb){XzWZc="s";XzWZb+=", "+XzWZm;}else{XzWZc="";XzWZb=XzWZm;};XzWZi="Popup"+XzWZc+" on page blocked by Ad Muncher: "+XzWZb;XzWZu();};};function XzWZox(){var x;for(var i=0;i<XzWZ_ams_onunload.length;i++){if(typeof(XzWZ_ams_onunload[i])=="function")XzWZ_ams_onunload[i]();};if(typeof(XzWZffad)!="undefined"&&!XzWZffadd){if(XzWZkou)XzWZul=1;XzWZffadd=1;if(typeof(XzWZffad)=="function")x=XzWZffad();else eval(XzWZffad);XzWZul=0;};return x;};function XzWZModalDialog(a,b,c){if(XzWZck(a,b))return XzWZfw();if(XzWZqn)XzWZqn-=1;if(c)return showModalDialog(a,b,c);else if(b)return showModalDialog(a,b);else return showModalDialog(a);};function XzWZs(a){if((typeof(a.target)!="undefined"&&typeof(a.action)!="undefined"&&a.target&&XzWZnw(a.target)&&XzWZck(a.action))||typeof(a.submit)=="undefined")return false;return a.submit();};function XzWZt(a){if((XzWZqn||XzWZa)&&!XzWZppa&&!XzWZul){if(XzWZqn)XzWZqn-=1;return alert(a);};if(a&&XzWZd){XzWZi="Alert message blocked by Ad Muncher: "+XzWZpl(a,"\n"," ");XzWZu();};return false;};function XzWZModelessDialog(a,b,c){if(XzWZck(a,b))return XzWZfw();if(XzWZqn)XzWZqn-=1;if(c)return showModelessDialog(a,b,c);else if(b)return showModelessDialog(a,b);else return showModelessDialog(a);};function XzWZsp(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 XzWZu(a){XzWZi=XzWZpl(XzWZpl(XzWZi.substring(0,1024),'"',"<~am~`"),"<~am~`",'\\"');XzWZir='defaultStatus="'+XzWZi+'";';if(!XzWZss){XzWZss=1;XzWZorgsin("eval(XzWZir);",3000);};XzWZorgsti("eval(XzWZir);",1000);};function XzWZe(){XzWZa=0;XzWZqnbu=XzWZqn;XzWZqn=0;XzWZolp=1;XzWZorgsti("XzWZa=1;",1000);if(!XzWZffd){XzWZffd=1;for(var i=0;i<XzWZ_ams_onload.length;i++){if(typeof(XzWZ_ams_onload[i])=="function")XzWZ_ams_onload[i]();};if(typeof(XzWZff)!="undefined"){if(typeof(XzWZff)=="function")XzWZff();else eval(XzWZff);};};XzWZqn=XzWZqnbu;XzWZolp=0;XzWZx();};function XzWZnw(a){XzWZagt=navigator.userAgent.toLowerCase();if(a!="_self"&&a!="_top"&&a!="_main"&&a!="_parent"&&!XzWZfcs(a)&&((XzWZagt.indexOf("msie")==-1||XzWZagt.indexOf("opera")!=-1)||(a!="_search"&&a!="_media")))return 1;return 0;};function XzWZobx(){var x;if(typeof(XzWZffreunload)!="undefined"&&!XzWZffreunloadd){if(XzWZkou)XzWZul=1;XzWZffreunloadd=1;if(typeof(XzWZffreunload)=="function")x=XzWZffreunload();else eval(XzWZffreunload);XzWZffreunloadd=0;XzWZul=0;};return x;};function XzWZtryk(){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 XzWZfcsd(){var v=self;if(XzWZfc(v.frames,XzWZfcsrz)||(typeof(v.name)!="undefined"&&v.name==XzWZfcsrz))return 1;while(v!=v.parent){v=v.parent;if(XzWZfc(v.frames,XzWZfcsrz)||(typeof(v.name)!="undefined"&&v.name==XzWZfcsrz))return 1;};return 0;};function XzWZtePopup(a,b,c,d,e,f){if(XzWZck())return XzWZfw();if(XzWZqn)XzWZqn-=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 XzWZmc(){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=XzWZr;return 0;};function XzWZck(a,b){if(!XzWZul&&!XzWZppa&&(XzWZro||XzWZqn||XzWZa||(b&&!XzWZnw(b)))){return 0;};XzWZgp(a);var l,s,c;for(var i=0;i<XzWZpmx.length;i++){l=0;s=XzWZsp(XzWZpmx[i],"*");for(var z=0;z<s.length;z++){c=XzWZn.indexOf(s[z],l);if(c==-1){l=0;break;};l=c;};if(l)return 0;};XzWZbn();if(XzWZrp){XzWZrpi5=XzWZrpi4;XzWZrpi4=XzWZrpi3;XzWZrpi3=XzWZrpi2;XzWZrpi2=XzWZrpi1;XzWZrpi1=new Image();var XzWZzn;XzWZtry("XzWZzn=document.referrer");XzWZrpi1.src="http://www.admuncher.com/cgi-bin/pr.pl?p="+escape(XzWZm)+"&s="+escape(document.location.href)+"&r="+escape(XzWZzn)+"&v=4.71.28140&l=1725";};return 1;};function XzWZr(e){if((e&&e.which==1)||(typeof(window.event)!="undefined"&&window.event.button==1)){XzWZqn=XzWZqnbu=10;XzWZorgsti("XzWZqn=XzWZqnbu=0;",500);if(typeof(document.XzWZusedown)!="undefined"){if(typeof(document.XzWZusedown)=="function")return document.XzWZusedown(e);else return eval(document.XzWZusedown);};};if(typeof(document.XzWZusedown)!="undefined"){if(e||typeof(window.event)!="undefined"){if(typeof(document.XzWZusedown)=="function"){XzWZpp(0);var XzWZtn=document.XzWZusedown(e);XzWZpp(1);return XzWZtn;}else return eval("XzWZpp(1);"+document.XzWZusedown+";XzWZpp(0);");};if(typeof(document.XzWZusedown)=="function")return document.XzWZusedown(e);else return eval(document.XzWZusedown);};return true;};function XzWZx(){XzWZtry('if(typeof(window.onload)=="undefined")window.onload=XzWZe;else{XzWZq=""+window.onload;if(!window.onload||!XzWZq||XzWZq.indexOf("XzWZe")!=-1)window.onload=XzWZe;};if(typeof(window.onunload)=="undefined")window.onunload=XzWZox;else{XzWZq=""+window.onunload;if(!window.onunload||!XzWZq||XzWZq.indexOf("XzWZox")!=-1)window.onunload=XzWZox;};if(typeof(window.onbeforeunload)=="undefined")window.onbeforeunload=XzWZobx;else{XzWZq=""+window.onbeforeunload;if(!window.onbeforeunload||!XzWZq||XzWZq.indexOf("XzWZobx")!=-1)window.onbeforeunload=XzWZobx;};if(typeof(window.onmousedown)=="undefined")XzWZmc();else{XzWZq=""+document.onmousedown;if(!window.onmousedown||!XzWZq||XzWZq.indexOf("XzWZr")!=-1){XzWZmc();};};');};function XzWZgp(a){if(a){var XzWZckjs=/[A-Za-z]+:/;if(a.search(XzWZckjs)!=-1){if(a.substring(0,5).toLowerCase()!="http:"){XzWZm="(No URL)";XzWZn=a.toLowerCase()+" "+document.URL.toLowerCase();return;};};XzWZp="/admuncherpopcheck&"+Math.random()+"&"+document.URL;XzWZmi3=XzWZmi2;XzWZmi2=XzWZmi1;XzWZmi1=new Image();XzWZn=a;XzWZnn=XzWZn.indexOf("#");if(XzWZnn!=-1)XzWZn=XzWZn.substring(0,XzWZnn);XzWZmi1.src=XzWZn+XzWZp;XzWZnn=XzWZmi1.src.indexOf(XzWZp);if(XzWZnn!=-1)XzWZm=XzWZmi1.src.substring(0,XzWZnn);XzWZn=XzWZm.toLowerCase()+" "+document.URL.toLowerCase();}else{XzWZm="(No URL)";XzWZn=document.URL.toLowerCase();XzWZp="/admuncherpopchecknourl&"+Math.random();XzWZmi3=XzWZmi2;XzWZmi2=XzWZmi1;XzWZmi1=new Image();XzWZmi1.src=document.URL+XzWZp;};};function XzWZ(a,b,c,d){if(XzWZck(a,b))return XzWZfw(b);if(XzWZqn)XzWZqn-=1;if(!a)a="";if(typeof(c)=="string"){c=XzWZpl(c.toLowerCase()," ","");if(XzWZw){c=XzWZpl(c,"height=","xxx=");c=XzWZpl(c,"width=","xxx=");c=XzWZpl(c,"top=","xxx=");c=XzWZpl(c,"left=","xxx=");c=XzWZpl(c,"screenx=","xxx=");c=XzWZpl(c,"screeny=","xxx=");};if(XzWZy){c=XzWZpl(c,"location=","xxx=");c=XzWZpl(c,"toolbar=","xxx=");c=XzWZpl(c,"menubar=","xxx=");c=XzWZpl(c,"resizable=","xxx=");c=XzWZpl(c,"scrollbars=","xxx=");c=XzWZpl(c,"status=","xxx=");c=XzWZpl(c,"titlebar=","xxx=");c=XzWZpl(c,"fullscreen=","xxx=");c=XzWZpl(c,"directories=","xxx=");};};if(XzWZy){if(typeof(c)=="string")c+=",";else c="";c+="location,toolbar,menubar,resizable,scrollbars,status,titlebar,directories";};if(d)return XzWZorgo(a,b,c,d);else if(c)return XzWZorgo(a,b,c);else if(b)return XzWZorgo(a,b);else return XzWZorgo(a);};function XzWZso(c,a){if(typeof(a)=="string"&&a.substring(0,11)=="javascript:"){a=a.substring(11,a.length);};if(typeof(XzWZsod[c])=="undefined"||!XzWZsod[c]){XzWZsod[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=XzWZpl(a,m,unescape("%"+x[i].substring((l-2),l)));};};if(c==1)XzWZff=new Function(a);if(c==2)XzWZffad=new Function(a);if(c==3)XzWZffreunload=new Function(a);};};function XzWZfw(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]]=XzWn;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]]=XzWn;r.document.body=new Object();r.document.body.style=new Object();r.name=b;r.amwin="a";r.location=new Object(XzWZm);r.location.href=XzWZm;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;XzWZclct+=1;eval("XzWZpc["+XzWZclct+"]=r;XzWZorgsti(\"XzWZpc["+XzWZclct+"].closed=true;\",1500);");return r;};if(typeof(self.XzWZinited)=="undefined"){var XzWZinited=1;var XzWZa,XzWZb,XzWZc,XzWZd,XzWZi,XzWZir,XzWZk,XzWZm,XzWZmi1,XzWZmi2,XzWZmi3,XzWZn,XzWZnn,XzWZp,XzWZq,XzWZss,XzWZv,XzWZw,XzWZy,XzWZro,XzWZolp,XzWZqn,XzWZqnbu,XzWZplt,XzWZagt,XzWZtz,XzWZti,XzWZsa,XzWZeb,XzWZrp,XzWZrpi1,XzWZrpi2,XzWZrpi3,XzWZrpi4,XzWZrpi5,XzWZppa,XzWZffd,XzWZorgo,XzWZorgsin,XzWZorgsti,XzWZul,XzWZkou,XzWZffreunloadd,XzWZffadd,XzWZfcsr,XzWZfcsrz;var XzWZ_ams_onload_i=0;var XzWZ_ams_onload=new Array();var XzWZ_ams_onunload_i=0;var XzWZ_ams_onunload=new Array();var XzWZsod=new Array();for(var XzWZvin="";XzWZvin!="aaaaaaaaaaaaaaaaaaaa";XzWZvin+="a")eval("var AdMch"+XzWZvin+";");var XzWZclct=0;var XzWZpc=new Array();XzWZk=1;XzWZd=1;XzWZw=0;XzWZy=0;XzWZro=0;XzWZi="";XzWZtz=0;XzWZti=0;XzWZrp=0;XzWZkou=1;var XzWZpmx=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');XzWZorgo=open;XzWZorgsti=setTimeout;XzWZorgsin=setInterval;XzWZx();if(XzWZk)XzWZtry("window.onerror=XzWZj;");var XzWZz;XzWZtry("XzWZz=document.referrer");if(!XzWZz){if(XzWZti){if(XzWZtz)XzWZz=location.protocol+"//"+location.host+"/";else XzWZz="http://www.admuncher.com/";};}else if(XzWZz.substring(0,7)=="http://"){XzWZsa=XzWZz;XzWZsa=XzWZsa.substring(7,1024);if(XzWZsa.indexOf("/")!=-1)XzWZsa=XzWZsa.substring(0,XzWZsa.indexOf("/"));if(XzWZsa!=location.host){if(XzWZtz)XzWZz=location.protocol+"//"+location.host+"/";else XzWZz="http://www.admuncher.com/";};};};
// End Ad Muncher helper script
// ]]>

// -----------------------------------------------------------------------------------
//
//	Lightbox v2.03.3
//	by Lokesh Dhakar - http://www.huddletogether.com
//	5/21/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.com), 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()
	- updateImageList()
	- start()
	- changeImage()
	- resizeImageContainer()
	- showImage()
	- updateDetails()
	- updateNav()
	- enableKeyboardNav()
	- disableKeyboardNav()
	- keyboardAction()
	- preloadNeighborImages()
	- end()
	
	Miscellaneous Functions
	- getPageScroll()
	- getPageSize()
	- getKey()
	- listenKey()
	- showSelectBoxes()
	- hideSelectBoxes()
	- showFlash()
	- hideFlash()
	- pause()
	- initLightbox()
	
	Function Calls
	- addLoadEvent(initLightbox)
	
*/
// -----------------------------------------------------------------------------------

//
//	Configuration
//
var fileLoadingImage = "http://www.labnol.org/assets/images/lightbox/loading.gif";		
var fileBottomNavCloseImage = "http://www.labnol.org/assets/images/lightbox/closelabel.gif";

var overlayOpacity = 0.8;	// controls transparency of shadow overlay

var animate = true;			// toggles resizing animations
var resizeSpeed = 7;		// controls the speed of the image resizing animations (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(animate == true){
	overlayDuration = 0.2;	// shadow fade in/out duration
	if(resizeSpeed > 10){ resizeSpeed = 10;}
	if(resizeSpeed < 1){ resizeSpeed = 1;}
	resizeDuration = (11 - resizeSpeed) * 0.15;
} else { 
	overlayDuration = 0;
	resizeDuration = 0;
}

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

//
//	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";
	},
	setLeft: function(element,l) {
	   	element = $(element);
    	element.style.left = l +"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 = 0; i < this.length; i++){
        for(j = this.length-1; j>i; j--){        
            if(this[i][0] == this[j][0]){
                this.splice(j,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. Calls updateImageList and then
	// the function inserts html at the bottom of the page which is used to display the shadow 
	// overlay and the image container.
	//
	initialize: function() {	
		
		this.updateImageList();

		// 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(); }
		objBody.appendChild(objOverlay);
		
		var objLightbox = document.createElement("div");
		objLightbox.setAttribute('id','lightbox');
		objLightbox.style.display = 'none';
		objLightbox.onclick = function(e) {	// close Lightbox is user clicks shadow overlay
			if (!e) var e = window.event;
			var clickObj = Event.element(e).id;
			if ( clickObj == 'lightbox') {
				myLightbox.end();
			}
		};
		objBody.appendChild(objLightbox);
			
		var objOuterImageContainer = document.createElement("div");
		objOuterImageContainer.setAttribute('id','outerImageContainer');
		objLightbox.appendChild(objOuterImageContainer);

		// When Lightbox starts it will resize itself from 250 by 250 to the current image dimension.
		// If animations are turned off, it will be hidden as to prevent a flicker of a
		// white 250 by 250 box.
		if(animate){
			Element.setWidth('outerImageContainer', 250);
			Element.setHeight('outerImageContainer', 250);			
		} else {
			Element.setWidth('outerImageContainer', 1);
			Element.setHeight('outerImageContainer', 1);			
		}

		var objImageContainer = document.createElement("div");
		objImageContainer.setAttribute('id','imageContainer');
		objOuterImageContainer.appendChild(objImageContainer);
	
		var objLightboxImage = document.createElement("img");
		objLightboxImage.setAttribute('id','lightboxImage');
		objImageContainer.appendChild(objLightboxImage);
	
		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');
		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);
	},


	//
	// updateImageList()
	// Loops through anchor tags looking for 'lightbox' references and applies onclick
	// events to appropriate links. You can rerun after dynamically adding images w/ajax.
	//
	updateImageList: function() {	
		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');
		var areas = document.getElementsByTagName('area');

		// 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;}
			}
		}

		// loop through all area tags
		// todo: combine anchor & area tag loops
		for (var i=0; i< areas.length; i++){
			var area = areas[i];
			
			var relAttribute = String(area.getAttribute('rel'));
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (area.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				area.onclick = function () {myLightbox.start(this); return false;}
			}
		}
	},
	
	
	//
	//	start()
	//	Display overlay and lightbox. If image is part of a set, add siblings to imageArray.
	//
	start: function(imageLink) {	

		hideSelectBoxes();
		hideFlash();

		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		Element.setWidth('overlay', arrayPageSize[0]);
		Element.setHeight('overlay', arrayPageSize[1]);

		new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: overlayOpacity });

		imageArray = [];
		imageNum = 0;		

		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName( imageLink.tagName);

		// 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 and left offset for the lightbox 
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
		var lightboxLeft = arrayPageScroll[0];
		Element.setTop('lightbox', lightboxTop);
		Element.setLeft('lightbox', lightboxLeft);
		
		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
		if(animate){ 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.onload=function(){};	//	clear onLoad, IE behaves irratically with animated gifs otherwise 
		}
		imgPreloader.src = imageArray[activeImage][0];
	},

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

		// get curren width and height
		this.widthCurrent = Element.getWidth('outerImageContainer');
		this.heightCurrent = Element.getHeight('outerImageContainer');

		// get new width and height
		var widthNew = (imgWidth  + (borderSize * 2));
		var heightNew = (imgHeight  + (borderSize * 2));

		// scalars based on change from old to new
		this.xScale = ( widthNew / this.widthCurrent) * 100;
		this.yScale = ( heightNew / this.heightCurrent) * 100;

		// calculate size difference between new and old image, and resize if necessary
		wDiff = this.widthCurrent - widthNew;
		hDiff = this.heightCurrent - heightNew;

		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', widthNew);

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

	//
	//	updateDetails()
	//	Display caption, image number, and bottom nav.
	//
	updateDetails: function() {
	
		// if caption is not null
		if(imageArray[activeImage][1]){
			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, from: 0.0, to: 1.0 }), 
			  new Effect.Appear('imageDataContainer', { sync: true, duration: resizeDuration }) ], 
			{ duration: resizeDuration, afterFinish: function() {
				// update overlay size and update nav
				var arrayPageSize = getPageSize();
				Element.setHeight('overlay', arrayPageSize[1]);
				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;
			escapeKey = 27;
		} else { // mozilla
			keycode = e.keyCode;
			escapeKey = e.DOM_VK_ESCAPE;
		}

		key = String.fromCharCode(keycode).toLowerCase();
		
		if((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)){	// close lightbox
			myLightbox.end();
		} else if((key == 'p') || (keycode == 37)){	// display previous image
			if(activeImage != 0){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage - 1);
			}
		} else if((key == 'n') || (keycode == 39)){	// 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: overlayDuration});
		showSelectBoxes();
		showFlash();
	}
}

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

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

	var xScroll, yScroll;

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

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

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

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		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;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			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;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

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

	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(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

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

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

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

function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}

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

function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}

}


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

//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Help from Ran Bar-On [ran2103@gmail.com]
//

function pause(ms){
	var date = new Date();
	curDate = null;
	do{var curDate = new Date();}
	while( curDate - date < ms);
}
/*
function pause(numberMillis) {
	var curently = new Date().getTime() + sender;
	while (new Date().getTime();	
}
*/
// ---------------------------------------------------



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