/**
 * The lightbox widget implemented with RightJS
 *
 * Home page: http://rightjs.org/ui/lightbox
 *
 * Copyright (C) 2009-2010 Nikolay V. Nemshilov
 */
if (!RightJS) { throw "Gimme RightJS please." };
Browser.IE6=navigator.userAgent.indexOf("MSIE 6")!=-1;var Lightbox=new Class({include:Options,extend:{Version:"#{version}",Options:{endOpacity:0.8,fxDuration:200,hideOnEsc:true,hideOnOutClick:true,showCloseButton:true,blockContent:false,cssRule:"a[rel^=lightbox]",mediaWidth:425,mediaHeight:350},i18n:{CloseText:'&times;',CloseTitle:'Close',PrevText:'&lsaquo;&lsaquo;&lsaquo;',PrevTitle:'Previous Image',NextText:'&rsaquo;&rsaquo;&rsaquo;',NextTitle:'Next Image'},Medias:[[/(http:\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)/,'$1/v/$2','swf'],[/(http:\/\/video.google.com)\/videoplay\?docid=([^&]+)/,'$1/googleplayer.swf?docId=$2','swf'],[/(http:\/\/vimeo\.[a-z]+)\/([0-9]+).*?/,'$1/moogaloop.swf?clip_id=$2','swf']],boxes:[],rescan:function(){}},initialize:function(o){this.setOptions(o).build().connectEvents();Lightbox.boxes.push(this)},setTitle:function(t){(function(){this.caption.update(t)}).bind(this).delay(this.options.fxDuration);return this},hide:function(){this.element.hide('fade',{duration:this.options.fxDuration/2,onFinish:this.element.remove.bind(this.element)});return this},show:function(c,s){return this.showingSelf(function(){this.lock();this.content.update(c||'');this.resize(s)}.bind(this))},resize:function(s,n){this.dialog.style.top=(window.sizes().y-this.dialog.sizes().y)/2+'px';var a=this.contentSize(s);var h=this.dialog.sizes().y-this.body.sizes().y;var b=a.height.toInt()||this.minBodyHeight();var d={top:(this.element.sizes().y-b-h)/2+'px'};if(Browser.IE6){var p=this.bodyWrap.getStyle('padding').toInt()>0?15:0;this.bodyWrap.setStyle('padding: '+p+'px');d.width=(a.width.toInt()+p*2)+'px'}if(n===true){this.body.setStyle(a);this.dialog.setStyle(d);this.loading=false}else this.resizeFx(a,d);return this},lock:function(){this.bodyLock.removeClass('lightbox-body-lock-transparent').removeClass('lightbox-body-lock-loading').show();if(Browser.OLD)this.bodyLock.setStyle("opacity: 1");return this},unlock:function(){if(this.options.blockContent)this.bodyLock.addClass('lightbox-body-lock-transparent');else this.bodyLock.hide();return this},resizeLock:function(){this.lock().content.hide()},resizeUnlock:function(){this.unlock().content.show('fade',{duration:this.options.fxDuration/2});this.loading=false},contentSize:function(s){var s=s===this.$listeners?null:s,a=this.element.offsetWidth*0.8,m=this.element.offsetHeight*0.8;if(s)this.content.setStyle(s);s=this.content.sizes();return{width:(s.x>a?a:s.x)+"px",height:(s.y>m?m:s.y)+"px"}},boxResize:function(r){this.element.resize(window.sizes());if(Browser.IE6){this.locker.resize(window.sizes());this.element.style.position='absolute';this.element.style.top=document.documentElement.scrollTop+'px'}return this.resize(false,true)},showingSelf:function(c){Lightbox.boxes.without(this).each('hide');if(this.element.hidden()){this.element.insertTo(document.body).show();this.boxResize()}c();return this},build:function(){this.element=this.E('lightbox').setStyle('display: none');this.locker=this.E('lightbox-locker',this.element);this.dialog=this.E('lightbox-dialog',this.element);this.caption=this.E('lightbox-caption',this.dialog);this.bodyWrap=this.E('lightbox-body-wrap',this.dialog);this.body=this.E('lightbox-body',this.bodyWrap);this.content=this.E('lightbox-content',this.body);this.bodyLock=this.E('lightbox-body-lock',this.body).hide();if(this.options.showCloseButton)this.closeButton=this.E('lightbox-close-button',this.dialog).onClick(this.hide.bind(this)).update(Lightbox.i18n.CloseText).set('title',Lightbox.i18n.CloseTitle);if(this.options.hideOnOutClick)this.locker.onClick(this.hide.bind(this));document.on('mousewheel',function(a){if(this.element.visible()){a.stop();this[(a.detail||-a.wheelDelta)<0?'showPrev':'showNext']()}}.bind(this));return this},connectEvents:function(){if(this.options.hideOnEsc)document.onKeydown(function(e){if(e.keyCode==27){e.stop();this.hide()}}.bindAsEventListener(this));window.on('resize',this.boxResize.bind(this));return this},minBodyHeight:function(){var e=$E('div',{'class':'lightbox-body',style:'background: none; position: absolute'}).insertTo(document.body),h=e.sizes().y;e.remove();return h},resizeFx:function(f,k){this.resizeLock();var e=this.body.sizes().x;var a=f.width.toInt();var c=this.body.sizes().y;var b=f.height.toInt();var i=this.dialog.style.top.toInt();var g=k.top.toInt();var j=this.dialog.sizes().x;var h=(k.width||'0').toInt();var f=this.body.style;var k=this.dialog.style;$ext(new Fx(this.dialog,{duration:this.options.fxDuration}),{render:function(d){f.width=(e+(a-e)*d)+'px';f.height=(c+(b-c)*d)+'px';k.top=(i+(g-i)*d)+'px';if(Browser.IE6)k.width=(j+(h-j)*d)+'px'}}).onFinish(this.resizeUnlock.bind(this)).start()},E:function(k,p){var e=$E('div',{'class':k});if(p)e.insertTo(p);return e}});Lightbox.include((function(p){var f=p.show;var e=p.build;return{show:function(c){if(c&&c.href)return this.load(c.href,{onComplete:function(r){this.checkTheRoad(c).setTitle(c.title).content.update(r.responseText)}.bind(this)});else return f.apply(this,arguments)},load:function(u,o){var o=o||{};$w('onCreate onComplete').each(function(n){o[n]=o[n]?isArray(o[n])?o[n]:[o[n]]:[]});if(o.onComplete.empty()&&!o.onSuccess)o.onComplete.push(function(r){this.content.update(r.responseText)}.bind(this));o.onCreate.unshift(this.loadLock.bind(this));o.onComplete.push(this.resize.bind(this));o.method=o.method||'get';return this.showingSelf(Xhr.load.bind(Xhr,u,o))},loadLock:function(){this.loading=true;this.lock().bodyLock.addClass('lightbox-body-lock-loading');return this},build:function(){var r=e.apply(this,arguments);var s=this.E('lightbox-body-lock-spinner',this.bodyLock);var b='1234'.split('').map(function(a){return $E('div',{'class':a==1?'glow':null}).insertTo(s)});(function(){var d=b.pop();d.insertTo(s,'top');b.unshift(d)}).periodical(400);return r}}})(Lightbox.prototype));Lightbox.include((function(p){var d=p.show;var o=p.build;var b=p.connectEvents;return{show:function(c){this.roadLink=(c&&c.roadtrip)?c:null;return d.apply(this,arguments)},build:function(){var r=o.apply(this,arguments);this.prevLink=this.E('lightbox-prev-link',this.dialog).onClick(this.showPrev.bind(this)).update(Lightbox.i18n.PrevText).set('title',Lightbox.i18n.PrevTitle).hide();this.nextLink=this.E('lightbox-next-link',this.dialog).onClick(this.showNext.bind(this)).update(Lightbox.i18n.NextText).set('title',Lightbox.i18n.NextTitle).hide();return r},connectEvents:function(){var r=b.apply(this,arguments);document.onKeydown(function(e){if(e.keyCode==37){e.stop();this.showPrev()}if(e.keyCode==39){e.stop();this.showNext()}}.bind(this));return r},showPrev:function(){if(this.hasPrev()&&this.element.visible()&&!this.loading)this.show(this.roadLink.roadtrip[this.roadLink.roadtrip.indexOf(this.roadLink)-1]);return this},showNext:function(){if(this.hasNext()&&this.element.visible()&&!this.loading)this.show(this.roadLink.roadtrip[this.roadLink.roadtrip.indexOf(this.roadLink)+1]);return this},checkRoadtrip:function(){this.prevLink[this.hasPrev()?'show':'hide']();this.nextLink[this.hasNext()?'show':'hide']();return this},hasPrev:function(){return this.roadLink&&this.roadLink.roadtrip&&this.roadLink.roadtrip.first()!=this.roadLink},hasNext:function(){return this.roadLink&&this.roadLink.roadtrip&&this.roadLink.roadtrip.last()!=this.roadLink},checkTheRoad:function(l){if(isElement(l)){var r=this.options.cssRule.split('[').last(),v=l.get(r.split('^=').first())||'',a=v.match(/\[(.+?)\]/);if(a){var m=r.split('^=').last().split(']').first();l.roadtrip=$$(this.options.cssRule.replace(m,"'"+m+"["+a[1]+"]'"))}}this.roadLink=l;return this}}})(Lightbox.prototype));Lightbox.include((function(){var o=Lightbox.prototype.show;return{IMAGE_FORMATS:$w('jpg jpeg gif png bmp'),show:function(c){this.element[(c&&(c.tagName=='IMG'||this.isImageUrl(c.href)))?'addClass':'removeClass']('lightbox-image');if(c&&c.href&&this.isImageUrl(c.href))return this.showingSelf(function(){this.checkTheRoad(c).loadLock();var i=new Image();i.onload=this.updateImage.bind(this,i,c);i.src=c.href}.bind(this));else return o.apply(this,arguments)},updateImage:function(i,l){this.content.update(i);this.checkRoadtrip().setTitle(l.title).resize()},isImageUrl:function(u){return this.IMAGE_FORMATS.include(String(u).toLowerCase().split('?').first().split('.').last())}}})());Lightbox.include((function(p){var o=p.show;var e={swf:['D27CDB6E-AE6D-11cf-96B8-444553540000','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0','application/x-shockwave-flash']};function b(a,t){var s=' width="'+this.options.mediaWidth+'" height="'+this.options.mediaHeight+'"';return '<object classid="clsid:'+e[t][0]+'" codebase="'+e[t][1]+'"'+s+'>'+'<param name="src" value="'+a+'" />'+'<embed src="'+a+'" type="'+e[t][2]+'"'+s+' />'+'</object>'};function c(l){if(isElement(l)&&l.href){var a=l.href;return Lightbox.Medias.map(function(d){return a.match(d[0])?b.call(this,a.replace(d[0],d[1]),d[2]):null},this).compact()[0]}}return{show:function(l){var m=c.call(this,l);this.element[m?'addClass':'removeClass']('lightbox-media');if(m){this.content.update(m);return this.showingSelf(function(){this.checkTheRoad(l).setTitle(l.title)}.bind(this))}return o.apply(this,arguments)}}})(Lightbox.prototype));Lightbox.extend({hide:function(){this.boxes.each('hide')},show:function(){return this.inst('show',arguments)},load:function(){return this.inst('load',arguments)},inst:function(n,a){var i=new Lightbox();return i[n].apply(i,a)}});$(document.documentElement).onClick(function(e){var t=$(e.target);var s=[t].concat(t.parents());var l=s.slice(0,s.length-2).first('match',Lightbox.Options.cssRule);if(l){e.stop();new Lightbox(eval('('+l.get('data-lightbox-options')+')')).show(l)}});document.write("<style type=\"text/css\">div.lightbox{position:fixed;top:0px;left:0px;width:100%;text-align:center;z-index:9999}div.ligthbox div.right-calendar{z-index:99999}div.lightbox div{line-height:normal}div.lightbox-locker{position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:#000;opacity:0.84;filter:alpha(opacity=84)}div.lightbox-dialog{display:inline-block;*display:inline;*zoom:1;position:relative;text-align:left;padding-bottom:1.6em}div.lightbox-body-wrap{background-color:white;padding:1em;border-radius:.6em;-moz-border-radius:.6em;-webkit-border-radius:.6em}div.lightbox-body{position:relative;height:10em;width:10em;min-height:10em;min-width:10em;overflow:hidden;*background-color:white}div.lightbox-content{position:absolute;*background-color:white}div.lightbox-body-lock{background-color:white;position:absolute;left:0px;top:0px;width:100%;height:100%;text-align:center}div.lightbox-body-lock-spinner{display:none;position:absolute;bottom:0;right:0}div.lightbox-body-lock-spinner div{float:left;width:.5em;height:.9em;background:#AAA;margin-left:.1em;-moz-border-radius:.15em;-webkit-border-radius:.15em}div.lightbox-body-lock-spinner div.glow{background:#666;height:1em;margin-top:-0.05em}div.lightbox-body-lock-loading div.lightbox-body-lock-spinner{display:inline-block;*display:inline;*zoom:1}div.lightbox-body-lock-transparent{background:none}div.lightbox-caption{height:1.2em;margin:0 .7em;margin-bottom:.1em;white-space:nowrap;color:#DDD;font-weight:bold;font-size:1.6em;font-family:Helvetica}div.lightbox-close-button,div.lightbox-prev-link,div.lightbox-next-link{position:absolute;bottom:0;color:#888;cursor:pointer;font-size:150%;font-weight:bold;font-family:Arial}div.lightbox-close-button:hover,div.lightbox-prev-link:hover,div.lightbox-next-link:hover{color:white}div.lightbox-close-button{right:.5em}div.lightbox-prev-link,div.lightbox-next-link{padding:0 .2em;bottom:2px}div.lightbox-prev-link{left:.2em}div.lightbox-next-link{left:2em}div.lightbox-image div.lightbox-body-wrap,div.lightbox-media div.lightbox-body-wrap{padding:0;border:1px solid #777;border-radius:0px;-moz-border-radius:0px;-webkit-border-radius:0px}div.lightbox-image div.lightbox-content img{vertical-align:middle}div.lightbox-image div.lightbox-caption,div.lightbox-media div.lightbox-caption{margin-left:.2em}div.lightbox-image div.lightbox-body-wrap,div.lightbox-image div.lightbox-body-lock,div.lightbox-media div.lightbox-body-wrap,div.lightbox-media div.lightbox-body-lock{background-color:#DDD}div.lightbox-image div.lightbox-body-lock-spinner{bottom:1em;right:1em}div.lightbox-image div.lightbox-close-button{right:.2em}div.lightbox-image div.lightbox-prev-link{left:0}</style>");