!function(n){var t=function(t){var r,i;(this.origHtmlMargin=parseFloat(n("html").css("margin-top")),this.options=n.extend({},n.smartbanner.defaults,t),r=navigator.standalone,this.options.force?this.type=this.options.force:navigator.userAgent.match(/iPad|iPhone|iPod/i)!=null?navigator.userAgent.match(/Safari/i)!=null&&(navigator.userAgent.match(/CriOS/i)!=null||window.Number(navigator.userAgent.substr(navigator.userAgent.indexOf("OS ")+3,3).replace("_","."))<6)&&(this.type="ios"):navigator.userAgent.match(/Android/i)!=null&&(this.type="android"),!this.type||r||this.getCookie("sb-closed")||this.getCookie("sb-installed"))||(this.scale=this.options.scale=="auto"?n(window).width()/window.screen.width:this.options.scale,this.scale<1&&(this.scale=1),i=n(this.type=="android"?'meta[name="google-play-app"]':'meta[name="apple-itunes-app"]'),i.length!=0)&&(this.appId=/app-id=([^\s,]+)/.exec(i.attr("content"))[1],this.title=this.options.title?this.options.title:i.data("title")||n("title").text().replace(/\s*[|\-·].*$/,""),this.author=this.options.author?this.options.author:i.data("author")||(n('meta[name="author"]').length?n('meta[name="author"]').attr("content"):window.location.hostname),this.iconUrl=i.data("icon-url"),this.price=i.data("price"),this.create(),this.show(),this.listen())};t.prototype={constructor:t,create:function(){var t,u=this.options.url?this.options.url:(this.type=="android"?"market://details?id=":"https://itunes.apple.com/"+this.options.appStoreLanguage+"/app/id")+this.appId,i=this.price||this.options.price,f=i?i+" - "+(this.type=="android"?this.options.inGooglePlay:this.options.inAppStore):"",r=this.options.iconGloss===null?this.type=="ios":this.options.iconGloss;n("body").append('<div id="smartbanner" class="'+this.type+'"><div class="sb-container"><a href="#" class="sb-close">&times;<\/a><span class="sb-icon"><\/span><div class="sb-info"><strong>'+this.title+"<\/strong><span>"+this.author+"<\/span><span>"+f+'<\/span><\/div><a href="'+u+'" class="sb-button"><span>'+this.options.button+"<\/span><\/a><\/div><\/div>");this.options.icon?t=this.options.icon:this.iconUrl?t=this.iconUrl:n('link[rel="apple-touch-icon-precomposed"]').length>0?(t=n('link[rel="apple-touch-icon-precomposed"]').attr("href"),this.options.iconGloss===null&&(r=!1)):n('link[rel="apple-touch-icon"]').length>0&&(t=n('link[rel="apple-touch-icon"]').attr("href"));t?(n("#smartbanner .sb-icon").css("background-image","url("+t+")"),r&&n("#smartbanner .sb-icon").addClass("gloss")):n("#smartbanner").addClass("no-icon");this.bannerHeight=n("#smartbanner").outerHeight()+2;this.scale>1&&(n("#smartbanner").css("top",parseFloat(n("#smartbanner").css("top"))*this.scale).css("height",parseFloat(n("#smartbanner").css("height"))*this.scale),n("#smartbanner .sb-container").css("-webkit-transform","scale("+this.scale+")").css("-msie-transform","scale("+this.scale+")").css("-moz-transform","scale("+this.scale+")").css("width",n(window).width()/this.scale))},listen:function(){n("#smartbanner .sb-close").on("click",n.proxy(this.close,this));n("#smartbanner .sb-button").on("click",n.proxy(this.install,this))},show:function(t){n("#smartbanner").stop().animate({top:0},this.options.speedIn).addClass("shown");n("html").animate({marginTop:this.origHtmlMargin+this.bannerHeight*this.scale},this.options.speedIn,"swing",t)},hide:function(t){n("#smartbanner").stop().animate({top:-1*this.bannerHeight*this.scale},this.options.speedOut).removeClass("shown");n("html").animate({marginTop:this.origHtmlMargin},this.options.speedOut,"swing",t)},close:function(n){n.preventDefault();this.hide();this.setCookie("sb-closed","true",this.options.daysHidden)},install:function(){this.hide();this.setCookie("sb-installed","true",this.options.daysReminder)},setCookie:function(n,t,i){var r=new Date;r.setDate(r.getDate()+i);t=escape(t)+(i==null?"":"; expires="+r.toUTCString());document.cookie=n+"="+t+"; path=/;"},getCookie:function(n){for(var r,u,i=document.cookie.split(";"),t=0;t<i.length;t++)if(r=i[t].substr(0,i[t].indexOf("=")),u=i[t].substr(i[t].indexOf("=")+1),r=r.replace(/^\s+|\s+$/g,""),r==n)return unescape(u);return null},switchType:function(){var t=this;this.hide(function(){t.type=t.type=="android"?"ios":"android";var i=n(t.type=="android"?'meta[name="google-play-app"]':'meta[name="apple-itunes-app"]').attr("content");t.appId=/app-id=([^\s,]+)/.exec(i)[1];n("#smartbanner").detach();t.create();t.show()})}};n.smartbanner=function(i){var u=n(window),r=u.data("typeahead"),f=typeof i=="object"&&i;r||u.data("typeahead",r=new t(f));typeof i=="string"&&r[i]()};n.smartbanner.defaults={title:null,author:null,price:"FREE",appStoreLanguage:"us",inAppStore:"On the App Store",inGooglePlay:"In Google Play",icon:null,iconGloss:null,button:"VIEW",url:null,scale:"auto",speedIn:300,speedOut:400,daysHidden:15,daysReminder:90,force:null};n.smartbanner.Constructor=t}(window.jQuery)