/* Add to Homescreen v3.2.2 ~ (c) 2015 Matteo Spinelli ~ @license: http://cubiq.org/license */
!function(e,t){function i(){e.removeEventListener("load",i,!1),r=!0}function n(e){return l=l||new n.Class(e)}function o(e,t){for(var i in t)e[i]=t[i];return e}function s(){"#ath"==t.location.hash&&history.replaceState("",e.document.title,t.location.href.split("#")[0]),h.test(t.location.href)&&history.replaceState("",e.document.title,t.location.href.replace(h,"$1")),d.test(t.location.search)&&history.replaceState("",e.document.title,t.location.href.replace(d,"$2"))}var a="addEventListener"in e,r=!1;"complete"===t.readyState?r=!0:a&&e.addEventListener("load",i,!1);var l,h=/\/ath(\/)?$/,d=/([\?&]ath=[^&]*$|&ath=[^&]*(&))/;n.intl={de_de:{ios:"Um diese Web-App zum Home-Bildschirm hinzuzufügen, tippen Sie auf %icon und dann <strong>Zum Home-Bildschirm</strong>.",android:'Um diese Web-App zum Home-Bildschirm hinzuzufügen, öffnen Sie das Menü und tippen dann auf <strong>Zum Startbildschirm hinzufügen</strong>. <small>Wenn Ihr Gerät eine Menütaste hat, lässt sich das Browsermenü über diese öffnen. Ansonsten tippen Sie auf <span class="ath-action-icon">icon</span>.</small>'},da_dk:{ios:"For at tilføje denne web app til hjemmeskærmen: Tryk %icon og derefter <strong>Føj til hjemmeskærm</strong>.",android:'For at tilføje denne web app til hjemmeskærmen, åbn browser egenskaber menuen og tryk på <strong>Føj til hjemmeskærm</strong>. <small>Denne menu kan tilgås ved at trykke på menu knappen, hvis din enhed har en, eller ved at trykke på det øverste højre menu ikon <span class="ath-action-icon">icon</span>.</small>'},en_us:{ios:"To add this web app to the home screen: tap %icon and then <strong>Add to Home Screen</strong>.",android:'To add this web app to the home screen open the browser option menu and tap on <strong>Add to homescreen</strong>. <small>The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon <span class="ath-action-icon">icon</span>.</small>'},es_es:{ios:"Para añadir esta aplicación web a la pantalla de inicio: pulsa %icon y selecciona <strong>Añadir a pantalla de inicio</strong>.",android:'Para añadir esta aplicación web a la pantalla de inicio, abre las opciones y pulsa <strong>Añadir a pantalla inicio</strong>. <small>El menú se puede acceder pulsando el botón táctil en caso de tenerlo, o bien el icono de la parte superior derecha de la pantalla <span class="ath-action-icon">icon</span>.</small>'},fi_fi:{ios:"Liitä tämä sovellus kotivalikkoon: klikkaa %icon ja tämän jälkeen <strong>Lisää kotivalikkoon</strong>.",android:'Lisätäksesi tämän sovelluksen aloitusnäytölle, avaa selaimen valikko ja klikkaa tähti -ikonia tai <strong>Lisää aloitusnäytölle tekstiä</strong>. <small>Valikkoon pääsee myös painamalla menuvalikkoa, jos laitteessasi on sellainen tai koskettamalla oikealla yläkulmassa menu ikonia <span class="ath-action-icon">icon</span>.</small>'},fr_fr:{ios:"Pour ajouter cette application web sur l'écran d'accueil : Appuyez %icon et sélectionnez <strong>Ajouter sur l'écran d'accueil</strong>.",android:'Pour ajouter cette application web sur l\'écran d\'accueil : Appuyez sur le bouton "menu", puis sur <strong>Ajouter sur l\'écran d\'accueil</strong>. <small>Le menu peut-être accessible en appyant sur le bouton "menu" du téléphone s\'il en possède un <i class="fa fa-bars"></i>. Sinon, il se trouve probablement dans la coin supérieur droit du navigateur %icon.</small>'},he_il:{ios:'<span dir="rtl">להוספת האפליקציה למסך הבית: ללחוץ על %icon ואז <strong>הוסף למסך הבית</strong>.</span>',android:'To add this web app to the home screen open the browser option menu and tap on <strong>Add to homescreen</strong>. <small>The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon <span class="ath-action-icon">icon</span>.</small>'},it_it:{ios:"Per aggiungere questa web app alla schermata iniziale: premi %icon e poi <strong>Aggiungi a Home</strong>.",android:'Per aggiungere questa web app alla schermata iniziale, apri il menu opzioni del browser e premi su <strong>Aggiungi alla homescreen</strong>. <small>Puoi accedere al menu premendo il pulsante hardware delle opzioni se la tua device ne ha uno, oppure premendo l\'icona <span class="ath-action-icon">icon</span> in alto a destra.</small>'},ja_jp:{ios:"このウェプアプリをホーム画面に追加するために%iconを押して<strong>ホーム画面に追加</strong>。",android:'To add this web app to the home screen open the browser option menu and tap on <strong>Add to homescreen</strong>. <small>The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon <span class="ath-action-icon">icon</span>.</small>'},ko_kr:{ios:"홈 화면에 바로가기 생성: %icon 을 클릭한 후 <strong>홈 화면에 추가</strong>.",android:'브라우저 옵션 메뉴의 <string>홈 화면에 추가</string>를 클릭하여 홈화면에 바로가기를 생성할 수 있습니다. <small>옵션 메뉴는 장치의 메뉴 버튼을 누르거나 오른쪽 상단의 메뉴 아이콘 <span class="ath-action-icon">icon</span>을 클릭하여 접근할 수 있습니다.</small>'},nb_no:{ios:"For å installere denne appen på hjem-skjermen: trykk på %icon og deretter <strong>Legg til på Hjem-skjerm</strong>.",android:'For å legge til denne webappen på startsiden åpner en nettlesermenyen og velger <strong>Legg til på startsiden</strong>. <small>Menyen åpnes ved å trykke på den fysiske menyknappen hvis enheten har det, eller ved å trykke på menyikonet øverst til høyre <span class="ath-action-icon">icon</span>.</small>'},pt_br:{ios:"Para adicionar este app à tela de início: clique %icon e então <strong>Tela de início</strong>.",android:'To add this web app to the home screen open the browser option menu and tap on <strong>Add to homescreen</strong>. <small>The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon <span class="ath-action-icon">icon</span>.</small>'},pt_pt:{ios:"Para adicionar esta app ao ecrã principal: clique %icon e depois <strong>Ecrã principal</strong>.",android:'To add this web app to the home screen open the browser option menu and tap on <strong>Add to homescreen</strong>. <small>The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon <span class="ath-action-icon">icon</span>.</small>'},nl_nl:{ios:"Om deze webapp op je telefoon te installeren, klik op %icon en dan <strong>Zet in beginscherm</strong>.",android:'To add this web app to the home screen open the browser option menu and tap on <strong>Add to homescreen</strong>. <small>The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon <span class="ath-action-icon">icon</span>.</small>'},ru_ru:{ios:'Чтобы добавить этот сайт на свой домашний экран, нажмите на иконку %icon и затем <strong>На экран "Домой"</strong>.',android:'Чтобы добавить сайт на свой домашний экран, откройте меню браузера и нажмите на <strong>Добавить на главный экран</strong>. <small>Меню можно вызвать, нажав на кнопку меню вашего телефона, если она есть. Или найдите иконку сверху справа <span class="ath-action-icon">иконка</span>.</small>'},sv_se:{ios:"För att lägga till denna webbapplikation på hemskärmen: tryck på %icon och därefter <strong>Lägg till på hemskärmen</strong>.",android:'För att lägga till den här webbappen på hemskärmen öppnar du webbläsarens alternativ-meny och väljer <strong>Lägg till på startskärmen</strong>. <small>Man hittar menyn genom att trycka på hårdvaruknappen om din enhet har en sådan, eller genom att trycka på menyikonen högst upp till höger <span class="ath-action-icon">icon</span>.</small>'},zh_cn:{ios:"如要把应用程式加至主屏幕,请点击%icon, 然后<strong>加至主屏幕</strong>",android:'To add this web app to the home screen open the browser option menu and tap on <strong>Add to homescreen</strong>. <small>The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon <span class="ath-action-icon">icon</span>.</small>'},zh_tw:{ios:"如要把應用程式加至主屏幕, 請點擊%icon, 然後<strong>加至主屏幕</strong>.",android:'To add this web app to the home screen open the browser option menu and tap on <strong>Add to homescreen</strong>. <small>The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon <span class="ath-action-icon">icon</span>.</small>'}};for(var p in n.intl)n.intl[p.substr(0,2)]=n.intl[p];n.defaults={appID:"org.cubiq.addtohome",fontSize:15,debug:!1,logging:!1,modal:!1,mandatory:!1,autostart:!0,skipFirstVisit:!1,startDelay:1,lifespan:15,displayPace:1440,maxDisplayCount:0,icon:!0,message:"",validLocation:[],onInit:null,onShow:null,onRemove:null,onAdd:null,onPrivate:null,privateModeOverride:!1,detectHomescreen:!1};var c=e.navigator.userAgent,m=e.navigator;o(n,{hasToken:"#ath"==t.location.hash||h.test(t.location.href)||d.test(t.location.search),isRetina:e.devicePixelRatio&&e.devicePixelRatio>1,isIDevice:/iphone|ipod|ipad/i.test(c),isMobileChrome:c.indexOf("Android")>-1&&/Chrome\/[.0-9]*/.test(c)&&-1==c.indexOf("Version"),isMobileIE:c.indexOf("Windows Phone")>-1,language:m.language&&m.language.toLowerCase().replace("-","_")||""}),n.language=n.language&&n.language in n.intl?n.language:"en_us",n.isMobileSafari=n.isIDevice&&c.indexOf("Safari")>-1&&c.indexOf("CriOS")<0,n.OS=n.isIDevice?"ios":n.isMobileChrome?"android":n.isMobileIE?"windows":"unsupported",n.OSVersion=c.match(/(OS|Android) (\d+[_\.]\d+)/),n.OSVersion=n.OSVersion&&n.OSVersion[2]?+n.OSVersion[2].replace("_","."):0,n.isStandalone="standalone"in e.navigator&&e.navigator.standalone,n.isTablet=n.isMobileSafari&&c.indexOf("iPad")>-1||n.isMobileChrome&&c.indexOf("Mobile")<0,n.isCompatible=n.isMobileSafari&&n.OSVersion>=6||n.isMobileChrome;var u={lastDisplayTime:0,returningVisitor:!1,displayCount:0,optedout:!1,added:!1};n.removeSession=function(e){try{if(!localStorage)throw new Error("localStorage is not defined");localStorage.removeItem(e||n.defaults.appID)}catch(t){}},n.doLog=function(e){this.options.logging&&console.log(e)},n.Class=function(i){if(this.doLog=n.doLog,this.options=o({},n.defaults),o(this.options,i),i.debug&&"undefined"==typeof i.logging&&(this.options.logging=!0),a){if(this.options.mandatory=this.options.mandatory&&("standalone"in e.navigator||this.options.debug),this.options.modal=this.options.modal||this.options.mandatory,this.options.mandatory&&(this.options.startDelay=-.5),this.options.detectHomescreen=this.options.detectHomescreen===!0?"hash":this.options.detectHomescreen,this.options.debug&&(n.isCompatible=!0,n.OS="string"==typeof this.options.debug?this.options.debug:"unsupported"==n.OS?"android":n.OS,n.OSVersion="ios"==n.OS?"8":"4"),this.container=t.documentElement,this.session=this.getItem(this.options.appID),this.session=this.session?JSON.parse(this.session):void 0,!n.hasToken||n.isCompatible&&this.session||(n.hasToken=!1,s()),!n.isCompatible)return void this.doLog("Add to homescreen: not displaying callout because device not supported");this.session=this.session||u;try{if(!localStorage)throw new Error("localStorage is not defined");localStorage.setItem(this.options.appID,JSON.stringify(this.session)),n.hasLocalStorage=!0}catch(r){n.hasLocalStorage=!1,this.options.onPrivate&&this.options.onPrivate.call(this)}for(var l=!this.options.validLocation.length,h=this.options.validLocation.length;h--;)if(this.options.validLocation[h].test(t.location.href)){l=!0;break}if(this.getItem("addToHome")&&this.optOut(),this.session.optedout)return void this.doLog("Add to homescreen: not displaying callout because user opted out");if(this.session.added)return void this.doLog("Add to homescreen: not displaying callout because already added to the homescreen");if(!l)return void this.doLog("Add to homescreen: not displaying callout because not a valid location");if(n.isStandalone)return this.session.added||(this.session.added=!0,this.updateSession(),this.options.onAdd&&n.hasLocalStorage&&this.options.onAdd.call(this)),void this.doLog("Add to homescreen: not displaying callout because in standalone mode");if(this.options.detectHomescreen){if(n.hasToken)return s(),this.session.added||(this.session.added=!0,this.updateSession(),this.options.onAdd&&n.hasLocalStorage&&this.options.onAdd.call(this)),void this.doLog("Add to homescreen: not displaying callout because URL has token, so we are likely coming from homescreen");"hash"==this.options.detectHomescreen?history.replaceState("",e.document.title,t.location.href+"#ath"):"smartURL"==this.options.detectHomescreen?history.replaceState("",e.document.title,t.location.href.replace(/(\/)?$/,"/ath$1")):history.replaceState("",e.document.title,t.location.href+(t.location.search?"&":"?")+"ath=")}if(!this.session.returningVisitor&&(this.session.returningVisitor=!0,this.updateSession(),this.options.skipFirstVisit))return void this.doLog("Add to homescreen: not displaying callout because skipping first visit");if(!this.options.privateModeOverride&&!n.hasLocalStorage)return void this.doLog("Add to homescreen: not displaying callout because browser is in private mode");this.ready=!0,this.options.onInit&&this.options.onInit.call(this),this.options.autostart&&(this.doLog("Add to homescreen: autostart displaying callout"),this.show())}},n.Class.prototype={events:{load:"_delayedShow",error:"_delayedShow",orientationchange:"resize",resize:"resize",scroll:"resize",click:"remove",touchmove:"_preventDefault",transitionend:"_removeElements",webkitTransitionEnd:"_removeElements",MSTransitionEnd:"_removeElements"},handleEvent:function(e){var t=this.events[e.type];t&&this[t](e)},show:function(i){if(this.options.autostart&&!r)return void setTimeout(this.show.bind(this),50);if(this.shown)return void this.doLog("Add to homescreen: not displaying callout because already shown on screen");var o=Date.now(),s=this.session.lastDisplayTime;if(i!==!0){if(!this.ready)return void this.doLog("Add to homescreen: not displaying callout because not ready");if(o-s<6e4*this.options.displayPace)return void this.doLog("Add to homescreen: not displaying callout because displayed recently");if(this.options.maxDisplayCount&&this.session.displayCount>=this.options.maxDisplayCount)return void this.doLog("Add to homescreen: not displaying callout because displayed too many times already")}this.shown=!0,this.session.lastDisplayTime=o,this.session.displayCount++,this.updateSession(),this.applicationIcon||(this.applicationIcon=t.querySelector("ios"==n.OS?'head link[rel^=apple-touch-icon][sizes="152x152"],head link[rel^=apple-touch-icon][sizes="144x144"],head link[rel^=apple-touch-icon][sizes="120x120"],head link[rel^=apple-touch-icon][sizes="114x114"],head link[rel^=apple-touch-icon]':'head link[rel^="shortcut icon"][sizes="196x196"],head link[rel^=apple-touch-icon]'));var a="";"object"==typeof this.options.message&&n.language in this.options.message?a=this.options.message[n.language][n.OS]:"object"==typeof this.options.message&&n.OS in this.options.message?a=this.options.message[n.OS]:this.options.message in n.intl?a=n.intl[this.options.message][n.OS]:""!==this.options.message?a=this.options.message:n.OS in n.intl[n.language]&&(a=n.intl[n.language][n.OS]),a="<p>"+a.replace("%icon",'<span class="ath-action-icon">icon</span>')+"</p>",this.viewport=t.createElement("div"),this.viewport.className="ath-viewport",this.options.modal&&(this.viewport.className+=" ath-modal"),this.options.mandatory&&(this.viewport.className+=" ath-mandatory"),this.viewport.style.position="absolute",this.element=t.createElement("div"),this.element.className="ath-container ath-"+n.OS+" ath-"+n.OS+(n.OSVersion+"").substr(0,1)+" ath-"+(n.isTablet?"tablet":"phone"),this.element.style.cssText="-webkit-transition-property:-webkit-transform,opacity;-webkit-transition-duration:0s;-webkit-transition-timing-function:ease-out;transition-property:transform,opacity;transition-duration:0s;transition-timing-function:ease-out;",this.element.style.webkitTransform="translate3d(0,-"+e.innerHeight+"px,0)",this.element.style.transform="translate3d(0,-"+e.innerHeight+"px,0)",this.options.icon&&this.applicationIcon&&(this.element.className+=" ath-icon",this.img=t.createElement("img"),this.img.className="ath-application-icon",this.img.addEventListener("load",this,!1),this.img.addEventListener("error",this,!1),this.img.src=this.applicationIcon.href,this.element.appendChild(this.img)),this.element.innerHTML+=a,this.viewport.style.left="-99999em",this.viewport.appendChild(this.element),this.container.appendChild(this.viewport),this.img?this.doLog("Add to homescreen: not displaying callout because waiting for img to load"):this._delayedShow()},_delayedShow:function(){setTimeout(this._show.bind(this),1e3*this.options.startDelay+500)},_show:function(){var i=this;this.updateViewport(),e.addEventListener("resize",this,!1),e.addEventListener("scroll",this,!1),e.addEventListener("orientationchange",this,!1),this.options.modal&&t.addEventListener("touchmove",this,!0),this.options.mandatory||setTimeout(function(){i.element.addEventListener("click",i,!0)},1e3),setTimeout(function(){i.element.style.webkitTransitionDuration="1.2s",i.element.style.transitionDuration="1.2s",i.element.style.webkitTransform="translate3d(0,0,0)",i.element.style.transform="translate3d(0,0,0)"},0),this.options.lifespan&&(this.removeTimer=setTimeout(this.remove.bind(this),1e3*this.options.lifespan)),this.options.onShow&&this.options.onShow.call(this)},remove:function(){clearTimeout(this.removeTimer),this.img&&(this.img.removeEventListener("load",this,!1),this.img.removeEventListener("error",this,!1)),e.removeEventListener("resize",this,!1),e.removeEventListener("scroll",this,!1),e.removeEventListener("orientationchange",this,!1),t.removeEventListener("touchmove",this,!0),this.element.removeEventListener("click",this,!0),this.element.addEventListener("transitionend",this,!1),this.element.addEventListener("webkitTransitionEnd",this,!1),this.element.addEventListener("MSTransitionEnd",this,!1),this.element.style.webkitTransitionDuration="0.3s",this.element.style.opacity="0"},_removeElements:function(){this.element.removeEventListener("transitionend",this,!1),this.element.removeEventListener("webkitTransitionEnd",this,!1),this.element.removeEventListener("MSTransitionEnd",this,!1),this.container.removeChild(this.viewport),this.shown=!1,this.options.onRemove&&this.options.onRemove.call(this)},updateViewport:function(){if(this.shown){this.viewport.style.width=e.innerWidth+"px",this.viewport.style.height=e.innerHeight+"px",this.viewport.style.left=e.scrollX+"px",this.viewport.style.top=e.scrollY+"px";var i=t.documentElement.clientWidth;this.orientation=i>t.documentElement.clientHeight?"landscape":"portrait";var o="ios"==n.OS?"portrait"==this.orientation?screen.width:screen.height:screen.width;this.scale=screen.width>i?1:o/e.innerWidth,this.element.style.fontSize=this.options.fontSize/this.scale+"px"}},resize:function(){clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(this.updateViewport.bind(this),100)},updateSession:function(){n.hasLocalStorage!==!1&&localStorage&&localStorage.setItem(this.options.appID,JSON.stringify(this.session))},clearSession:function(){this.session=u,this.updateSession()},getItem:function(e){try{if(!localStorage)throw new Error("localStorage is not defined");return localStorage.getItem(e)}catch(t){n.hasLocalStorage=!1}},optOut:function(){this.session.optedout=!0,this.updateSession()},optIn:function(){this.session.optedout=!1,this.updateSession()},clearDisplayCount:function(){this.session.displayCount=0,this.updateSession()},_preventDefault:function(e){e.preventDefault(),e.stopPropagation()}},e.addToHomescreen=n}(window,document);
