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

