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

