/*
	Videobox v1 - jQuery lightbox clone for displaying iframe videos
	Based on Slimbox 2.04 
		(c) 2007-2010 Christophe Beyls <http://www.digitalia.be>
		MIT-style license.
*/

(function vb(f){var e=f(window),d,l,C=-1,b,p,q,c,B,r,m,i=!window.XMLHttpRequest,o=[],A=document.documentElement,u,z,t,y,j,v,a;f(function g(){f("body").append(f([u=f('<div id="vbOverlay" />')[0],z=f('<div id="vbCenter" />')[0],y=f('<div id="vbBottomContainer" />')[0]]).css("display","none"));t=f('<iframe id="vbVideo" frameborder="0" allowfullscreen="true" oallowfullscreen msallowfullscreen webkitallowfullscreen mozallowfullscreen />').appendTo(z)[0];j=f('<div id="vbBottom" />').appendTo(y).append([f('<a id="vbCloseLink" href="#" />').add(u).click(k)[0],v=f('<div id="vbCaption" />')[0],a=f('<div id="vbNumber" />')[0],f('<div style="clear: both;" />')[0]])[0]});f.videobox=function(G,F,E){d=f.extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeEasing:"swing",initialWidth:250,initialHeight:250,videoWidth:640,videoHeight:363,videoFadeDuration:400,captionAnimationDuration:400,counterText:"Video {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},E);if(typeof G=="string"){G=[[G,F]];F=0}B=e.scrollTop()+(e.height()/2);r=d.initialWidth;m=d.initialHeight;f(z).css({top:Math.max(0,B-(m/2)),width:r,height:m,marginLeft:-r/2}).show();c=i||(u.currentStyle&&(u.currentStyle.position!="fixed"));if(c){u.style.position="absolute"}f(u).css("opacity",d.overlayOpacity).fadeIn(d.overlayFadeDuration);x();n(1);l=G;d.loop=d.loop&&(l.length>1);return D(F)};f.fn.videobox=function(F,J,H){J=J||function E(K){return[K.href,K.title]};H=H||function I(){return true};var G=this;return G.unbind("click").click(function I(){var M=this,O=0,N,K=0,L;N=f.grep(G,function(Q,P){return H.call(M,Q,P)});for(L=N.length;K<L;++K){if(N[K]==M){O=K}N[K]=J(N[K],K)}return f.videobox(N,O,F)})};function x(){var F=e.scrollLeft(),E=e.width();f([z,y]).css("left",F+(E/2));if(c){f(u).css({left:F,top:e.scrollTop(),width:E,height:e.height()})}}function n(E){if(E){f("object").add(i?"select":"embed").each(function(G,H){o[G]=[H,H.style.visibility];H.style.visibility="hidden"})}else{f.each(o,function(G,H){H[0].style.visibility=H[1]});o=[]}var F=E?"bind":"unbind";e[F]("scroll resize",x)}function D(E){if(E>=0){C=E;b=l[C][0];z.className="vbLoading";s();h()}return false}function h(){z.className="";var F=l[C][2]||d.videoWidth;var E=l[C][3]||d.videoHeight;if(F>(e.width()-20)){F=e.width()-20}E=(E*F)/(l[C][2]||d.videoWidth);f(t).css({visibility:"hidden",display:""});t.src=b;f(t).width(F);f(t).height(E);f(v).html(l[C][1]||"");f(a).html((((l.length>1)&&d.counterText)||"").replace(/{x}/,C+1).replace(/{y}/,l.length));r=parseInt(F)+20;m=parseInt(E)+20;var G=Math.max(0,B-(m/2));f(z).animate({height:m,top:G,width:r,marginLeft:-r/2},d.resizeDuration,d.resizeEasing);f(z).queue(function H(){f(y).css({width:r,top:G+m,marginLeft:-r/2,visibility:"hidden",display:""});f(t).css({display:"none",visibility:"",opacity:""}).fadeIn(d.videoFadeDuration,w)})}function w(){f(j).css("marginTop",-j.offsetHeight).animate({marginTop:0},d.captionAnimationDuration);y.style.visibility=""}function s(){f([z,t,j]).stop(true);f([t,y]).hide();t.src="";t.title=""}function k(){if(C>=0){s();C=-1;f(z).hide();f(u).stop().fadeOut(d.overlayFadeDuration,n)}return false}})(jQuery);
// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
	jQuery(function vb($) {
	$("a[rel^='videobox']").videobox({ /* Put custom options here */ }, function vbl(el) {
			return [el.href, el.getAttribute("title"), el.getAttribute("videowidth"), el.getAttribute("videoheight")];
	}, function vbl(el) {
	  return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	 });
	});