/*

Better(?) Image cross fader (C)2004 Patrick H. Lauke aka redux

Inspired by Steve at Slayeroffice http://slayeroffice.com/code/imageCrossFade/ 

preInit "Scheduler" idea by Cameron Adams aka The Man in Blue
http://www.themaninblue.com/writing/perspective/2004/09/29/ 

Tweaked to deal with empty nodes 19 Feb 2006

*/

/* general variables */

var galleryId = 'gallery'; /* change this to the ID of the gallery list */
var	gallery; /* this will be the object reference to the list later on */
var galleryImages; /* array that will hold all child elements of the list */
var currentImage; /* keeps track of which image should currently be showing */
var previousImage;
var preInitTimer;
preInit();

/* functions */

function preInit() {
	/* an inspired kludge that - in most cases - manages to initially hide the image gallery list
	   before even onload is triggered (at which point it's normally too late, and the whole list already
	   appeared to the user before being remolded) */
	if ((document.getElementById)&&(gallery=document.getElementById(galleryId))) {
		gallery.style.visibility = "hidden";
		if (typeof preInitTimer != 'undefined') clearTimeout(preInitTimer); /* thanks to Steve Clay http://mrclay.org/ for this small Opera fix */
	} else {
		preInitTimer = setTimeout("preInit()",2);
	}
}

function fader(imageNumber,opacity) {
	/* helper function to deal specifically with images and the cross-browser differences in opacity handling */
	var obj=galleryImages[imageNumber];
	if (obj.style) {
		if (obj.style.MozOpacity!=null) {  
			/* Mozilla's pre-CSS3 proprietary rule */
			obj.style.MozOpacity = (opacity/100) - .001;
		} else if (obj.style.opacity!=null) {
			/* CSS3 compatible */
			obj.style.opacity = (opacity/100) - .001;
		} else if (obj.style.filter!=null) {
			/* IE's proprietary filter */
			obj.style.filter = "alpha(opacity="+opacity+")";
		}
	}
}

function fadeInit() {
	if (document.getElementById) {
		preInit(); /* shouldn't be necessary, but IE can sometimes get ahead of itself and trigger fadeInit first */
		galleryImages = new Array;
		var node = gallery.firstChild;
		/* instead of using childNodes (which also gets empty nodes and messes up the script later)
		we do it the old-fashioned way and loop through the first child and its siblings */
		while (node) {
			if (node.nodeType==1) {
				galleryImages.push(node);
			}
			node = node.nextSibling;
		}
		for(i=0;i<galleryImages.length;i++) {
			/* loop through all these child nodes and set up their styles */
			galleryImages[i].style.position='absolute';
			galleryImages[i].style.top=0;
			galleryImages[i].style.zIndex=0;
			/* set their opacity to transparent */
			fader(i,0);
		}
		/* make the list visible again */
		gallery.style.visibility = 'visible';
		/* initialise a few parameters to get the cycle going */
		currentImage=0;
		previousImage=galleryImages.length-1;
		opacity=100;
		fader(currentImage,100);
		/* start the whole crossfade process after a second's pause */
		window.setTimeout("crossfade(100)", 3000);
	}
}

function crossfade(opacity) {
		if (opacity < 100) {
			/* current image not faded up fully yet...so increase its opacity */
			fader(currentImage,opacity);
			/* fader(previousImage,100-opacity); */
			opacity += 5;
			window.setTimeout("crossfade("+opacity+")", 30);
		} else {
			/* make the previous image - which is now covered by the current one fully - transparent */
			fader(previousImage,0);
			/* current image is now previous image, as we advance in the list of images */
			previousImage=currentImage;
			currentImage+=1;
			if (currentImage>=galleryImages.length) {
				/* start over from first image if we cycled through all images in the list */
				currentImage=0;
			}
			/* make sure the current image is on top of the previous one */
			galleryImages[previousImage].style.zIndex = 0;
			galleryImages[currentImage].style.zIndex = 100;
			/* and start the crossfade after a second's pause */
			opacity=0;
			window.setTimeout("crossfade("+opacity+")", 3000);
		}
		
}

/* initialise fader by hiding image object first */
addEvent(window,'load',fadeInit)



/* 3rd party helper functions */

/* addEvent handler for IE and other browsers */
function addEvent(elm, evType, fn, useCapture) 
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
 if (elm.addEventListener){
   elm.addEventListener(evType, fn, useCapture);
   return true;
 } else if (elm.attachEvent){
   var r = elm.attachEvent("on"+evType, fn);
   return r;
 }
} 


/*
	AMenu - Menu inspired the Adobe web 
	by Bretislav Stepan http://bretislavstepan.cz
	@ver 0.0
*/

function initAMenu(countItems) {
	for (i = 1; i <= countItems; i++)
	{
		elementById = document.getElementById("headItem" + i);
		elementById.style.display = "block";
		
		elementById = document.getElementById("bodyItem" + i);
		elementById.style.display = "none";
	}
}
function openItem(itemNumber, countItems) {
	for (i = 1; i <= countItems; i++)
	{
		if (itemNumber == i)
		{
			elementById = document.getElementById("headItem" + i);
			elementById.style.display = "none";
	
			elementById = document.getElementById("bodyItem" + i);
			elementById.style.display = "block";
		}
		else
		{
			elementById = document.getElementById("headItem" + i);
			elementById.style.display = "block";
	
			elementById = document.getElementById("bodyItem" + i);
			elementById.style.display = "none";
		} 
	}
}
function closeItems(countItems) {
	for (i = 1; i <= countItems; i++)
	{
		elementById = document.getElementById("headItem" + i);
		elementById.style.display = "block";
	
		elementById = document.getElementById("bodyItem" + i);
		elementById.style.display = "none";
	}
}

function iDisplay(elementID)
{
var id;
	id = "ref" + elementID;
	hhh = document.getElementById(id);
	if (hhh != null){
	if (hhh.style.display == "none")
	{
		hhh.style.display = "block";
	}
	else
	{
		hhh.style.display = "none";
	}
	}
}

//MooTools, My Object Oriented Javascript Tools. Copyright (c) 2006-2007 Valerio Proietti, <http://mad4milk.net>, MIT Style License.

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('o 6W={84:\'1.11\'};k $3Q(T){h(T!=5Z)};k $q(T){m(!$3Q(T))h 1c;m(T.2C)h\'12\';o q=3u T;m(q==\'2d\'&&T.7J){1M(T.4p){17 1:h\'12\';17 3:h(/\\S/).1X(T.67)?\'75\':\'7R\'}}m(q==\'2d\'||q==\'k\'){1M(T.60){17 1v:h\'14\';17 4e:h\'7T\';17 1g:h\'5I\'}m(3u T.O==\'4L\'){m(T.1S)h\'7W\';m(T.6n)h\'M\'}}h q};k $2G(){o 36={};C(o i=0;i<M.O;i++){C(o t V M[i]){o 3I=M[i][t];o 3H=36[t];m(3H&&$q(3I)==\'2d\'&&$q(3H)==\'2d\')36[t]=$2G(3H,3I);W 36[t]=3I}}h 36};o $P=k(){o U=M;m(!U[1])U=[c,U[0]];C(o t V U[1])U[0][t]=U[1][t];h U[0]};o $2E=k(){C(o i=0,l=M.O;i<l;i++){M[i].P=k(1d){C(o 1j V 1d){m(!c.1b[1j])c.1b[1j]=1d[1j];m(!c[1j])c[1j]=$2E.3B(1j)}}}};$2E.3B=k(1j){h k(K){h c.1b[1j].2z(K,1v.1b.6l.1G(M,1))}};$2E(4H,1v,4q,5S);k $35(T){h!!(T||T===0)};k $4r(T,6z){h $3Q(T)?T:6z};k $4Z(2p,2b){h Y.7V(Y.4Z()*(2b-2p+1)+2p)};k $1U(){h X 7j().7c()};k $4j(1r){77(1r);76(1r);h 1e};o 2t=k(T){T=T||{};T.P=$P;h T};o 78=X 2t(H);o 7t=X 2t(L);L.6h=L.3K(\'6h\')[0];H.6N=!!(L.7s);m(H.7n)H.1D=H[H.7m?\'7o\':\'6v\']=1f;W m(L.6k&&!L.7q&&!7r.7d)H.2v=H[H.6N?\'7A\':\'4O\']=1f;W m(L.7X!=1e)H.4c=1f;H.7L=H.2v;70.P=$P;m(3u 2X==\'5Z\'){o 2X=k(){};m(H.2v)L.6H("73");2X.1b=(H.2v)?H["[[7E.1b]]"]:{}}2X.1b.2C=k(){};m(H.6v)4w{L.7u("7v",1c,1f)}4C(e){};o 1g=k(1N){o 31=k(){h(M[0]!==1e&&c.1z&&$q(c.1z)==\'k\')?c.1z.2z(c,M):c};$P(31,c);31.1b=1N;31.60=1g;h 31};1g.2c=k(){};1g.1b={P:k(1N){o 3J=X c(1e);C(o t V 1N){o 5G=3J[t];3J[t]=1g.6e(5G,1N[t])}h X 1g(3J)},6b:k(){C(o i=0,l=M.O;i<l;i++)$P(c.1b,M[i])}};1g.6e=k(2g,2s){m(2g&&2g!=2s){o q=$q(2s);m(q!=$q(2g))h 2s;1M(q){17\'k\':o 4x=k(){c.1B=M.6n.1B;h 2s.2z(c,M)};4x.1B=2g;h 4x;17\'2d\':h $2G(2g,2s)}}h 2s};o 6d=X 1g({7G:k(B){c.2q=c.2q||[];c.2q.1n(B);h c},5i:k(){m(c.2q&&c.2q.O)c.2q.5F().1u(10,c)},7S:k(){c.2q=[]}});o 1T=X 1g({2o:k(q,B){m(B!=1g.2c){c.$J=c.$J||{};c.$J[q]=c.$J[q]||[];c.$J[q].51(B)}h c},1Y:k(q,U,1u){m(c.$J&&c.$J[q]){c.$J[q].1s(k(B){B.1L({\'K\':c,\'1u\':1u,\'M\':U})()},c)}h c},4b:k(q,B){m(c.$J&&c.$J[q])c.$J[q].2H(B);h c}});o 5d=X 1g({5B:k(){c.G=$2G.2z(1e,[c.G].P(M));m(c.2o){C(o 2R V c.G){m($q(c.G[2R]==\'k\')&&(/^41[A-Z]/).1X(2R))c.2o(2R,c.G[2R])}}h c}});1v.P({3v:k(B,K){C(o i=0,j=c.O;i<j;i++)B.1G(K,c[i],i,c)},5n:k(B,K){o 2y=[];C(o i=0,j=c.O;i<j;i++){m(B.1G(K,c[i],i,c))2y.1n(c[i])}h 2y},1R:k(B,K){o 2y=[];C(o i=0,j=c.O;i<j;i++)2y[i]=B.1G(K,c[i],i,c);h 2y},3M:k(B,K){C(o i=0,j=c.O;i<j;i++){m(!B.1G(K,c[i],i,c))h 1c}h 1f},7i:k(B,K){C(o i=0,j=c.O;i<j;i++){m(B.1G(K,c[i],i,c))h 1f}h 1c},2K:k(1S,F){o 2x=c.O;C(o i=(F<0)?Y.2b(0,2x+F):F||0;i<2x;i++){m(c[i]===1S)h i}h-1},6f:k(1o,O){1o=1o||0;m(1o<0)1o=c.O+1o;O=O||(c.O-1o);o 4a=[];C(o i=0;i<O;i++)4a[i]=c[1o++];h 4a},2H:k(1S){o i=0;o 2x=c.O;6m(i<2x){m(c[i]===1S){c.3o(i,1);2x--}W{i++}}h c},19:k(1S,F){h c.2K(1S,F)!=-1},7p:k(1l){o T={},O=Y.2p(c.O,1l.O);C(o i=0;i<O;i++)T[1l[i]]=c[i];h T},P:k(14){C(o i=0,j=14.O;i<j;i++)c.1n(14[i]);h c},2G:k(14){C(o i=0,l=14.O;i<l;i++)c.51(14[i]);h c},51:k(1S){m(!c.19(1S))c.1n(1S);h c},7Y:k(){h c[$4Z(0,c.O-1)]||1e},6g:k(){h c[c.O-1]||1e}});1v.1b.1s=1v.1b.3v;1v.1s=1v.3v;k $A(14){h 1v.6f(14)};k $1s(2j,B,K){m(2j&&3u 2j.O==\'4L\'&&$q(2j)!=\'2d\'){1v.3v(2j,B,K)}W{C(o 1x V 2j)B.1G(K||2j,2j[1x],1x)}};1v.1b.1X=1v.1b.19;4q.P({1X:k(3x,1I){h(($q(3x)==\'1Z\')?X 4e(3x,1I):3x).1X(c)},3F:k(){h 3b(c,10)},6L:k(){h 2Y(c)},44:k(){h c.2e(/-\\D/g,k(22){h 22.4Q(1).6a()})},6j:k(){h c.2e(/\\w[A-Z]/g,k(22){h(22.4Q(0)+\'-\'+22.4Q(1).3f())})},5E:k(){h c.2e(/\\b[a-z]/g,k(22){h 22.6a()})},6o:k(){h c.2e(/^\\s+|\\s+$/g,\'\')},4F:k(){h c.2e(/\\s{2,}/g,\' \').6o()},3S:k(14){o 1C=c.22(/\\d{1,3}/g);h(1C)?1C.3S(14):1c},3l:k(14){o 2m=c.22(/^#?(\\w{1,2})(\\w{1,2})(\\w{1,2})$/);h(2m)?2m.6l(1).3l(14):1c},19:k(1Z,s){h(s)?(s+c+s).2K(s+1Z+s)>-1:c.2K(1Z)>-1},7y:k(){h c.2e(/([.*+?^${}()|[\\]\\/\\\\])/g,\'\\\\$1\')}});1v.P({3S:k(14){m(c.O<3)h 1c;m(c.O==4&&c[3]==0&&!14)h\'7x\';o 2m=[];C(o i=0;i<3;i++){o 2D=(c[i]-0).7w(16);2m.1n((2D.O==1)?\'0\'+2D:2D)}h 14?2m:\'#\'+2m.1Q(\'\')},3l:k(14){m(c.O!=3)h 1c;o 1C=[];C(o i=0;i<3;i++){1C.1n(3b((c[i].O==1)?c[i]+c[i]:c[i],16))}h 14?1C:\'1C(\'+1C.1Q(\',\')+\')\'}});4H.P({1L:k(G){o B=c;G=$2G({\'K\':B,\'u\':1c,\'M\':1e,\'1u\':1c,\'2w\':1c,\'3q\':1c},G);m($35(G.M)&&$q(G.M)!=\'14\')G.M=[G.M];h k(u){o U;m(G.u){u=u||H.u;U=[(G.u===1f)?u:X G.u(u)];m(G.M)U.P(G.M)}W U=G.M||M;o 21=k(){h B.2z($4r(G.K,B),U)};m(G.1u)h 7l(21,G.1u);m(G.2w)h 7k(21,G.2w);m(G.3q)4w{h 21()}4C(7a){h 1c};h 21()}},7b:k(U,K){h c.1L({\'M\':U,\'K\':K})},3q:k(U,K){h c.1L({\'M\':U,\'K\':K,\'3q\':1f})()},K:k(K,U){h c.1L({\'K\':K,\'M\':U})},79:k(K,U){h c.1L({\'K\':K,\'u\':1f,\'M\':U})},1u:k(1u,K,U){h c.1L({\'1u\':1u,\'K\':K,\'M\':U})()},2w:k(5R,K,U){h c.1L({\'2w\':5R,\'K\':K,\'M\':U})()}});5S.P({3F:k(){h 3b(c)},6L:k(){h 2Y(c)},7h:k(2p,2b){h Y.2p(2b,Y.2b(2p,c))},2Q:k(30){30=Y.2r(10,30||0);h Y.2Q(c*30)/30},7g:k(B){C(o i=0;i<c;i++)B(i)}});o I=X 1g({1z:k(r,1d){m($q(r)==\'1Z\'){m(H.1D&&1d&&(1d.1x||1d.q)){o 1x=(1d.1x)?\' 1x="\'+1d.1x+\'"\':\'\';o q=(1d.q)?\' q="\'+1d.q+\'"\':\'\';48 1d.1x;48 1d.q;r=\'<\'+r+1x+q+\'>\'}r=L.6H(r)}r=$(r);h(!1d||!r)?r:r.2f(1d)}});o 2l=X 1g({1z:k(R){h(R)?$P(R,c):c}});2l.P=k(1d){C(o 1j V 1d){c.1b[1j]=1d[1j];c[1j]=$2E.3B(1j)}};k $(r){m(!r)h 1e;m(r.2C)h 1w.2B(r);m([H,L].19(r))h r;o q=$q(r);m(q==\'1Z\'){r=L.7e(r);q=(r)?\'12\':1c}m(q!=\'12\')h 1e;m(r.2C)h 1w.2B(r);m([\'2d\',\'7f\'].19(r.59.3f()))h r;$P(r,I.1b);r.2C=k(){};h 1w.2B(r)};L.6U=L.3K;k $$(){o R=[];C(o i=0,j=M.O;i<j;i++){o 2I=M[i];1M($q(2I)){17\'12\':R.1n(2I);17\'7z\':1y;17 1c:1y;17\'1Z\':2I=L.6U(2I,1f);4D:R.P(2I)}}h $$.4A(R)};$$.4A=k(14){o R=[];C(o i=0,l=14.O;i<l;i++){m(14[i].$3L)5C;o 12=$(14[i]);m(12&&!12.$3L){12.$3L=1f;R.1n(12)}}C(o n=0,d=R.O;n<d;n++)R[n].$3L=1e;h X 2l(R)};2l.3X=k(t){h k(){o U=M;o 3P=[];o R=1f;C(o i=0,j=c.O,21;i<j;i++){21=c[i][t].2z(c[i],U);m($q(21)!=\'12\')R=1c;3P.1n(21)};h(R)?$$.4A(3P):3P}};I.P=k(1N){C(o t V 1N){2X.1b[t]=1N[t];I.1b[t]=1N[t];I[t]=$2E.3B(t);o 6A=(1v.1b[t])?t+\'2l\':t;2l.1b[6A]=2l.3X(t)}};I.P({2f:k(1d){C(o 1j V 1d){o 2U=1d[1j];1M(1j){17\'7U\':c.5K(2U);1y;17\'J\':m(c.42)c.42(2U);1y;17\'1N\':c.6q(2U);1y;4D:c.3R(1j,2U)}}h c},2A:k(r,5c){r=$(r);1M(5c){17\'57\':r.29.4m(c,r);1y;17\'56\':o 3e=r.6c();m(!3e)r.29.4G(c);W r.29.4m(c,3e);1y;17\'4l\':o 4n=r.4y;m(4n){r.4m(c,4n);1y}4D:r.4G(c)}h c},83:k(r){h c.2A(r,\'57\')},82:k(r){h c.2A(r,\'56\')},81:k(r){h c.2A(r,\'5M\')},7Z:k(r){h c.2A(r,\'4l\')},80:k(){o R=[];$1s(M,k(5H){R=R.7Q(5H)});$$(R).2A(c);h c},2H:k(){h c.29.6J(c)},7P:k(5L){o r=$(c.7F(5L!==1c));m(!r.$J)h r;r.$J={};C(o q V c.$J)r.$J[q]={\'1l\':$A(c.$J[q].1l),\'2n\':$A(c.$J[q].2n)};h r.3i()},7D:k(r){r=$(r);c.29.7B(r,c);h r},6I:k(1W){c.4G(L.7C(1W));h c},52:k(1m){h c.1m.19(1m,\' \')},5u:k(1m){m(!c.52(1m))c.1m=(c.1m+\' \'+1m).4F();h c},5v:k(1m){c.1m=c.1m.2e(X 4e(\'(^|\\\\s)\'+1m+\'(?:\\\\s|$)\'),\'$1\').4F();h c},7H:k(1m){h c.52(1m)?c.5v(1m):c.5u(1m)},2S:k(t,N){1M(t){17\'1t\':h c.5N(2Y(N));17\'7I\':t=(H.1D)?\'7N\':\'7O\'}t=t.44();1M($q(N)){17\'4L\':m(![\'7M\',\'5p\'].19(t))N+=\'33\';1y;17\'14\':N=\'1C(\'+N.1Q(\',\')+\')\'}c.1a[t]=N;h c},5K:k(28){1M($q(28)){17\'2d\':I.3k(c,\'2S\',28);1y;17\'1Z\':c.1a.4s=28}h c},5N:k(1t){m(1t==0){m(c.1a.3m!="5O")c.1a.3m="5O"}W{m(c.1a.3m!="5a")c.1a.3m="5a"}m(!c.3A||!c.3A.7K)c.1a.5p=1;m(H.1D)c.1a.5n=(1t==1)?\'\':"6Z(1t="+1t*71+")";c.1a.1t=c.$25.1t=1t;h c},2a:k(t){t=t.44();o 18=c.1a[t];m(!$35(18)){m(t==\'1t\')h c.$25.1t;18=[];C(o 1a V I.2k){m(t==1a){I.2k[1a].1s(k(s){o 1a=c.2a(s);18.1n(3b(1a)?1a:\'5t\')},c);m(t==\'2i\'){o 3M=18.3M(k(2D){h(2D==18[0])});h(3M)?18[0]:1c}h 18.1Q(\' \')}}m(t.19(\'2i\')){m(I.2k.2i.19(t)){h[\'5q\',\'47\',\'4g\'].1R(k(p){h c.2a(t+p)},c).1Q(\' \')}W m(I.5l.19(t)){h[\'5m\',\'5k\',\'5e\',\'6x\'].1R(k(p){h c.2a(\'2i\'+p+t.2e(\'2i\',\'\'))},c).1Q(\' \')}}m(L.5U)18=L.5U.6Y(c,1e).72(t.6j());W m(c.3A)18=c.3A[t]}m(H.1D)18=I.5P(t,18,c);m(18&&t.1X(/3Y/i)&&18.19(\'1C\')){h 18.5X(\'1C\').3o(1,4).1R(k(3Y){h 3Y.3S()}).1Q(\' \')}h 18},74:k(){h I.4P(c,\'2a\',M)},3d:k(3t,1o){3t+=\'6X\';o r=(1o)?c[1o]:c[3t];6m(r&&$q(r)!=\'12\')r=r[3t];h $(r)},8p:k(){h c.3d(\'2g\')},6c:k(){h c.3d(\'3e\')},9B:k(){h c.3d(\'3e\',\'4y\')},6g:k(){h c.3d(\'2g\',\'9C\')},9D:k(){h $(c.29)},9A:k(){h $$(c.6k)},4f:k(r){h!!$A(c.3K(\'*\')).19(r)},4u:k(t){o 1V=I.3O[t];m(1V)h c[1V];o 4I=I.5A[t]||0;m(!H.1D||4I)h c.9z(t,4I);o 4S=c.9w[t];h(4S)?4S.67:1e},9x:k(t){o 1V=I.3O[t];m(1V)c[1V]=\'\';W c.9y(t);h c},9E:k(){h I.4P(c,\'4u\',M)},3R:k(t,N){o 1V=I.3O[t];m(1V)c[1V]=N;W c.9F(t,N);h c},6q:k(28){h I.3k(c,\'3R\',28)},5j:k(){c.5b=$A(M).1Q(\'\');h c},9L:k(1W){o 2h=c.4E();m([\'1a\',\'2J\'].19(2h)){m(H.1D){m(2h==\'1a\')c.6r.4s=1W;W m(2h==\'2J\')c.3R(\'1W\',1W);h c}W{c.6J(c.4y);h c.6I(1W)}}c[$3Q(c.4v)?\'4v\':\'54\']=1W;h c},9M:k(){o 2h=c.4E();m([\'1a\',\'2J\'].19(2h)){m(H.1D){m(2h==\'1a\')h c.6r.4s;W m(2h==\'2J\')h c.4u(\'1W\')}W{h c.5b}}h($4r(c.4v,c.54))},4E:k(){h c.59.3f()},2c:k(){1w.3D(c.3K(\'*\'));h c.5j(\'\')}});I.5P=k(t,18,12){m($35(3b(18)))h 18;m([\'9K\',\'3Z\'].19(t)){o 2n=(t==\'3Z\')?[\'6R\',\'6T\']:[\'4l\',\'5M\'];o 3V=0;2n.1s(k(N){3V+=12.2a(\'2i-\'+N+\'-3Z\').3F()+12.2a(\'4M-\'+N).3F()});h 12[\'9J\'+t.5E()]-3V+\'33\'}W m(t.1X(/2i(.+)5q|5J|4M/)){h\'5t\'}h 18};I.2k={\'2i\':[],\'4M\':[],\'5J\':[]};[\'5m\',\'5k\',\'5e\',\'6x\'].1s(k(5g){C(o 1a V I.2k)I.2k[1a].1n(1a+5g)});I.5l=[\'9G\',\'9H\',\'9I\'];I.4P=k(r,3y,1l){o 18={};$1s(1l,k(1F){18[1F]=r[3y](1F)});h 18};I.3k=k(r,3y,4T){C(o 1F V 4T)r[3y](1F,4T[1F]);h r};I.3O=X 2t({\'5I\':\'1m\',\'C\':\'9v\',\'9u\':\'9h\',\'9i\':\'9j\',\'9g\':\'9f\',\'9c\':\'9d\',\'9e\':\'9k\',\'9l\':\'9O\',\'9r\':\'9s\',\'N\':\'N\',\'5x\':\'5x\',\'5w\':\'5w\',\'5y\':\'5y\',\'5z\':\'5z\'});I.5A={\'9t\':2,\'3r\':2};I.24={3n:{2u:k(q,B){m(c.49)c.49(q,B,1c);W c.9q(\'41\'+q,B);h c},61:k(q,B){m(c.5o)c.5o(q,B,1c);W c.9p(\'41\'+q,B);h c}}};H.P(I.24.3n);L.P(I.24.3n);I.P(I.24.3n);o 1w={R:[],2B:k(r){m(!r.$25){1w.R.1n(r);r.$25={\'1t\':1}}h r},3D:k(R){C(o i=0,j=R.O,r;i<j;i++){m(!(r=R[i])||!r.$25)5C;m(r.$J)r.1Y(\'3D\').3i();C(o p V r.$25)r.$25[p]=1e;C(o d V I.1b)r[d]=1e;1w.R[1w.R.2K(r)]=1e;r.2C=r.$25=r=1e}1w.R.2H(1e)},2c:k(){1w.2B(H);1w.2B(L);1w.3D(1w.R)}};H.2u(\'68\',k(){H.2u(\'4K\',1w.2c);m(H.1D)H.2u(\'4K\',9m)});o 1E=X 1g({1z:k(u){m(u&&u.$5D)h u;c.$5D=1f;u=u||H.u;c.u=u;c.q=u.q;c.2F=u.2F||u.9n;m(c.2F.4p==3)c.2F=c.2F.29;c.5F=u.9o;c.9N=u.a4;c.a6=u.a9;c.a3=u.a5;m([\'4V\',\'3p\'].19(c.q)){c.a8=(u.58)?u.58/a1:-(u.9T||0)/3}W m(c.q.19(\'1F\')){c.3N=u.6O||u.9S;C(o 1x V 1E.1l){m(1E.1l[1x]==c.3N){c.1F=1x;1y}}m(c.q==\'5W\'){o 3G=c.3N-a2;m(3G>0&&3G<13)c.1F=\'f\'+3G}c.1F=c.1F||4q.9R(c.3N).3f()}W m(c.q.1X(/(5T|9P|9Q)/)){c.9U={\'x\':u.4t||u.5f+L.1H.6P,\'y\':u.4h||u.62+L.1H.6s};c.9V={\'x\':u.4t?u.4t-H.6K:u.5f,\'y\':u.4h?u.4h-H.6Q:u.62};c.a0=(u.6O==3)||(u.85==2);1M(c.q){17\'4U\':c.1p=u.1p||u.9Z;1y;17\'4X\':c.1p=u.1p||u.9Y}c.6t()}h c},3c:k(){h c.3E().3C()},3E:k(){m(c.u.3E)c.u.3E();W c.u.9W=1f;h c},3C:k(){m(c.u.3C)c.u.3C();W c.u.9X=1c;h c}});1E.3T={1p:k(){m(c.1p&&c.1p.4p==3)c.1p=c.1p.29},6w:k(){4w{1E.3T.1p.1G(c)}4C(e){c.1p=c.2F}}};1E.1b.6t=(H.4c)?1E.3T.6w:1E.3T.1p;1E.1l=X 2t({\'a7\':13,\'9a\':38,\'8s\':40,\'6R\':37,\'6T\':39,\'8t\':27,\'8r\':32,\'8q\':8,\'8n\':9,\'48\':46});I.24.1T={2o:k(q,B){c.$J=c.$J||{};c.$J[q]=c.$J[q]||{\'1l\':[],\'2n\':[]};m(c.$J[q].1l.19(B))h c;c.$J[q].1l.1n(B);o 3z=q;o 1q=I.1T[q];m(1q){m(1q.4J)1q.4J.1G(c,B);m(1q.1R)B=1q.1R;m(1q.q)3z=1q.q}m(!c.49)B=B.1L({\'K\':c,\'u\':1f});c.$J[q].2n.1n(B);h(I.4d.19(3z))?c.2u(3z,B):c},4b:k(q,B){m(!c.$J||!c.$J[q])h c;o 1J=c.$J[q].1l.2K(B);m(1J==-1)h c;o 1F=c.$J[q].1l.3o(1J,1)[0];o N=c.$J[q].2n.3o(1J,1)[0];o 1q=I.1T[q];m(1q){m(1q.2H)1q.2H.1G(c,B);m(1q.q)q=1q.q}h(I.4d.19(q))?c.61(q,N):c},42:k(28){h I.3k(c,\'2o\',28)},3i:k(q){m(!c.$J)h c;m(!q){C(o 3j V c.$J)c.3i(3j);c.$J=1e}W m(c.$J[q]){c.$J[q].1l.1s(k(B){c.4b(q,B)},c);c.$J[q]=1e}h c},1Y:k(q,U,1u){m(c.$J&&c.$J[q]){c.$J[q].1l.1s(k(B){B.1L({\'K\':c,\'1u\':1u,\'M\':U})()},c)}h c},64:k(F,q){m(!F.$J)h c;m(!q){C(o 3j V F.$J)c.64(F,3j)}W m(F.$J[q]){F.$J[q].1l.1s(k(B){c.2o(q,B)},c)}h c}};H.P(I.24.1T);L.P(I.24.1T);I.P(I.24.1T);I.1T=X 2t({\'65\':{q:\'4U\',1R:k(u){u=X 1E(u);m(u.1p!=c&&!c.4f(u.1p))c.1Y(\'65\',u)}},\'5Y\':{q:\'4X\',1R:k(u){u=X 1E(u);m(u.1p!=c&&!c.4f(u.1p))c.1Y(\'5Y\',u)}},\'3p\':{q:(H.4c)?\'4V\':\'3p\'}});I.4d=[\'5T\',\'8o\',\'9b\',\'8u\',\'3p\',\'4V\',\'4U\',\'4X\',\'8v\',\'5W\',\'8A\',\'8B\',\'5Q\',\'4K\',\'68\',\'8z\',\'8y\',\'8w\',\'8x\',\'5r\',\'8m\',\'8l\',\'2P\',\'8b\',\'8c\',\'8a\',\'6B\'];4H.P({89:k(K,U){h c.1L({\'K\':K,\'M\':U,\'u\':1E})}});I.1T.4Y={4J:k(B){m(H.3w){B.1G(c);h}o 2T=k(){m(H.3w)h;H.3w=1f;H.1r=$4j(H.1r);c.1Y(\'4Y\')}.K(c);m(L.3s&&H.2v){H.1r=k(){m([\'3w\',\'6V\'].19(L.3s))2T()}.2w(50)}W m(L.3s&&H.1D){m(!$(\'4W\')){o 3r=(H.86.87==\'88:\')?\'://0\':\'8d:8e(0)\';L.8j(\'<2J 8k="4W" 8i 3r="\'+3r+\'"><\\/2J>\');$(\'4W\').8h=k(){m(c.3s==\'6V\')2T()}}}W{H.2u("5Q",2T);L.2u("8f",2T)}}};H.8g=k(B){h c.2o(\'4Y\',B)};H.P({6y:k(){m(c.4O)h c.8C;m(c.5V)h L.3U.69;h L.1H.69},6D:k(){m(c.4O)h c.8D;m(c.5V)h L.3U.66;h L.1H.66},6E:k(){m(c.1D)h Y.2b(L.1H.90,L.1H.43);m(c.2v)h L.3U.43;h L.1H.43},6C:k(){m(c.1D)h Y.2b(L.1H.91,L.1H.4k);m(c.2v)h L.3U.4k;h L.1H.4k},6F:k(){h c.6K||L.1H.6P},6u:k(){h c.6Q||L.1H.6s},8Z:k(){h{\'3V\':{\'x\':c.6y(),\'y\':c.6D()},\'8Y\':{\'x\':c.6E(),\'y\':c.6C()},\'6B\':{\'x\':c.6F(),\'y\':c.6u()}}},8V:k(){h{\'x\':0,\'y\':0}}});o Q={};Q.3h=X 1g({G:{63:1g.2c,55:1g.2c,6i:1g.2c,1k:k(p){h-(Y.6G(Y.4o*p)-1)/2},4R:8W,1K:\'33\',3a:1f,6M:50},1z:k(G){c.12=c.12||1e;c.5B(G);m(c.G.1z)c.G.1z.1G(c)},53:k(){o 1U=$1U();m(1U<c.1U+c.G.4R){c.5s=c.G.1k((1U-c.1U)/c.G.4R);c.3g();c.2W()}W{c.3c(1f);c.2f(c.E);c.1Y(\'55\',c.12,10);c.5i()}},2f:k(E){c.1h=E;c.2W();h c},3g:k(){c.1h=c.34(c.F,c.E)},34:k(F,E){h(E-F)*c.5s+F},1o:k(F,E){m(!c.G.3a)c.3c();W m(c.1r)h c;c.F=F;c.E=E;c.5r=c.E-c.F;c.1U=$1U();c.1r=c.53.2w(Y.2Q(8X/c.G.6M),c);c.1Y(\'63\',c.12);h c},3c:k(3W){m(!c.1r)h c;c.1r=$4j(c.1r);m(!3W)c.1Y(\'6i\',c.12);h c},1q:k(F,E){h c.1o(F,E)},92:k(3W){h c.3c(3W)}});Q.3h.6b(X 6d,X 1T,X 5d);Q.1O={2P:k(t,E){m(t.1X(/3Y/i))h c.4g;o q=$q(E);m((q==\'14\')||(q==\'1Z\'&&E.19(\' \')))h c.3X;h c.6p},1A:k(r,t,2O){m(!2O.1n)2O=[2O];o F=2O[0],E=2O[1];m(!$35(E)){E=F;F=r.2a(t)}o 15=c.2P(t,E);h{\'F\':15.1A(F),\'E\':15.1A(E),\'15\':15}}};Q.1O.6p={1A:k(N){h 2Y(N)},2M:k(F,E,2N){h 2N.34(F,E)},2L:k(N,1K,t){m(1K==\'33\'&&t!=\'1t\')N=Y.2Q(N);h N+1K}};Q.1O.3X={1A:k(N){h N.1n?N:N.5X(\' \').1R(k(v){h 2Y(v)})},2M:k(F,E,2N){o 1h=[];C(o i=0;i<F.O;i++)1h[i]=2N.34(F[i],E[i]);h 1h},2L:k(N,1K,t){m(1K==\'33\'&&t!=\'1t\')N=N.1R(Y.2Q);h N.1Q(1K+\' \')+1K}};Q.1O.4g={1A:k(N){h N.1n?N:N.3l(1f)},2M:k(F,E,2N){o 1h=[];C(o i=0;i<F.O;i++)1h[i]=Y.2Q(2N.34(F[i],E[i]));h 1h},2L:k(N){h\'1C(\'+N.1Q(\',\')+\')\'}};Q.47=Q.3h.P({1z:k(r,t,G){c.12=$(r);c.t=t;c.1B(G)},93:k(){h c.2f(0)},3g:k(){c.1h=c.15.2M(c.F,c.E,c)},2f:k(E){c.15=Q.1O.2P(c.t,E);h c.1B(c.15.1A(E))},1o:k(F,E){m(c.1r&&c.G.3a)h c;o 1i=Q.1O.1A(c.12,c.t,[F,E]);c.15=1i.15;h c.1B(1i.F,1i.E)},2W:k(){c.12.2S(c.t,c.15.2L(c.1h,c.G.1K,c.t))}});I.P({98:k(t,G){h X Q.47(c,t,G)}});Q.2k=Q.3h.P({1z:k(r,G){c.12=$(r);c.1B(G)},3g:k(){C(o p V c.F)c.1h[p]=c.15[p].2M(c.F[p],c.E[p],c)},2f:k(E){o 1i={};c.15={};C(o p V E){c.15[p]=Q.1O.2P(p,E[p]);1i[p]=c.15[p].1A(E[p])}h c.1B(1i)},1o:k(T){m(c.1r&&c.G.3a)h c;c.1h={};c.15={};o F={},E={};C(o p V T){o 1i=Q.1O.1A(c.12,p,T[p]);F[p]=1i.F;E[p]=1i.E;c.15[p]=1i.15}h c.1B(F,E)},2W:k(){C(o p V c.1h)c.12.2S(p,c.15[p].2L(c.1h[p],c.G.1K,p))}});I.P({99:k(G){h X Q.2k(c,G)}});Q.2l=Q.3h.P({1z:k(R,G){c.R=$$(R);c.1B(G)},3g:k(){C(o i V c.F){o 2V=c.F[i],26=c.E[i],23=c.15[i],2Z=c.1h[i]={};C(o p V 2V)2Z[p]=23[p].2M(2V[p],26[p],c)}},2f:k(E){o 1i={};c.15={};C(o i V E){o 26=E[i],23=c.15[i]={},6S=1i[i]={};C(o p V 26){23[p]=Q.1O.2P(p,26[p]);6S[p]=23[p].1A(26[p])}}h c.1B(1i)},1o:k(T){m(c.1r&&c.G.3a)h c;c.1h={};c.15={};o F={},E={};C(o i V T){o 4N=T[i],2V=F[i]={},26=E[i]={},23=c.15[i]={};C(o p V 4N){o 1i=Q.1O.1A(c.R[i],p,4N[p]);2V[p]=1i.F;26[p]=1i.E;23[p]=1i.15}}h c.1B(F,E)},2W:k(){C(o i V c.1h){o 2Z=c.1h[i],23=c.15[i];C(o p V 2Z)c.R[i].2S(p,23[p].2L(2Z[p],c.G.1K,p))}}});Q.4z=k(1k,1I){1I=1I||[];m($q(1I)!=\'14\')1I=[1I];h $P(1k,{97:k(1J){h 1k(1J,1I)},96:k(1J){h 1-1k(1-1J,1I)},94:k(1J){h(1J<=0.5)?1k(2*1J,1I)/2:(2-1k(2*(1-1J),1I))/2}})};Q.1P=X 2t({95:k(p){h p}});Q.1P.P=k(4B){C(o 1k V 4B){Q.1P[1k]=X Q.4z(4B[1k]);Q.1P.4i(1k)}};Q.1P.4i=k(1k){[\'8U\',\'8T\',\'8J\'].1s(k(45){Q.1P[1k.3f()+45]=Q.1P[1k][\'8K\'+45]})};Q.1P.P({8I:k(p,x){h Y.2r(p,x[0]||6)},8H:k(p){h Y.2r(2,8*(p-1))},8E:k(p){h 1-Y.5h(Y.8F(p))},8G:k(p){h 1-Y.5h((1-p)*Y.4o/2)},8L:k(p,x){x=x[0]||1.8M;h Y.2r(p,2)*((x+1)*p-x)},8R:k(p){o N;C(o a=0,b=1;1;a+=b,b/=2){m(p>=(7-4*a)/11){N=-Y.2r((11-6*a-11*p)/4,2)+b*b;1y}}h N},8S:k(p,x){h Y.2r(2,10*--p)*Y.6G(20*p*Y.4o*(x[0]||1)/3)}});[\'8Q\',\'8P\',\'8N\',\'8O\'].1s(k(1k,i){Q.1P[1k]=X Q.4z(k(p){h Y.2r(p,[i+2])});Q.1P.4i(1k)});',62,630,'||||||||||||this|||||return|||function||if||var||type|el||property|event|||||||fn|for||to|from|options|window|Element|events|bind|document|arguments|value|length|extend|Fx|elements||obj|args|in|else|new|Math||||element||array|css||case|result|contains|style|prototype|false|props|null|true|Class|now|parsed|prop|transition|keys|className|push|start|relatedTarget|custom|timer|each|opacity|delay|Array|Garbage|name|break|initialize|parse|parent|rgb|ie|Event|key|call|documentElement|params|pos|unit|create|switch|properties|CSS|Transitions|join|map|item|Events|time|index|text|test|fireEvent|string||returns|match|iCss|Methods|tmp|iTo||source|parentNode|getStyle|max|empty|object|replace|set|previous|tag|border|iterable|Styles|Elements|hex|values|addEvent|min|chains|pow|current|Abstract|addListener|webkit|periodical|len|results|apply|inject|collect|htmlElement|bit|native|target|merge|remove|selector|script|indexOf|getValue|getNow|fx|fromTo|select|round|option|setStyle|domReady|val|iFrom|increase|HTMLElement|parseFloat|iNow|precision|klass||px|compute|chk|mix||||wait|parseInt|stop|walk|next|toLowerCase|setNow|Base|removeEvents|evType|setMany|hexToRgb|visibility|Listeners|splice|mousewheel|attempt|src|readyState|brother|typeof|forEach|loaded|regex|method|realType|currentStyle|generic|preventDefault|trash|stopPropagation|toInt|fKey|mp|ap|proto|getElementsByTagName|included|every|code|Properties|items|defined|setProperty|rgbToHex|fix|body|size|end|Multi|color|width||on|addEvents|scrollWidth|camelCase|easeType||Style|delete|addEventListener|newArray|removeEvent|gecko|NativeEvents|RegExp|hasChild|Color|pageY|compat|clear|scrollHeight|top|insertBefore|first|PI|nodeType|String|pick|cssText|pageX|getProperty|innerText|try|merged|firstChild|Transition|unique|transitions|catch|default|getTag|clean|appendChild|Function|flag|add|unload|number|padding|iProps|webkit419|getMany|charAt|duration|node|pairs|mouseover|DOMMouseScroll|ie_ready|mouseout|domready|random||include|hasClass|step|textContent|onComplete|after|before|wheelDelta|tagName|visible|innerHTML|where|Options|Bottom|clientX|direction|sin|callChain|setHTML|Right|borderShort|Top|filter|removeEventListener|zoom|Width|change|delta|0px|addClass|removeClass|checked|disabled|multiple|selected|PropertiesIFlag|setOptions|continue|extended|capitalize|shift|pp|argument|class|margin|setStyles|contents|bottom|setOpacity|hidden|fixStyle|load|interval|Number|click|defaultView|opera|keydown|split|mouseleave|undefined|constructor|removeListener|clientY|onStart|cloneEvents|mouseenter|clientHeight|nodeValue|beforeunload|clientWidth|toUpperCase|implement|getNext|Chain|Merge|copy|getLast|head|onCancel|hyphenate|childNodes|slice|while|callee|trim|Single|setProperties|styleSheet|scrollTop|fixRelatedTarget|getScrollTop|ie6|relatedTargetGecko|Left|getWidth|picked|elementsProperty|scroll|getScrollHeight|getHeight|getScrollWidth|getScrollLeft|cos|createElement|appendText|removeChild|pageXOffset|toFloat|fps|xpath|which|scrollLeft|pageYOffset|left|iParsed|right|getElementsBySelector|complete|MooTools|Sibling|getComputedStyle|alpha|Object|100|getPropertyValue|iframe|getStyles|textnode|clearInterval|clearTimeout|Window|bindAsEventListener|err|pass|getTime|taintEnabled|getElementById|embed|times|limit|some|Date|setInterval|setTimeout|XMLHttpRequest|ActiveXObject|ie7|associate|all|navigator|evaluate|Document|execCommand|BackgroundImageCache|toString|transparent|escapeRegExp|boolean|webkit420|replaceChild|createTextNode|replaceWith|DOMElement|cloneNode|chain|toggleClass|float|nodeName|hasLayout|khtml|zIndex|styleFloat|cssFloat|clone|concat|whitespace|clearChain|regexp|styles|floor|collection|getBoxObjectFor|getRandom|injectTop|adopt|injectInside|injectAfter|injectBefore|version|button|location|protocol|https|bindWithEvent|contextmenu|error|abort|javascript|void|DOMContentLoaded|onDomReady|onreadystatechange|defer|write|id|reset|submit|tab|dblclick|getPrevious|backspace|space|down|esc|mousedown|mousemove|focus|blur|move|resize|keypress|keyup|innerWidth|innerHeight|Circ|acos|Sine|Expo|Pow|InOut|ease|Back|618|Quart|Quint|Cubic|Quad|Bounce|Elastic|Out|In|getPosition|500|1000|scrollSize|getSize|offsetWidth|offsetHeight|clearTimer|hide|easeInOut|linear|easeOut|easeIn|effect|effects|up|mouseup|tabindex|tabIndex|maxlength|accessKey|accesskey|colSpan|rowspan|rowSpan|maxLength|readonly|CollectGarbage|srcElement|shiftKey|detachEvent|attachEvent|frameborder|frameBorder|href|colspan|htmlFor|attributes|removeProperty|removeAttribute|getAttribute|getChildren|getFirst|lastChild|getParent|getProperties|setAttribute|borderWidth|borderStyle|borderColor|offset|height|setText|getText|control|readOnly|mouse|menu|fromCharCode|keyCode|detail|page|client|cancelBubble|returnValue|toElement|fromElement|rightClick|120|111|meta|ctrlKey|metaKey|alt|enter|wheel|altKey'.split('|'),0,{}))

/*
	Slimbox v1.41 - The ultimate lightweight Lightbox clone
	by Christophe Beyls (http://www.digitalia.be) - MIT-style license.
	Inspired by the original Lightbox v2 by Lokesh Dhakar.
*/

var Lightbox = {

	init: function(options){
		this.options = $extend({
			resizeDuration: 1000,
			resizeTransition: false,	// default transition
			initialWidth: 350,
			initialHeight: 350,
			animateCaption: true,
			showCounter: true
		}, options || {});

		this.anchors = [];
		$each(document.links, function(el){
			if (el.rel && el.rel.test(/^lightbox/i)){
				el.onclick = this.click.pass(el, this);
				this.anchors.push(el);
			}
		}, this);
		this.eventKeyDown = this.keyboardListener.bindAsEventListener(this);
		this.eventPosition = this.position.bind(this);

		this.overlay = new Element('div', {'id': 'lbOverlay'}).injectInside(document.body);

		this.center = new Element('div', {'id': 'lbCenter', 'styles': {'width': this.options.initialWidth, 'height': this.options.initialHeight, 'marginLeft': -(this.options.initialWidth/2), 'display': 'none'}}).injectInside(document.body);
		this.image = new Element('div', {'id': 'lbImage'}).injectInside(this.center);
		this.prevLink = new Element('a', {'id': 'lbPrevLink', 'href': '#', 'styles': {'display': 'none'}}).injectInside(this.image);
		this.nextLink = this.prevLink.clone().setProperty('id', 'lbNextLink').injectInside(this.image);
		this.prevLink.onclick = this.previous.bind(this);
		this.nextLink.onclick = this.next.bind(this);

		this.bottomContainer = new Element('div', {'id': 'lbBottomContainer', 'styles': {'display': 'none'}}).injectInside(document.body);
		this.bottom = new Element('div', {'id': 'lbBottom'}).injectInside(this.bottomContainer);
		new Element('a', {'id': 'lbCloseLink', 'href': '#'}).injectInside(this.bottom).onclick = this.overlay.onclick = this.close.bind(this);
		this.caption = new Element('div', {'id': 'lbCaption'}).injectInside(this.bottom);
		this.number = new Element('div', {'id': 'lbNumber'}).injectInside(this.bottom);
		new Element('div', {'styles': {'clear': 'both'}}).injectInside(this.bottom);

		var nextEffect = this.nextEffect.bind(this);
		this.fx = {
			overlay: this.overlay.effect('opacity', {duration: 500}).hide(),
			resize: this.center.effects($extend({duration: this.options.resizeDuration, onComplete: nextEffect}, this.options.resizeTransition ? {transition: this.options.resizeTransition} : {})),
			image: this.image.effect('opacity', {duration: 500, onComplete: nextEffect}),
			bottom: this.bottom.effect('margin-top', {duration: 400, onComplete: nextEffect})
		};

		this.preloadPrev = new Image();
		this.preloadNext = new Image();
	},

	click: function(link){
		if (link.rel.length == 8) return this.show(link.href, link.title);

		var j, imageNum, images = [];
		this.anchors.each(function(el){
			if (el.rel == link.rel){
				for (j = 0; j < images.length; j++) if(images[j][0] == el.href) break;
				if (j == images.length){
					images.push([el.href, el.title]);
					if (el.href == link.href) imageNum = j;
				}
			}
		}, this);
		return this.open(images, imageNum);
	},

	show: function(url, title){
		return this.open([[url, title]], 0);
	},

	open: function(images, imageNum){
		this.images = images;
		this.position();
		this.setup(true);
		this.top = window.getScrollTop() + (window.getHeight() / 15);
		this.center.setStyles({top: this.top, display: ''});
		this.fx.overlay.start(0.8);
		return this.changeImage(imageNum);
	},

	position: function(){
		this.overlay.setStyles({'top': window.getScrollTop(), 'height': window.getHeight()});
	},

	setup: function(open){
		var elements = $A(document.getElementsByTagName('object'));
		elements.extend(document.getElementsByTagName(window.ie ? 'select' : 'embed'));
		elements.each(function(el){
			if (open) el.lbBackupStyle = el.style.visibility;
			el.style.visibility = open ? 'hidden' : el.lbBackupStyle;
		});
		var fn = open ? 'addEvent' : 'removeEvent';
		window[fn]('scroll', this.eventPosition)[fn]('resize', this.eventPosition);
		document[fn]('keydown', this.eventKeyDown);
		this.step = 0;
	},

	keyboardListener: function(event){
		switch (event.keyCode){
			case 27: case 88: case 67: this.close(); break;
			case 37: case 80: this.previous(); break;	
			case 39: case 78: this.next();
		}
	},

	previous: function(){
		return this.changeImage(this.activeImage-1);
	},

	next: function(){
		return this.changeImage(this.activeImage+1);
	},

	changeImage: function(imageNum){
		if (this.step || (imageNum < 0) || (imageNum >= this.images.length)) return false;
		this.step = 1;
		this.activeImage = imageNum;

		this.bottomContainer.style.display = this.prevLink.style.display = this.nextLink.style.display = 'none';
		this.fx.image.hide();
		this.center.className = 'lbLoading';

		this.preload = new Image();
		this.preload.onload = this.nextEffect.bind(this);
		this.preload.src = this.images[imageNum][0];
		return false;
	},

	nextEffect: function(){
		switch (this.step++){
		case 1:
			this.center.className = '';
			this.image.style.backgroundImage = 'url('+this.images[this.activeImage][0]+')';
			this.image.style.width = this.bottom.style.width = this.preload.width+'px';
			this.image.style.height = this.prevLink.style.height = this.nextLink.style.height = this.preload.height+'px';

			this.caption.setHTML(this.images[this.activeImage][1] || '');
			this.number.setHTML((!this.options.showCounter || (this.images.length == 1)) ? '' : 'Image '+(this.activeImage+1)+' of '+this.images.length);

			if (this.activeImage) this.preloadPrev.src = this.images[this.activeImage-1][0];
			if (this.activeImage != (this.images.length - 1)) this.preloadNext.src = this.images[this.activeImage+1][0];
			if (this.center.clientHeight != this.image.offsetHeight){
				this.fx.resize.start({height: this.image.offsetHeight});
				break;
			}
			this.step++;
		case 2:
			if (this.center.clientWidth != this.image.offsetWidth){
				this.fx.resize.start({width: this.image.offsetWidth, marginLeft: -this.image.offsetWidth/2});
				break;
			}
			this.step++;
		case 3:
			this.bottomContainer.setStyles({top: this.top + this.center.clientHeight, height: 0, marginLeft: this.center.style.marginLeft, display: ''});
			this.fx.image.start(1);
			break;
		case 4:
			if (this.options.animateCaption){
				this.fx.bottom.set(-this.bottom.offsetHeight);
				this.bottomContainer.style.height = '';
				this.fx.bottom.start(0);
				break;
			}
			this.bottomContainer.style.height = '';
		case 5:
			if (this.activeImage) this.prevLink.style.display = '';
			if (this.activeImage != (this.images.length - 1)) this.nextLink.style.display = '';
			this.step = 0;
		}
	},

	close: function(){
		if (this.step < 0) return;
		this.step = -1;
		if (this.preload){
			this.preload.onload = Class.empty;
			this.preload = null;
		}
		for (var f in this.fx) this.fx[f].stop();
		this.center.style.display = this.bottomContainer.style.display = 'none';
		this.fx.overlay.chain(this.setup.pass(false, this)).start(0);
		return false;
	}
};

window.addEvent('domready', Lightbox.init.bind(Lightbox));

