/**
 * @package		CeraBox
 *
 * @author 		Sven
 * @since 		13-01-2011
 * @version 	1.3.2
 *
 * This package requires
 * - MooTools 1.4 >
 * - MooTools More Assets
 *
 * @license The MIT License
 *
 * Copyright (c) 2011-2012 Ceramedia, <http://ceramedia.net/>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
var CeraBox=CeraBox||new Class({version:"1.3.2",Implements:[Options],boxWindow:null,collection:[],currentItem:0,options:{ajax:null,group:true,width:null,height:null,displayTitle:true,fullSize:false,displayOverlay:true,clickToClose:false,loaderAtItem:false,animation:"fade",errorLoadingMessage:"The requested content cannot be loaded or might not be supported. Please try again later.",titleFormat:"{number} / {total} {title}",addContentProtectionLayer:false,mobileView:Browser.Platform.ios||Browser.Platform.android||Browser.Platform.webos,events:{onOpen:function(a,b){},onChange:function(a,b){},onClose:function(a,b){},onAnimationEnd:function(a,b){}}},initialize:function(b,a){this.boxWindow=CeraBoxWindow;b=$$(b);if(a&&typeOf(a.group)!="null"&&a.group===false&&b.length>1){b.each(function(c){c.store("cerabox",new CeraBox(c,a))})}this.setOptions(a);b.each(function(e,c){this.collection[c]=e;var d=e.dataset?(typeOf(e.dataset.type)=="string"&&e.dataset.type.trim()!=""?e.dataset.type.trim():null):(e.get("data-type")&&e.get("data-type").trim()!=""?e.get("data-type").trim():null);if((null!==this.options.ajax&&d===null)||d=="ajax"){e.addEvent("click",function(f){if(this._itemClick(f)){this.currentItem=c;this.showAjax();return true}return false}.bind(this))}else{if((e.get("href").test(/^#/i)&&d===null)||d=="inline"){e.addEvent("click",function(f){if(this._itemClick(f)){this.currentItem=c;this.showInline();return true}return false}.bind(this))}else{if((e.get("href").test(/\.(jpg|jpeg|png|gif|bmp)(.*)?$/i)&&d===null)||d=="image"){e.addEvent("click",function(f){if(this._itemClick(f)){this.currentItem=c;this.showImage();return true}return false}.bind(this))}else{if((e.get("href").test(/\.(swf)(.*)?$/i)&&d===null)||d=="swf"){e.addEvent("click",function(f){if(this._itemClick(f)){this.currentItem=c;this.showSwf();return true}return false}.bind(this))}else{if(d!==null&&d!="iframe"){throw"Unknown type in dataset: "+d}e.addEvent("click",function(f){if(this._itemClick(f)){this.currentItem=c;this.showIframe();return true}return false}.bind(this))}}}}}.bind(this))},showAjax:function(){var ceraBox=this,currentItem=ceraBox.collection[ceraBox.currentItem],requestEr=new Request.HTML({url:currentItem.get("href"),method:ceraBox.options.ajax.method?ceraBox.options.ajax.method:"post",data:ceraBox.options.ajax.data?ceraBox.options.ajax.data:"",evalScripts:ceraBox.options.ajax.evalScripts?ceraBox.options.ajax.evalScripts:false,onSuccess:function(responseTree,responseElements,responseHTML,responseJavaScript){if(false===ceraBox.boxWindow.getBusy()){return}var assets=[null];Array.each(responseElements,function(ele){if(ele.get("tag")=="img"&&ele.get("src")){assets.append([ele.get("src")])}});Asset.images(assets,{onComplete:function(){var ajaxEle=ceraBox.boxWindow.preLoadElement(responseTree);ajaxEle.setStyle("width",ceraBox.options.width?ceraBox.options.width:ajaxEle.getScrollSize().x+"px");ajaxEle.setStyle("height",ceraBox.options.height?ceraBox.options.height:ajaxEle.getScrollSize().y+"px");var dimension=ceraBox.boxWindow.getSizeElement(ajaxEle);ajaxEle=ajaxEle.get("html");ceraBox.boxWindow.onLoad(dimension.width,dimension.height).addEvent("complete",function(){this.removeEvents("complete");if(false===ceraBox.boxWindow.getBusy()){return}if(false!==ceraBox.options.displayTitle){ceraBox.boxWindow.displayTitle((currentItem.get("title")?currentItem.get("title"):""),ceraBox.currentItem+1,ceraBox.collection.length)}ceraBox.boxWindow.setContent(new Element("div",{html:ajaxEle})).openWindow();(function(){eval(responseJavaScript)}).call(ceraBox)})}})},onerror:ceraBox._timedOut.bind(ceraBox),onTimeout:ceraBox._timedOut.bind(ceraBox),onFailure:ceraBox._timedOut.bind(ceraBox),onException:ceraBox._timedOut.bind(ceraBox)}).send()},showInline:function(){var b=this,a=b.collection[b.currentItem],d=(a.get("href").test(/^#\$/i)&&typeOf(window[a.get("href").replace(/^#\$/i,"")])!="null")?((typeOf(window[a.get("href").replace(/^#\$/i,"")])!="element")?new Element("div",{html:window[a.get("href").replace(/^#\$/i,"")]}):window[a.get("href").replace(/^#\$/i,"")]):(document.id(document.body).getElement(a.get("href"))?document.id(document.body).getElement(a.get("href")).clone():null);if(null!==d){var c=[null];Array.each(d.getElements("img"),function(e){if(e.get("src")){c.append([e.get("src")])}});Asset.images(c,{onComplete:function(){var e=b.boxWindow.preLoadElement(d.clone());e.setStyle("width",b.options.width?b.options.width:e.getScrollSize().x+"px");e.setStyle("height",b.options.height?b.options.height:e.getSize().y+"px");var f=b.boxWindow.getSizeElement(e);b.boxWindow.onLoad(f.width,f.height).addEvent("complete",function(){this.removeEvents("complete");if(false===b.boxWindow.getBusy()){return}if(false!==b.options.displayTitle){b.boxWindow.displayTitle((a.get("title")?a.get("title"):""),b.currentItem+1,b.collection.length)}b.boxWindow.setContent(d).openWindow()})}})}else{b._timedOut()}},showImage:function(){var b=this,a=b.collection[b.currentItem],c=new Asset.image(a.get("href"),{"class":"image",onload:function(){if(false===b.boxWindow.getBusy()){return}this.set("width",b.options.width?b.options.width:this.get("width"));this.set("height",b.options.height?b.options.height:this.get("height"));var d=b.boxWindow.getSizeElement(this);b.boxWindow.onLoad(d.width,d.height).addEvent("complete",function(){this.removeEvents("complete");if(false===b.boxWindow.getBusy()){return}if(false!==b.options.displayTitle){b.boxWindow.displayTitle((a.get("title")?a.get("title"):""),b.currentItem+1,b.collection.length)}b.boxWindow.setContent(c).openWindow()})},onerror:b._timedOut.bind(b)})},showSwf:function(){if(Browser.Plugins.Flash.version==0){this._timedOut();return}var c=this,b=c.collection[c.currentItem],d={width:c.options.width?c.options.width:500,height:c.options.height?c.options.height:400},a=new Swiff(b.get("href"),{width:d.width,height:d.height,params:{wMode:"opaque"}});c.boxWindow.onLoad(d.width,d.height).addEvent("complete",function(){this.removeEvents("complete");if(false===c.boxWindow.getBusy()){return}if(false!==c.options.displayTitle){c.boxWindow.displayTitle((b.get("title")?b.get("title"):""),c.currentItem+1,c.collection.length)}c.boxWindow.setContent(a).openWindow()})},showIframe:function(){this.boxWindow.setTimeOuter(this._timedOut.delay(10000,this));var c=this,b=c.collection[c.currentItem],a=new IFrame({src:b.get("href"),"class":"iframe",styles:{width:1,height:1,border:"0px"},events:{load:function(){if(false===c.boxWindow.getBusy()&&!c.boxWindow.getWindowOpen()){return}this.setStyles({width:c.options.width?c.options.width:"1px",height:c.options.height?c.options.height:"1px",border:0});var d=c.boxWindow.getSizeElement(this);c.boxWindow.onLoad(d.width,d.height).addEvent("complete",function(){this.removeEvents("complete");if(false===c.boxWindow.getBusy()&&!c.boxWindow.getWindowOpen()){return}c.boxWindow.openWindow()})}}});a.set("border",0);a.set("frameborder",0);this.boxWindow.setContent(a)},_timedOut:function(){var b=this,a=new Element("span",{"class":"cerabox-error",html:b.options.errorLoadingMessage});var d=b.boxWindow.preLoadElement(a.clone());d.setStyle("width","270px");d.setStyle("height",d.getSize().y+"px");var c=b.boxWindow.getSizeElement(d,true);b.boxWindow.onLoad(c.width,c.height).addEvent("complete",function(){this.removeEvents("complete");if(false===b.boxWindow.getBusy()){return}b.boxWindow.hideTitle();b.boxWindow.setContent(a).openWindow()})},_itemClick:function(a){if(a){a.preventDefault()}if(this.boxWindow.getBusy()){return false}this.boxWindow.loading(this);return true},_log:function(a,c){try{console.log(a)}catch(b){if(c){alert(a)}}}});var CeraBoxWindow=(function(j){var x=false,z=false,C=null,u=null,l=false,k=null,A={x:0,y:0},t=null,E={x:null,y:null},q={x:null,y:null},w={x:0,y:0},p=null;var e=new Class({initialize:function(){j.addEvent("domready",function(){m();this.updateWindow();document.id("cerabox-loading").addEvent("click",function(F){F.stop();this.close(true)}.bind(this));document.addEvent("keyup",function(F){if(F.key=="esc"){this.close()}if(F.target.get("tag")=="input"||F.target.get("tag")=="select"||F.target.get("tag")=="textarea"){return}if(F.key=="left"){p.getElement(".cerabox-left").fireEvent("click",F)}if(F.key=="right"){p.getElement(".cerabox-right").fireEvent("click",F)}}.bind(this));p.addEvent("touchstart",c);p.addEvent("touchmove",s);p.addEvent("touchend",h);p.addEvent("touchcancel",i);document.id("cerabox-loading").addEvent("touchmove",function(F){F.stop()})}.bind(this));j.addEvent("resize",this.updateWindow.bind(this));j.addEvent("scroll",this.updateWindow.bind(this,"scroll"));j.addEvent("orientationchange",this.updateWindow.bind(this))},updateWindow:function(F){this.setViewport();if(!l||null===k||x||(F=="scroll"&&!k.options.mobileView)){return}x=true;if(false!==k.options.displayOverlay||k.options.mobileView){f()}r().addEvent("complete",function(){this.removeEvents("complete");o();x=false})},close:function(F){if((x&&!F)||z||!k){return}x=!F;clearInterval(u);clearInterval(C);clearInterval(t);document.id("cerabox-loading").setStyle("display","none");if(k.options.mobileView){document.id("cerabox-background").setStyles({display:"none",width:0,height:0,opacity:0});p.setStyles({display:"none"});p.getElement(".cerabox-content").empty().setStyle("opacity",0);p.getElement(".cerabox-left").removeEvents("click").setStyle("display","none");p.getElement(".cerabox-right").removeEvents("click").setStyle("display","none");this.hideTitle();if(l){k.options.events.onClose.call(k,k.collection[k.currentItem],k.collection)}k=null;l=false;x=false}else{p.set("tween",{duration:50}).tween("opacity",0).get("tween").addEvent("complete",function(){this.removeEvents("complete");document.id("cerabox-background").set("tween",{duration:50,link:"chain"}).tween("opacity",0).tween("display","none").get("tween").addEvent("chainComplete",function(){this.removeEvents("chainComplete");p.setStyles({display:"none"});p.getElement(".cerabox-content").empty().setStyle("opacity",0);p.getElement(".cerabox-left").removeEvents("click").setStyle("display","none");p.getElement(".cerabox-right").removeEvents("click").setStyle("display","none");b.hideTitle();if(l){k.options.events.onClose.call(k,k.collection[k.currentItem],k.collection)}k=null;l=false;x=false})})}},setContent:function(F){p.getElement(".cerabox-content").empty().adopt(F);return this},loading:function(F){if(!instanceOf(F,CeraBox)){throw"Instance should be an instance of CeraBox"}this.setViewport();k=F;x=true;p.getElement(".cerabox-content-protection").setStyle("display","none");if(true===k.options.addContentProtectionLayer){p.getElement(".cerabox-content-protection").setStyle("display","block")}p.setStyle("cursor","auto").removeEvents("click");if(true===k.options.clickToClose){p.setStyle("cursor","pointer").addEvent("click",function(G){G.stop();this.close()}.bind(this))}clearInterval(u);clearInterval(C);document.id("cerabox-loading").setStyle("display","none");C=a.delay(200);p.removeClass("mobile");if(k.options.mobileView){p.addClass("mobile")}return this},preLoadElement:function(F){p.setStyle("display","block");return p.getElement("#cerabox-ajaxPreLoader").empty().adopt(F)},onLoad:function(G,F){z=true;clearInterval(u);clearInterval(C);if(false!==k.options.displayOverlay||k.options.mobileView){f()}p.getElement("#cerabox-ajaxPreLoader").empty().setStyles({width:"auto",height:"auto"});A={x:G,y:F};return p.getElement(".cerabox-content").set("tween",{duration:k.options.mobileView?0:300}).tween("opacity",(l&&p.getElement(".cerabox-content iframe")?1:0)).get("tween")},openWindow:function(H,F){document.id("cerabox-loading").setStyle("display","none");H=A.x=H||A.x;F=A.y=F||A.y;var G=k.collection[k.currentItem];o();if(l){r(H,F);if(k.options.mobileView){p.getElement(".cerabox-content").setStyle("opacity",1);z=false;x=false;d();k.options.events.onChange.call(k,G,k.collection)}else{p.getElement(".cerabox-content").set("tween",{duration:p.getElement(".cerabox-content iframe")?0:200}).tween("opacity",1).get("tween").addEvent("complete",function(){this.removeEvents("complete");z=false;x=false;d();k.options.events.onChange.call(k,G,k.collection)})}return}if(!k.options.mobileView){p.getElement(".cerabox-content").setStyle("opacity",1)}k.options.events.onOpen.call(k,G,k.collection);r(H,F).addEvent("complete",function(){this.removeEvents("complete");if(k.options.mobileView){p.getElement(".cerabox-content").setStyle("opacity",1)}z=false;x=false;d();k.options.events.onAnimationEnd.call(k,G,k.collection)});G.blur();l=true},displayTitle:function(H,G,F){if(F>1){H=k.options.titleFormat.substitute({number:G,total:F,title:H})}if(H){p.getElement(".cerabox-title span").setStyle("display","block").set("text",H)}else{p.getElement(".cerabox-title span").setStyle("display","block")}return this},hideTitle:function(){p.getElement(".cerabox-title span").setStyle("display","none");return this},setViewport:function(){w={x:(j.innerWidth?j.innerWidth:j.getSize().x),y:(j.innerHeight?j.innerHeight:j.getSize().y)};return this},getViewport:function(){return w},getCurrentInstance:function(){return k},getBusy:function(){return x},getWindowOpen:function(){return l},setTimeOuter:function(F){u=F;return this},getSizeElement:function(G,H){var F=0,K=0;if(G.get("tag")=="iframe"){p.setStyle("display","block");try{F=(G.get("width")?n(G.get("width"),"x"):(G.getStyle("width").toInt()>1?n(G.getStyle("width"),"x"):(G.contentWindow.document.getScrollSize().x?G.contentWindow.document.getScrollSize().x:w.x*0.75)))}catch(J){F=w.x*0.75}try{K=(G.get("height")?n(G.get("height"),"y"):(G.getStyle("height").toInt()>1?n(G.getStyle("height"),"y"):(G.contentWindow.document.getScrollSize().y?G.contentWindow.document.getScrollSize().y:w.y*0.75)))}catch(J){K=w.y*0.75}if(Browser.ie){K=K+20}if(!H&&false===k.options.fullSize){if((w.y-100)<K){F=F+(Browser.Platform.mac?15:17)}return{width:(w.x-50)<F?(w.x-50):F,height:(w.y-100)<K?(w.y-100):K}}else{return{width:F,height:K}}}F=(G.get("width")?n(G.get("width"),"x"):(G.getStyle("width")&&G.getStyle("width")!="auto"?n(G.getStyle("width"),"x"):w.x-50));K=(G.get("height")?n(G.get("height"),"y"):(G.getStyle("height")&&G.getStyle("height")!="auto"?n(G.getStyle("height"),"y"):w.y-100));if(!H&&false===k.options.fullSize){var I=Math.min(Math.min(w.x-50,F)/F,Math.min(w.y-100,K)/K);return{width:Math.round(I*F),height:Math.round(I*K)}}else{return{width:F,height:K}}}}),b=new e();function d(){p.getElement(".cerabox-left").removeEvents("click").setStyle("display","none");p.getElement(".cerabox-right").removeEvents("click").setStyle("display","none");if(k.collection[k.currentItem-1]){p.getElement(".cerabox-left").setStyle("display","block").addEvent("click",function(F){F.stopPropagation();if(!x){this.setStyle("display","none").removeEvents("click");k.collection[k.currentItem-1].fireEvent("click",F)}})}if(k.collection[k.currentItem+1]){p.getElement(".cerabox-right").setStyle("display","block").addEvent("click",function(F){F.stopPropagation();if(!x){this.setStyle("display","none").removeEvents("click");k.collection[k.currentItem+1].fireEvent("click",F)}})}}function r(G,O){G=G||A.x;O=O||A.y;if(!k.options.displayTitle||p.getElement(".cerabox-content iframe")){b.hideTitle()}if(k.options.mobileView){var L=Math.abs(j.orientation)==90,F=L?screen.height:screen.width,K,M,J,I;if(p.getElement(".cerabox-content iframe")){K=w.x,M=w.y,J=(M<(O*K/G)?M/O:K/G),I=1;p.getElements(".cerabox-close, .cerabox-left, .cerabox-right, .cerabox-title").setStyles({"-webkit-transform":"scale("+(w.x/F)+")",transform:"scale("+(w.x/F)+")"})}else{K=Math.round(w.x*(F/w.x)),M=Math.round(w.y*(F/w.x)),J=(M<(O*K/G)?M/O:K/G),I=(w.x/F);p.getElements(".cerabox-close, .cerabox-left, .cerabox-right, .cerabox-title").setStyles({"-webkit-transform":"scale(1)",transform:"scale(1)"})}p.setStyles({display:"block",width:K+"px",height:M+"px",opacity:1,left:document.id(document.body).getScroll().x,right:0,top:document.id(document.body).getScroll().y,bottom:0,margin:0,"-webkit-transform":"scale("+(I)+")",transform:"scale("+(I)+")"});p.getElement(".cerabox-content").setStyles({width:Math.round(G*J),height:Math.round(O*J),left:((K-Math.round(G*J))/2),top:((M-Math.round(O*J))/2)});if(p.getElement(".cerabox-content iframe")){p.getElement(".cerabox-content iframe").setStyles({width:Math.round(G*J),height:Math.round(O*J)})}return p.set("tween",{duration:0}).tween("opacity",1).get("tween")}else{if(p.getElement(".cerabox-content iframe")){p.getElement(".cerabox-content iframe").setStyles({width:G,height:O})}var H={display:"block",width:G,height:O,opacity:1,"-webkit-transform":"scale(1)",transform:"scale(1)"};p.setStyles({top:Math.round((w.y/2))+"px",left:Math.round((w.x/2))+"px",right:"auto",bottom:"auto"});if(w.x>G+60){H["margin-left"]=Math.round((-G/2)+document.id(document.body).getScroll().x)+"px"}else{H["margin-left"]=Math.round(((w.x/2)-G-40)+document.id(document.body).getScroll().x)+"px"}if(w.y>O+40){H["margin-top"]=Math.round((-O/2)+document.id(document.body).getScroll().y)+"px"}else{H["margin-top"]=Math.round((-w.y/2+20)+document.id(document.body).getScroll().y)+"px"}p.getElement(".cerabox-content").setStyles({width:"100%",height:"100%",left:0,top:0});if(!l){switch(k.options.animation){case"ease":var N=k.collection[k.currentItem];Object.append(H,{top:p.getStyle("top"),left:p.getStyle("left")});return p.setStyles({display:"block",left:N.getPosition().x+"px",top:N.getPosition().y+"px",width:N.getSize().x+"px",height:N.getSize().y+"px",margin:0,opacity:0}).set("morph",{duration:200}).morph(H).get("morph");break;case"fade":default:Object.append(H,{opacity:0});return p.setStyles(H).set("tween",{duration:200}).tween("opacity",1).get("tween");break}}else{return p.set("morph",{duration:150}).morph(H).get("morph")}}}function f(){var F={display:"block",opacity:k.options.mobileView?1:0.5,top:0,left:0,height:"100%",width:"100%",position:"fixed"};if(k.options.mobileView){Object.merge(F,{top:0,left:0,width:(document.id(document.body).getScrollSize().x)+"px",height:(document.id(document.body).getScrollSize().y)+"px",position:"absolute"})}document.id("cerabox-background").setStyles(F)}function a(){var G={position:"fixed",display:"block",top:"50%",left:"50%","margin-top":"-20px","margin-left":"-20px","-webkit-transform":"scale(1)",transform:"scale(1)"};if(true===k.options.loaderAtItem&&!l){var F=k.collection[k.currentItem];Object.append(G,{position:"absolute",top:Math.round(((F.getSize().y/2)-(document.id("cerabox-loading").getStyle("height").toInt()/2))+F.getPosition().y)+"px",left:Math.round(((F.getSize().x/2)-(document.id("cerabox-loading").getStyle("width").toInt()/2))+F.getPosition().x)+"px","margin-top":0,"margin-left":0})}else{if(k.options.mobileView){var I=Math.abs(j.orientation)==90,H=I?screen.height:screen.width;Object.append(G,{position:"absolute",top:Math.round(((w.y/2)-(document.id("cerabox-loading").getStyle("height").toInt()/2))+document.id(document.body).getScroll().y)+"px",left:Math.round(((w.x/2)-(document.id("cerabox-loading").getStyle("width").toInt()/2))+document.id(document.body).getScroll().x)+"px","margin-top":0,"margin-left":0,"-webkit-transform":"scale("+(w.x/H)+")",transform:"scale("+(w.x/H)+")"})}}document.id("cerabox-loading").setStyles(G);D()}function D(F){if(!F){F=0}document.id("cerabox-loading").getElement("div").setStyle("top",(F*-40)+"px");F=(F+1)%12;if(document.id("cerabox-loading").getStyle("display")!="none"){D.delay(60,this,F)}}function n(F,G){return(typeOf(F)=="string"&&F.test("%")?w[G]*(F.toInt()/100):F.toInt())}function m(){var F=document.id(document.body);if(!F.getElement("#cerabox")){F.adopt([new Element("div",{id:"cerabox-loading"}).adopt(new Element("div")),new Element("div",{id:"cerabox-background",events:{click:function(G){G.stop();b.close()}}}),p=new Element("div",{id:"cerabox"}).adopt([new Element("div",{"class":"cerabox-content"}),new Element("div",{"class":"cerabox-title"}).adopt(new Element("span")),new Element("a",{"class":"cerabox-close",events:{click:function(G){G.stop();b.close()}}}),new Element("a",{"class":"cerabox-left"}).adopt(new Element("span")),new Element("a",{"class":"cerabox-right"}).adopt(new Element("span")),new Element("div",{"class":"cerabox-content-protection"}),new Element("div",{id:"cerabox-ajaxPreLoader",styles:{"float":"left",overflow:"hidden",display:"block"}})])])}}function y(){clearInterval(t);p.getElements(".cerabox-title, .cerabox-close, .cerabox-left, .cerabox-right").set("tween",{duration:500}).tween("opacity",0)}function o(){p.getElements(".cerabox-title, .cerabox-close, .cerabox-left, .cerabox-right").setStyle("opacity",1);clearInterval(t);if(k.options.mobileView&&!k.options.clickToClose&&"createTouch" in document&&!p.getElement(".cerabox-content iframe")){t=y.delay(5000)}}function c(F){E=q=F.client}function s(F){q=F.client;F.preventDefault()}function h(F){if(null!==E.x&&null!==q.x){var I=g(),H=Math.abs(j.orientation)==90,G=H?screen.height:screen.width;if(50<=Math.round(I*(G/w.x))){v(F,B())}else{if(!I){if(F.target.get("tag")!="a"&&!F.target.getParent(".cerabox-close")&&!F.target.getParent(".cerabox-left")&&!F.target.getParent(".cerabox-right")){p.fireEvent("click",F);F.stop();if(p.getElement(".cerabox-close").getStyle("opacity")!=1){o()}else{y()}}}i()}}else{i()}}function i(){E={x:null,y:null};q={x:null,y:null}}function g(){return Math.round(Math.sqrt(Math.pow(q.x-E.x,2)+Math.pow(q.y-E.y,2)))}function B(){var F=E.x-q.x;var H=q.y-E.y;var G=Math.round(Math.atan2(H,F)*180/Math.PI);if(G<0){G=360-Math.abs(G)}return G}function v(F,G){if(G>=315||G<=45){p.getElement(".cerabox-right").fireEvent("click",F)}else{if(G>=135&&G<=225){p.getElement(".cerabox-left").fireEvent("click",F)}}i()}return b})(window);Array.implement({cerabox:function(a){if(!a||typeOf(a.group)=="null"||a.group===true){var b=new CeraBox(this,a);this.each(function(c){c.store("cerabox",b)})}else{this.each(function(c){c.store("cerabox",new CeraBox(c,a))})}return this}});Element.implement({cerabox:function(a){return this.store("cerabox",new CeraBox(this,a))}});
