if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());(function(){var a=function(){return(window.frosmo.config.debug&&window.console)};if(!window.frosmo){window.frosmo={api:null,pb:null,messageApi:null,message:null,fbWrapper:null,fbElement:null,cookies:null,session:null,pmm:null}}if(!window.frosmo.config){window.frosmo.config={api:{origin:null,server:null},message:{origin:null,rpc:null,enabled:true},fbWrapper:{locale:null,reloadOnLogin:null,cookieName:null,permissions:null,fbAppId:null,fanPageHref:false,loginTimeout:false},popup:{animationSpeed:200,closeButtonText:"Close",destroyOnClose:true},pb:{html:null,popups:null,navigation:null,apiUrl:null},cookies:{domain:window.location.host},debug:false}}if(!window.frosmo.browser){window.frosmo.browser={cors:function(){if(window.XMLHttpRequest){var b=new XMLHttpRequest();if("withCredentials" in b){return true}else{if(window.XDomainRequest){return true}}}return false}}}if(!window.frosmo.console){window.frosmo.console={log:function(b){if(a()){console.log(b)}},debug:function(b){if(a()){if(typeof console.debug==="function"){console.debug(b)}else{console.log("Debug: "+b)}}},info:function(b){if(a()){if(typeof console.info==="function"){console.info(b)}else{console.log("Info: "+b)}}},warn:function(b){if(a()){if(typeof console.warn==="function"){console.warn(b)}else{console.log("Warn: "+b)}}},error:function(b){if(a()){if(typeof console.error==="function"){console.error(b)}else{console.log("Error: "+b)}}}}}if(!window.frosmo.addCss){window.frosmo.addCss=function(e,d){if(d){document.write("<!--[if "+d+"]>\n");document.write('<link type="text/css" rel="stylesheet" href="'+e+'" />\n');document.write("<![endif]-->")}else{var c=document.getElementsByTagName("head")[0],b=document.createElement("link");b.type="text/css";b.rel="stylesheet";b.href=e;c.appendChild(b)}}}if(!window.frosmo.site){window.frosmo.site={}}if(!window.frosmo.loader){window.frosmo.loader={ready:function(b){b.call(window)}}}}());frosmo.utils=(function(){var c=function(h){var i=h.getFullYear(),j=h.getMonth(),g=h.getDate();if(j<10){j="0"+j}if(g<10){g="0"+g}return i+"-"+j+"-"+g},f=function(i){var g=i.getHours(),j=i.getMinutes(),h=i.getSeconds();if(g<10){g="0"+g}if(j<10){j="0"+j}if(h<10){h="0"+h}return g+":"+j+":"+h},a=function(g){return c(g)+" "+f(g)},b=function(g){return window.unescape(g)},d=function(h){try{return window.decodeURIComponent(h)}catch(g){return h}},e=function(h){var k=window.location.search.replace(/^\?/,""),m,g={},j,n,o,l;if(h){o=h.indexOf("?");if(o!==-1){k=h.substring(o+1)}else{k=null}}if(k){m=k.split("&");for(j in m){if(typeof(m[j])==="string"){n=m[j].split("=");l=d(n[1]);l=b(l);if(n[0].indexOf("[]")!==-1){n[0]=n[0].replace("[]","");if(!g[n[0]]){g[n[0]]=[]}g[n[0]].push(l)}else{g[n[0]]=decodeURIComponent(l)}}}}return g};return{formatDate:c,formatTime:f,formatDatetime:a,getUrlParams:e}}());frosmo.session=(function(){var o={cookie_name:"frosmo.session",persistent_cookie_id:"frosmo.id",duration:30},F=null,x,f=null,n=null,k=function(){if(!frosmo.cookies){throw"frosmo.cookies library is not loaded"}if(F===null){var H=frosmo.cookies.get(o.cookie_name);if(H&&H!=="null"){F=JSON.parse(H);if(typeof F.loginTime==="string"){F.loginTime=new Date(F.loginTime)}if(typeof F.startTime==="string"){F.startTime=new Date(F.startTime)}if(typeof F.lastActivityTime==="string"){F.lastActivityTime=new Date(F.lastActivityTime)}}}if(F===null){F={}}},z=function(){if(!frosmo.cookies){throw"frosmo.cookies library is not loaded"}frosmo.cookies.set(o.cookie_name,JSON.stringify(F))},q=function(){k();return F.source},i=function(H){k();F.source=H;z();return this},s=function(){k();return F.loginTime},v=function(H){if(H instanceof Date){k();F.loginTime=H;z()}else{throw"Invalid argument, setLoginTime expects Date object"}return this},p=function(H){H=H||{};if(H.source&&!q()){i(H.source)}if(!s()){v(new Date())}return this},c=function(){k();return F.lastActivityTime},e=function(){frosmo.console.log("frosmo.session.updateLastActivityTime(): updating last activity time");k();F.lastActivityTime=new Date();z();return this},D=function(){var H=new Date(),I=c();if(I){return H.getTime()-I.getTime()}else{return null}},y=function(){k();return F.startTime},C=function(){k();if(!F.startTime){frosmo.console.log("frosmo.session.setStartTime(): Set session start time");F.startTime=new Date();z()}return this},E=function(){var H=new Date(),I=y();if(I){return H.getTime()-I.getTime()}else{return null}},j=function(J){var H=2166136261,I;for(I=0;I<J.length;I+=1){H+=(H<<1)+(H<<4)+(H<<7)+(H<<8)+(H<<24);H^=J.charCodeAt(I)}return H&2147483647},m=function(){if(!frosmo.cookies){frosmo.console.error("frosmo.session.getPersistendId(): frosmo.cookies library is not loaded");return false}var H=frosmo.cookies.get(o.persistent_cookie_id);if(H===""||H===null){return false}else{return true}},w=function(){var H=frosmo.cookies.get(o.persistent_cookie_id);if(H===""||H===null){return null}return H},G=function(H){frosmo.cookies.set(o.persistent_cookie_id,H,null,3650)},r=function(){var H=w();if(H===null){return false}else{return true}},l=function(){if(!frosmo.cookies){frosmo.console.error("frosmo.session.getPersistendId(): frosmo.cookies library is not loaded");return null}var H=w();if(H===null){H=j(navigator.userAgent).toString(36)+"."+new Date().getTime().toString(36);G(H)}return H},a=function(){k();return F.userId},B=function(H){k();F.userId=H;z();return this},A=function(){G(null)},d=function(H){var I=new RegExp("\\w+\\.\\w+");if(I.test(H)){frosmo.console.log("frosmo.session.setPersistentId(): setting id to "+H);G(H)}else{frosmo.console.log("frosmo.session.setPersistentId(): invalid persistent id supplied: "+H)}},h=function(I){var J=new RegExp("https?://((?:[\\w\\-]+)(?:\\.[\\w\\-]+)*)/?"),H=J.exec(I);if(H){return H[1]}else{return null}},t=function(I){var J=new RegExp("[\\w\\-]+\\.[\\w\\-]+$"),H=J.exec(I);if(H){return H[0]}else{return null}},b=function(I){var H=new RegExp("\\d+\\.\\d+");if(H.test(I)){return false}return true},g=function(L){frosmo.console.log("frosmo.session.detectSource(): Detecting user source.");if(q()){frosmo.console.log("frosmo.session.detectSource(): Old source present, don't overwrite");return}var N,M,I,H,K,J;if(L){if(typeof L==="string"){frosmo.console.log("frosmo.session.detectSource(): Source supplied, using "+L);i(L);return}else{if(typeof L==="function"){frosmo.console.log("frosmo.session.detectSource(): Getting source from custom function");N=L.call(window);if(N){frosmo.console.log('frosmo.session.detectSource(): Custom function returned "'+N+'", setting source');i(N);return}else{frosmo.console.log("frosmo.session.detectSource(): Custom function returned empty value, autodetecting")}}}}if(frosmo.utils){M=frosmo.utils.getUrlParams();if(M.fssrc){frosmo.console.log('frosmo.session.detectSource(): Using url param "fssrc", setting source to "'+M.fssrc+'"');i(M.fssrc);return}}H=(f!==null?f:document.referrer);J=(n!==null?n:document.location.hostname);if(H){frosmo.console.log("frosmo.session.detectSource(): Checking if referrer is different from current domain.");I=(function(){var O=h(H),P;if(O){P=t(O);if(P){return P}}return null}());K=(function(){var O=t(J);if(O){return O}return null}());if(K&&I&&K!==I){if(b(I)){L=I;if(I.indexOf("google.")===0){L="google"}else{if(I==="facebook.com"){L="fb"}}frosmo.console.log('frosmo.session.detectSource(): Setting source based on referrer to "'+L+'"');i(L);return}}frosmo.console.log('frosmo.session.detectSource(): Ambigous referrer, setting source to "direct"');i("direct")}else{frosmo.console.log('frosmo.session.detectSource(): No referrer, setting source to "direct"');i("direct")}},u=function(K){frosmo.console.log("frosmo.session: Initializing...");if(!frosmo.cookies){throw"frosmo.cookies library is not loaded"}frosmo.console.log("frosmo.session.init(): init");var H=D(),J=(E()===null),I;if(H===null||H>o.duration*60*1000){frosmo.console.log("frosmo.session.init(): New session or user inactive over "+o.duration+"min, acquiring source.");I=true;i(null);g(K)}if(frosmo.api){if(!r()){if(l()){frosmo.console.log("frosmo.session.init(): Create and send new persistentId to Optimizer API");frosmo.api.setUserData(null,{source:q()})}else{frosmo.console.error("frosmo.session.init(): Failed to create new persistentId")}}else{frosmo.console.log("frosmo.session.init(): User has existing persistentId")}if(I){frosmo.console.log("frosmo.session.init(): Log new visit (newSession: "+J.toString()+")");frosmo.api.visit(null,q(),J)}}C();e()};if(window.frosmo.test){window.frosmo.test.session={configuration:o,setStartTime:function(H){k();F.startTime=H;z()},setReferrer:function(H){f=H},setHostname:function(H){n=H},reset:function(){if(!frosmo.cookies){frosmo.console.error("frosmo.cookies.js not loaded")}F=null;frosmo.cookies.set(o.cookie_name,null);A()}}}x={init:u,login:p,getSource:q,setSource:i,getDuration:E,getStartTime:y,setLoginTime:v,getLoginTime:s,getPersistentId:l,getUserId:a,setUserId:B,resetPersistentId:A,setPersistentId:d,update:e};if(window.frosmo.test){x.getHostnameFromUrl=h;x.getDomainFromHostname=t;x.detectSource=g;x.isValidDomain=b}return x}());if(!window.frosmo){window.frosmo={}}frosmo.cookies=(function(){if(frosmo.cookies){return frosmo.cookies}return{set:function(b,f,e,a){var d="",c;if(f===null){d=escape(b)+"="}else{d=escape(b)+"="+escape(f)}if(a){c=new Date();c.setTime(new Date().getTime()+a*24*60*60*1000);d+=";expires="+c.toUTCString()}if(!e){e=frosmo.config.cookies.domain||null}if(e&&/\.[a-z]+$/.exec(e)){d+=";domain="+escape(e)}d+=";path=/";document.cookie=d},get:function(b){if(document.cookie.length>0){var c=document.cookie.indexOf(b+"="),a;if(c!==-1){c+=b.length+1;a=document.cookie.indexOf(";",c);if(a===-1){a=document.cookie.length}return unescape(document.cookie.substring(c,a))}}return""}}}());frosmo.api=(function(){var a=0,c,g,k=[],f=function(p,l){var n,o,m,q,r={};if(typeof c==="undefined"||typeof g==="undefined"){k.push({event:p,args:l});frosmo.console.error('frosmo.api: API not initialized, event "'+p+'" queued');return null}if(frosmo.pmm){frosmo.pmm.handleEvent(p,l)}for(n in l){if(l[n] instanceof Object){m=l[n];for(o in m){if(m.hasOwnProperty(o)){r[o]=m[o]}}}else{if(l[n]===undefined){r[n]=null}else{r[n]=l[n]}}}for(n in r){if(r[n]===null||r[n]===false){r[n]=""}else{if(r[n]===true){r[n]="1"}}}if(frosmo.session){r.cookieId=frosmo.session.getPersistentId();frosmo.console.log('frosmo.api: Event "'+p+'" using cookieId "'+r.cookieId+'"')}else{frosmo.console.log('frosmo.api: Event "'+p+'" without cookieId')}r.event=p;r.origin=g;q=[];for(n in r){if(r.hasOwnProperty(n)){q.push(encodeURIComponent(n)+"="+encodeURIComponent(r[n]))}}return c+q.join("&")+"&"+(a+=1)},j=function(m){var n=m.getFullYear(),o=m.getMonth(),l=m.getDate();if(o<10){o="0"+o}if(l<10){l="0"+l}return n+"-"+o+"-"+l},i=function(n){var l=n.getHours(),o=n.getMinutes(),m=n.getSeconds();if(l<10){l="0"+l}if(o<10){o="0"+o}if(m<10){m="0"+m}return l+":"+o+":"+m},d=function(l){return j(l)+" "+i(l)},b=function(m){if(m){var l=new Image();l.src=m;frosmo.console.log("frosmo.api: Call URL "+m)}},e=function(){var o,m,n;if(k.length>0){for(o=0,m=k.length;o<m;o+=1){frosmo.console.log('frosmo.api: Call queued "'+k[o].event+'" event');n=f(k[o].event,k[o].args);b(n)}k=[]}},h=function(l,m){c=l;g=m;frosmo.console.log('frosmo.api: Initialized with origin "'+g+'"');e()};return{init:h,setCallUrl:function(l){b=l},login:function(m,n){var l=f("login",{userId:m,source:n});b(l)},showFeed:function(l,n){var m=f("showFeed",{feedType:l,userId:n});b(m)},publishFeed:function(l,n,o){var m=f("publishFeed",{feedType:l,userId:n,uniqueId:o});b(m)},clickFeed:function(l,n,o){var m=f("clickFeed",{feedType:l,userId:n,uniqueId:o});b(m)},invite:function(n,m,o){var l=f("invite",{userId:n,invitationType:m,uniqueId:o});b(l)},acceptInvitation:function(m,n,o){var l=f("acceptInvitation",{userId:m,invitationType:n,uniqueId:o});b(l)},newUser:function(n,r,s,o,m,q,p){var l=f("newUser",{userId:n,country:r,language:s,gender:o,email:m,dob:q,source:p});b(l)},updateUser:function(n,r,s,o,m,q,p){var l=f("updateUser",{userId:n,country:r,language:s,gender:o,email:m,dob:q,source:p});b(l)},sendGift:function(o,n,m){var l=f("sendGift",{senderId:o,giftType:n,onRequest:m});b(l)},receiveGift:function(n,m){var l=f("receiveGift",{receiverId:n,giftType:m});b(l)},useGift:function(m,n){var l=f("useGift",{userId:m,giftType:n});b(l)},requestGift:function(m){var l=f("requestGift",{userId:m});b(l)},buyVirtualGood:function(o,q,n,p,l){var m=f("buyVirtualGood",{userId:o,category:q,name:n,price:p,currency:l});b(m)},receiveMoney:function(o,n,l,p){var m=f("receiveMoney",{userId:o,amount:n,currency:l,moneySource:p});b(m)},trackUserPath:function(o,p,n,l){var m=f("trackUserPath",{userId:o,pathId:p,pathState:n,position:l});b(m)},advanceToRank:function(m,n){var l=f("advanceToRank",{userId:m,rank:n});b(l)},showSaleTrigger:function(n,l,o){var m=f("showSaleTrigger",{userId:n,campaignId:l,triggerId:o});b(m)},clickSaleTrigger:function(n,l,o){var m=f("clickSaleTrigger",{userId:n,campaignId:l,triggerId:o});b(m)},buySaleTrigger:function(n,l,o){var m=f("buySaleTrigger",{userId:n,campaignId:l,triggerId:o});b(m)},setVirtualGoodInfo:function(n,m,o){var l=f("setVirtualGoodInfo",{category:n,name:m,imgUrl:o});b(l)},viewProduct:function(m,o,n){var l=f("viewProduct",{userId:m,productType:o,productId:n});b(l)},buyProduct:function(o,s,q,m,l,p,r){var n=f("buyProduct",{userId:o,productType:s,productId:q,netValue:m,fee:l,tax:p,paymentChannel:r});b(n)},recommendProduct:function(m,o,n){var l=f("recommendProduct",{userId:m,productType:o,productId:n});b(l)},practice:function(n,m){var l=f("practice",{gameId:n,userId:m});b(l)},setUserData:function(n,m){var l=f("setUserData",{userId:n,userAttributes:m});b(l)},showMessage:function(n,m){var l=f("showMessage",{userId:n,messageId:m});b(l)},clickMessage:function(n,m){var l=f("clickMessage",{userId:n,messageId:m});b(l)},progressBarEvent:function(q,p,o,l,n){var m=f("progressBarEvent",{userId:q,progressBarName:p,progressBarState:o,progressBarEvent:l,progressBarValue:n});b(m)},advanceProgressBarState:function(o,n,m){var l=f("advanceProgressBarState",{userId:o,progressBarName:n,progressBarState:m});b(l)},skipProgressBarState:function(o,n,m){var l=f("skipProgressBarState",{userId:o,progressBarName:n,progressBarState:m});b(l)},setCustomUserData:function(n,l){var m=f("setCustomUserData",{userId:n,customUserAttributes:l});b(m)},visit:function(m,o,n){var l=f("visit",{userId:m,source:o,newSession:n});b(l)},showOffer:function(n,o,m){var l=f("showOffer",{userId:n,compositeOfferId:o,placement:m});b(l)},clickOffer:function(m,n){var l=f("clickOffer",{userId:m,compositeOfferId:n});b(l)},setProductData:function(m,n){var l=f("setProductData",{productId:m,productAttributes:n});b(l)},buyOffer:function(n,q,l,p,o,r){var m=f("buyOffer",{userId:n,compositeOfferId:q,normalPrice:l,discountPrice:p,businessPrice:o,paymentChannel:r});b(m)},clearCustomAttribute:function(n,m){var l=f("clearCustomAttribute",{userId:n,customAttributeName:m});b(l)}}}());if(!window.frosmo){window.frosmo={}}frosmo.request=(function(){if(frosmo.request){return frosmo.request}var i,b={},d=0,g={},a="function",j=function(m,k,l){if(typeof m===a){if(l){return m.apply(k,l)}else{return m.apply(k)}}else{return false}},h=function(k){window.setTimeout(function(){document.getElementsByTagName("head")[0].appendChild(k)},10)},c=function(l,m){var k=document.createElement("script");if(m){l=l+(/\?/.exec(l)?"&":"?")+m.join("&").replace(/%20/g,"+")}k.setAttribute("type","text/javascript");k.setAttribute("charset","utf-8");k.setAttribute("src",l);k.setAttribute("async",true);return k},e=function(l,k){g[l.id]=function(m){};if(k){k.removeAttribute("src");k.parentNode.removeChild(k)}},f=function(m){var k=this,l;d+=1;l="req"+d;return l};i=function(){this.init.apply(this,arguments)};i.prototype={init:function(k,m){var l;m=(typeof m===a)?{on:{success:m}}:m||{};this.getUrl=function(){return k};this.getCallback=function(){return m}},send:function(){var m=this,r=this.getCallback(),o=this.getUrl(),q="JSONPRequest.send(): ",l,n,p=[],k=function(s,t){p[p.length]=encodeURIComponent(s)+"="+encodeURIComponent(t)};if(!o){frosmo.console.error(q+"No request URL defined, aborting request.");return this}if(!r.on){frosmo.console.error(q+"No callback methods defined, aborting request.");return this}if(!r.on.success){frosmo.console.error(q+"No success handler method defined, aborting request.");return this}r.id=f(r);k("callback","frosmo.request.callbacks."+r.id);if(r.params){for(n in r.params){if(n){k(n,r.params[n])}}}l=c(o,p);g[r.id]=function(s){e(r,l);if(r.timeout){window.clearTimeout(b[r.id])}r.on.success.call(m,s)};if(r.timeout){b[r.id]=window.setTimeout(function(){e(r,l);j(r.on.timeout,m)},r.timeout)}h(l);return this}};return{callbacks:g,create:function(k,l){return new i(k,l)},jsonp:function(k,m){var l=new i(k,m);return l.send.call(l)}}}());frosmo.messageApi=(function(){var n="https://frosmo.com/messageApi",t="0.30.0",k=60,d=0,e=5000,j=1000,g=/^(https?:\/\/[a-zA-Z0-9:\-]+)\//,w=function(){var B=arguments[0]||{},A=arguments[1]||{},z;for(z in A){if(z){B[z]=A[z]}}return B},c=function(z){if(typeof z==="function"){return true}else{return false}},o=function(B,z,A){if(c(B)){if(A){return B.apply(z,A)}else{return B.apply(z)}}else{return false}},x,v,b=function(z,A){if(A){frosmo.console.log(A+": "+z)}else{frosmo.console.log("frosmo.messageApi: "+z)}},i=function(z,A){if(A){frosmo.console.error(A+": "+z)}else{frosmo.console.error("frosmo.messageApi: "+z)}},p=function(D,E){var G=function(H,I,J){if(H.removeEventListener){return H.removeEventListener(I,J,false)}else{if(H.detachtEvent){return H.detachEvent("on"+I,J)}}},z=function(K,M){if(K.className){if(/(close|fb_button)/i.exec(K.className)){return false}}var J,H,I,N,L=function(O,Q,P){P.call(this,Q,function(){G(O,"click",N);if(H){window.location.href=H}})};if(/fb_button/i.exec(K.className)){H=null;J=K.parentNode.tagName.toLowerCase()+" > a"}else{H=K.getAttribute("href");J="a[href="+H+"]"}if(K.addEventListener){b("Add click event listener to ("+J+") with element.addEventListener()");N=function(O){b("("+J+") clicked");O.preventDefault();L(this,O,M)};return K.addEventListener("click",N,false)}else{if(K.attachEvent){b("Add click event listener to ("+J+") with element.attachEvent()");N=function(){b("("+J+") clicked");var O=window.event;O.returnValue=false;L(K,O,M)};return K.attachEvent("onclick",N)}}i("Failed to add click event listener");return false},B=function(H,J){var K,I=function(L,N,M){M.call(this,N,function(){G(L,"submit",K);L.submit()})};if(H.addEventListener){b("Add submit event listener to form with element.addEventListener()");K=function(L){L.preventDefault();I(this,L,J)};return H.addEventListener("submit",K,false)}else{if(H.attachEvent){b("Add submit event listener to form with element.attachEvent()");K=function(){var L=window.event;L.returnValue=false;I(H,L,J)};return H.attachEvent("onsubmit",K)}}i("Failed to add submit event listener");return false},F,C,A;F=D.getElementsByTagName("a");for(C=0,A=F.length;C<A;C+=1){z(F[C],E)}F=D.getElementsByTagName("form");for(C=0,A=F.length;C<A;C+=1){B(F[C],E)}if(frosmo.fbWrapper){frosmo.fbWrapper.bindButtonClicks(D,E)}},a=function(E){var C=this,D,A,z,B;if(!frosmo.fbWrapper){b("Method frosmo.fbWrapper not loaded");return false}if(!frosmo.fbWrapper.parseFBMLElements){i("Method frosmo.fbWrapper.parseFBMLElements() not found");return false}if(!frosmo.fbWrapper.removeElementCallback){b("Method frosmo.fbWrapper.removeElementCallback() not found")}z=frosmo.fbWrapper.parseFBMLElements(E.content);if(z.length>0){B=function(F){var G={id:"message_"+E.id,on:{}};if(F.element==="like"){G.on.click=function(H,I){o(E.on.click,C)}}else{if(F.element==="login-button"){G.on.login=function(H){o(E.on.login,C,[H])}}else{return}}frosmo.fbWrapper.addElementCallback(F,G);if(frosmo.fbWrapper.removeElementCallback){E.callbacks.on.close.push(function(){frosmo.fbWrapper.removeElementCallback(F,G)})}};b("Add click tracking to XFBML elements");E.fbmlElements=z;for(D=0,A=z.length;D<A;D+=1){if(z[D]){B(z[D])}}return true}else{b("No XFBML elements found");return false}},q=function(z){return(Object.prototype.toString.call(z)==="[object Array]")},y=function(A,B){var D=document.createElement("div"),z=document.createDocumentFragment(),C;D.innerHTML=A;if(D.children.length>0){for(C=0;C<D.children.length;C+=1){if(D.childNodes[C]){if(typeof B==="function"){B.call(window,D.childNodes[C])}z.appendChild(D.childNodes[C])}}}else{z=document.createTextNode(D.innerHTML)}return z},m=function(C,B){var z=document.createDocumentFragment(),A;for(A=0;A<C.length;A+=1){if(C[A]){if(typeof B==="function"){B.call(window,C[A])}z.appendChild(C[A])}}return z},h=function(A){if(window.location.origin){return(A.indexOf(window.location.origin)===0)}else{var z=g.exec(window.location);if(z){return(A.indexOf(z[1])===0)}else{return false}}},l=function(B){if(B.length>0){var A="",z;for(z=0;z<B.length;z+=1){if(z>0){A+=","}if(typeof B[z]==="object"){A+=B[z].id}else{A+=B[z]}}return A}else{return null}},u=function(){if(window.XMLHttpRequest){var z=new XMLHttpRequest();if("withCredentials" in z){return true}else{if(window.XDomainRequest){return true}}}return false},r=function(A){if(typeof(A)!=="string"){return false}var z=new RegExp("(\\d+)\\.?(\\d+)?\\.?(\\d+)?"),B=z.exec(A);return{major:parseInt(B[1],10)||0,minor:parseInt(B[2],10)||0,patch:parseInt(B[3],10)||0}},s=function(A,B){var z=r(""+A),C=r(""+B);if(z.major!==C.major){return(C.major>z.major)}else{if(A.minor!==C.minor){return(C.minor>z.minor)}else{if(z.patch!==C.patch){return(C.patch>z.patch)}else{return true}}}},f={POPUP:"popup",INLINE:"inline"};x=function(){var K=arguments[0],M=arguments[1]||null,E=arguments[2]||null,N=arguments[3]||null,G=n,J=null,C=false,H=1,I=0,L=0,F=null,D={},A=null,B=null,z=null;this.getFacebookFriends=function(){return z};this.setFacebookFriends=function(O){if(q(O)){z=l(O)}return this};this.setMetadata=function(O){J=O||null;return this};this.addMetadata=function(O){if(O){if(!J){J={}}J=w(J,O)}return this};this.getMetadata=function(){var P={},O;if(J){for(O in J){if(O&&O.match(/(product([A-Z][a-z]+)+|source)/)){P[O]=J[O]}}}return P};this.getOrigin=function(){return K};this.setOrigin=function(O){K=O;return this};this.getOptions=function(){return N};this.setOptions=function(O){N=O;return this};this.getMessageType=function(){return F};this.setMessageType=function(O){F=O;return this};this.getRequestTime=function(){return A};this.setRequestTime=function(O){A=O;return this};this.resetRequestTime=function(){A=null;return this};this.getStartTime=function(){return B};this.resetStartTime=function(){B=this.getTime();return this};this.getMessageCount=function(){return L};this.incrementMessageCount=function(){L+=1};this.getRequestCount=function(){return I};this.incrementRequestCount=function(){I+=1};this.addMessage=function(O){D[O.id]=O;return this};this.getMessage=function(O){if(O in D){return D[O]}else{return null}};this.resetMessages=function(){I=0;L=0;D={};return this};this.getMessageLimit=function(){return H};this.setMessageLimit=function(O){if(typeof H==="number"){H=O||false}else{H=false}return this};this.getPath=function(){return M};this.setPath=function(O){M=O||null;return this};this.getRpc=function(){return G};this.setRpc=function(O){G=O;return this};this.getUser=function(){return E};this.setUser=function(O){E=O||null;return this};this.getInterval=function(){if(C===false){return 0}if(C>0){return(C<j?j:C)}else{return 0}};this.setInterval=function(O){if(typeof O==="boolean"){C=(O?e:false)}else{if(typeof O==="number"){C=O||false}}return this};this.init(N)};x.prototype={timers:{},debug:false,testing:false,afterClick:null,afterClose:null,afterDisplay:null,afterLogin:null,xhr:false,timeout:false,init:function(z){this.resetStartTime();if(z){if(z.metadata){this.setMetadata(z.metadata)}if(z.xhr){this.xhr=z.xhr}if(z.debug){this.debug=z.debug}if(z.testing){this.testing=z.testing}if(typeof z.interval!=="undefined"){this.setInterval(z.interval)}if(typeof z.limit!=="undefined"){this.setMessageLimit(z.limit)}if(typeof z.rpc==="string"||typeof z.rpc==="function"){this.setRpc(z.rpc)}if(z.afterDisplay){this.afterDisplay=z.afterDisplay}if(z.afterClose){this.afterClose=z.afterClose}if(z.afterClick){this.afterClick=z.afterClick}if(z.afterLogin){this.afterLogin=z.afterLogin}if(z.messageType){this.setMessageType(z.messageType)}}if(this.xhr){if(!window.jQuery){i("jQuery is needed to make XHR requests","frosmo.messageApi.init()");this.setRpc(null)}else{if(!this.isXhrRpcAccessible()){i("RPC url and current document origin do not match","frosmo.messageApi.init()");this.setRpc(null)}else{b("Using XHR for making message RPC requests","frosmo.messageApi.init()")}}}if(this.getRpc()){if(typeof this.getRpc()==="function"){b("Message RPC defined as a function","frosmo.messageApi.init()")}else{b("Message RPC URL set to: "+this.getRpc(),"frosmo.messageApi.init()")}}else{b("Message RPC not defined","frosmo.messageApi.init()")}},isXhrRpcAccessible:function(){if(this.xhr){var z=this.getXhrRpcUrl();if(h(z)){return true}if(u()){return true}return false}else{return true}},getVersion:function(){return t},getTime:function(){return new Date().getTime()},getDelay:function(){var z=this.getStartTime();if(z){return this.getTime()-z}else{return null}},fetchMore:function(){var z=this.getMessageLimit();if(z===false){return true}if(this.getMessageCount()<z){return true}return false},inlineHtml:function(z){return'<div class="pmm-message"><h4 class="pmm-title">'+z.title+'</h4><div class="pmm-content">'+z.content+"</div></div>"},inlineHtmlRaw:function(z){return z.content},inlineMessage:function(E,F){var A=this,B=A.getOptions(),D,z,C;if(!B.inline){i("No inline target or callback function defined","frosmo.messageApi.inlineMessage()");return false}if(E.options.displayFormatRaw){D=A.inlineHtmlRaw.call(A,E)}else{if(typeof B.inlineHtml==="function"){D=B.inlineHtml.call(A,E)}else{D=A.inlineHtml.call(A,E)}}if(typeof B.inline==="function"){return B.inline.call(A,E,D)}if(typeof B.inline==="object"){if(typeof B.inline.html==="function"){z=B.inline.get(0)}else{z=B.inline}}else{if(B.inline.match(/^#/)){z=document.getElementById(B.inline.replace(/^#/,""))}else{z=document.getElementById(B.inline)}}z.innerHTML=D;if(E.callbacks.on.click.length>0){b("Add click tracking to the message","frosmo.messageApi.inlineMessage()");p(z,E.on.click)}if(window.FB){b("Parse XFBML elements in inline message","frosmo.messageApi.inlineMessage()");window.FB.XFBML.parse(z)}o(E.on.display,A);return true},popupHtmlRaw:function(z){return z.content},popupMessage:function(G,A){var F=this,H=F.getOptions(),E,z,D,C,B={displayDelay:0};G.callbacks.on.close.push(function(){b("Popup closed, request new messages","frosmo.messageApi.popupMessage()");F.afterRequestMessage.call(F)});if(s("0.2",A.version)){if(G.options.displayDelay>0){D=parseInt(G.options.displayDelay,10);b("Message display delay set to "+D+" second(s)","frosmo.messageApi.popupMessage()");B.displayDelay=D*1000}}if(G.options.promptDoNotShowAgain==="1"){G.content=G.content+'<div style="width:100%;text-align:right;"><input type="checkbox" id="do-not-show-again" style="width:20px" onclick="frosmo.cookies.set(\'do-not-show-again-msg-'+G.id+"',1);\"> Do not show again</div>"}if(G.options.displayFormatRaw){b("Using internal function to display message with raw content","frosmo.messageApi.popupMessage()");E=F.popupHtmlRaw(G);F.displayPopup.call(F,G,E,B);return}if(typeof H.popupHtml==="function"){b("Creating message HTML using custom popupHtml function","frosmo.messageApi.popupMessage()");E=H.popupHtml.call(F,G)}if(typeof H.popup==="function"){b("Using custom function to display message","frosmo.messageApi.popupMessage()");H.popup.call(F,G,E,B)}else{if(H.fancybox){if(window.jQuery&&jQuery.fancybox){b("Using jQuery.fancybox to display message","frosmo.messageApi.popupMessage()");F.displayFancyBox.call(F,G,E,B)}else{i("jQuery.fancybox library not loaded","frosmo.messageApi.popupMessage()")}}else{if(E){b("Using internal function to display message with custom HTML","frosmo.messageApi.popupMessage()");F.displayPopup.call(F,G,E,B)}else{if(window.frosmo.popup){(function(){b("Using frosmo.popup to generate and display message","frosmo.messageApi.popupMessage()");var I=function(){o(G.on.close,F)},K={afterClose:I},J=function(){var L=frosmo.popup.create(G.content,G.title,null,true,K)};if(G.callbacks.on.display.length>0){K.afterShow=function(){o(G.on.display,F)}}if(G.callbacks.on.click.length>0){K.afterClick=function(M,L){o(G.on.click,F,[M,L])}}G.callbacks.on.login.push(function(L){b("Call frosmo.popup.hide() when user has logged in","frosmo.messageApi.popupMessage()");frosmo.popup.hide(K)});if(B.displayDelay>0){F.timers[G.id]=window.setTimeout(function(){J.call(F)},B.displayDelay)}else{J.call(F)}}())}else{i("Can't display message: Popup HTML not defined and frosmo.popup not loaded","frosmo.messageApi.popupMessage()")}}}}},displayFancyBox:function(D,B,F,C){var z=this,A=z.getOptions(),E;if(typeof A.fancybox!=="object"){A.fancybox={}}if(!B){if(D.title){A.fancybox.title=D.title}B=D.content}E=function(){var H=A.fancybox.onClosed||null,I=A.fancybox.onComplete||null,G=A.fancybox;G.onClosed=function(){b("FancyBox closed","frosmo.messageApi.displayFancyBox()");o(D.on.close,z);o(H,this)};G.onComplete=function(){b("FancyBox displayed","frosmo.messageApi.displayFancyBox()");var J=document.getElementById("fancybox-content");D.callbacks.on.login.push(function(K){b("Close FancyBox popup when user has logged in","frosmo.messageApi.displayFancyBox()");jQuery.fancybox.close()});if(D.callbacks.on.click.length>0){b("Add click tracking to the message","frosmo.messageApi.displayFancyBox()");p(J,D.on.click)}if(window.FB){b("Parse XFBML elements in inline message","frosmo.messageApi.inlineMessage()");window.FB.XFBML.parse(J)}o(D.on.display,z);o(C,z,[D]);o(I,this)};b("Displaying message with FancyBox","frosmo.messageApi.displayFancyBox()");jQuery.fancybox(B,G)};if(F.displayDelay>0){b("Displaying message with delay","frosmo.messageApi.displayFancyBox()");z.timers[D.id]=window.setTimeout(function(){E()},F.displayDelay)}else{b("Displaying message instantly","frosmo.messageApi.displayFancyBox()");E()}},displayPopup:function(I,C,B,E){var H=this,J=H.getOptions(),D,A,F,G=function(K){if(I.callbacks.on.click.length>0){b("Add click tracking to the message","frosmo.messageApi.displayPopup()");p(K,I.on.click)}},z=function(K){if(window.FB){b("Parse XFBML elements in popup message","frosmo.messageApi.displayPopup()");window.FB.XFBML.parse(K)}};if(typeof C==="string"){b("Creating DOM elements from HTML","frosmo.messageApi.displayPopup()");D=y(C,function(K){G(K);z(K)});A=function(){document.body.appendChild(D)}}else{if(typeof C==="object"){if(q(C)){b("Appending an array of HTMLElements","frosmo.messageApi.displayPopup()");D=m(C,function(K){G(K);z(K)});A=function(){document.body.appendChild(D)}}else{if(window.jQuery&&typeof C.toArray==="function"){b("Appending elements from jQuery set","frosmo.messageApi.displayPopup()");D=m(C.toArray(),function(K){G(K);z(K)});A=function(){document.body.appendChild(D)}}else{b("Appending single DOM object","frosmo.messageApi.displayPopup()");G(C);z(C);A=function(){document.body.appendChild(C)}}}}}if(typeof A==="function"){F=function(){b("Appending popup elements to the document","frosmo.messageApi.displayPopup()");A();o(E,H,[I]);o(I.on.display(),H)};if(c(J.closePopup)){I.callbacks.on.login.push(function(K){b("Call closePopup when user has logged in","frosmo.messageApi.displayPopup()");o(J.closePopup,H)})}if(B.displayDelay>0){b("Appending message with delay","frosmo.messageApi.displayPopup()");H.timers[I.id]=window.setTimeout(function(){F()},B.displayDelay)}else{b("Appending message instantly","frosmo.messageApi.displayPopup()");F()}}},afterRequestMessage:function(){var A=this,z=A.getInterval();if(z>0){if(A.getRequestCount()<k){if(typeof A.timers.interval==="undefined"){b("Check for new messages in "+z+" ms","frosmo.messageApi.afterRequestMessage()");A.timers.interval=window.setTimeout(function(){A.timers.interval=undefined;A.requestMessage()},z)}}else{b("Message request limit ("+k+") reached","frosmo.messageApi.afterRequestMessage()")}}else{b("Message request interval not enabled","frosmo.messageApi.afterRequestMessage()")}},getRequestParams:function(){var z,G=this.getMetadata(),A=this.getRequestTime(),F=this.getMessageType(),C={origin:this.getOrigin(),version:t},H=this.getPath(),E=this.getUser(),D;if(this.debug){C.debug=1}if(E){C.path=H;C.uid=E}else{C.path=H;C.visitor=1}if(A){C.time=A}if(F){C.messageType=F}if(G){C=w(C,G)}if(frosmo.session){try{C.cid=frosmo.session.getPersistentId();D=frosmo.session.getDuration();if(D!==null){C.duration=frosmo.session.getDuration()}}catch(B){i(B)}}C.interval=this.getInterval();C.delay=this.getDelay();return C},getTestRequestParams:function(){var A=this.getRequestTime(),z=this.getMessageType(),B={path:this.getPath(),origin:this.getOrigin(),test:1,version:t};if(this.debug){B.debug=1}if(A){B.time=A}if(z){B.messageType=z}B.interval=this.getInterval();B.delay=this.getDelay();return B},getRequestData:function(){var A={},z=this.getFacebookFriends();if(z){A.facebookFriends=z}return A},requestMessage:function(){var z=this,D,C,B,E,A;if(!z.fetchMore()){frosmo.console.log("Do not fetch more messages","frosmo.messageApi.requestMessage()");return false}if(window.frosmo.popup&&frosmo.popup.visible()){b("Popup open, do not make request","frosmo.messageApi.requestMessage()");return false}if(!z.getRpc()){i("Message RPC not defined","frosmo.messageApi.requestMessage()");return false}if(z.testing){D=z.getTestRequestParams()}else{D=z.getRequestParams()}if(!D){i("No params for message RPC request","frosmo.messageApi.requestMessage()");return false}if(D.duration){b("Session duration set to "+D.duration+" ms","frosmo.messageApi.requestMessage()")}z.incrementRequestCount();A=z.getRequestData();if(z.xhr){b("Making XHR request","frosmo.messageApi.requestMessage()");return this.xhrRequest(D,A)}else{if(A){D=w(D,A)}if(typeof z.getRpc()==="function"){b("Calling RPC callback function","frosmo.messageApi.requestMessage()");z.handleResponseSuccess.call(z,z.getRpc().call(z,D));return true}else{b("Making JSONP request","frosmo.messageApi.requestMessage()");if(!frosmo.request){i("frosmo.request is not loaded","frosmo.messageApi.requestMessage()");return false}E={params:D,timeout:z.timeout,on:{failure:function(){i("JSONP request failed","frosmo.messageApi.requestMessage()")},timeout:function(){i("JSONP request timed out","frosmo.messageApi.requestMessage()")},success:function(F){b("JSONP request success","frosmo.messageApi.requestMessage()");z.handleResponseSuccess.call(z,F)}}};B=frosmo.request.create(z.getRpc(),E);B.send.apply(B);return true}}},getXhrRpcUrl:function(){var z=this.getRpc();return(typeof z==="function"?z.call(this):z)},xhrRequest:function(D,A){b("Making XHR request","frosmo.messageApi.requestMessage()");var z=this,C=z.getXhrRpcUrl(),B={cache:false,success:function(G,E,F){z.handleResponseSuccess.call(z,G,E,F)},error:function(G,E,F){},dataType:"json"};if(A){B.type="POST";B.url=C+"?"+jQuery.param(D);B.data=A}else{B.type="GET";B.url=C;B.data=D}jQuery.ajax(B);return true},handleResponseSuccess:function(A,C,F){var G=this,z,D,H,B,E;if(A){if(typeof A.version==="undefined"){A.version="0.1"}b("Message RPC version: "+A.version,"frosmo.messageApi.handleResponseSuccess()");if(A.time){G.setRequestTime(A.time)}if(typeof A.message==="undefined"){b("No messages found","frosmo.messageApi.handleResponseSuccess()");G.afterRequestMessage.call(G);return}H=A.message;B=f.POPUP;if(G.getMessage(H.id)){b("Received duplicate message: "+H.id,"frosmo.messageApi.handleResponseSuccess()");G.afterRequestMessage.call(G);return}if(H.endTime){if(new Date().getTime()>(H.endTime*1000)){b("Message in response had already expired","frosmo.messageApi.handleResponseSuccess()");G.afterRequestMessage.call(G);return}}if(s("0.2",A.version)){if(H.options.displayType){if(H.options.displayType===f.INLINE){B=f.INLINE}}}else{i("Message RPC is not up-to-date with the Javascript library","frosmo.messageApi.handleResponseSuccess()")}H.callbacks={on:{click:[],close:[],display:[],login:[]}};if(typeof G.afterDisplay==="function"){H.callbacks.on.display.push(function(){b("Calling afterDisplay callback function","frosmo.messageApi.handleResponseSuccess()");G.afterDisplay.call(G,H)})}if(typeof G.afterClose==="function"){H.callbacks.on.close.push(function(){b("Call frosmo.messageApi.afterClose() method","frosmo.messageApi.handleResponseSuccess()");G.afterClose.call(G,H)})}if(typeof G.afterClick==="function"){H.callbacks.on.click.push(function(J,I){b("Call frosmo.messageApi.afterClick() method","frosmo.messageApi.handleResponseSuccess()");G.afterClick.call(G,H,J,I)})}if(typeof G.afterLogin==="function"){H.callbacks.on.login.push(function(I){b("Call frosmo.messageApi.afterLogin() method","frosmo.messageApi.handleResponseSuccess()");G.afterLogin.call(G,H,I)})}H.on={click:function(K,J){var I;if(H.callbacks.on.click.length>0){b("Run callbacks in message.callbacks.on.click","message.on.click()");for(I=0;I<H.callbacks.on.click.length;I+=1){H.callbacks.on.click[I].call(G,K,J)}}},close:function(){var I;if(H.callbacks.on.close.length>0){b("Run callbacks in message.callbacks.on.close","message.on.close()");for(I=0;I<H.callbacks.on.close.length;I+=1){H.callbacks.on.close[I].call(G)}}},display:function(){var I;if(H.callbacks.on.display.length>0){b("Run callbacks in message.callbacks.on.display","message.on.display()");for(I=0;I<H.callbacks.on.display.length;I+=1){H.callbacks.on.display[I].call(G)}}},login:function(I){var J;if(H.callbacks.on.login.length>0){b("Run callbacks in message.callbacks.on.login","message.on.login()");for(J=0;J<H.callbacks.on.login.length;J+=1){H.callbacks.on.login[J].call(G,I)}}}};a(H);G.incrementMessageCount();G.addMessage(H);if(B===f.INLINE){b("Display inline message","frosmo.messageApi.handleResponseSuccess()");G.inlineMessage.call(G,H,A)}else{if(frosmo.cookies.get("do-not-show-again-msg-"+H.id)==="1"){b("Popup message "+H.id+" 'Do not show again' set","frosmo.messageApi.handleResponseSuccess()")}else{b("Display popup message","frosmo.messageApi.handleResponseSuccess()");G.popupMessage.call(G,H,A)}}}else{i("No response from server","frosmo.messageApi.handleResponseSuccess()")}G.afterRequestMessage.call(G)}};return x}());frosmo.message=(function(){var b=function(c,d){if(d){frosmo.console.log(d+": "+c)}else{frosmo.console.log("frosmo.message: "+c)}},a=function(c,d){if(d){frosmo.console.error(d+": "+c)}else{frosmo.console.error("frosmo.message: "+c)}};return{api:null,init:function(c){frosmo.console.log("frosmo.message: Initializing...");if(!c){c={}}if(typeof frosmo.config.message.enabled==="undefined"){frosmo.config.message.enabled=true}if(typeof c.limit==="undefined"){b("Message limit not defined, set it to unlimited","frosmo.message.init()");c.limit=false}else{if(c.limit){b("Message limit set to: "+c.limit,"frosmo.message.init()")}else{b("Message limit set to unlimited","frosmo.message.init()")}}if(!c.rpc){b("Using rpc URL from frosmo.config.message","frosmo.message.init()");c.rpc=frosmo.config.message.rpc}if(!c.afterDisplay){if(frosmo.api){b("Tracking displayed messages with frosmo.api.showMessage()","frosmo.message.init()");c.afterDisplay=function(d){b("Track message display with frosmo.api.showMessage()","frosmo.message.init()");frosmo.api.showMessage(frosmo.message.api.getUser(),d.id)}}}if(!c.afterClick){if(frosmo.api){b("Tracking message clicks with frosmo.api.clickMessage()","frosmo.message.init()");c.afterClick=function(g,f,e){var d=this;b("Track message click with frosmo.api.clickMessage()","frosmo.message.init()");frosmo.api.clickMessage(frosmo.message.api.getUser(),g.id);if(typeof e==="function"){window.setTimeout(function(){b("Call callback function after clicking","frosmo.message.init()");e.call(d)},500)}}}}this.api=new frosmo.messageApi(frosmo.config.message.origin,null,null,c);b("frosmo.messageApi version "+this.api.getVersion()+" initialized","frosmo.message.init()")},display:function(e,c,d){if(!this.api){a("frosmo.message is not initialized","frosmo.message.display()");return false}if(!frosmo.config.message.enabled){b("frosmo.message is disabled","frosmo.message.display()")}if(e!==undefined){this.api.setPath(e)}if(c!==undefined){this.api.setUser(c)}if(d!==undefined){this.api.addMetadata(d)}this.api.resetStartTime();this.api.resetRequestTime();this.api.resetMessages();this.api.requestMessage();return true}}}());frosmo.inlineMessage=(function(){var b=function(c,d){if(d){frosmo.console.log(d+": "+c)}else{frosmo.console.log("frosmo.inlineMessage: "+c)}},a=function(c,d){if(d){frosmo.console.error(d+": "+c)}else{frosmo.console.error("frosmo.inlineMessage: "+c)}};return{apis:[],show:function(g,d,c,e){frosmo.console.log("frosmo.inlineMessage: Initializing...");if(!d){b("no user","frosmo.inlineMessage.show()")}if(!g){b("no path","frosmo.inlineMessage.show()")}if(!e){e={}}if(c){e.inline=c}if(!e.inline){a("no inline container defined","frosmo.inlineMessage.show()");return false}if(typeof frosmo.config.message.enabled==="undefined"){frosmo.config.message.enabled=true}if(!frosmo.config.message.enabled){b("frosmo.message is disabled","frosmo.inlineMessage.show()");return false}if(typeof e.limit==="undefined"){b("Message limit not defined, set it to unlimited","frosmo.inlineMessage.show()");e.limit=false}else{if(e.limit){b("Message limit set to: "+e.limit,"frosmo.inlineMessage.show()")}else{b("Message limit set to unlimited","frosmo.inlineMessage.show()")}}if(!e.rpc){b("Using rpc URL from frosmo.config.message","frosmo.inlineMessage.show()");e.rpc=frosmo.config.message.rpc}if(!e.afterDisplay){if(frosmo.api){b("Tracking displayed messages with frosmo.api.showMessage()","frosmo.inlineMessage.show()");e.afterDisplay=function(h){b("Track message display with frosmo.api.showMessage()","frosmo.inlineMessage.show()");frosmo.api.showMessage(frosmo.message.api.getUser(),h.id)}}}if(!e.afterClick){b("Tracking message clicks with frosmo.api.clickMessage()","frosmo.inlineMessage.show()");if(frosmo.api){e.afterClick=function(k,j,i){var h=this;b("Track message click with frosmo.api.clickMessage()","frosmo.inlineMessage.show()");frosmo.api.clickMessage(h.getUser(),k.id);if(typeof i==="function"){window.setTimeout(function(){b("Call callback function after clicking","frosmo.inlineMessage.show()");i.call(h)},500)}}}}var f=new frosmo.messageApi(frosmo.config.message.origin,g,d,e);b("frosmo.messageApi version "+f.getVersion()+" initialized","frosmo.inlineMessage.show()");this.apis.push(f);if(e.metaData!==undefined){f.addMetadata(e.metaData)}f.requestMessage();return true}}}());window.SocialOptimizer=(function(){return{debug:false,testMode:false,target:null,interval:0,popupMessage:null,inlineMessage:null,displayPopup:null,metadata:null,init:function(b,d,a){frosmo.console.log("WARNING: Using deprecated SocialOptimizer API");var c=new frosmo.messageApi(b,d,a,this.getOptions());if(window.jQuery){jQuery(document).ready(function(){c.requestMessage()})}},getOptions:function(){var a={};if(typeof this.interval==="number"||typeof this.interval==="boolean"){a.interval=this.interval}if(typeof this.debug==="boolean"){a.debug=this.debug}if(typeof this.testMode==="boolean"){a.testing=this.testMode}if(typeof this.messageRpc==="string"){a.rpc=this.messageRpc}if(this.metadata){a.metadata=this.metadata}if(typeof this.target==="function"||typeof this.target==="string"||typeof this.target==="object"){a.inline=this.target}if(typeof this.displayPopup==="function"){a.popup=this.displayPopup}if(typeof this.popupMessage==="function"){a.popupHtml=this.popupMessage}if(typeof this.inlineMessage==="function"){a.inlineHtml=this.inlineMessage}return a}}}());(function(){var a,i,j,e=function(p,q){if(q){frosmo.console.log(q+": "+p)}else{frosmo.console.log("frosmo.popup: "+p)}},k=function(p,q){if(q){frosmo.console.error(q+": "+p)}else{frosmo.console.error("frosmo.popup: "+p)}},d=function(){if(a){a=null}},g=function(){if(a&&a.is(":visible")){return true}else{return false}},o=function(r,s){var q=jQuery(window),t,p,v={},u={horizontal:true,vertical:true,margin:frosmo.config.popup.centerIncludeMargins};r=jQuery(r);s=jQuery.extend(u,s);if(s.horizontal){if(s.margin){t=r.outerWidth({margin:true})}else{t=r.width()}v.left=Math.floor(Math.max((q.width()-t)/2,0))}if(s.vertical){if(s.margin){p=r.outerHeight({margin:true})}else{p=r.height()}v.top=Math.floor(Math.max((q.height()-p)/2,0))}if(v){v.position="fixed";r.css(v)}},c=function(q){if(!a){k("No popup found to hide","frosmo.popup.hide()");return}var r={hideBackground:true},p=function(){if(q.hideBackground){e("Hide background","frosmo.popup.hide()");j.hide()}if(q&&typeof q.afterClose==="function"){e("Calling afterClose callback function","frosmo.popup.hide()");q.afterClose.call(window)}};q=jQuery.extend(r,q);e("Hide popup","frosmo.popup.hide()");if(g()){e("Popup is visible, hiding it","frosmo.popup.hide()");a.hide(frosmo.config.popup.animationSpeed,p)}else{e("Popup is already hidden","frosmo.popup.hide()");p()}},l=function(r){var p=this,q;e("Showing popup","frosmo.popup.show()");a.find(".frosmoPopupClose").click(function(s){s.preventDefault();e("User clicked close button in popup","frosmo.popup.show()");p.hide(r)});if(r&&r.closeOnBgClick){jQuery("#frosmoPopupBackground").bind("click.bg",function(s){s.preventDefault();e("User clicked background in popup","frosmo.popup.show()");p.hide(r);j.unbind("click.bg")})}if(r&&r.closeOnEsc){jQuery(document).bind("keyup.esc",function(s){if(s.keyCode===27){s.preventDefault();e("User pressed esc","frosmo.popup.show()");p.hide(r);jQuery(document).unbind("keyup.esc")}})}if(r&&r.center){e("Center popup","frosmo.popup.show()");frosmo.popup.center(a,r.centerOptions||null);jQuery(window).resize(function(s){frosmo.popup.center(a,r.centerOptions)})}if(r&&typeof r.afterClick==="function"){e("Add afterClick callbacks to popup links and forms","frosmo.popup.show()");a.find("a").not("#frosmoPopupClose").not(".fb_button").bind("click",function(u){u.preventDefault();e("User clicked a link in the popup","frosmo.popup.show()");var t=jQuery(this),s=this.href;r.afterClick.call(window,u,function(){e("Link afterClick complete callback, update window.location","frosmo.popup.show()");t.unbind(u);if(s){window.location.href=s}})});a.find("form").bind("submit",function(t){t.preventDefault();e("User submitted a form in the popup","frosmo.popup.show()");var s=jQuery(this);r.afterClick.call(window,t,function(){e("From afterClick complete callback, submit form data","frosmo.popup.show()");s.unbind(t);s.submit()})});if(frosmo.fbWrapper){e("Add event listeners to Facebook buttons","frosmo.popup.show()");frosmo.fbWrapper.bindButtonClicks(a.get(0),r.afterClick)}}if(window.FB){e("Parse XFBML elements in popup","frosmo.popup.show()");FB.XFBML.parse(a.get(0))}q=function(){if(r&&typeof r.afterShow==="function"){e("Calling afterShow callback function","frosmo.popup.show()");r.afterShow.call(window)}};j.show();if(g()){e("Message is already visible","frosmo.popup.show()");q()}else{e("Displaying message","frosmo.popup.show()");a.show(frosmo.config.popup.animationSpeed,q)}},m=function(p){if(typeof p!=="string"){p=""}var q=frosmo.config.popup.closeButtonAltText?frosmo.config.popup.closeButtonAltText:frosmo.config.popup.closeButtonText;return'<div id="frosmoPopupHeader">'+p+'<a href="#" id="frosmoPopupClose" class="frosmoPopupClose" title="'+q+'">'+frosmo.config.popup.closeButtonText+"</a></div>"},f=function(p){if(typeof p!=="string"){p=""}return'<div id="frosmoPopupContent">'+p+"</div>"},b=function(p){if(typeof p!=="string"){p=""}return'<div id="frosmoPopupFooter">'+p+"</div>"},h=function(p){a=jQuery(p);if(!i){e("Append popup container to the document","frosmo.popup.set()");i=jQuery('<div id="frosmoPopupContainer"></div>');jQuery("body").append(i)}if(!j){e("Append popup background to the document","frosmo.popup.set()");j=jQuery('<div id="frosmoPopupBackground"></div>');jQuery("body").append(j)}e("Appending popup HTML","frosmo.popup.set()");i.html(a)},n=function(t,s,w,x,z){var y=this,p=y.header(s),u=y.content(t),v=y.footer(w),q='<div id="frosmoPopup">'+p+u+v+"</div>",r={closeExisting:false,center:frosmo.config.popup.center,closeOnBgClick:frosmo.config.popup.closeOnBgClick,closeOnEsc:frosmo.config.popup.closeOnEsc};z=jQuery.extend(r,z);if(x){e("Created popup and displaying it","frosmo.popup.create()");if(z.closeExisting&&g()){e("Hide existing popup before replacing it","frosmo.popup.create()");y.hide({hideBackground:false,afterClose:function(){y.set(q);y.show(z)}})}else{y.set(q);y.show(z)}return a}else{e("Created popup and returned HTML","frosmo.popup.create()");return q}};if(!window.frosmo){window.frosmo={}}if(!window.frosmo.config){window.frosmo.config={}}window.frosmo.popup={header:m,content:f,footer:b,create:n,visible:g,center:o,set:h,show:l,hide:c};window.frosmo.config.popup={animationSpeed:200,closeButtonText:"Close",center:false,closeOnBgClick:false,closeOnEsc:false,centerIncludeMargins:false}}());frosmo.sanitizer=(function(){var c={clone:function(g){var e,f;if(g===null||typeof(g)!=="object"){return g}if(g instanceof Array){return{}}e=new g.constructor();for(f in g){if(g.hasOwnProperty(f)){e[f]=g[f]}}return e},unescapeParam:function(e){return unescape(e)},decodeParam:function(f){try{return decodeURIComponent(f)}catch(e){return f}},removeTrailingSpaces:function(e){return e.replace(/^\s+|\s+$/g,"")},trim:function(f,e){e=parseInt(e,10);return f.substr(0,e)},matchDate:function(g,f){var h=new RegExp(f),e=g.match(h);if(e){g=g.replace(/-00/g,"-01")}else{g=""}return g}},b=function(e,f){var g=f.split(":");e=c.decodeParam(e);e=c.unescapeParam(e);e=c.removeTrailingSpaces(e);switch(g[0]){case"0":if(typeof e==="string"){e=parseInt(e,10)}break;case"1":e=c.trim(e,g[1]);break;case"3":e=c.matchDate(e,g[2]);break;default:break}return e},d={user:{userId:"0",country:"1:4",language:"1:4",gender:"1:1",email:"1:96",dob:"3:10:^\\d{4}-(\\d{2})-\\d{2}$",rank:"0",source:"1:32",city:"1:16",displayname:"1:20",firstname:"1:16",lastname:"1:16",facebookId:"0",linkedinId:"1:10",registrationTime:"3:19:^\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}$"},product:{productType:"1:32",productName:"1:64",productUrn:"1:32",productCategory:"1:32",productCampaign:"1:32",productArea:"1:32",productCountry:"1:32",productCity:"1:32",productVenue:"1:32",productCompany:"1:32",productManufacturer:"1:32",productModel:"1:32"}},a=function(e,h){var g,f=c.clone(e);if(typeof f==="object"){for(g in f){if(f.hasOwnProperty(g)){if(d[h][g]){f[g]=b(f[g],d[h][g]);if(!f[g]){delete f[g]}}else{delete f[g];frosmo.console.log("Deleting unidentified attribute:"+g)}}}}else{f={}}return f};return{userData:function(e){return a(e,"user")},productData:function(e){return a(e,"product")}}}());(function(){var b=[],a=[],d,c=function(f){var h=document.getElementsByTagName("head")[0],g=document.createElement("script");g.type="text/javascript";g.charset="utf-8";g.src=f;h.appendChild(g)},e=function(h){var g=document.getElementsByTagName("head")[0],f=document.createElement("link");f.type="text/css";f.rel="stylesheet";f.href=h;g.appendChild(f)};a=[];for(d=0;d<b.length;d++){c(b[d])}for(d=0;d<a.length;d++){e(a[d])}}());if(!frosmo.verkkoteollisuus){frosmo.verkkoteollisuus={}}frosmo.verkkoteollisuus.loadConfig=function(){jQuery("html").attr("XMLNS:frosmo","www.frosmo.com");jQuery("html").attr("XMLNS:fb","www.facebook.com/2008/fbml");jQuery("html").attr("XMLNS:og","http://ogp.me/ns#");frosmo.config.debug=false;frosmo.config.api.server="http://frosmo.com/optimizerApi?";frosmo.config.api.origin="verkkoteollisuus";frosmo.config.message={origin:frosmo.config.api.origin,rpc:"http://frosmo.com/messageApi?",debug:frosmo.config.debug};switch(frosmo.cookies.get("frosmo_mode")){case"dev47":frosmo.config.debug=true;frosmo.console.log("============= Development Mode: Sovereign =================");frosmo.config.api.server="http://83.145.240.209:1111/optimizerApiTesting?";frosmo.config.message.rpc="http://83.145.240.209:1111/messageApi?";frosmo.config.message.debug=true;break;case"stage47":frosmo.config.debug=true;frosmo.console.log("============= Staging Mode: frosmodev =================");frosmo.config.api.server="http://frosmodev.com/optimizerApi?";frosmo.config.message.rpc="http://frosmodev.com/messageApi?";break;case"release47":frosmo.config.debug=true;frosmo.config.message.debug=true;frosmo.console.log("============= Release Mode: frosmo =================");break}};(function(){frosmo.utils.urlSplitter=function(d){var c,b={},e=/^((?:ht|f)tp(?:s?)\:)\/\/(?:\w+:\w+@)?(((?:[\-\w]+\.)+(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{1,4})|(?:[\d]{1,3}){4}|(?:[\w]+))(:[\d]{1,5})?)((?:(?:\/(?:[\-\w~!\$\+\|\.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?((?:(?:\?(?:[\-\w~!\$\+\|\.,\*:]|%[a-f\d{2}])+=?(?:[\-\w~!\$\+\|\.,\*:=]|%[a-f\d]{2})*)(?:&(?:[\-\w~!\$\+\|.,*:]|%[a-f\d{2}])+=?(?:[\-\w~!\$\+\|\.,\*:=]|%[a-f\d]{2})*)*)*)?(#(?:[\-\w~!\$\+\|\.,\*:=]|%[a-f\d]{2})*)?$/i;if((c=e.exec(d))){b.href=c[0];b.protocol=c[1]||null;b.host=c[2]||null;b.hostname=c[3]||null;b.port=c[4]||null;b.pathname=c[5]||null;b.search=c[6]||null;b.hash=c[7]||null}return b};var a=(function(){var d,e=false,c="",f="",b=document.getElementsByTagName("link");for(d=0;d<b.length;d++){if(b[d].rel){if(b[d].rel==="canonical"&&b[d].href){e=true;c=b[d].href;f=frosmo.utils.urlSplitter(c)}}}return{isExist:function(){return e},getUrl:function(){return c},getPath:function(){var g="";if(typeof f==="object"){g=f.pathname}return g}}}());if(!frosmo.domAdapter){frosmo.domAdapter={}}frosmo.domAdapter=function(){var i="",d="",b="",c="",f="",e="",h="",g={};i=window.location.protocol;d=window.document.referrer;b=window.location.href;c=window.location.search;e=window.location.host;h=window.document.title;g=frosmo.utils.getUrlParams();if(window.location.pathname==="/"){f=window.location.pathname}else{if(a.isExist()){f=a.getPath()}else{f=window.location.pathname}}f=f.replace(/\//g,":/");f=f.split(":");f.shift();this.getProtocol=function(){return i};this.getReferrer=function(){return d};this.getHref=function(){return b};this.getSearch=function(){return c};this.getPath=function(){return f};this.getHost=function(){return e};this.getUrlParams=function(){return g};this.title=function(){return h}}}());(function(){var d=new frosmo.domAdapter(),a,b=d.getPath(),c;frosmo.verkkoteollisuus.descriptions={translate:{"/":"Etusivu","/Toiminta":"Toiminta","/Laatumerkki":"Laatumerkki","/Tietoa-yhdistyksesta":"Verkkoteollisuus-ry","/Yhdistyksen-jasenet":"Jasenet","/Tule-mukaan":"Tule-mukaan","/Blogi":"Blogi","/Yhteystiedot":"Yhteystiedot"}};if(b.length>0){b[0]=frosmo.verkkoteollisuus.descriptions.translate[b[0]];if(b.length===2){b[1]=b[1].replace(/\//g,"");c=b[1]}else{c=b[0]}a=b.join(":")}jQuery("head").append('<meta property="og:type" content="pages"/>');jQuery("head").append('<meta property="frosmo:pathname" content="'+a+'"/>');jQuery("head").append('<meta property="frosmo:productType" content="'+b[0]+'"/>');jQuery("head").append('<meta property="frosmo:productName" content="'+c+'"/>')}());frosmo.verkkoteollisuus.parseMetaTag=function(){var b,a={},c;c=function(){b=jQuery(this).attr("property").split(":");a[b[1]]=jQuery(this).attr("content")};jQuery('meta[property^="frosmo"]').each(c);jQuery('meta[property^="og"]').each(c);return a};frosmo.utils.product=(function(){var a={};a=function(){var b=frosmo.verkkoteollisuus.parseMetaTag();this.id="";this.name="";this.type="";if(b.productName&&b.productName!=="undefined"){this.id="id:"+b.productName;this.name=b.productName}if(b.productType&&b.productType!=="undefined"){this.type=b.productType}this.category="";this.getProductId=function(){return this.id};this.getType=function(){return this.type};this.getName=function(){return this.name};this.getProductAttributes=function(){return{productType:this.type,productName:this.name,productCategory:this.category}}};a.prototype.setProductData=function(){frosmo.console.log("********SetProduct Data: Done **********");frosmo.api.setProductData(this.getProductId(),frosmo.sanitizer.productData(this.getProductAttributes()))};a.prototype.viewProduct=function(){frosmo.console.log("********ViewProduct: Done**********");frosmo.api.viewProduct(frosmo.session.getUserId(),null,this.getProductId())};a.pages=function(){this.category=this.name};a.factory=function(b){var c="";if(a[b]&&typeof a[b]==="function"){a[b].prototype=new a();c=new a[b]()}else{frosmo.console.log("No such product specified")}return c};return{factory:a.factory}}());frosmo.verkkoteollisuus.main={productTracker:function(){if(window.location.href.match(/ViewAction=ViewFBForm\&ObjectID=11294/)){var d=jQuery("div[class=ThanksMessage]"),b=jQuery("#Liity_jaseneksi");if(d.length>0&&b.length===0){frosmo.api.buyProduct(frosmo.session.getUserId(),"","id:membership","1","0","0","")}else{if(b.length>0&&d.length===0){frosmo.api.setProductData("id:membership",{productType:"membership"});frosmo.api.viewProduct(frosmo.session.getUserId(),"","id:membership")}}}else{var a=frosmo.verkkoteollisuus.parseMetaTag(),c=frosmo.utils.product.factory(a.type);if(c.getProductId()){c.setProductData();c.viewProduct()}}}};frosmo.init=(function(){var b,f,e,a,c,d;b=function(){frosmo.verkkoteollisuus.loadConfig()};f=function(){frosmo.api.init(frosmo.config.api.server,frosmo.config.api.origin)};a=function(){frosmo.session.init()};e=function(){frosmo.message.init()};c=function(){frosmo.console.log("Initializing product tracker");frosmo.verkkoteollisuus.main.productTracker()};d=function(){frosmo.console.log("Initializing frosmo componenets");b();f();a();c()};return d}());jQuery(document).ready(function(){frosmo.init()});
