/* Copyright (C) YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

/*
 Lightbox Plugin is based on Fancybox (http://fancybox.net, Janis Skarnelis, MIT License)
*/
(function(d){var k,n,v,r,f,F,l,E,j,A,B,G,s=0,c={},p=[],q=0,a={},m=[],C=null,w=new Image,H,I=1,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,M=/[^\.]\.(swf)\s*$/i,K=/(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,N=/youtu\.be\/(.*)/,L=/(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/,O=/\.(mp4|ogv|webm|flv)(.*)?$/i,z=0,x="",u,g,h=!1,D=d.extend(d("<div/>")[0],{prop:0});_abort=function(){v.hide();w.onerror=w.onload=null;C&&C.abort();n.empty()};_error=function(){!1===c.onError(p,s,c)?(v.hide(),h=!1):(c.titleShow=!1,c.width=
"auto",c.height="auto",n.html('<p id="lightbox-error">The requested content cannot be loaded.<br />Please try again later.</p>'),_process_inline())};_start=function(){var b=p[s],e,a,f,g,j,t;_abort();c=d.extend({},k.defaults,"undefined"==typeof d(b).data(k.name)?c:d(b).data(k.name));d(b).attr("data-lightbox")&&d.each(d(b).attr("data-lightbox").split(";"),function(b,a){var e=a.match(/\s*([A-Z_]*?)\s*:\s*(.+)\s*/i);if(e&&(c[e[1]]=e[2],"true"===c[e[1]]||"false"===c[e[1]]))c[e[1]]=eval(e[2])});t=c.onStart(p,
s,c);if(!1===t)h=!1;else{"object"==typeof t&&(c=d.extend(c,t));f=c.title||(b.nodeName?d(b).attr("title"):b.title)||"";b.nodeName&&!c.orig&&(c.orig=d(b).children("img:first").length?d(b).children("img:first"):d(b));""===f&&(c.orig&&c.titleFromAlt)&&(f=c.orig.attr("alt"));e=c.href||(b.nodeName?d(b).attr("href"):b.href)||null;if(/^(?:javascript)/i.test(e)||"#"==e)e=null;c.type?(a=c.type,e||(e=c.content)):c.content?a="html":e&&(e.match(J)?a="image":e.match(M)?a="swf":e.match(O)?a="video":e.match(K)?(e=
e.replace(K,"$1/embed/$2?$3").replace("/(.*)?$/",""),a="iframe"):e.match(N)?(a=e.split("/"),e="//www.youtube.com/embed/"+a[a.length-1],a="iframe"):e.match(L)?(e=e.replace(L,"$1player.vimeo.com/video/$2"),a="iframe"):a=-1!=e.indexOf("http://")&&-1==e.indexOf(location.hostname.toLowerCase())?"iframe":0===e.indexOf("#wk-")?window.wk_ajax_render_url?"widget":!1:0===e.indexOf("#")?"inline":"ajax");if(a)switch("inline"==a&&(b=e.substr(e.indexOf("#")),a=0<d(b).length?"inline":"ajax"),c.type=a,c.href=e,c.title=
f,c.autoDimensions&&("iframe"!==c.type&&"swf"!==c.type&&"video"!==c.type&&"widget"!==c.type)&&(c.width="auto",c.height="auto"),c.modal&&(c.overlayShow=!0,c.hideOnOverlayClick=!1,c.hideOnContentClick=!1,c.enableEscapeButton=!1,c.showCloseButton=!1),c.padding=parseInt(c.padding,10),c.margin=parseInt(c.margin,10),n.css("padding",c.padding+c.margin),d(".lightbox-inline-tmp").unbind("lightbox-cancel").bind("lightbox-change",function(){d(this).replaceWith(l.children())}),a){case "html":n.html(c.content);
_process_inline();break;case "video":h=!1;c.scrolling="no";var m="auto"==c.width?320:c.width,b="auto"==c.height?240:c.height;f=[];f.push('src="'+e+'"');f.push('width="'+m+'"');f.push('height="'+b+'"');f.push('preload="none"');"undefined"!=d.type(c.autoplay)&&f.push('autoplay="'+String(c.autoplay)+'"');"undefined"!=d.type(c.controls)&&f.push('controls="'+String(c.controls)+'"');"undefined"!=d.type(c.loop)&&f.push('loop="'+String(c.loop)+'"');"undefined"!=d.type(c.poster)&&f.push('poster="'+String(c.poster)+
'"');n.html("<video "+f.join(" ")+" /></video>");d.fn.mediaelementplayer&&d("video",n).each(function(){var b=new mejs.MediaElementPlayer(this);m>d(window).width()&&b.setPlayerSize("100%","100%")});c.width="auto";c.height="auto";_process_inline();break;case "inline":if(!0===d(b).parent().is("#lightbox-content")){h=!1;break}d('<div class="lightbox-inline-tmp" />').hide().insertBefore(d(b)).bind("lightbox-cleanup",function(){d(this).replaceWith(l.children())}).bind("lightbox-cancel",function(){d(this).replaceWith(n.children())});
d(b).appendTo(n);_process_inline();break;case "image":h=!1;k.showActivity();w=new Image;w.onerror=function(){_error()};w.onload=function(){h=!0;w.onerror=w.onload=null;_process_image()};w.src=e;break;case "swf":c.scrolling="no";c.autoDimensions=!1;g='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+c.width+'" height="'+c.height+'"><param name="movie" value="'+e+'"></param>';j="";d.each(c.swf,function(b,a){g+='<param name="'+b+'" value="'+a+'"></param>';j+=" "+b+'="'+a+'"'});g+=
'<embed src="'+e+'" type="application/x-shockwave-flash" width="'+c.width+'" height="'+c.height+'"'+j+"></embed></object>";n.html(g);_process_inline();break;case "ajax":h=!1;k.showActivity();c.ajax.win=c.ajax.success;C=d.ajax(d.extend({},c.ajax,{url:e,data:c.ajax.data||{},error:function(b){0<b.status&&_error()},success:function(b,a,d){if(200==("object"==typeof d?d:C).status){if("function"==typeof c.ajax.win){t=c.ajax.win(e,b,a,d);if(!1===t){v.hide();return}if("string"==typeof t||"object"==typeof t)b=
t}n.html(b);_process_inline()}}}));break;case "widget":h=!1;c.autoDimensions=!1;k.showActivity();c.ajax.win=c.ajax.success;C=d.ajax(d.extend({},c.ajax,{url:wk_ajax_render_url(e.split("-")[1]),data:c.ajax.data||{},error:function(b){0<b.status&&_error()},success:function(b,a,f){if(200==("object"==typeof f?f:C).status){if("function"==typeof c.ajax.win){t=c.ajax.win(e,b,a,f);if(!1===t){v.hide();return}if("string"==typeof t||"object"==typeof t)b=t}n.html(b);_process_inline();$widgetkit.lazyload(d("#lightbox-content"))}}}));
break;case "iframe":c.autoDimensions=!1,_show()}else _error()}};_process_inline=function(){n.wrapInner('<div style="width:'+("auto"==c.width?"auto":c.width+"px")+";height:"+("auto"==c.height?"auto":c.height+"px")+";overflow: "+("auto"==c.scrolling?"auto":"yes"==c.scrolling?"scroll":"hidden")+'"></div>');c.width=n.width();c.height=n.height();_show()};_process_image=function(){c.width=w.width;c.height=w.height;d("<img />").attr({id:"lightbox-img",src:w.src,alt:c.title}).appendTo(n);_show()};_show=function(){var b,
e;v.hide();f.is(":visible")&&!1===a.onCleanup(m,q,a)?(d(".lightbox-inline-tmp").trigger("lightbox-cancel"),h=!1):(h=!0,d(l.add(r)).unbind(),d(window).unbind("resize.fb scroll.fb"),d(document).unbind("keydown.fb"),f.is(":visible")&&"outside"!==a.titlePosition&&f.css("height",f.height()),m=p,q=s,a=c,a.overlayShow?(r.css({"background-color":a.overlayColor,opacity:a.overlayOpacity,cursor:a.hideOnOverlayClick?"pointer":"auto",height:d(document).height()}),r.is(":visible")||r.show()):r.hide(),g=_get_zoom_to(),
_process_title(),f.is(":visible")?(d(E.add(A).add(B)).hide(),b=f.position(),u={top:b.top,left:b.left,width:f.width(),height:f.height()},e=u.width==g.width&&u.height==g.height,l.fadeTo(a.changeFade,0.3,function(){var b=function(){l.html(n.contents()).fadeTo(a.changeFade,1,_finish)};d(".lightbox-inline-tmp").trigger("lightbox-change");l.empty().removeAttr("filter").css({"border-width":a.padding,width:g.width-2*a.padding,height:"image"==a.type||"swf"==a.type||"iframe"==a.type?g.height-z-2*a.padding:
"auto"});e?b():(D.prop=0,d(D).animate({prop:1},{duration:a.changeSpeed,easing:a.easingChange,step:_draw,complete:b}))})):(f.removeAttr("style"),l.css("border-width",a.padding),l.css("-webkit-transform","translateZ(0)"),"elastic"==a.transitionIn?(u=_get_zoom_from(),l.html(n.contents()),f.show(),a.opacity&&(g.opacity=0),D.prop=0,d(D).animate({prop:1},{duration:a.speedIn,easing:a.easingIn,step:_draw,complete:_finish})):("inside"==a.titlePosition&&0<z&&j.show(),l.css({width:g.width-2*a.padding,height:"image"==
a.type||"swf"==a.type||"iframe"==a.type?g.height-z-2*a.padding:"auto"}).html(n.contents()),f.css(g).fadeIn("none"==a.transitionIn?0:a.speedIn,_finish))))};_format_title=function(b){return b&&b.length?'<div id="lightbox-title-'+a.titlePosition+'">'+b+"</div>":!1};_process_title=function(){x=a.title||"";z=0;j.empty().removeAttr("style").removeClass();if(!1!==a.titleShow&&(x=d.isFunction(a.titleFormat)?a.titleFormat(x,m,q,a):_format_title(x))&&""!==x)switch(j.addClass("lightbox-title-"+a.titlePosition).html(x).appendTo("body").show(),
a.titlePosition){case "inside":j.css({width:g.width-2*a.padding,marginLeft:a.padding,marginRight:a.padding});z=j.outerHeight(!0);j.appendTo(F);g.height+=z;break;case "over":j.css({marginLeft:a.padding,width:g.width-2*a.padding,bottom:a.padding}).appendTo(F);break;case "float":j.css("left",-1*parseInt((j.width()-g.width-40)/2,10)).appendTo(f);break;default:j.css({width:g.width-2*a.padding,paddingLeft:a.padding,paddingRight:a.padding}).appendTo(f)}j.hide()};_set_navigation=function(){(a.enableEscapeButton||
a.enableKeyboardNav)&&d(document).bind("keydown.fb",function(b){if(27==b.keyCode&&a.enableEscapeButton)b.preventDefault(),k.close();else if((37==b.keyCode||39==b.keyCode)&&a.enableKeyboardNav&&"INPUT"!==b.target.tagName&&"TEXTAREA"!==b.target.tagName&&"SELECT"!==b.target.tagName)b.preventDefault(),k[37==b.keyCode?"prev":"next"]()});a.showNavArrows?((a.cyclic&&1<m.length||0!==q)&&A.show(),(a.cyclic&&1<m.length||q!=m.length-1)&&B.show()):(A.hide(),B.hide())};_finish=function(){d.support.opacity||(l.get(0).style.removeAttribute("filter"),
f.get(0).style.removeAttribute("filter"));f.css("height","auto");"image"!==a.type&&("swf"!==a.type&&"iframe"!==a.type)&&l.css("height","auto");x&&x.length&&j.show();a.showCloseButton&&E.show();_set_navigation();a.hideOnContentClick&&l.bind("click",k.close);a.hideOnOverlayClick&&r.bind("click",k.close);d(window).bind("resize.fb",k.resize);a.centerOnScroll&&d(window).bind("scroll.fb",k.center);"iframe"==a.type&&d('<iframe id="lightbox-frame" name="lightbox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" '+
(!d.support.opacity?'allowtransparency="true""':"")+' scrolling="'+c.scrolling+'" src="'+a.href+'"></iframe>').appendTo(l);f.show();h=!1;k.center();a.onComplete(m,q,a);_preload_images()};_preload_images=function(){var b,a;m.length-1>q&&(b=m[q+1].href,"undefined"!==typeof b&&b.match(J)&&(a=new Image,a.src=b));0<q&&(b=m[q-1].href,"undefined"!==typeof b&&b.match(J)&&(a=new Image,a.src=b))};_draw=function(b){var e={width:parseInt(u.width+(g.width-u.width)*b,10),height:parseInt(u.height+(g.height-u.height)*
b,10),top:parseInt(u.top+(g.top-u.top)*b,10),left:parseInt(u.left+(g.left-u.left)*b,10)};"undefined"!==typeof g.opacity&&(e.opacity=0.5>b?0.5:b);f.css(e);l.css({width:e.width-2*a.padding,height:e.height-z*b-2*a.padding})};_get_viewport=function(){return[d(window).width()-2*a.margin,d(window).height()-2*a.margin,d(document).scrollLeft()+a.margin,d(document).scrollTop()+a.margin]};_get_zoom_to=function(){var b=_get_viewport(),e={},d=a.autoScale,f=2*a.padding;e.width=-1<a.width.toString().indexOf("%")?
parseInt(b[0]*parseFloat(a.width)/100,10):parseInt(a.width)+f;e.height=-1<a.height.toString().indexOf("%")?parseInt(b[1]*parseFloat(a.height)/100,10):parseInt(a.height)+f;if(d&&(e.width>b[0]||e.height>b[1]))"image"==c.type||"swf"==c.type?(d=a.width/a.height,e.width>b[0]&&(e.width=b[0],e.height=parseInt((e.width-f)/d+f,10)),e.height>b[1]&&(e.height=b[1],e.width=parseInt((e.height-f)*d+f,10))):(e.width=Math.min(e.width,b[0]),e.height=Math.min(e.height,b[1]));e.top=parseInt(Math.max(b[3]-20,b[3]+0.5*
(b[1]-e.height-40)),10);e.left=parseInt(Math.max(b[2]-20,b[2]+0.5*(b[0]-e.width-40)),10);return e};_get_obj_pos=function(b){var a=b.offset();a.top+=parseInt(b.css("paddingTop"),10)||0;a.left+=parseInt(b.css("paddingLeft"),10)||0;a.top+=parseInt(b.css("border-top-width"),10)||0;a.left+=parseInt(b.css("border-left-width"),10)||0;a.width=b.width();a.height=b.height();return a};_get_zoom_from=function(){var b=c.orig?d(c.orig):!1,e={};b&&b.length?(b=_get_obj_pos(b),e={width:b.width+2*a.padding,height:b.height+
2*a.padding,top:b.top-a.padding-20,left:b.left-a.padding-20}):(b=_get_viewport(),e={width:2*a.padding,height:2*a.padding,top:parseInt(b[3]+0.5*b[1],10),left:parseInt(b[2]+0.5*b[0],10)});return e};_animate_loading=function(){v.is(":visible")?(d("div",v).css("top",-40*I+"px"),I=(I+1)%12):clearInterval(H)};var y=function(){};y.prototype=d.extend(y.prototype,{name:"lightbox",defaults:{padding:10,margin:40,opacity:!1,modal:!1,cyclic:!1,scrolling:"auto",width:560,height:340,autoScale:!0,autoDimensions:!0,
centerOnScroll:!1,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:!0,hideOnContentClick:!1,overlayShow:!0,overlayOpacity:0.7,overlayColor:"#777",titleShow:!0,titlePosition:"float",titleFormat:null,titleFromAlt:!1,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",easingOut:"swing",showCloseButton:!0,showNavArrows:!0,enableEscapeButton:!0,enableKeyboardNav:!0,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},
onClosed:function(){},onError:function(){}},init:function(){var b=this;d("#lightbox-wrap").length||(d("body").append(n=d('<div id="lightbox-tmp"></div>'),v=d('<div id="lightbox-loading"><div></div></div>'),r=d('<div id="lightbox-overlay"></div>'),f=d('<div id="lightbox-wrap"></div>')),G=r.show().position(),r.hide(),0!=G.top&&r.css("top",-1*G.top),F=d('<div id="lightbox-outer"></div>').appendTo(f),F.append(l=d('<div id="lightbox-content"></div>'),E=d('<a id="lightbox-close"></a>'),j=d('<div id="lightbox-title"></div>'),
A=d('<a href="javascript:;" id="lightbox-left"><span id="lightbox-left-ico"></span></a>'),B=d('<a href="javascript:;" id="lightbox-right"><span id="lightbox-right-ico"></span></a>')),E.bind("click",this.close),v.bind("click",this.cancel),A.bind("click",function(a){a.preventDefault();b.prev()}),B.bind("click",function(a){a.preventDefault();b.next()}),d.fn.mousewheel&&f.bind("mousewheel.fb",function(d,c){(h||"image"==a.type)&&d.preventDefault();b[0<c?"prev":"next"]()}),"ontouchend"in document&&(f.bind("touchstart",
function(a){function b(a){if(g){var c=a.originalEvent.touches?a.originalEvent.touches[0]:a;h={time:(new Date).getTime(),coords:[c.pageX,c.pageY]};10<Math.abs(g.coords[0]-h.coords[0])&&a.preventDefault()}}var c=a.originalEvent.touches?a.originalEvent.touches[0]:a,g={time:(new Date).getTime(),coords:[c.pageX,c.pageY],origin:d(a.target)},h;f.bind("touchmove",b).one("touchend",function(){f.unbind("touchmove",b);g&&h&&1E3>h.time-g.time&&(30<Math.abs(g.coords[0]-h.coords[0])&&75>Math.abs(g.coords[1]-h.coords[1]))&&
g.origin.trigger("swipe").trigger(g.coords[0]>h.coords[0]?"swipeleft":"swiperight");g=h=void 0})}),f.bind("swipeleft",function(c){(h||"image"==a.type)&&c.preventDefault();b.next()}).bind("swiperight",function(c){(h||"image"==a.type)&&c.preventDefault();b.prev()})))},open:function(a,c){var f;if(!h){h=!0;f="undefined"!==typeof c?c:{};p=[];s=parseInt(f.index,10)||0;if(d.isArray(a)){for(var g=0,j=a.length;g<j;g++)"object"==typeof a[g]?d(a[g]).data(k.name,d.extend({},f,a[g])):a[g]=d({}).data(k.name,d.extend({content:a[g]},
f));p=d.merge(p,a)}else"object"==typeof a?d(a).data(k.name,d.extend({},f,a)):a=d({}).data(k.name,d.extend({content:a},f)),p.push(a);if(s>p.length||0>s)s=0;_start()}},showActivity:function(){clearInterval(H);v.show();H=setInterval(_animate_loading,66)},hideActivity:function(){v.hide()},next:function(){return this.pos(q+1)},prev:function(){return this.pos(q-1)},pos:function(b){h||(b=parseInt(b),p=m,-1<b&&b<m.length?(s=b,_start()):a.cyclic&&1<m.length&&(s=b>=m.length?0:m.length-1,_start()))},cancel:function(){h||
(h=!0,d(".lightbox-inline-tmp").trigger("lightbox-cancel"),_abort(),c.onCancel(p,s,c),h=!1)},close:function(){function b(){r.fadeOut("fast");j.empty().hide();f.hide();d(".lightbox-inline-tmp").trigger("lightbox-cleanup");l.empty();a.onClosed(m,q,a);m=c=[];q=s=0;a=c={};h=!1}if(!h&&!f.is(":hidden"))if(h=!0,a&&!1===a.onCleanup(m,q,a))h=!1;else if(_abort(),d(E.add(A).add(B)).hide(),d(l.add(r)).unbind(),d(window).unbind("resize.fb scroll.fb"),d(document).unbind("keydown.fb"),l.find("iframe").attr("src",
"about:blank"),"inside"!==a.titlePosition&&j.empty(),f.stop(),"elastic"==a.transitionOut){u=_get_zoom_from();var e=f.position();g={top:e.top,left:e.left,width:f.width(),height:f.height()};a.opacity&&(g.opacity=1);j.empty().hide();D.prop=1;d(D).animate({prop:0},{duration:a.speedOut,easing:a.easingOut,step:_draw,complete:b})}else f.fadeOut("none"==a.transitionOut?0:a.speedOut,b)},resize:function(){r.is(":visible")&&r.css("height",d(document).height());g=_get_zoom_to();switch(a.titlePosition){case "float":j.css("left",
-1*parseInt((j.width()-g.width-40)/2,10));break;default:j.css("width",g.width-2*a.padding)}k.center(!0)},center:function(b){var c,d;if(!h&&(d=!0===b?1:0,c=_get_viewport(),d||!(f.width()>c[0]||f.height()>c[1])))f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+0.5*(c[1]-l.height()-40)-a.padding)),left:parseInt(Math.max(c[2]-20,c[2]+0.5*(c[0]-l.width()-40)-a.padding))},"number"==typeof b?b:200)}});d.fn[y.prototype.name]=function(){var a=arguments,c=a[0]?a[0]:{};return this.each(function(){d(this).data(y.prototype.name,
c).unbind("click."+y.prototype.name).bind("click."+y.prototype.name,function(a){a.preventDefault();h||(h=!0,d(this).blur(),p=[],s=0,(a=d(this).attr("data-lightbox")||"")&&(a=a.match(/group:([^;]+)/i))?(p=d('a[data-lightbox*="'+a[0]+'"], area[data-lightbox*="'+a[0]+'"]'),s=p.index(this)):p.push(this),_start())})})};d(document).ready(function(){k=new y;k.init();d[y.prototype.name]=k})})(jQuery);
