/*!
	Easybox v0.1 - Lightweight easy to use lightbox clone for jQuery
	Based on Slimbox2 by Christophe Beyls <http://www.digitalia.be>
*/
/android|iphone|ipod|series60|symbian|windows ce|blackberry|msie 6/i.test(navigator.userAgent)||jQuery(function(a){a("a[rel^='lightbox']").easybox({/* custom options here */},null,function(a){return this==a||this.rel.length>8&&this.rel==a.rel})});
(function(a){function N(c){c?a("object").add("embed").each(function(a,c){B[a]=[c,c.style.visibility];c.style.visibility="hidden"}):(a.each(B,function(a,c){c[0].style.visibility=c[1]}),B=[]);a(document)[c?"bind":"unbind"]("keydown",S)}function S(c){var c=c.keyCode,i=a.inArray;return i(c,b.closeKeys)>=0?C():i(c,b.nextKeys)>=0?D():i(c,b.previousKeys)>=0?E():!1}function E(){r=1;return u(m)}function D(){r=0;return u(k)}function u(c){if(c>=0){e=c;m=(e||(b.loop?d.length:0))-1;k=(e+1)%d.length||(b.loop?0:
-1);F();if(m>=0&&/(\.jpg|\.jpeg|\.png|\.gif)$/i.test(d[m][0]))(new Image).src=d[m][0];if(k>=0&&/(\.jpg|\.jpeg|\.png|\.gif)$/i.test(d[k][0]))(new Image).src=d[k][0];O()?(a(f).addClass("easyLoading"),j=new Image,j.onload=function(){G=this.width;H=this.height;n()},j.onerror=function(){o=!0;n()},j.src=d[e][0]):(id=P())!=!1?(a(f).addClass("easyLoading"),s=a.ajax("http://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc",{type:"GET",data:{q:id},dataType:"jsonp",timeout:2E3,success:function(a){a.data.totalItems&&
(a.data.items[0].accessControl.embed=="allowed"?I=a.data.items[0].aspectRatio=="widescreen":o=!0);n()},error:function(a,c){c!="abort"&&(o=!0,n())}})):(id=Q())!=!1?(a(f).addClass("easyLoading"),s=a.ajax("http://vimeo.com/api/v2/video/"+id+".json",{type:"GET",dataType:"jsonp",timeout:2E3,success:function(a){a.length&&(a[0].embed_privacy=="anywhere"||a[0].embed_privacy=="approved"?(J=a[0].width||0,K=a[0].height||0):o=!0);n()},error:function(a,c){c!="abort"&&(o=!0,n())}})):n()}return!1}function n(){var c,
i;a(f).removeClass();o?(a(f).addClass("easyError"),g=b.initWidth,l=b.initHeight,a([L,M]).html("")):(O()?(c=t({w:G,h:H}),i=a('<img src="'+d[e][0]+'" width="'+c.w+'" height="'+c.h+'" alt="'+d[e][1]+'" />')):(id=P())!=!1?(c=t({w:Math.round(b.ytPlayerHeight*(I?16/9:4/3)),h:b.ytPlayerHeight}),i=a('<iframe src="http://www.youtube.com/embed/'+id+'?version=3&autohide=1&autoplay=1&rel=0" width="'+c.w+'" height="'+c.h+'" frameborder="0"></iframe>')):(id=Q())!=!1?(c=t({w:J,h:K}),i=a('<iframe src="http://player.vimeo.com/video/'+
id+'?title=0&byline=0&portrait=0&autoplay=true" width="'+c.w+'" height="'+c.h+'" frameborder="0"></iframe>')):(id=T())!=!1?(h=a("#"+id)[0],a(h).parent(),c=t({w:a(h).width(),h:a(h).height()}),i=a(h).css({display:"block"})):(c=t({}),i=a('<iframe width="'+c.w+'" height="'+c.h+'" src="'+d[e][0]+'" frameborder="0"></iframe>')),a(p).css({visibility:"hidden",display:""}).width(c.w).height(c.h),g=p.offsetWidth,l=p.offsetHeight,a(L).html(d[e][1]||""),a(M).html((d.length>1&&b.counterText||"").replace(/{x}/,
e+1).replace(/{y}/,d.length)));(f.offsetHeight!=l||f.offsetWidth!=g)&&a(f).animate({height:l,marginTop:-l/2,width:g,marginLeft:-g/2},b.resizeDuration,b.resizeEasing);a(f).queue(function(){a(v).css({width:g,marginLeft:-g/2,marginTop:l/2});a(q).css({marginLeft:-g/2-Math.floor(a(q).width()*1.5)});a(w).css({marginLeft:g/2+Math.ceil(a(q).width()*0.5)});a(p).append(i).css({display:"none",visibility:"",opacity:""}).fadeIn(b.fadeDuration,U);b.slideshow&&k>=0&&(x=setInterval(r?E:D,b.slideshow));b.autoClose&&
(y=setInterval(C,b.autoClose))})}function U(){m>=0&&a(q).css({display:"none",visibility:"",opacity:""}).fadeIn(b.captionFadeDuration);k>=0&&a(w).css({display:"none",visibility:"",opacity:""}).fadeIn(b.captionFadeDuration);a(v).css({opacity:""}).fadeIn(b.captionFadeDuration);a(z).css("marginTop",-z.offsetHeight).animate({marginTop:0},b.captionFadeDuration)}function F(){var c;a(f).removeClass();if(j!=null)c=j.onload=j.onerror=null,j=c;s!=null&&(s.abort(),s=null);x!=null&&(clearInterval(x),x=null);y!=
null&&(clearInterval(y),y=null);h!=null&&(a("body").append(a(h).css({display:""})),h=null);I=o=!1;J=K=G=H=0;a(p).empty();a([f,z]).stop(!0);a([p,v,q,w]).stop(!0).css({display:"none"})}function C(){e>=0&&(F(),e=m=k=-1,r=0,a(A).stop().fadeOut(b.fadeDuration,N),a(f).animate({height:b.closeHeight,marginTop:-b.closeHeight/2,width:b.closeWidth,marginLeft:-b.closeWidth/2,opacity:0},b.fadeDuration,function(){a(f).hide()}));return!1}function O(){return/(\.jpg|\.jpeg|\.png|\.gif)$/i.test(d[e][0])}function P(){var a=
/^http\:\/\/www\.youtube\.com\/watch\?v=([A-Za-z0-9]*)(&(.*))?$/i.exec(d[e][0]);return a!=null?a[1]:!1}function Q(){var a=/^http\:\/\/vimeo\.com\/([0-9]*)(.*)?$/i.exec(d[e][0]);return a!=null?a[1]:!1}function T(){var c=/^(.*)\#([A-Za-z0-9\-_]*)$/i.exec(d[e][0]);return c!=null&&a("#"+c[2]).length?c[2]:!1}function t(a){if(!(a.w>0&&a.h>0))a.w=b.defWidth,a.h=b.defHeight;if(a.h>b.maxHeight)a.w=Math.round(b.maxHeight*a.w/a.h),a.h=b.maxHeight;if(a.w>b.maxWidth)a.h=Math.round(b.maxWidth/a.w*a.h),a.w=b.maxWidth;
return a}var b,d,e=-1,m,k,g,l,B=[],r=0,j=null,s=null,h=null,x=null,y=null,G=0,H=0,J=0,K=0,I=0,o=!1,A,f,p,q,w,v,z,L,M;a(function(){a("body").append(a([A=a('<div id="easyOverlay" />')[0],f=a('<div id="easyCenter" />').append([p=a('<div id="easyContainer" />')[0]])[0],q=a('<a id="easyPrevLink" href="#" />').click(E)[0],w=a('<a id="easyNextLink" href="#" />').click(D)[0],v=a('<div id="easyBottomContainer" />').append([z=a('<div id="easyBottom" />').append([a('<a id="easyCloseLink" href="#" />').add(A).click(C)[0],
L=a('<div id="easyCaption" />')[0],M=a('<div id="easyNumber" />')[0],a('<div style="clear: both;" />')[0]])[0]])[0]]).css("display","none"))});a.easybox=function(c,i,j,h){var R=!1;e>=0&&(F(),e=m=k=-1,r=0,R=!0);b=a.extend({loop:!1,dynOpts:!0,overlayOpacity:0.8,resizeDuration:400,resizeEasing:"easybox",fadeDuration:400,initWidth:250,initHeight:250,defWidth:960,defHeight:720,closeWidth:128,closeHeight:128,maxWidth:1280,maxHeight:720,maxScreenFill:0.7,ytPlayerHeight:480,captionFadeDuration:200,slideshow:0,
autoClose:0,counterText:"{x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},j);b.dynOpts&&a("#easyOptions").length&&(j=a.parseJSON(a("#easyOptions").html()),a.each(j,function(c,i){if(c=="global"||typeof h=="string"&&c==h)b=a.extend(b,i)}));typeof c=="string"&&(c=[[c,i]],i=0);if(b.maxScreenFill)b.maxWidth=Math.min(Math.round(screen.width*b.maxScreenFill),b.maxWidth),b.maxHeight=Math.min(Math.round(screen.height*b.maxScreenFill),b.maxHeight);d=c;b.loop=b.loop&&d.length>1;R?u(i):
(g=b.initWidth,l=b.initHeight,a(f).css({width:g,height:l,marginLeft:-g/2,marginTop:-l/2,opacity:""}),N(1),a(f).show(),a(A).css("opacity",b.overlayOpacity).fadeIn(b.fadeDuration,function(){u(i)}));return!1};a.fn.easybox=function(c,b,d){var b=b||function(a){return[a.href,a.title]},d=d||function(a){return this==a},e=this;return e.unbind("click").click(function(){var f=this,j=0,g,h=0,k;g=a.grep(e,function(a,c){return d.call(f,a,c)});for(k=g.length;h<k;++h)g[h]==f&&(j=h),g[h]=b(g[h],h);return a.easybox(g,
j,c,a(f).attr("rel")||null)})};a.easing.easybox=function(a){return a<0.7?Math.pow(a/0.7,2)*1.2:1.2-Math.sqrt((a-0.7)/(1-0.7))*0.2}})(jQuery);

