/*
        Easybox v1.2 - 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(b){b("a[rel^='lightbox']").easybox({/* custom options here */},null,function(a){return this==a||this.rel.length>8&&this.rel==a.rel})});
(function(a){function W(c){c?a("object:visible").add("embed").each(function(a,c){M[a]=[c,c.style.visibility];c.style.visibility="hidden"}):(a.each(M,function(a,c){c[0].style.visibility=c[1]}),M=[]);c=c?"bind":"unbind";a(document)[c]("keydown",ga);if(a.fn.mousewheel)a(window)[c]("mousewheel",ha)}function ga(c){var c=c.keyCode,g=a.inArray;return A?!0:0<=g(c,b.closeKeys)?F():0<=g(c,b.nextKeys)&&!b.noNavigation?G():0<=g(c,b.previousKeys)&&!b.noNavigation?H():!b.preventOtherKeys}function ha(a,g){return A?
!0:0<g&&!b.noNavigation?H():0>g&&!b.noNavigation?G():!b.preventOtherKeys}function H(){s=!0;return N(k)}function G(){s=!1;return N(i)}function X(){if(b.slideshow&&!t&&null==l){if(s&&0<=k)return l=setTimeout(H,b.slideshow),!1;if(!s&&0<=i)return l=setTimeout(G,b.slideshow),!1}b.autoClose&&null==B&&(B=setTimeout(ia,b.autoClose));return!1}function N(a){if(0<=a){h=a;k=(h||(b.loop?d.length:0))-1;i=(h+1)%d.length||(b.loop?0:-1);O();b.busyTimeout&&(I=setTimeout(ja,b.busyTimeout));if(0<=k&&/(\.jpg|\.jpeg|\.png|\.gif)$/i.test(d[k][0]))(new Image).src=
d[k][0];if(0<=i&&/(\.jpg|\.jpeg|\.png|\.gif)$/i.test(d[i][0]))(new Image).src=d[i][0];Y()?ka():!1!=(id=Z())?$(0,id):!1!=(id=aa())?$(1,id):u()}return!1}function u(){var c,g;if(v)a(f).addClass("easyError"),j=b.initWidth,m=b.initHeight,g=null;else{if(Y())c=C({w:D,h:E}),g=a('<img src="'+d[h][0]+'" width="'+c.w+'" height="'+c.h+'" alt="'+d[h][1]+'" />');else if(!1!=(id=Z())){var e="?version=3&autohide=1&autoplay=1&rel=0";if(b.ytPlayerTheme&&null!=(r=/^([a-z]*),([a-z]*)$/.exec(b.ytPlayerTheme)))e+="&theme="+
r[1]+"&color="+r[2];b.loopVideos&&(e+="&loop=1&playlist="+id);c=C({w:Math.round(b.ytPlayerHeight*(P?16/9:4/3)),h:b.ytPlayerHeight});g=a('<iframe src="http://www.youtube.com/embed/'+id+e+'" width="'+c.w+'" height="'+c.h+'" frameborder="0"></iframe>')}else!1!=(id=aa())?(e="?title=0&byline=0&portrait=0&autoplay=true",c=C({w:D,h:E}),b.loopVideos&&(e+="&loop=true"),g=a('<iframe src="http://player.vimeo.com/video/'+id+e+'" width="'+c.w+'" height="'+c.h+'" frameborder="0"></iframe>')):!1!=(id=la())?(n=a("#"+
id)[0],Q=a(n).parent(),R=a(n).css("display"),c=C({w:a(n).width(),h:a(n).height()}),g=a(n)):(c=C({}),g=a('<iframe width="'+c.w+'" height="'+c.h+'" src="'+d[h][0]+'" frameborder="0"></iframe>'));a(o).css({visibility:"hidden",display:""}).width(c.w).height(c.h);j=o.offsetWidth;m=o.offsetHeight;d[h][1].length&&a(w).html(d[h][1]).css({display:""});1<d.length&&b.counterText.length&&a(x).html(b.counterText.replace(/{x}/,h+1).replace(/{y}/,d.length)).css({display:""})}(f.offsetHeight!=m||f.offsetWidth!=j)&&
a(f).animate({height:m,marginTop:-m/2,width:j,marginLeft:-j/2},b.resizeDuration,b.resizeEasing);a(f).queue(function(){a(p).css({width:j,marginLeft:-j/2,marginTop:m/2});a(o).css({display:"none",visibility:"",opacity:""});null!=g&&a(g).css({display:"block"}).appendTo(o);a(o).fadeIn(b.fadeDuration,ma);X();A=!1})}function ma(){if(!b.hideBottom){if(0<=k||0<=i&&!b.noNavigation&&!b.hideButtons)a(S).css({display:""}),a([w,x]).addClass("nav"),b.hideCaption&&a([w,x]).css({display:"none"}),0<=k&&a(y).fadeIn(b.captionFadeDuration),
0<=i&&a(z).fadeIn(b.captionFadeDuration);a(p).css({opacity:""}).fadeIn(b.captionFadeDuration);a(J).css("marginTop",-J.offsetHeight).animate({marginTop:0},b.captionFadeDuration)}}function O(){var c;A=!0;a(f).removeClass();if(null!=q)c=q.onload=q.onerror=null,q=c;null!=K&&(K.abort(),K=null);null!=l&&(clearTimeout(l),l=null);null!=I&&(clearTimeout(I),I=null);null!=B&&(clearTimeout(B),B=null);null!=n&&(a(Q).append(a(n).css({display:R})),n=Q=R=null);P=v=!1;D=E=0;a(o).empty();a([f,J]).stop(!0);a([S,w,x]).css({display:"none"});
a([w,x]).removeClass().html("");a([o,p,y,z]).stop(!0).css({display:"none"})}function na(){t=!t;s=!1;a(T).toggleClass("disabled",t);t?null!=l&&(clearTimeout(l),l=null):X();return!1}function F(c){if(!(b.noClose&&1!=c))return 0<=h&&(O(),h=k=i=-1,s=t=!1,a(U).stop().fadeOut(b.fadeDuration,W),a(f).animate({height:b.closeHeight,marginTop:-b.closeHeight/2,width:b.closeWidth,marginLeft:-b.closeWidth/2,opacity:0},b.fadeDuration,function(){V();a([f,p,y,z]).css({left:"",top:""});a(f).hide()})),!1}function ia(){F(1)}
function ja(){A=!1}function Y(){return/(\.jpg|\.jpeg|\.png|\.gif)$/i.test(d[h][0])}function Z(){var a=/^http\:\/\/www\.youtube\.com\/watch\?v=([A-Za-z0-9\-_]*)(&(.*))?$/i.exec(d[h][0]);return null!=a?a[1]:!1}function aa(){var a=/^http\:\/\/vimeo\.com\/([0-9]*)(.*)?$/i.exec(d[h][0]);return null!=a?a[1]:!1}function la(){var c=/^(.*)\#([A-Za-z0-9\-_]*)$/i.exec(d[h][0]);return null!=c&&a("#"+c[2]).length?c[2]:!1}function ka(){a(f).addClass("easyLoading");q=new Image;q.onload=function(){D=this.width;E=
this.height;a(f).removeClass("easyLoading");u()};q.onerror=function(){v=!0;u()};q.src=d[h][0]}function $(c,b){var e,d;a(f).addClass("easyLoading");d={type:"GET",dataType:"jsonp",timeout:2E3,error:function(b,c){"abort"!=c&&(v=!0,a(f).removeClass("easyLoading"),u())}};if(0==c)e="http://gdata.youtube.com/feeds/api/videos/"+b+"?v=2&alt=jsonc",d.success=function(c){!c.error&&c.data&&"allowed"==c.data.accessControl.embed?P="widescreen"==c.data.aspectRatio:v=!0;a(f).removeClass("easyLoading");u()};else if(1==
c)e="http://vimeo.com/api/v2/video/"+b+".json",d.success=function(c){c.length&&("anywhere"==c[0].embed_privacy||"approved"==c[0].embed_privacy?(D=c[0].width||0,E=c[0].height||0):v=!0);a(f).removeClass("easyLoading");u()};K=a.ajax(e,d)}function C(a){if(!(0<a.w&&0<a.h))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}function oa(c){if(b.dragDrop)return L=!0,a([f,p,y,z]).css({cursor:"pointer"}),
ca=c.pageX-a(this).position().left,da=c.pageY-a(this).position().top,!1}function pa(c){if(b.dragDrop&&L){var d=c.pageX-a(window).scrollLeft()-ca,c=c.pageY-a(window).scrollTop()-da;a([f,p]).css({left:d+"px",top:c+"px"})}}function V(){L&&(L=!1,a([f,p,y,z]).css({cursor:""}))}var ea,b,d,h=-1,k,i,j,m,M=[],s=!1,t=!1,L=!1,ca=0,da=0,A=!1,q=null,K=null,n=null,Q=null,R=null,I=null,l=null,B=null,D=0,E=0,P=0,v=!1,U,f,o,S,y,z,T,fa,p,J,w,x;a(function(){ea={loop:!1,loopVideos:!1,dynOpts:!0,dragDrop:!0,hideBottom:!1,
hideCaption:!1,hideButtons:!1,noNavigation:!1,noClose:!1,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,ytPlayerTheme:"light,white",captionFadeDuration:200,slideshow:0,autoClose:0,busyTimeout:800,counterText:"{x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78],preventOtherKeys:!0};a("body").append(a([U=
a('<div id="easyOverlay" />').click(F)[0],f=a('<div id="easyCenter" />').append([o=a('<div id="easyContainer" />')[0]])[0],p=a('<div id="easyBottomContainer" />').append([J=a('<div id="easyBottom" />').append([S=a('<div id="easyNavigation" />').append([y=a('<a id="easyPrevLink" href="#" />').click(H)[0],z=a('<a id="easyNextLink" href="#" />').click(G)[0]])[0],fa=a('<a id="easyCloseLink" href="#" />').click(F)[0],T=a('<a id="easySlideLink" href="#" />').click(na)[0],w=a('<div id="easyCaption" />')[0],
x=a('<div id="easyNumber" />')[0],a('<div style="clear: both;" />')[0]])[0]])[0]]).css("display","none"));a([f,p]).mousedown(oa).mousemove(pa).mouseup(V);a(window).mouseup(V)});a.easybox=function(c,g,e,k){if(0<=h)return!1;b=a.extend({},ea,e);b.dynOpts&&a("#easyOptions").length&&(e=a.parseJSON(a("#easyOptions").html()),a.each(e,function(c,d){if("global"==c||"string"==typeof k&&c==k)b=a.extend(b,d)}));if("string"==typeof c)d=[[c,g||""]],g=0;else{var e=0,ba;d=[];for(ba=c.length;e<ba;++e)"string"==typeof c[e]?
d.push([c[e],""]):d.push([c[e][0],c[e][1]||""]);g=g||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);b.loop=b.loop&&1<d.length;b.slideshow=b.slideshow&&1<d.length?b.slideshow:0;a(T).css({display:b.slideshow&&1<d.length&&!b.hideButtons?"":"none"});a(fa).css({display:!b.hideButtons?"":"none"});j=b.initWidth;m=b.initHeight;a(f).css({width:j,height:m,marginLeft:-j/2,marginTop:-m/2,
opacity:""});W(1);O();a(f).show();a(U).css("opacity",b.overlayOpacity).fadeIn(b.fadeDuration,function(){N(g)});return!1};a.fn.easybox=function(b,d,e){var d=d||function(a){return[a.href,a.title]},e=e||function(a){return this==a},f=this;return f.unbind("click").click(function(){var h=this,k=0,j,i=0,l;j=a.grep(f,function(a,b){return e.call(h,a,b)});for(l=j.length;i<l;++i)j[i]==h&&(k=i),j[i]=d(j[i],i);return a.easybox(j,k,b,a(h).attr("rel")||null)})};a.easing.easybox=function(a){return 0.7>a?1.2*Math.pow(a/
0.7,2):1.2-0.2*Math.sqrt((a-0.7)/(1-0.7))}})(jQuery);

