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

