/*
 * fancyBox - jQuery Plugin
 * version: 2.0.4 (12/12/2011)
 * @requires jQuery v1.6 or later
 *
 * Examples at http://fancyapps.com/fancybox/
 * License: www.fancyapps.com/fancybox/#license
 *
 * Copyright 2011 Janis Skarnelis - janis@fancyapps.com
 *
 */
(function(H,E,I){var C=I(H),J=I(E),G=I.fancybox=function(){G.open.apply(this,arguments)},B=false,A=null;I.extend(G,{version:"2.0.4",defaults:{padding:15,margin:20,width:800,height:600,minWidth:200,minHeight:200,maxWidth:9999,maxHeight:9999,autoSize:true,fitToView:true,aspectRatio:false,topRatio:0.5,fixed:!I.browser.msie||I.browser.version>6||(E.documentElement.hasOwnProperty&&!E.documentElement.hasOwnProperty("ontouchstart")),scrolling:"auto",wrapCSS:"fancybox-default",arrows:true,closeBtn:true,closeClick:false,nextClick:false,mouseWheel:true,autoPlay:false,playSpeed:3000,modal:false,loop:true,ajax:{},keys:{next:[13,32,34,39,40],prev:[8,33,37,38],close:[27]},index:0,type:null,href:null,content:null,title:null,tpl:{wrap:'<div class="fancybox-wrap"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div>',image:'<img class="fancybox-image" src="{href}" alt="" />',iframe:'<iframe class="fancybox-iframe" name="fancybox-frame{rnd}" frameborder="0" hspace="0" '+(I.browser.msie?'allowtransparency="true""':"")+' scrolling="{scrolling}" src="{href}"></iframe>',swf:'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="wmode" value="transparent" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{href}" /><embed src="{href}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="100%" height="100%" wmode="transparent"></embed></object>',error:'<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',closeBtn:'<div title="Close" class="fancybox-item fancybox-close"></div>',next:'<a title="Next" class="fancybox-item fancybox-next"><span></span></a>',prev:'<a title="Previous" class="fancybox-item fancybox-prev"><span></span></a>'},openEffect:"fade",openSpeed:250,openEasing:"swing",openOpacity:true,openMethod:"zoomIn",closeEffect:"fade",closeSpeed:250,closeEasing:"swing",closeOpacity:true,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:300,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic",prevSpeed:300,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:{speedIn:0,speedOut:300,opacity:0.8,css:{cursor:"pointer"},closeClick:true},title:{type:"float"}},onCancel:I.noop,beforeLoad:I.noop,afterLoad:I.noop,beforeShow:I.noop,afterShow:I.noop,beforeClose:I.noop,afterClose:I.noop},group:{},opts:{},coming:null,current:null,isOpen:false,isOpened:false,wrap:null,outer:null,inner:null,player:{timer:null,isActive:false},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(F,D){if(!I.isArray(F)){F=[F]}if(!F.length){return }G.close(true);G.opts=I.extend(true,{},G.defaults,D);G.group=F;G._start(G.opts.index||0)},cancel:function(){if(G.coming&&false===G.trigger("onCancel")){return }G.coming=null;G.hideLoading();if(G.ajaxLoad){G.ajaxLoad.abort()}G.ajaxLoad=null;if(G.imgPreload){G.imgPreload.onload=G.imgPreload.onabort=G.imgPreload.onerror=null}},close:function(D){G.cancel();if(!G.current||false===G.trigger("beforeClose")){return }G.unbindEvents();if(!G.isOpen||(D&&D[0]===true)){I(".fancybox-wrap").stop().trigger("onReset").remove();G._afterZoomOut()}else{G.isOpen=G.isOpened=false;I(".fancybox-item").remove();G.wrap.stop(true).removeClass("fancybox-opened");G.inner.css("overflow","hidden");G.transitions[G.current.closeMethod]()}},play:function(F){var D=function(){clearTimeout(G.player.timer)},M=function(){D();if(G.current&&G.player.isActive){G.player.timer=setTimeout(G.next,G.current.playSpeed)}},K=function(){D();I("body").unbind(".player");G.player.isActive=false;G.trigger("onPlayEnd")},L=function(){if(G.current&&(G.current.loop||G.current.index<G.group.length-1)){G.player.isActive=true;I("body").bind({"afterShow.player onUpdate.player":M,"onCancel.player beforeClose.player":K,"beforeLoad.player":D});M();G.trigger("onPlayStart")}};if(G.player.isActive||(F&&F[0]===false)){K()}else{L()}},next:function(){if(G.current){G.jumpto(G.current.index+1)}},prev:function(){if(G.current){G.jumpto(G.current.index-1)}},jumpto:function(D){if(!G.current){return }D=parseInt(D,10);if(G.group.length>1&&G.current.loop){if(D>=G.group.length){D=0}else{if(D<0){D=G.group.length-1}}}if(typeof G.group[D]!=="undefined"){G.cancel();G._start(D)}},reposition:function(D){if(G.isOpen){G.wrap.css(G._getPosition(D))}},update:function(){if(G.isOpen){if(!B){A=setInterval(function(){if(B){B=false;clearTimeout(A);if(G.current){if(G.current.autoSize){G.inner.height("auto");G.current.height=G.inner.height()}G._setDimension();if(G.current.canGrow){G.inner.height("auto")}G.reposition();G.trigger("onUpdate")}}},100)}B=true}},toggle:function(){if(G.isOpen){G.current.fitToView=!G.current.fitToView;G.update()}},hideLoading:function(){I("#fancybox-loading").remove()},showLoading:function(){G.hideLoading();I('<div id="fancybox-loading"></div>').click(G.cancel).appendTo("body")},getViewport:function(){return{x:C.scrollLeft(),y:C.scrollTop(),w:C.width(),h:C.height()}},unbindEvents:function(){if(G.wrap){G.wrap.unbind(".fb")}J.unbind(".fb");C.unbind(".fb")},bindEvents:function(){var F=G.current,D=F.keys;if(!F){return }C.bind("resize.fb, orientationchange.fb",G.update);if(D){J.bind("keydown.fb",function(L){var K;if(!L.ctrlKey&&!L.altKey&&!L.shiftKey&&!L.metaKey&&I.inArray(L.target.tagName.toLowerCase(),["input","textarea","select","button"])<0){K=L.keyCode;if(I.inArray(K,D.close)>-1){G.close();L.preventDefault()}else{if(I.inArray(K,D.next)>-1){G.next();L.preventDefault()}else{if(I.inArray(K,D.prev)>-1){G.prev();L.preventDefault()}}}}})}if(I.fn.mousewheel&&F.mouseWheel&&G.group.length>1){G.wrap.bind("mousewheel.fb",function(L,M){var K=I(L.target).get(0);if(K.clientHeight===0||K.scrollHeight===K.clientHeight){L.preventDefault();G[M>0?"prev":"next"]()}})}},trigger:function(F){var D,K=G[I.inArray(F,["onCancel","beforeLoad","afterLoad"])>-1?"coming":"current"];if(!K){return }if(I.isFunction(K[F])){D=K[F].apply(K,Array.prototype.slice.call(arguments,1))}if(D===false){return false}if(K.helpers){I.each(K.helpers,function(M,L){if(L&&typeof G.helpers[M]!=="undefined"&&I.isFunction(G.helpers[M][F])){G.helpers[M][F](L,K)}})}I.event.trigger(F+".fb")},isImage:function(D){return D&&D.match(/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i)},isSWF:function(D){return D&&D.match(/\.(swf)(.*)?$/i)},_start:function(F){var M={},L=G.group[F]||null,K,D,N,O;if(typeof L==="object"&&(L.nodeType||L instanceof I)){K=true;if(I.metadata){M=I(L).metadata()}}M=I.extend(true,{},G.opts,{index:F,element:L},(I.isPlainObject(L)?L:M));I.each(["href","title","content","type"],function(Q,P){M[P]=G.opts[P]||(K&&I(L).attr(P))||M[P]||null});if(typeof M.margin==="number"){M.margin=[M.margin,M.margin,M.margin,M.margin]}if(M.modal){I.extend(true,M,{closeBtn:false,closeClick:false,nextClick:false,arrows:false,mouseWheel:false,keys:null,helpers:{overlay:{css:{cursor:"auto"},closeClick:false}}})}G.coming=M;if(false===G.trigger("beforeLoad")){G.coming=null;return }N=M.type;D=M.href;if(!N){if(K){O=I(L).data("fancybox-type");if(!O&&L.className){O=L.className.match(/fancybox\.(\w+)/);N=O?O[1]:null}}if(!N&&D){if(G.isImage(D)){N="image"}else{if(G.isSWF(D)){N="swf"}else{if(D.match(/^#/)){N="inline"}}}}if(!N){N=K?"inline":"html"}M.type=N}if(N==="inline"||N==="html"){M.content=M.content||(N==="inline"&&D?I(D):L);if(!M.content.length){N=null}}else{M.href=D||L;if(!M.href){N=null}}M.group=G.group;if(N==="image"){G._loadImage()}else{if(N==="ajax"){G._loadAjax()}else{if(N){G._afterLoad()}else{G._error("type")}}}},_error:function(D){I.extend(G.coming,{type:"html",autoSize:true,minHeight:"0",hasError:D,content:G.coming.tpl.error});G._afterLoad()},_loadImage:function(){G.imgPreload=new Image();G.imgPreload.onload=function(){this.onload=this.onerror=null;G.coming.width=this.width;G.coming.height=this.height;G._afterLoad()};G.imgPreload.onerror=function(){this.onload=this.onerror=null;G._error("image")};G.imgPreload.src=G.coming.href;if(!G.imgPreload.complete){G.showLoading()}},_loadAjax:function(){G.showLoading();G.ajaxLoad=I.ajax(I.extend({},G.coming.ajax,{url:G.coming.href,error:function(D,F){if(F!=="abort"){G._error("ajax",D)}else{G.hideLoading()}},success:function(D,F){if(F==="success"){G.coming.content=D;G._afterLoad()}}}))},_preload:function(){var K=G.group,D=G.current.index,F=function(L){if(L&&G.isImage(L)){new Image().src=L}};if(K.length>1){F(I(K[D+1]||K[0]).attr("href"));F(I(K[D-1]||K[K.length-1]).attr("href"))}},_afterLoad:function(){G.hideLoading();if(!G.coming||false===G.trigger("afterLoad",G.current)){G.coming=false;return }if(G.isOpened){I(".fancybox-item").remove();G.wrap.stop(true).removeClass("fancybox-opened");G.inner.css("overflow","hidden");G.transitions[G.current.prevMethod]()}else{I(".fancybox-wrap").stop().trigger("onReset").remove();G.trigger("afterClose")}G.unbindEvents();G.isOpen=false;G.current=G.coming;G.coming=false;G.wrap=I(G.current.tpl.wrap).addClass("fancybox-tmp "+G.current.wrapCSS).appendTo("body");G.outer=I(".fancybox-outer",G.wrap).css("padding",G.current.padding+"px");G.inner=I(".fancybox-inner",G.wrap);G._setContent();G.trigger("beforeShow");G._setDimension();G.wrap.hide().removeClass("fancybox-tmp");G.bindEvents();G._preload();G.transitions[G.isOpened?G.current.nextMethod:G.current.openMethod]()},_setContent:function(){var F,K,L=G.current,D=L.type;switch(D){case"inline":case"ajax":case"html":F=L.content;if(D==="inline"&&F instanceof I){F=F.show().detach();if(F.parent().hasClass("fancybox-inner")){F.parents(".fancybox-wrap").trigger("onReset").remove()}I(G.wrap).bind("onReset",function(){F.appendTo("body").hide()})}if(L.autoSize){K=I('<div class="fancybox-tmp"></div>').appendTo(I("body")).append(F);L.width=K.outerWidth();L.height=K.outerHeight(true);F=K.contents().detach();K.remove()}break;case"image":F=L.tpl.image.replace("{href}",L.href);L.aspectRatio=true;break;case"swf":F=L.tpl.swf.replace(/\{width\}/g,L.width).replace(/\{height\}/g,L.height).replace(/\{href\}/g,L.href);break;case"iframe":F=L.tpl.iframe.replace("{href}",L.href).replace("{scrolling}",L.scrolling).replace("{rnd}",new Date().getTime());break}if(I.inArray(D,["image","swf","iframe"])>-1){L.autoSize=false;L.scrolling=false}G.inner.append(F)},_setDimension:function(){var L=G.wrap,W=G.outer,X=G.inner,P=G.current,Q=G.getViewport(),N=P.margin,F=P.padding*2,M=P.width+F,V=P.height+F,R=P.width/P.height,T=P.maxWidth,S=P.maxHeight,K=P.minWidth,U=P.minHeight,O,D;Q.w-=(N[1]+N[3]);Q.h-=(N[0]+N[2]);if(M.toString().indexOf("%")>-1){M=((Q.w*parseFloat(M))/100)}if(V.toString().indexOf("%")>-1){V=((Q.h*parseFloat(V))/100)}if(P.fitToView){T=Math.min(Q.w,T);S=Math.min(Q.h,S)}K=Math.min(M,K);U=Math.min(M,U);T=Math.max(K,T);S=Math.max(U,S);if(P.aspectRatio){if(M>T){M=T;V=((M-F)/R)+F}if(V>S){V=S;M=((V-F)*R)+F}if(M<K){M=K;V=((M-F)/R)+F}if(V<U){V=U;M=((V-F)*R)+F}}else{M=Math.max(K,Math.min(M,T));V=Math.max(U,Math.min(V,S))}M=Math.round(M);V=Math.round(V);I(L.add(W).add(X)).width("auto").height("auto");X.width(M-F).height(V-F);L.width(M);O=L.height();if(M>T||O>S){while((M>T||O>S)&&M>K&&O>U){V=V-10;if(P.aspectRatio){M=Math.round(((V-F)*R)+F);if(M<K){M=K;V=((M-F)/R)+F}}else{M=M-10}X.width(M-F).height(V-F);L.width(M);O=L.height()}}P.dim={width:M,height:O};P.canGrow=P.autoSize&&V>U&&V<S;P.canShrink=false;P.canExpand=false;if((M-F)<P.width||(V-F)<P.height){P.canExpand=true}else{if((M>Q.w||O>Q.h)&&M>K&&V>U){P.canShrink=true}}D=O-F;G.innerSpace=D-X.height();G.outerSpace=D-W.height()},_getPosition:function(K){var O=G.current,F=G.getViewport(),M=O.margin,L=G.wrap.width()+M[1]+M[3],D=G.wrap.height()+M[0]+M[2],N={position:"absolute",top:M[0]+F.y,left:M[3]+F.x};if(O.fixed&&(!K||K[0]===false)&&D<=F.h&&L<=F.w){N={position:"fixed",top:M[0],left:M[3]}}N.top=Math.ceil(Math.max(N.top,N.top+((F.h-D)*O.topRatio)))+"px";N.left=Math.ceil(Math.max(N.left,N.left+((F.w-L)*0.5)))+"px";return N},_afterZoomIn:function(){var D=G.current;G.isOpen=G.isOpened=true;G.wrap.addClass("fancybox-opened").css("overflow","visible");G.update();G.inner.css("overflow",D.scrolling==="auto"?"auto":(D.scrolling==="yes"?"scroll":"hidden"));if(D.closeClick||D.nextClick){G.inner.css("cursor","pointer").bind("click.fb",D.nextClick?G.next:G.close)}if(D.closeBtn){I(D.tpl.closeBtn).appendTo(G.wrap).bind("click.fb",G.close)}if(D.arrows&&G.group.length>1){if(D.loop||D.index>0){I(D.tpl.prev).appendTo(G.wrap).bind("click.fb",G.prev)}if(D.loop||D.index<G.group.length-1){I(D.tpl.next).appendTo(G.wrap).bind("click.fb",G.next)}}G.trigger("afterShow");if(G.opts.autoPlay&&!G.player.isActive){G.opts.autoPlay=false;G.play()}},_afterZoomOut:function(){G.trigger("afterClose");G.wrap.trigger("onReset").remove();I.extend(G,{group:{},opts:{},current:null,isOpened:false,isOpen:false,wrap:null,outer:null,inner:null})}});G.transitions={getOrigPosition:function(){var K=G.current.element,N={},L=50,F=50,M,D;if(K&&K.nodeName&&I(K).is(":visible")){M=I(K).find("img:first");if(M.length){N=M.offset();L=M.outerWidth();F=M.outerHeight()}else{N=I(K).offset()}}else{D=G.getViewport();N.top=D.y+(D.h-F)*0.5;N.left=D.x+(D.w-L)*0.5}N={top:Math.ceil(N.top)+"px",left:Math.ceil(N.left)+"px",width:Math.ceil(L)+"px",height:Math.ceil(F)+"px"};return N},step:function(F,L){var K,D,M;if(L.prop==="width"||L.prop==="height"){D=M=Math.ceil(F-(G.current.padding*2));if(L.prop==="height"){K=(F-L.start)/(L.end-L.start);if(L.start>L.end){K=1-K}D-=G.innerSpace*K;M-=G.outerSpace*K}G.inner[L.prop](D);G.outer[L.prop](M)}},zoomIn:function(){var K=G.wrap,M=G.current,F,D,L=M.dim;if(M.openEffect==="elastic"){D=I.extend({},L,G._getPosition(true));delete D.position;F=this.getOrigPosition();if(M.openOpacity){F.opacity=0;D.opacity=1}K.css(F).show().animate(D,{duration:M.openSpeed,easing:M.openEasing,step:this.step,complete:G._afterZoomIn})}else{K.css(I.extend({},L,G._getPosition()));if(M.openEffect==="fade"){K.fadeIn(M.openSpeed,G._afterZoomIn)}else{K.show();G._afterZoomIn()}}},zoomOut:function(){var F=G.wrap,K=G.current,D;if(K.closeEffect==="elastic"){if(F.css("position")==="fixed"){F.css(G._getPosition(true))}D=this.getOrigPosition();if(K.closeOpacity){D.opacity=0}F.animate(D,{duration:K.closeSpeed,easing:K.closeEasing,step:this.step,complete:G._afterZoomOut})}else{F.fadeOut(K.closeEffect==="fade"?K.closeSpeed:0,G._afterZoomOut)}},changeIn:function(){var F=G.wrap,K=G.current,D;if(K.nextEffect==="elastic"){D=G._getPosition(true);D.opacity=0;D.top=(parseInt(D.top,10)-200)+"px";F.css(D).show().animate({opacity:1,top:"+=200px"},{duration:K.nextSpeed,complete:G._afterZoomIn})}else{F.css(G._getPosition());if(K.nextEffect==="fade"){F.hide().fadeIn(K.nextSpeed,G._afterZoomIn)}else{F.show();G._afterZoomIn()}}},changeOut:function(){var D=G.wrap,K=G.current,F=function(){I(this).trigger("onReset").remove()};D.removeClass("fancybox-opened");if(K.prevEffect==="elastic"){D.animate({opacity:0,top:"+=200px"},{duration:K.prevSpeed,complete:F})}else{D.fadeOut(K.prevEffect==="fade"?K.prevSpeed:0,F)}}};G.helpers.overlay={overlay:null,update:function(){var K,D,F;this.overlay.width(0).height(0);if(I.browser.msie){D=Math.max(E.documentElement.scrollWidth,E.body.scrollWidth);F=Math.max(E.documentElement.offsetWidth,E.body.offsetWidth);K=D<F?C.width():D}else{K=J.width()}this.overlay.width(K).height(J.height())},beforeShow:function(D){if(this.overlay){return }this.overlay=I('<div id="fancybox-overlay"></div>').css(D.css||{background:"black"}).appendTo("body");this.update();if(D.closeClick){this.overlay.bind("click.fb",G.close)}C.bind("resize.fb",I.proxy(this.update,this));this.overlay.fadeTo(D.speedIn||"fast",D.opacity||1)},onUpdate:function(){this.update()},afterClose:function(D){if(this.overlay){this.overlay.fadeOut(D.speedOut||"fast",function(){I(this).remove()})}this.overlay=null}};G.helpers.title={beforeShow:function(D){var K,F=G.current.title;if(F){K=I('<div class="fancybox-title fancybox-title-'+D.type+'-wrap">'+F+"</div>").appendTo("body");if(D.type==="float"){K.width(K.width());K.wrapInner('<span class="child"></span>');G.current.margin[2]+=Math.abs(parseInt(K.css("margin-bottom"),10))}K.appendTo(D.type==="over"?G.inner:(D.type==="outside"?G.wrap:G.outer))}}};I.fn.fancybox=function(F){var K=F||{},D=this.selector||"";function L(P){var O=[],N,Q,M=this.rel;if(!(P.ctrlKey||P.altKey||P.shiftKey||P.metaKey)){P.preventDefault();Q=I(this).data("fancybox-group");if(typeof Q!=="undefined"){N=Q?"data-fancybox-group":false}else{if(M&&M!==""&&M!=="nofollow"){Q=M;N="rel"}}if(N){O=D.length?I(D).filter("["+N+'="'+Q+'"]'):I("["+N+'="'+Q+'"]')}if(O.length){K.index=O.index(this);G.open(O.get(),K)}else{G.open(this,K)}}}if(D){J.undelegate(D,"click.fb-start").delegate(D,"click.fb-start",L)}else{I(this).unbind("click.fb-start").bind("click.fb-start",L)}return this}}(window,document,jQuery));
