/*
	mediaboxAdvanced v0.9.0 (c) 2007-2007 John Einselen <http://iaian7.com>
		based on
	Slimbox v1.64 (c) 2007-2008 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
var Mediabox;(function(){var L=0,r,h,C,w,B,k,p,n,q=new Image(),J=new Image(),G,b,j,D,c,I,u,y,H,K,e,t,E,v,s,l,i="none",f,d="mediaBox";window.addEvent("domready",function(){$(document.body).adopt($$([G=new Element("div",{id:"mbOverlay"}).addEvent("click",A),b=new Element("div",{id:"mbCenter"}),D=new Element("div",{id:"mbBottomContainer"})]).setStyle("display","none"));j=new Element("div",{id:"mbImage"}).injectInside(b);c=new Element("div",{id:"mbBottom"}).injectInside(D).adopt(new Element("a",{id:"mbCloseLink",href:"#"}).addEvent("click",A),e=new Element("a",{id:"mbNextLink",href:"#"}).addEvent("click",g),H=new Element("a",{id:"mbPrevLink",href:"#"}).addEvent("click",z),u=new Element("div",{id:"mbTitle"}),K=new Element("div",{id:"mbNumber"}),y=new Element("div",{id:"mbCaption"}),new Element("div",{styles:{clear:"both"}}));p={overlay:new Fx.Tween(G,{property:"opacity",duration:360}).set(0),image:new Fx.Tween(j,{property:"opacity",duration:360,onComplete:F}),bottom:new Fx.Tween(c,{property:"margin-top",duration:240})}});Mediabox={open:function(P,O,M){r=$extend({loop:false,overlayOpacity:0.8,resizeDuration:240,resizeTransition:false,initialWidth:320,initialHeight:180,showCaption:true,animateCaption:true,showCounter:true,counterText:"  ({x} of {y})",scriptaccess:"true",fullscreen:"true",fullscreenNum:"1",autoplay:"true",autoplayNum:"1",bgcolor:"#000000",playerpath:"../script/player.swf",backcolor:"000000",frontcolor:"ffffff",lightcolor:"ffffff",screencolor:"ffffff",controlbar:"over",bgcolor:"none"},M||{});if(typeof P=="string"){P=[[P,O,M]];O=0}if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){var N=new Number(RegExp.$1);if(N<3){r.overlayOpacity=1;G.className="mbOverlayFF"}}if(Browser.Engine.trident4){r.overlayOpacity=1;G.className="mbOverlayIE"}h=P;r.loop=r.loop&&(h.length>1);x();m(true);k=window.getScrollTop()+(window.getHeight()/15);p.resize=new Fx.Morph(b,$extend({duration:r.resizeDuration,onComplete:F},r.resizeTransition?{transition:r.resizeTransition}:{}));b.setStyles({top:k,width:r.initialWidth,height:r.initialHeight,marginLeft:-(r.initialWidth/2),display:""});p.overlay.start(r.overlayOpacity);L=1;return a(O)}};Element.implement({mediabox:function(M,N){$$(this).mediabox(M,N);return this}});Elements.implement({mediabox:function(M,P,O){P=P||function(Q){return[Q.href,Q.title,Q.rel]};O=O||function(){return true};var N=this;N.removeEvents("click").addEvent("click",function(){var Q=N.filter(O,this);return Mediabox.open(Q.map(P),Q.indexOf(this),M)});return N}});function x(){G.setStyles({top:window.getScrollTop(),height:window.getHeight()})}function m(M){["object",window.ie?"select":"embed"].forEach(function(O){Array.forEach(document.getElementsByTagName(O),function(P){if(M){P._mediabox=P.style.visibility}P.style.visibility=M?"hidden":P._mediabox})});G.style.display=M?"":"none";var N=M?"addEvent":"removeEvent";window[N]("scroll",x)[N]("resize",x);document[N]("keydown",o)}function o(M){switch(M.code){case 27:case 88:case 67:A();break;case 37:case 80:z();break;case 39:case 78:g()}}function z(){return a(w)}function g(){return a(B)}function a(M){if((L==1)&&(M>=0)){L=2;j.set("html","");C=M;w=((C||!r.loop)?C:h.length)-1;B=C+1;if(B==h.length){B=r.loop?0:-1}$$(H,e,j,D).setStyle("display","none");p.bottom.cancel().set(0);p.image.set(0);b.className="mbLoading";E=h[M][2].match(/[0-9]+/g);if(E){v=E.length;s=E[v-2]+"px";l=E[v-1]+"px"}else{s=r.initialWidth;s=r.initialWidth}t=h[M][0];I=h[C][1].split("::");if(t.match(/\.gif|\.jpg|\.png/i)){i="img";n=new Image();n.onload=F;n.src=h[M][0]}else{if(t.match(/\.flv|\.mp4/i)){i="obj";n=new Swiff(""+r.playerpath+"?file="+t+"&backcolor="+r.backcolor+"&frontcolor="+r.frontcolor+"&lightcolor="+r.lightcolor+"&screencolor="+r.screencolor+"&autostart="+r.autoplay+"&controlbar="+r.controlbar,{id:"MediaboxSWF",width:s,height:l,params:{wmode:"opaque",bgcolor:r.bgcolor,allowscriptaccess:r.scriptaccess,allowfullscreen:r.fullscreen}});F()}else{if(t.match(/\.mp3|\.aac/i)){i="obj";n=new Swiff(""+r.playerpath+"?file="+t+"&backcolor="+r.backcolor+"&frontcolor="+r.frontcolor+"&lightcolor="+r.lightcolor+"&screencolor="+r.screencolor+"&autostart="+r.autoplay,{id:"MediaboxSWF",width:s,height:l,params:{wmode:"opaque",bgcolor:r.bgcolor,allowscriptaccess:r.scriptaccess,allowfullscreen:r.fullscreen}});F()}else{if(t.match(/\.swf/i)){i="obj";n=new Swiff(t,{id:"MediaboxSWF",width:s,height:l,params:{wmode:"transparent",bgcolor:r.bgcolor,allowscriptaccess:r.scriptaccess,allowfullscreen:r.fullscreen,pluginurl:"http://www.adobe.com/go/getflashplayer"}});F()}else{if(t.match(/\#mb_/i)){i="inline";URLsplit=t.split("#");n=$(URLsplit[1]).get("html");F()}else{i="url";d="mediaId_"+new Date().getTime();n=new Element("iframe",{src:t,id:d,width:s,height:l,frameborder:0});F()}}}}}}return false}function F(){switch(L++){case 2:if(i=="img"){s=n.width;l=n.height;j.setStyles({backgroundImage:"url("+t+")",display:""})}else{if(i=="obj"){if(Browser.Plugins.Flash.version<8){j.setStyles({backgroundImage:"none",display:""});j.set("html",'<div id="mbError"><b>Error</b><br/>Adobe Flash is either not installed or not up to date,<br/>please visit <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" title="Get Flash" target="_new">Adobe.com</a> to download the free player.</div>')}else{j.setStyles({backgroundImage:"none",display:""});n.inject(j)}}else{if(i=="inline"){j.setStyles({backgroundImage:"none",display:""});j.set("html",n)}else{if(i=="url"){j.setStyles({backgroundImage:"none",display:""});n.inject(j)}else{alert("this file type is not supported\n"+t+"\nplease visit iaian7.com/webcode/Mediabox for more information")}}}}$$(j,c).setStyle("width",s);j.setStyle("height",l);u.set("html",(r.showCaption&&(I.length>1))?I[0]:h[C][1]);y.set("html",(r.showCaption&&(I.length>1))?I[1]:"");K.set("html",(r.showCounter&&(h.length>1))?r.counterText.replace(/{x}/,C+1).replace(/{y}/,h.length):"");if((w>=0)&&(h[w][0].match(/\.gif|\.jpg|\.png/i))){q.src=h[w][0]}if((B>=0)&&(h[B][0].match(/\.gif|\.jpg|\.png/i))){J.src=h[B][0]}L++;case 3:if(t.match(/\.swf/i)){b.className="flash";D.className="flashBottom"}else{b.className="";D.className=""}p.resize.start({height:j.offsetHeight,width:j.offsetWidth,marginLeft:-j.offsetWidth/2});break;L++;case 4:D.setStyles({top:k+b.clientHeight,marginLeft:b.style.marginLeft,visibility:"hidden",display:""});p.image.start(1);break;case 5:if(w>=0){H.style.display=""}if(B>=0){e.style.display=""}if(r.animateCaption){p.bottom.set(-c.offsetHeight).start(0)}D.style.visibility="";L=1}}function A(){if(L){L=0;n.onload=$empty;j.set("html","");for(var M in p){p[M].cancel()}$$(b,D).setStyle("display","none");p.overlay.chain(m).start(0)}return false}})();Mediabox.scanPage=function(){var a=$$("a").filter(function(b){return b.rel&&b.rel.test(/^lightbox/i)});$$(a).mediabox({},null,function(c){var b=this.rel.replace(/[[]|]/gi," ");var d=b.split(" ");return(this==c)||((this.rel.length>8)&&c.rel.match(d[1]))})};window.addEvent("domready",Mediabox.scanPage);