/* R_20120223-1241 | af830ff1e5564b27048d36cf6fc6d8154188010b */
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")}}}());if(!window.frosmo){window.frosmo={}}(function(){var c=window.frosmo,a=function(){return(c.config.debug&&window.console)},b=function(){var h=arguments[0],g,e,f;if(!a()){return}e=Array.prototype.slice.call(arguments,1);try{f=(e.length>1?JSON.stringify(e):e[0])}catch(d){f=e.toString()}if(h==="debug"){g="log";f=h.toUpperCase()+": "+f}else{if(h==="deprecated"){g="warn";f=h.toUpperCase()+": "+f}else{g=h}}if(typeof window.console[g]==="function"){window.console[g](f)}else{window.console.log(h.toUpperCase()+": "+f)}if(c.admin){if(!window.frosmo.log){window.frosmo.log={}}if(!c.log[h]){c.log[h]=[]}c.log[h].push(f)}};if(!c){c={api:null,pb:null,messageApi:null,message:null,fbWrapper:null,fbElement:null,cookies:null,session:null,pmm:null,site:{events:null,contexts:null,config:{init:null},auth:null},event:null}}if(!c.config){c.config={origin:null,css:null,domain:null,pathname:window.location.pathname,api:{server:null},message:{rpc:null,enabled:true},fbWrapper:{locale:null,reloadOnLogin:null,cookieName:null,permissions:null,fbAppId:null,fanPageHref:false,loginTimeout:false,oauth:true},popup:{animationSpeed:200,closeButtonText:"Close",destroyOnClose:true},pb:{html:null,popups:null,navigation:null,apiUrl:null},cookies:{domain:window.location.host},user:{anonymize:false},product:{rpc:null},admin:{js:null},debug:false};c.config.get=function(e){var d=e.split("."),f,g=null;for(f=0;f<d.length;f=f+1){if(f===0&&c.config[d[f]]){g=c.config[d[f]]}else{if(g&&g[d[f]]){g=g[d[f]]}else{return null}}}return g}}if(!c.browser){c.browser={cors:function(){if(window.XMLHttpRequest){var d=new XMLHttpRequest();if("withCredentials" in d){return true}else{if(window.XDomainRequest){return true}}}return false}}}if(!c.error){c.error={log:function(d,e){e=e||0;c.console.error(d+" ["+e+"]");c.api.error(d,e)}}}c.error.SESSION_INVALID_CID=10001;c.error.SESSION_UNDEFINED_STARTTIME=10002;c.error.MESSAGE_CID_MISSING=20001;c.error.INIT_CID_MISSING=30001;c.error.INIT_SESSION_FAILED=30003;c.error.INIT_JSTORAGE_MISSING_BACKEND=30004;if(!c.enableDebug){c.enableDebug=function(){c.config.debug=true}}if(!c.console){c.console={log:function(){var d=["log"];d=d.concat(Array.prototype.slice.call(arguments));b.apply(this,d)},debug:function(){var d=["debug"];d=d.concat(Array.prototype.slice.call(arguments));b.apply(this,d)},info:function(){var d=["info"];d=d.concat(Array.prototype.slice.call(arguments));b.apply(this,d)},warn:function(){var d=["warn"];d=d.concat(Array.prototype.slice.call(arguments));b.apply(this,d)},error:function(){var d=["error"];d=d.concat(Array.prototype.slice.call(arguments));b.apply(this,d);if(a()&&typeof window.console.trace==="function"){window.console.trace()}},deprecated:function(){var d=["deprecated"];d=d.concat(Array.prototype.slice.call(arguments));b.apply(this,d);if(a()&&typeof window.console.trace==="function"){window.console.trace()}}}}if(!c.addCss){c.addCss=function(f,g){var e=false,h,d;if(typeof f==="undefined"||f===null){return}h=document.createElement("link");h.type="text/css";h.rel="stylesheet";h.href=f;h.onload=function(){if(!e){e=true;c.console.log("frosmo.core.js -- loaded CSS file: "+f);if(g){g(h)}}};document.getElementsByTagName("head")[0].appendChild(h);if(document.body){d=document.createElement("img");d.src=f;d.onerror=function(){if(!e){e=true;c.console.log("frosmo.core.js -- loaded CSS file: "+f);if(g){g(h)}}document.body.removeChild(d)};document.body.appendChild(d)}else{c.console.error("Trying to load CSS file before document is fully loaded")}}}if(!c.site){c.site={}}if(!c.loader){c.loader={ready:function(d){d.call(window)}}}c.EventHandler={bind:function(f,h,e){var d,g;d=this._callbacks||(this._callbacks={});g=d[f]||(d[f]=[]);g.push([h,e]);return this},unbind:function(g,j){var f,h,e,d;if(!g){this._callbacks={}}else{if(this._callbacks){f=this._callbacks;if(!j){f[g]=[]}else{h=f[g];if(!h){return this}for(e=0,d=h.length;e<d;e++){if(h[e]&&j===h[e][0]){h[e]=null;break}}}}}return this},trigger:function(f){var g,n,k,m,h,e,d,j=2;if(!(n=this._callbacks)){return this}while(j--){k=j?f:"all";g=n[k];if(g){for(e=0,d=g.length;e<d;e+=1){if(!(m=g[e])){g.splice(e,1);e--;d--}else{h=j?Array.prototype.slice.call(arguments,1):arguments;m[0].apply(m[1]||this,h)}}}}return this}}}());frosmo.api=(function(){var k="2.13",a=0,c,g,l=[],f=function(q,m){var o,p,n,r,s={};if(typeof c==="undefined"||typeof g==="undefined"){l.push({event:q,args:m});frosmo.console.error('frosmo.api: API not initialized, event "'+q+'" queued');return null}for(o in m){if(m[o] instanceof Object){n=m[o];for(p in n){if(n.hasOwnProperty(p)){s[p]=n[p]}}}else{if(m[o]===undefined){s[o]=null}else{s[o]=m[o]}}}for(o in s){if(s[o]===null||s[o]===false){s[o]=""}else{if(s[o]===true){s[o]="1"}}}if(frosmo.session){if(q!=="error"||frosmo.session.hasPersistentId()){s.cookieId=frosmo.session.getPersistentId();frosmo.console.log('frosmo.api: Event "'+q+'" using cookieId "'+s.cookieId+'"')}else{frosmo.console.log('frosmo.api: Event "'+q+'" with missing cookieId')}}else{frosmo.console.log('frosmo.api: Event "'+q+'" without cookieId')}s.event=q;s.origin=g;r=[];for(o in s){if(s.hasOwnProperty(o)){r.push(encodeURIComponent(o)+"="+encodeURIComponent(s[o]))}}return c+r.join("&")+"&"+(a+=1)},j=function(n){var o=n.getFullYear(),p=n.getMonth(),m=n.getDate();if(p<10){p="0"+p}if(m<10){m="0"+m}return o+"-"+p+"-"+m},i=function(o){var m=o.getHours(),p=o.getMinutes(),n=o.getSeconds();if(m<10){m="0"+m}if(p<10){p="0"+p}if(n<10){n="0"+n}return m+":"+p+":"+n},d=function(m){return j(m)+" "+i(m)},b=function(n){if(n){var m=new Image();m.src=n;frosmo.console.log("frosmo.api: Call URL "+n)}},e=function(){var o,m,n;if(l.length>0){for(o=0,m=l.length;o<m;o+=1){frosmo.console.log('frosmo.api: Call queued "'+l[o].event+'" event');n=f(l[o].event,l[o].args);b(n)}l=[]}},h=function(m,n){c=m;g=n;frosmo.console.log('frosmo.api: Initialized with origin "'+g+'"');e()};return{VERSION:k,init:h,setCallUrl:function(m){b=m},error:function(o,p){var n,m=window.location.href,q=navigator.userAgent;p=p||0;n=f("error",{error:o,code:p,href:m,ua:q});b(n)},custom:function(n){var m=f("custom",n);b(m)},login:function(o,n){var m=f("login",{userId:o,source:n});b(m)},publishFeed:function(m,o,p){var n=f("publishFeed",{feedType:m,userId:o,uniqueId:p});b(n)},clickFeed:function(m,o,p){var n=f("clickFeed",{feedType:m,userId:o,uniqueId:p});b(n)},viewProduct:function(p,o,n){var m=f("viewProduct",{userId:p,productType:o,productId:n});b(m)},buyProduct:function(t,s,q,n,m,p,r){var o=f("buyProduct",{userId:t,productType:s,productId:q,netValue:n,fee:m,tax:p,paymentChannel:r});b(o)},setUserData:function(o,n){var m=f("setUserData",{userId:o,userAttributes:n});b(m)},showMessage:function(p,o,n){var m=f("showMessage",{userId:p,messageId:o,revision:n});b(m)},clickMessage:function(p,o,n){var m=f("clickMessage",{userId:p,messageId:o,revision:n});b(m)},setCustomUserData:function(o,m){var n=f("setCustomUserData",{userId:o,customUserAttributes:m});b(n)},visit:function(p,o,n){var m=f("visit",{userId:p,source:o,newSession:n});b(m)},setProductData:function(n,o){var m=f("setProductData",{productId:n,productAttributes:o});b(m)},clearCustomAttribute:function(o,n){var m=f("clearCustomAttribute",{userId:o,customAttributeName:n});b(m)},setUserSegment:function(p,o,m){var n=f("setUserSegment",{userId:p,segmentName:o,segmentValue:m});b(n)},clearUserSegment:function(o,n){var m=f("clearUserSegment",{userId:o,segmentName:n});b(m)}}}());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.event=(function(){var g=function(){if(typeof frosmo.api==="undefined"){throw new Error("frosmo.api.js not loaded (required by frosmo.event.js)")}if(typeof frosmo.session==="undefined"){throw new Error("frosmo.session.js not loaded (required by frosmo.event.js)")}if(typeof frosmo.user==="undefined"){throw new Error("frosmo.user.js not loaded (required by frosmo.event.js)")}},d=function(i,h){frosmo.console.log("frosmo.event.login() userId: "+i);frosmo.user.setUserData(i,h);frosmo.session.login();frosmo.api.login(i,(frosmo.session?frosmo.session.getSource():null));if(frosmo.site.event.login){frosmo.site.event.login()}},b=function(){frosmo.console.log("frosmo.event.logout()");var h=frosmo.site.auth&&frosmo.site.auth.isLoggedIn?frosmo.site.auth.isLoggedIn():false;if(!frosmo.fbWrapper.getLoggedIn()&&!h){frosmo.console.log("not logged in with FB or site: "+h+" & "+frosmo.fbWrapper.getLoggedIn());frosmo.user.deleteUserData()}if(frosmo.site.event.logout){frosmo.site.event.logout()}},c=function(i,j){i=i||null;j=j||i;frosmo.console.log("frosmo.event.newVisitor()");frosmo.api.setUserData(null,{source:j});frosmo.api.visit(null,i,true);var h=function(){if(frosmo.site.event.newVisitor){frosmo.site.event.newVisitor()}};frosmo.init.afterInit(h)},a=function(i){frosmo.console.log("frosmo.event.returningVisitor()");frosmo.api.visit(null,i,false);var h=function(){if(frosmo.site.event.returningVisitor){frosmo.site.event.returningVisitor()}};frosmo.init.afterInit(h)},f=function(){var h=arguments[0]||{},i;frosmo.console.log("Event Call >>>> Message Call with context name");if(h.inline){if(typeof h.inline==="object"){if(typeof h.inline.html==="function"){i=h.inline.get(0)}else{i=h.inline}}else{if(h.inline.match(/^#/)){i=document.getElementById(h.inline.replace(/^#/,""))}else{i=document.getElementById(h.inline)}}if(!i||i.length===0){frosmo.console.error("Can not find inline element!!!",h.inline);return}}h.inline=i;if(i&&h.position){frosmo.console.log("calling message to position: "+h.position);frosmo.message.display(h.position,h)}else{frosmo.console.log("calling popup message");frosmo.message.display()}},e=function(){frosmo.console.log("Event Call >>>> viewProduct");frosmo.pageContext.viewProduct()};return{init:g,login:d,logout:b,newVisitor:c,returningVisitor:a,provideMessage:f,viewProduct:e}}());frosmo.fbElement=(function(){var b={"login-button":"show-faces, width, max-rows, autologoutlink, scope, perms, registration-url, onlogin",activity:"site, width, height, colorscheme, font, border_color, recommendations, header, filter",recommendations:"site, width, height, colorscheme, font, border_color, header, filter",like:"href, width, layout, action, font, colorscheme, ref, show_faces, send",comments:"xid, numposts, width",facepile:"max-rows, width, href, app_id","live-stream":"event_app_id, width, height, xid, via_url, always_post_to_friends","share-button":"href, type","like-box":"href, width, connections, stream, header","multi-friend-selector":"actiontext, showborder, rows, max, exclude_ids, bypass, email_invite, cols, import_external_friends","request-form":"type, content, invite, action, method",serverFbml:"style, width"},a={liveStream:function(e){if(e.event_app_id.length===0){frosmo.console.error("liveSteam: event_app_id can't be empty");return false}return true},likeBox:function(e){if(e.href.length===0){frosmo.console.error("like-box attribute: href must be defined");return false}return true}},c=function(f,i,e){var h,g=document.createElement("fb:"+f);for(h in i){if(i.hasOwnProperty(h)){if(!e[h]&&h!=="class"){frosmo.console.error(f+" doesn't have attribute: "+h);return null}else{if(h==="class"){g.className=i[h]}else{g.setAttribute(h,i[h])}}}}if(a[f]){if(!a[f](i)){return null}}return g},d=function(h){var g,f=b[h].split(", "),e={};for(g=0;g<f.length;g+=1){e[f[g]]=1}return function(i){return c(h,i,e)}};return{activityFeed:d("activity"),comments:d("comments"),facepile:d("facepile"),likeButton:d("like"),likeBox:d("like-box"),liveStream:d("live-stream"),loginButton:d("login-button"),recommendations:d("recommendations"),shareButton:d("share-button"),requestForm:d("request-form"),multiFriendSelector:d("multi-friend-selector"),serverFbml:d("serverFbml")}}());frosmo.fbWrapper=(function(){var x=null,A=false,h,f=null,e=null,F=true,L,i,D=null,I=function(O,P){if(P){frosmo.console.log(P+": "+O)}else{frosmo.console.log("frosmo.fbWrapper: "+O)}},p=function(O,P){if(P){frosmo.console.error(P+": "+O)}else{frosmo.console.error("frosmo.fbWrapper: "+O)}},y=function(P){var R="abcdefghijklmnopqrstuvwxyz0123456789",Q="",O;if(!P){P=32}for(O=0;O<P;O+=1){Q+=R.charAt(Math.floor(Math.random()*R.length))}return Q},w=[],o=[],q=function(R){var O,Q,P=0;if(w.length===0){return false}for(O=0;O<w.length;O+=1){if(w[O].callback.id===R.id){w.splice(O,1);P+=1}}return P},s=function(R){var O,Q,P=0;if(o.length===0){return false}for(O=0;O<o.length;O+=1){if(o[O].callback.id===R.id){o.splice(O,1);P+=1}}return P},B=function(O,P){if(O.params.ref||O.params.href){w.push({element:O,callback:P});return true}return false},m=function(O,P){o.push({element:O,callback:P});return true},E=function(O,S){if(w.length===0){return}var R=S.getAttribute("ref"),Q,T,P;for(Q=0;Q<w.length;Q+=1){P=w[Q].element;T=w[Q].callback;if(R){if(!P.params.ref||P.params.ref!==R){continue}}else{if(P.params.ref){continue}}if(P.params.href&&P.params.href!==O){continue}if(R){I('Found callback function for element with ref "'+R+'"')}else{I("Found callback function for element with no ref attribute")}T.on.click.call(window,O,S)}},r=function(O,P){return{element:O,params:P}},k=function(O){var Q=[],P=function(U){var V,T,S,W,R=O.getElementsByTagName("fb:"+U);for(V=0;V<R.length;V+=1){W={};S=R[V].attributes;for(T=0;T<S.length;T+=1){W[S[T].nodeName]=S[T].nodeValue}Q.push(r(U,W))}};P("like");P("login-button");return Q},H=function(O){return new RegExp("(<fb:"+O+"[^>]*>[^<]*</fb:"+O+">)")},t=function(P){var R=[],Q=function(X,V){var Y={},U,W,T,S;if(X.length>0){V=V.replace(/'/g,'"');for(T=0;T<X.length;T+=1){if(X[T]){U=new RegExp(X[T]+'="([^"]+)"');if((S=U.exec(V))){Y[X[T]]=S[1]}}}}return Y},O=function(U,Y,W,Z){var T=[],S,X,V;while(W.length>0&&(S=Y.exec(W))){W=W.substr(S.index+S[0].length);T.push(r(U,Q(Z,S[1])))}if(T.length>0){for(V=0;V<T.length;V+=1){if(typeof T[V]==="object"){R.push(T[V])}}}};O("like",H("like"),P,["ref","href"]);O("login-button",H("login-button"),P,["onclick"]);return R},g=function(){},C=function(O,R){var Q=R.getAttribute("ref"),P,S;if(Q){frosmo.api.publishFeed(Q,frosmo.fbWrapper.getUserId(),null);I('Logged fb-like with ref "'+Q+'"')}else{frosmo.api.publishFeed("like",frosmo.fbWrapper.getUserId(),null);I("Logged fb-like without ref")}E.call(window,O,R)},l=function(P,O){if(!P){f={};e={}}else{f=P;e={country:(function(){if(f.current_location&&f.current_location.country){return f.current_location.country.substring(0,2)}else{return null}}()),gender:(function(){if(f.sex){return f.sex.substring(0,1)}else{return null}}()),dob:(function(){if(f.birthday_date===null){return null}var Q=f.birthday_date.split("/");if(Q.length===3){return Q[2]+"-"+Q[0]+"-"+Q[1]}else{return null}}()),city:(function(){if(f.current_location){return f.current_location.city}else{return null}}()),email:f.email,displayname:f.name,firstname:f.first_name,lastname:f.last_name,facebookId:f.uid,language:f.locale.replace("_","")}}if(typeof O==="function"){O.call(this)}},d=function(O){var Q="SELECT uid,first_name,last_name,name,email,locale,current_location,sex,birthday_date,pic_square,pic_square_with_logo FROM user WHERE uid = me()",P=FB.Data.query(Q);P.wait(function(R){if(!R||R.length===0){l(null,O);p("failed to fetch userinfo from Facebook")}else{l(R[0],O)}})},u=function(O){if(!A||!f){return null}if(O.indexOf(".")!==-1){var P=O.split(".");if(typeof f[P[0]]!=="undefined"&&f[P[0]]&&typeof f[P[0]][P[1]]!=="undefined"&&f[P[0]][P[1]]){return f[P[0]][P[1]]}else{return null}}if(typeof f[O]==="undefined"||!f[O]){return null}else{return f[O]}},a=function(O){var P=u(O);if(P===null){return""}else{return P}},c=function(O){I("Handle login");var P=function(){A=true;frosmo.event.login(f.uid,e);if(window.FrosmoNavigation){FrosmoNavigation.triggerEvent("facebook_login")}if(frosmo.config.fbWrapper.reloadOnLogin){window.location.reload()}};d(P)},N=function(P){var R,O,Q,S;if(o.length===0){return}for(R=0,O=o.length;R<O;R+=1){Q=o[R].element;S=o[R].callback;I("Found callback function");S.on.login.call(window,P)}},v=function(O){N.call(window,O);frosmo.fbWrapper.onHandleLogin.call(this,O,function(){c.call(x,O)})},G=function(O){A=false;f=null;frosmo.fbWrapper.afterLogout(O);frosmo.event.logout()},M=function(){var P=frosmo.utils.getUrlParams(),O;if(P){if(P.fsh&&!frosmo.cookies.get(P.fsh)){if(P.fsh&&P.fst){frosmo.cookies.set(P.fsh,1,frosmo.config.cookies.domain,1);frosmo.api.clickFeed(unescape(P.fst),frosmo.fbWrapper.getUserId(),unescape(P.fsh));I("Logged incoming feed (share button) click with id "+P.fsh)}}if(P.fb_ref&&!frosmo.cookies.get(P.fb_ref)){if(P.fb_ref){frosmo.cookies.set(P.fb_ref,1,frosmo.config.cookies.domain,1);frosmo.api.clickFeed(unescape(P.fb_ref),frosmo.fbWrapper.getUserId(),null);I("Logged incoming feed (like button) with id "+P.fb_ref)}}}},K=function(O,Q,P){if(P==="share"){frosmo.api.publishFeed(frosmo.fbWrapper.feedType,frosmo.fbWrapper.getUserId(),Q);I("Logged share with id "+Q)}else{if(P==="publish"&&(O&&O.post_id)){frosmo.api.publishFeed(frosmo.fbWrapper.feedType,frosmo.fbWrapper.getUserId(),Q);I("Logged publish with id "+Q)}}},J=function(P){var S,O,R,Q,T;if(!(P[0].method==="stream.share"||P[0].method==="stream.publish")){return}S={fssrc:"fb",fsh:y(),fst:this.feedType};T=function(V,U){var X=[],W;for(W in U){if(U[W]){X.push(escape(W)+"="+escape(U[W]))}}V+=(V.match(/\?/)?"&":"?");V+=X.join("&");return V};if(P[0].u){P[0].u=T(P[0].u,S)}else{if(P[0].method==="stream.publish"){Q=function(V){var U;for(U in V){if(U==="href"){V[U]=T(V[U],S)}else{if(typeof V[U]==="object"||typeof V[U]==="array"){V[U]=Q(V[U])}}}return V};P[0]=Q(P[0])}}O=null;if(P.length===2){O=P[1]}R=((P[0].method==="stream.share")?"share":"publish");P[1]=function(){K(arguments[0],S.fsh,R);if(O){return O.apply(this,arguments)}return false};P.length=2;I("Trapped FB.ui "+P[0].method+" call")},j=function(O){FB.getLoginStatus(function(P){if(i){window.clearTimeout(i)}I("Facebook login status: "+P.status);if(P.status==="connected"){I("set loggedIn = true");A=true;if(typeof P.authResponse!=="undefined"){D=P.authResponse.accessToken}else{D=P.session.accessToken}d(function(){if(!frosmo.user.getUserId()){frosmo.user.setUserData(f.uid,e)}M.call(this);if(typeof O==="function"){I("Calling updateLoginStatus callback");O.call(window,P)}})}else{I("set loggedIn = false");A=false;M.call(this);if(typeof O==="function"){I("Calling updateLoginStatus callback");O.call(window,P)}}})},b=false,n=function(){var O=document.documentElement;if(O.getAttribute("xmlns")){if(O.getAttribute("xmlns:fb")===null){O.setAttribute("xmlns:fb","http://www.facebook.com/2008/fbml")}}},z=function(T,O){var P=this,R,S,Q,U=function(){I("frosmo.fbWrapper.fbAsyncInit called");if(b){p("frosmo.fbWrapper.fbAsyncInit already initialized");return}b=true;var V=FB.ui;FB.ui=function(){J.call(P,arguments);return V.apply(window,arguments)};if(!FB._apiKey||FB._apiKey==="your app id"){I("Running Fb.init");FB.init({appId:T,status:true,cookie:true,xfbml:true,oauth:frosmo.config.fbWrapper.oauth})}else{I("Facebook already initialized");if(FB._apiKey!==T){I("Invalid Facebook application ID");F=false}}if(F){FB.Event.subscribe("auth.login",v);FB.Event.subscribe("auth.logout",G)}FB.Event.subscribe("edge.create",C);FB.Event.subscribe("comments.add",g);if(F){j(function(W){I("updateLoginStatus complete");if(typeof O==="function"){I("Calling init callback in updateLoginStatus callback");O.call(window,W);O=function(){I("Init callback run already, skipping it")}}});if(frosmo.config.fbWrapper.loginTimeout){i=window.setTimeout(function(){I("FB.getLoginStatus() timeout");M.call(this);if(typeof O==="function"){I("Calling init callback");O.call(window);O=function(){I("Init callback run already, skipping it")}}},frosmo.config.fbWrapper.loginTimeout)}}else{I("Unsupported Facebook application");M.call(this);if(typeof O==="function"){I("Calling init callback");O.call(window);O=function(){I("Init callback run already, skipping it")}}}};if(!document.getElementById("fb-root")){R=document.createElement("div");R.id="fb-root";document.body.appendChild(R);I("Created fb-root div")}if(frosmo.config.fbWrapper.noload||typeof window.fbAsyncInit==="function"){I("Site has an existing fb implementation, waiting for it to initialize.");Q=window.setInterval(function(){if(window.FB&&window.FB._apiKey){if(T===window.FB._apiKey){I("Site fb implementation initialized, init frosmo.");Q=window.clearInterval(Q);U.call(window)}else{I("frosmo.fbWrapper.facebookInit() failed: Different facebook app_id "+window.FB._apiKey+", should be "+T);Q=window.clearInterval(Q);U.call(window)}}},10)}else{if(window.FB){I("no fbAsyncInit function but window.FB exists. call fbAsyncInit");U.call(window)}else{I("Setting fbAsyncInit");window.fbAsyncInit=U}}if(!window.FB){I("no FB yet, load library");S=document.createElement("script");S.type="text/javascript";S.src=document.location.protocol+"//connect.facebook.net/"+frosmo.config.fbWrapper.locale+"/all.js";S.async=true;document.getElementById("fb-root").appendChild(S);I("Created fb script element")}};frosmo.config.fbWrapper={locale:"en_US",reloadOnLogin:false,cookieName:"fsouserid",permissions:"publish_stream,email,user_birthday,user_location",fanPageHref:false,fbAppId:null,loginTimeout:false};if(window.frosmo.test){window.frosmo.test.fbWrapper={likeCallbacks:w,handleFBLike:C,setLocation:function(O){L=O}}}return{addXMLNamespace:n,addElementCallback:function(O,P){if(typeof O!=="object"){p("Invalid element passed as argument","frosmo.fbWrapper.addElementCallback()");return false}if(O.element==="like"){P=(typeof P==="function")?{on:{click:P}}:P||{};if(typeof P.on.click!=="function"){p("Callback function missing","frosmo.fbWrapper.addElementCallback()");return false}return B(O,P)}else{if(O.element==="login-button"){P=(typeof P==="function")?{on:{login:P}}:P||{};if(typeof P.on.login!=="function"){p("Callback function missing","frosmo.fbWrapper.addElementCallback()");return false}return m(O,P)}}p("Unsupported element","frosmo.fbWrapper.addElementCallback()");return false},removeElementCallback:function(O,P){P=(typeof P!=="object")?{id:P}:P||{};if(typeof O!=="object"){p("Invalid element passed as argument","frosmo.fbWrapper.removeElementCallback()");return false}if(!P.id){p("Callback identifier missing","frosmo.fbWrapper.removeElementCallback()");return false}if(O.element==="like"){return q(P)}else{if(O.element==="login-button"){return s(P)}}p("Unsupported element","frosmo.fbWrapper.removeElementCallback()");return false},parseFBMLElements:t,getCallbackElements:k,bindButtonClicks:function(P,R){I("Attach callback to Facebook button onclick events","frosmo.fbWrapper.bindButtonClicks()");var O=function(U,V){var T=U.tagName.toLowerCase(),S;I("Add click event listener to ("+T+")","frosmo.fbWrapper.bindButtonClicks()");if(U.onclick&&typeof U.onclick==="function"){I("Override existing ("+T+") onclick event","frosmo.fbWrapper.bindButtonClicks()");S=U.onclick}U.onclick=function(){I("User clicked ("+T+")","frosmo.fbWrapper.bindButtonClicks()");V.call(this,null,function(){I("("+T+") onclick callback function complete","frosmo.fbWrapper.bindButtonClicks()");if(S){I("Calling original onclick function for ("+T+")","frosmo.fbWrapper.bindButtonClicks()");S.call(this)}})}},Q=function(T,V,W){var U,S,X=T.getElementsByTagName(V);S=X.length;if(S>0){for(U=0;U<S;U+=1){O(X[U],W)}return true}else{return false}};if(Q(P,"fb:login-button",R)){return true}if(Q(P,"login-button",R)){return true}I("No elements found","frosmo.fbWrapper.bindButtonClicks()");return false},getFbAppId:function(){return h},getAccessToken:function(){return(A?D:null)},feedType:"blog",getLoggedIn:function(){return A},getUserId:function(){return(A&&f?f.uid:null)},getUserInfo:function(){return f},getUserAttr:u,getUserAttrString:a,onHandleLogin:function(O,P){P.call(this,O)},afterLogout:function(){},updateLoginStatus:j,init:function(O,P){if(typeof O==="function"){P=O;O=null}if(!O||O===undefined){if(typeof frosmo.config.fbWrapper.fbAppId!=="number"){p("fb app id is NOT defined!");return}else{O=frosmo.config.fbWrapper.fbAppId}}I("Initializing Facebook application...","frosmo.fbWrapper.init()");I("Facebook Application ID: "+O,"frosmo.fbWrapper.init()");h=O;z.call(this,O,P)}}}());frosmo.utils=(function(){var b={},h=/(\d\d\d\d)-(\d\d)-(\d\d)/,c=/(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)(\.\d+)?(Z|([+\-])(\d\d)(:)?(\d\d))/,d=function(i){return window.unescape(i)},f=function(j){try{return window.decodeURIComponent(j)}catch(i){return j}},a=function(i){return i!==i},e=function(j){if(typeof j!=="string"){return false}var i=new RegExp("(\\d+)\\.?(\\d+)?\\.?(\\d+)?"),k=i.exec(j);return{major:parseInt(k[1],10)||0,minor:parseInt(k[2],10)||0,patch:parseInt(k[3],10)||0}},g=function(k){var i=new Date(),j;j=k.match(new RegExp(h));i.setUTCDate(1);i.setUTCFullYear(parseInt(j[1],10));i.setUTCMonth(parseInt(j[2],10)-1);i.setUTCDate(parseInt(j[3],10));i.setUTCHours(0);i.setUTCMinutes(0);i.setUTCSeconds(0);i.setUTCMilliseconds(0);return i};b.isDate=function(i){if(i.toString().match(new RegExp(h))){return true}else{return false}};b.isISO8601Date=function(i){if(i.toString().match(new RegExp(c))){return true}else{return false}};b.parseISO8601Date=function(l){var i=new Date(),k,j;k=l.match(new RegExp(c));j=0;i.setUTCDate(1);i.setUTCFullYear(parseInt(k[1],10));i.setUTCMonth(parseInt(k[3],10)-1);i.setUTCDate(parseInt(k[5],10));i.setUTCHours(parseInt(k[7],10));i.setUTCMinutes(parseInt(k[9],10));i.setUTCSeconds(parseInt(k[11],10));if(k[12]){i.setUTCMilliseconds(parseFloat(k[12])*1000)}else{i.setUTCMilliseconds(0)}if(k[13]!=="Z"){j=(k[15]*60)+parseInt(k[17],10);j*=((k[14]==="-")?-1:1);i.setTime(i.getTime()-j*60*1000)}return i};b.parseDate=function(j){var i;if(j instanceof Date){return j}i=new Date(j);if(a(i.getDate())){if(b.isISO8601Date(j)){return b.parseISO8601Date(j)}else{if(b.isDate(j)){return g(j)}else{return null}}}else{return i}};b.formatDate=function(j){j=b.parseDate(j);if(j===null){return null}var k=j.getFullYear(),l=j.getMonth(),i=j.getDate();if(l<10){l="0"+l}if(i<10){i="0"+i}return k+"-"+l+"-"+i};b.formatTime=function(k){k=b.parseDate(k);if(k===null){return null}var i=k.getHours(),l=k.getMinutes(),j=k.getSeconds();if(i<10){i="0"+i}if(l<10){l="0"+l}if(j<10){j="0"+j}return i+":"+l+":"+j};b.formatDatetime=function(i){i=b.parseDate(i);if(i===null){return null}return b.formatDate(i)+" "+b.formatTime(i)};b.getUrlPaths=function(k){var i,j=k||frosmo.site.config.pathname||window.location.pathname;if(typeof j!=="string"){return null}if(j.match(/^\/$/)){return["","home"]}i=j.split("/");return i};b.getUrlParams=function(j){var k=window.location.search.replace(/^\?/,""),i={},m,l;l=function(n){var q=n.split("="),o,p;o=q[0];p=f(q[1]);p=d(p);if(o.indexOf("[]")!==-1){o=o.replace("[]","");if(!i[o]){i[o]=[]}i[o].push(p)}else{i[o]=decodeURIComponent(p)}};if(j){m=j.indexOf("?");if(m!==-1){k=j.substring(m+1)}else{k=null}}if(k){b.each(k.split("&"),function(n){if(typeof n==="string"){l(n)}})}return i};b.getUrlParam=function(j,i){var k=b.getUrlParams(i);if(b.keyExists(j,k)){return k[j]}return null};b.getUrlPath=function(i){var j=window.location.pathname;return j.split("/")};b.each=function(k,p,o){var n,j,m;if(typeof k==="undefined"||k===null){return}if(Array.prototype.forEach&&k.forEach===Array.prototype.forEach){k.forEach(p,o)}else{if(k.length===+k.length){for(n=0,j=k.length;n<j;n+=1){if(typeof k[n]!=="undefined"){p.call(o,k[n],n,k)}}}else{for(m in k){if(Object.prototype.hasOwnProperty.call(k,m)){p.call(o,k[m],m,k)}}}}};b.extend=function(i){b.each(Array.prototype.slice.call(arguments,1),function(k){var j;for(j in k){if(k.hasOwnProperty(j)){i[j]=k[j]}}});return i};b.contains=function(o,n){var m=false,k,j;if(b.isArray(o)){if(Array.prototype.indexOf){return Array.prototype.indexOf.call(o,n)!==-1}for(k=0,j=o.length;k<j;k+=1){if(o[k]===n){return true}}}else{b.each(o,function(i){if(i===n){m=true}})}return m};b.isArray=Array.isArray||function(i){return(Object.prototype.toString.call(i)==="[object Array]")};b.isFunction=function(i){if(typeof i==="function"){return true}else{return false}};b.isRegExp=function(i){return typeof i==="object"&&Object.prototype.toString.call(i)==="[object RegExp]"};b.callIfDefined=function(k,i,j){if(b.isFunction(k)){if(j){return k.apply(i,j)}else{return k.apply(i)}}else{return false}};b.keyExists=function(j,i){if(typeof i!=="object"){return false}if(Object.prototype.hasOwnProperty.call(i,j)){return true}return false};b.objectKeys=Object.keys||function(j){var k=[],i;if(typeof j!=="object"){throw new TypeError("Invalid object")}for(i in j){if(Object.prototype.hasOwnProperty.call(j,i)){k.push(i)}}return k};b.clone=function(j){if(typeof j!=="object"){return j}var i=this.isArray(j)?[]:{},k;for(k in j){if(j.hasOwnProperty(k)){if(j[k]&&typeof j[k]==="object"){i[k]=b.clone(j[k])}else{i[k]=j[k]}}}return i};b.inArray=function(n,m){if(!m||!this.isArray(m)){frosmo.console.error("frosmo.utils.inArray() -- given argument is not an array!");return false}var k,j;for(k=0,j=m.length;k<j;k=k+1){if(m[k]===n){return true}}return false};b.domReady=function(l){var j,i,m,k=false,o;if(document.readyState==="complete"){return setTimeout(l,1)}o=function(){if(!m){m=true;l()}};i=function(){if(m){return}try{document.documentElement.doScroll("left")}catch(p){setTimeout(i,1);return}o()};if(window.jQuery){window.jQuery(document).ready(l)}else{if(document.addEventListener){j=function(){document.removeEventListener("DOMContentLoaded",j,false);o()};document.addEventListener("DOMContentLoaded",j,false);window.addEventListener("load",o,false)}else{if(document.attachEvent){j=function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",j);o()}};document.attachEvent("onreadystatechange",j);window.attachEvent("onload",o);try{k=window.frameElement==null}catch(n){}if(document.documentElement.doScroll&&k){i()}}}}};b.versionCompare=function(j,k){var i=e(j.toString()),l=e(k.toString());if(i.major!==l.major){return(l.major>i.major)}else{if(i.minor!==l.minor){return(l.minor>i.minor)}else{if(i.patch!==l.patch){return(l.patch>i.patch)}else{return true}}}};return b}());frosmo.message=(function(){var e="2.1.0",d=function(h,i){if(i){frosmo.console.log(i+": "+h)}else{frosmo.console.log("frosmo.message: "+h)}},a=function(h,i){if(i){frosmo.console.error(i+": "+h)}else{frosmo.console.error("frosmo.message: "+h)}},c={},b=false,g=function(h){var j,i;frosmo.console.log("frosmo.message: Initializing...");if(typeof frosmo.request==="undefined"){throw new Error("frosmo.request.js not loaded (required by frosmo.message.js)")}if(typeof frosmo.messageApi==="undefined"){throw new Error("frosmo.messageApi.js not loaded (required by frosmo.message.js)")}if(typeof frosmo.pageContext==="undefined"){throw new Error("frosmo.pageContext.js not loaded (required by frosmo.message.js)")}frosmo.utils.extend(this,frosmo.EventHandler);h=h||{};if(typeof frosmo.config.message.enabled==="undefined"){frosmo.config.message.enabled=true}if(typeof h.limit==="undefined"){d("Message limit not defined, set it to unlimited","frosmo.message.init()");h.limit=false}else{if(h.limit){d("Message limit set to: "+h.limit,"frosmo.message.init()")}else{d("Message limit set to unlimited","frosmo.message.init()")}}if(!h.rpc){d("Using rpc URL from frosmo.config.message","frosmo.message.init()");h.rpc=frosmo.config.message.rpc}if(frosmo.api){d("Tracking message displays with frosmo.api.showMessage()","frosmo.message.init()");this.bind("message.display",function(k,l){d("Track message display with frosmo.api.showMessage()","frosmo.message.init()");frosmo.api.showMessage(k.getUser(),l.id,l.revision)},this)}else{d("frosmo.api is not loaded, not tracking message displays","frosmo.message.init()")}if(h.afterDisplay&&typeof h.afterDisplay==="function"){d("Adding custom display event","frosmo.message.init()");j=h.afterDisplay;delete h.afterDisplay;this.bind("message.display",function(k,l){j.call(k,l)},this)}if(h.afterClick&&typeof h.afterClick==="function"){d("Adding custom click event, default click tracking is disabled","frosmo.message.init()");i=h.afterClick;delete h.afterClick;this.bind("message.click",function(l,n,m,k){i.call(l,n,m,k)},this)}else{if(frosmo.api){d("Tracking message clicks with frosmo.api.clickMessage()","frosmo.message.init()");this.bind("message.click",function(l,n,m,k){d("Track message click with frosmo.api.clickMessage()","frosmo.message.init()");frosmo.api.clickMessage(l.getUser(),n.id,n.revision);if(typeof k==="function"){window.setTimeout(function(){d("Call callback function after clicking","frosmo.message.init()");k()},500)}},this)}else{d("frosmo.api is not loaded, not tracking message clicks","frosmo.message.init()")}}b=h;d("frosmo.message default configuration set","frosmo.message.init()")},f=function(l,q){var o=this,m,i,p,h=false,n=false,k=false,j=false;q=q||{};if(!frosmo.config.message.enabled){d("frosmo.message is disabled","frosmo.message.display()");return}if(typeof b==="undefined"||b===null||b===false){a("frosmo.message is not initialized","frosmo.message.display()");return}if(l===undefined){d("position is not set, using popup by default","frosmo.message.display()");l="popup"}if(l!=="popup"&&!q.inline){a("Trying to call inline message without inline container","frosmo.message.display()");return}p=frosmo.pageContext.getPath();if(typeof p==="undefined"||p===null||p===""){a("Message path not defined");return}i=frosmo.utils.extend({},b);if(q&&typeof q==="object"){i=frosmo.utils.extend(i,q)}if(typeof i.ignoreCurrent!=="undefined"){j=i.ignoreCurrent;delete i.ignoreCurrent}if(frosmo.utils.keyExists(l,this.apis)){if(this.apis[l] instanceof frosmo.messageApi){k=this.apis[l];k.stopRequests();if(j){h=k.getCurrentMessage();n=k.getPath()}}}m=new frosmo.messageApi(frosmo.config.message.origin,null,null,i);d("frosmo.messageApi version "+m.getVersion()+" initialized for position: "+l,"frosmo.message.init()");m.bind("all",function(s){var t=[s,m],r=Array.prototype.slice.call(arguments,1);frosmo.console.debug(t.concat(r));o.trigger.apply(o,t.concat(r))});d("Set message path to '"+p+"'");m.setPath(p);m.setPosition(l);if(h&&n===p){d("Ignore current message "+h.id+" revision "+h.revision);m.ignoreMessageRevision(h)}m.setUser(frosmo.user.getUserId());d("Set segment metadata");m.addMetadata(frosmo.user.getSegments());d("Set pageContext metadata");m.addMetadata(frosmo.pageContext.getContextAttributes());d("Set user metadata");m.addMetadata(frosmo.user.getUserData());d("Set state metadata");m.addMetadata(frosmo.user.getStates());m.addMetadata({source:frosmo.session.getSource(),referer:frosmo.session.getReferer()});m.resetStartTime();m.resetRequestTime();m.resetMessages();frosmo.console.log("frosmo.message.js -- Call frosmo.messageApi.requestMessage()");m.requestMessage();this.apis[l]=m;return true};return{VERSION:e,apis:c,init:g,display:f}}());frosmo.messageApi=(function(){var o="2.4.0",n=0,p,q=frosmo.utils,j=q.callIfDefined,l=q.versionCompare,b=function(t,u){if(u){frosmo.console.log(u+": "+t)}else{frosmo.console.log("frosmo.messageApi: "+t)}},f=function(t,u){if(u){frosmo.console.error(u+": "+t)}else{frosmo.console.error("frosmo.messageApi: "+t)}},g=function(t){if(typeof t==="undefined"||t===null){return}if(typeof t==="object"){if(typeof t.html==="function"){return t.get(0)}else{return t}}if(typeof t==="string"){if(t.match(/^#/)){return document.getElementById(t.replace(/^#/,""))}else{return document.getElementById(t)}}},c=function(v){var u=false,w,t;w=function(){v.unbind("display",t);v.unbind("render",w);u=true};t=function(){v.unbind("display",t);v.unbind("render",w);if(!u){frosmo.console.warn("Message 'render' event was not called before 'display' event in custom popup method")}};v.bind("render",w);v.bind("display",t)},k=function(x,y){var A=function(B,C,D){if(B.removeEventListener){return B.removeEventListener(C,D,false)}else{if(B.detachtEvent){return B.detachEvent("on"+C,D)}}},t=function(D,F){if(D.className){if(/(close|fb_button)/i.exec(D.className)){return false}}var C,B,G,E=function(H,J,I){I.call(this,J,function(){A(H,"click",G);if(B){window.location.href=B}})};if(/fb_button/i.exec(D.className)){B=null;C=D.parentNode.tagName.toLowerCase()+" > a"}else{B=D.getAttribute("href");C="a[href="+B+"]"}if(D.addEventListener){b("Add click event listener to ("+C+") with element.addEventListener()");G=function(H){b("("+C+") clicked");H.preventDefault();E(this,H,F)};return D.addEventListener("click",G,false)}else{if(D.attachEvent){b("Add click event listener to ("+C+") with element.attachEvent()");G=function(){b("("+C+") clicked");var H=window.event;H.returnValue=false;E(D,H,F)};return D.attachEvent("onclick",G)}}f("Failed to add click event listener");return false},v=function(B,D){var E,C=function(F,H,G){G.call(this,H,function(){A(F,"submit",E);F.submit()})};if(B.addEventListener){b("Add submit event listener to form with element.addEventListener()");E=function(F){F.preventDefault();C(this,F,D)};return B.addEventListener("submit",E,false)}else{if(B.attachEvent){b("Add submit event listener to form with element.attachEvent()");E=function(){var F=window.event;F.returnValue=false;C(B,F,D)};return B.attachEvent("onsubmit",E)}}f("Failed to add submit event listener");return false},z,w,u;z=x.getElementsByTagName("a");for(w=0,u=z.length;w<u;w+=1){t(z[w],y)}z=x.getElementsByTagName("form");for(w=0,u=z.length;w<u;w+=1){v(z[w],y)}if(frosmo.fbWrapper){frosmo.fbWrapper.bindButtonClicks(x,y)}},a=function(w){var v=this,t,u;if(!frosmo.fbWrapper){b("Method frosmo.fbWrapper not loaded");return false}if(!frosmo.fbWrapper.parseFBMLElements){f("Method frosmo.fbWrapper.parseFBMLElements() not found");return false}if(!frosmo.fbWrapper.removeElementCallback){b("Method frosmo.fbWrapper.removeElementCallback() not found")}if(w.content===null){b("Message has not content to parse FBML elements from");return false}t=frosmo.fbWrapper.parseFBMLElements(w.content);if(t.length>0){u=function(x){var y={id:"message_"+w.id,on:{}};if(x.element==="like"){y.on.click=function(z,A){w.trigger("click")}}else{if(x.element==="login-button"){y.on.login=function(z){w.trigger("login",z)}}else{return}}frosmo.fbWrapper.addElementCallback(x,y);if(frosmo.fbWrapper.removeElementCallback){w.bind("close",function(){frosmo.fbWrapper.removeElementCallback(x,y)})}};b("Add click tracking to XFBML elements");w.fbmlElements=t;q.each(t,function(y,x){u(y)});return true}else{return false}},s=function(u,v){var x=document.createElement("div"),t=document.createDocumentFragment(),w;x.innerHTML=u;if(x.children.length>0){for(w=0;w<x.children.length;w+=1){if(x.childNodes[w]){if(typeof v==="function"){v.call(window,x.childNodes[w])}t.appendChild(x.childNodes[w])}}}else{t=document.createTextNode(x.innerHTML)}return t},i=function(w,v){var t=document.createDocumentFragment(),u;for(u=0;u<w.length;u+=1){if(w[u]){if(typeof v==="function"){v.call(window,w[u])}t.appendChild(w[u])}}return t},r="html",h="external",e="raw",m="hidden",d={POPUP:"popup",INLINE:"inline"};if(typeof q==="undefined"){throw new Error("frosmo.utils.js not loaded (required by frosmo.messageApi.js)")}if(typeof frosmo.EventHandler==="undefined"){throw new Error("frosmo.EventHandler missing (required by frosmo.messageApi.js)")}p=function(){var B=arguments[0],D=arguments[1]||null,w=arguments[2]||null,E=arguments[3]||null,y=null,A=null,z=1,C=0,v={},t=null,u=null,x=null;this.setMetadata=function(F){A=F||null;return this};this.addMetadata=function(F){if(F&&q.objectKeys(F).length>0){if(!A){frosmo.console.debug("frosmo.messageApi -- creating empty metadata object");A={}}frosmo.console.debug("frosmo.messageApi -- extending metadata with "+JSON.stringify(F));A=q.extend(A,F)}return this};this.getAge=function(M){var J,K,H,G,L,F,I=/^\d{4}-\d{2}-\d{2}$/;if(!M){return}if(I.test(M)){L=M.split("-");J=parseInt(L[0],10);K=parseInt(L[1],10);H=parseInt(L[2],10);G=new Date();F=G.getFullYear()-J;if(G.getMonth()<K||(G.getMonth()===K&&G.getDate()<H)){F=F-1}return F}else{frosmo.console.error("Date of Birth "+M+" is in wrong format! must be in YYYY-MM-DD");return null}};this.getMetadata=function(){var F={};if(A){q.each(A,function(I,H){var G;if(H.match(/^(segment|state|product)([A-Z][a-z]+)+$/)){F[H]=I}if(H.match(/^(gender|language|age|source|referer|userAccount|loginId|facebookId|locale)$/)){if(!I){F[H]=""}else{F[H]=I}}if(H==="dob"){G=this.getAge(I);if(G){F.age=G}}},this)}return F};this.getOrigin=function(){return B};this.setOrigin=function(F){B=F;return this};this.getOptions=function(){return E};this.setOptions=function(F){E=F;return this};this.setOption=function(F,G){E[F]=G;return this};this.getRequestTime=function(){return t};this.setRequestTime=function(F){t=F;return this};this.resetRequestTime=function(){t=null;return this};this.getStartTime=function(){return u};this.resetStartTime=function(){u=this.getTime();return this};this.getMessageCount=function(){return C};this.incrementMessageCount=function(){C+=1};this.addMessage=function(F){v[F.id]=F;return this};this.getMessage=function(F){if(F in v){return v[F]}else{return null}};this.resetMessages=function(){C=0;v={};return this};this.getMessageLimit=function(){return z};this.setMessageLimit=function(F){if(typeof z==="number"){z=F||false}else{z=false}return this};this.getPath=function(){return D};this.setPath=function(F){D=F||null;return this};this.getPosition=function(){return x};this.setPosition=function(F){x=F||null;return this};this.getRpc=function(){return y};this.setRpc=function(F){y=F;return this};this.getUser=function(){return w};this.setUser=function(F){w=F||null;return this};this.init(E)};p.prototype={stopped:false,requesting:false,message:false,timers:null,ignoredRevisions:null,debug:false,afterClick:null,afterClose:null,afterDisplay:null,afterLogin:null,timeout:false,init:function(t){q.extend(this,frosmo.EventHandler);this.timers={};this.ignoredRevisions={};this.resetStartTime();if(t){if(t.fancybox){throw new Error("jQuery fancybox support is deprecated")}if(t.xhr){throw new Error("XHR is deprecated")}if(t.debug){this.debug=t.debug}if(t.testing){throw new Error("Testing mode is deprecated")}if(typeof t.interval!=="undefined"){throw new Error("Fetching messages with interval is deprecated")}if(t.messageType){throw new Error("Message type is deprecated")}if(t.metadata){this.setMetadata(t.metadata)}if(typeof t.limit!=="undefined"){this.setMessageLimit(t.limit)}if(typeof t.rpc==="string"||typeof t.rpc==="function"){this.setRpc(t.rpc)}if(t.afterDisplay){this.afterDisplay=function(u){frosmo.console.deprecated("frosmo.messageApi.afterDisplay() is deprecated, use messageApi.bind('message.display') or message.bind('display')");t.afterDisplay.call(this,u)}}if(t.afterClose){this.afterClose=function(u){frosmo.console.deprecated("frosmo.messageApi.afterClose() is deprecated, use messageApi.bind('message.close') or message.bind('close')");t.afterClose.call(this,u)}}if(t.afterClick){this.afterClick=function(w,v,u){frosmo.console.deprecated("frosmo.messageApi.afterClick() is deprecated, use messageApi.bind('message.click') or message.bind('click')");t.afterClick.call(this,w,v,u)}}if(t.afterLogin){this.afterLogin=function(v,u){frosmo.console.deprecated("frosmo.messageApi.afterLogin() is deprecated, use messageApi.bind('message.login') or message.bind('login')");t.afterLogin.call(this,v,u)}}}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()")}},getCurrentMessage:function(){return this.message},ignoreMessageRevision:function(t){if(typeof t.revision!=="undefined"){this.ignoredRevisions[t.id]=t.revision}},isMessageRevisionIgnored:function(t){if(typeof t.id==="undefined"||typeof t.revision==="undefined"){return false}if(!q.keyExists(t.id,this.ignoredRevisions)){return false}if(this.ignoredRevisions[t.id]>0){if(this.ignoredRevisions[t.id]===t.revision){return true}}return false},getVersion:function(){return o},getTime:function(){return new Date().getTime()},getDelay:function(){var t=this.getStartTime();if(t){return this.getTime()-t}else{return null}},fetchMore:function(){var t=this.getMessageLimit();if(t===false){return true}if(this.getMessageCount()<t){return true}return false},inlineHtml:function(t){return'<div class="pmm-message"><h4 class="pmm-title">'+t.title+'</h4><div class="pmm-content">'+t.content+"</div></div>"},inlineHtmlRaw:function(t){if(t.content===""){return null}return t.content},createInlineMessageContent:function(u,v){var t;if(l("2.2.0",v.version)){if(u.revisionType===m){return null}}if(u.options.displayFormatRaw){return this.inlineHtmlRaw.call(this,u)}t=this.getOptions();if(typeof t.inlineHtml==="function"){return t.inlineHtml.call(this,u)}return this.inlineHtml.call(this,u)},inlineMessage:function(z,A){var v=this,w=v.getOptions(),u=function(){z.trigger("display")},y=function(C,B){z.container=C;if(B!==null){b("Add click tracking to the message","frosmo.messageApi.inlineMessage()");k(C,function(E,D){z.trigger("click",E,D)});if(window.FB){b("Parse XFBML elements in inline message","frosmo.messageApi.inlineMessage()");window.FB.XFBML.parse(C)}}z.trigger("render")},t,x;if(!w.inline){f("No inline target or callback function defined","frosmo.messageApi.inlineMessage()");return false}x=v.createInlineMessageContent(z,A);if(typeof w.inline==="function"){c(z);return w.inline.call(v,z,x,A)}t=g(w.inline);if(!t){f("container for inline message missing, can NOT display message!");return false}if(w.inlineRenderer&&typeof w.inlineRenderer==="function"){w.inlineRenderer.call(v,z,x,t,function(){y(t,x);u()});return false}if(typeof window.jQuery==="undefined"){if(x===null){t.innerHTML=""}else{t.innerHTML=x}y(t,x);u()}else{if(jQuery(t).hasClass("frosmo-inline-content")){(function(C,B){var D=jQuery("<div></div>"),E;C=jQuery(C);E=C.attr("id");D.css({display:"none"});if(B===null){D.html("")}else{D.html(B)}C.after(D);b("frosmo.messageApi.inlineMessage() -- Hide hide existing container ["+E+"]");if(B!==null&&w.inlineAnimation){C.fadeOut(500,function(){b("frosmo.messageApi.inlineMessage() -- Display new container ["+E+"]");C.remove();if(typeof E!=="undefined"&&E!==null){D.attr("id",E)}n+=1;D.addClass("frosmo-inline-content").addClass("frosmo-inline-"+n);y(D.get(0),B);D.fadeIn(500,function(){u()})})}else{C.remove();if(typeof E!=="undefined"&&E!==null){D.attr("id",E)}n+=1;D.addClass("frosmo-inline-content").addClass("frosmo-inline-"+n);y(D.get(0),B);D.css({display:"block"});u()}v.setOption("inline",D)}(t,x))}else{if(x===null){t.innerHTML=""}else{t.innerHTML=x}n+=1;jQuery(t).addClass("frosmo-inline-content").addClass("frosmo-inline-"+n);y(t,x);u()}}return true},popupHtmlRaw:function(t){return t.content},popupMessage:function(w,y){var t=this,u=t.getOptions(),v,x={displayDelay:0};if(l("2.2.0",y.version)){if(w.revisionType===m){w.trigger("display");return}}if(l("0.2",y.version)){if(w.options.displayDelay>0){x.displayDelay=(function(z){return parseInt(z,10)*1000}(w.options.displayDelay));b("Message display delay set to "+x.displayDelay+" second(s)","frosmo.messageApi.popupMessage()")}}if(w.options.displayFormatRaw){b("Using internal function to display message with raw content","frosmo.messageApi.popupMessage()");v=t.popupHtmlRaw(w);t.displayPopup.call(t,w,v,x);return}if(typeof u.popupHtml==="function"){b("Creating message HTML using custom popupHtml function","frosmo.messageApi.popupMessage()");v=u.popupHtml.call(t,w)}if(typeof u.popup==="function"){b("Using custom function to display message","frosmo.messageApi.popupMessage()");c(w);u.popup.call(t,w,v,x)}else{if(u.fancybox){f("Fancybox support is deprecated");return}else{if(v){b("Using internal function to display message with custom HTML","frosmo.messageApi.popupMessage()");t.displayPopup.call(t,w,v,x)}else{if(window.frosmo.popup){(function(){b("Using frosmo.popup to generate and display message","frosmo.messageApi.popupMessage()");var A={},z=function(){frosmo.popup.create(w.content,w.title,null,true,A)};A.afterClose=function(){w.trigger("close")};A.afterRender=function(){w.trigger("render")};A.afterShow=function(){w.trigger("display")};A.afterClick=function(C,B){w.trigger("click",C,B)};w.bind("login",function(B){frosmo.popup.hide(A)});if(x.displayDelay>0){t.timers[w.id]=window.setTimeout(function(){z.call(t)},x.displayDelay)}else{z.call(t)}}())}else{f("Can't display message: Popup HTML not defined and frosmo.popup not loaded","frosmo.messageApi.popupMessage()")}}}}},displayPopup:function(C,w,v,y){var B=this,D=B.getOptions(),x,u,z,A=function(E){b("Add click tracking to the message","frosmo.messageApi.displayPopup()");k(E,function(G,F){C.trigger("click",G,F)})},t=function(E){if(window.FB){b("Parse XFBML elements in popup message","frosmo.messageApi.displayPopup()");window.FB.XFBML.parse(E)}};if(typeof w==="string"){b("Creating DOM elements from HTML","frosmo.messageApi.displayPopup()");x=s(w,function(E){A(E);t(E)});u=function(){document.body.appendChild(x);C.trigger("render")}}else{if(typeof w==="object"){if(q.isArray(w)){b("Appending an array of HTMLElements","frosmo.messageApi.displayPopup()");x=i(w,function(E){A(E);t(E)});u=function(){document.body.appendChild(x);C.trigger("render")}}else{if(window.jQuery&&typeof w.toArray==="function"){b("Appending elements from jQuery set","frosmo.messageApi.displayPopup()");x=i(w.toArray(),function(E){A(E);t(E)});u=function(){document.body.appendChild(x);C.trigger("render")}}else{b("Appending single DOM object","frosmo.messageApi.displayPopup()");A(w);t(w);u=function(){document.body.appendChild(w);C.trigger("render")}}}}}if(typeof u==="function"){z=function(){b("Appending popup elements to the document","frosmo.messageApi.displayPopup()");u();j(y,B,[C]);C.trigger("display")};if(q.isFunction(D.closePopup)){C.bind("login",function(E){b("Call closePopup when user has logged in","frosmo.messageApi.displayPopup()");j(D.closePopup,B)})}if(v.displayDelay>0){b("Appending message with delay","frosmo.messageApi.displayPopup()");B.timers[C.id]=window.setTimeout(function(){z()},v.displayDelay)}else{b("Appending message instantly","frosmo.messageApi.displayPopup()");z()}}},getRequestParams:function(){var w=this.getMetadata(),v=this.getRequestTime(),A={origin:this.getOrigin(),version:o},z=this.getPath(),u=this.getUser(),t=this.getPosition(),y;A.path=z;A.position=t;if(u){A.uid=u}if(v){A.time=v}if(w){A=q.extend(A,w)}if(frosmo.session){try{if(frosmo.session.hasPersistentId()){A.cid=frosmo.session.getPersistentId()}else{frosmo.error.log("Visitor persistentId not initialized",frosmo.error.MESSAGE_CID_MISSING)}y=frosmo.session.getDuration();if(y!==null){A.duration=frosmo.session.getDuration()}}catch(x){f(x)}}return A},requestMessage:function(){var t=this,v,u,w;if(t.requesting){b("Existing message request has not completed","frosmo.messageApi.requestMessage()");return false}if(t.stopped){b("Message requests have been stopped","frosmo.messageApi.requestMessage()");return false}if(!t.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(!t.getRpc()){f("Message RPC not defined","frosmo.messageApi.requestMessage()");return false}v=t.getRequestParams();if(!v){f("No params for message RPC request","frosmo.messageApi.requestMessage()");return false}if(v.duration){b("Session duration set to "+v.duration+" ms","frosmo.messageApi.requestMessage()")}if(typeof t.getRpc()==="function"){b("Calling RPC callback function","frosmo.messageApi.requestMessage()");t.requesting=true;t.handleResponseSuccess.call(t,t.getRpc().call(t,v));return true}else{b("Making JSONP request","frosmo.messageApi.requestMessage()");if(!frosmo.request){f("frosmo.request is not loaded","frosmo.messageApi.requestMessage()");return false}t.requesting=true;w={params:v,timeout:t.timeout,on:{failure:function(){f("JSONP request failed","frosmo.messageApi.requestMessage()");t.requesting=false},timeout:function(){f("JSONP request timed out","frosmo.messageApi.requestMessage()");t.requesting=false},success:function(x){b("JSONP request success","frosmo.messageApi.requestMessage()");t.handleResponseSuccess.call(t,x)}}};u=frosmo.request.create(t.getRpc(),w);u.send.apply(u);return true}},stopRequests:function(){b("Request handling has been halted","frosmo.messageApi.stopRequests()");this.stopped=true;this.trigger("stop")},handleResponseSuccess:function(t,v,y){var z=this,A,u,B=z.getOptions(),w=function(C,D,E){if(q.isArray(D)&&D.length>0){q.each(D,function(F){if(q.isFunction(F)){if(E){F.apply(C,E)}else{F.apply(C)}}});return true}else{return false}};if(z.stopped){z.requesting=false;b("Request handling has been halted, ignore response","frosmo.messageApi.handleResponseSuccess()");return}if(t){if(typeof t.version==="undefined"){t.version="0.1"}b("Message RPC version: "+t.version,"frosmo.messageApi.handleResponseSuccess()");if(t.time){z.setRequestTime(t.time)}if(typeof t.message==="undefined"){z.requesting=false;b("No messages found","frosmo.messageApi.handleResponseSuccess()");return}A=t.message;u=d.POPUP;if(z.getMessage(A.id)){z.requesting=false;b("Received duplicate message: "+A.id,"frosmo.messageApi.handleResponseSuccess()");return}if(z.isMessageRevisionIgnored(A)){z.requesting=false;b("Message "+A.id+" revision "+A.revision+" ignored","frosmo.messageApi.handleResponseSuccess()");return}if(A.endTime){if(new Date().getTime()>(A.endTime*1000)){z.requesting=false;b("Message in response had already expired","frosmo.messageApi.handleResponseSuccess()");return}}if(l("2.0.0",t.version)){if(this.getPosition()!==d.POPUP){u=d.INLINE}}else{if(l("0.2",t.version)){if(A.options.displayType){if(A.options.displayType===d.INLINE){u=d.INLINE}}}else{f("Message RPC is not up-to-date with the Javascript library","frosmo.messageApi.handleResponseSuccess()")}}if(l("2.0.0",t.version)){if(typeof A.options.displayFormatRaw==="object"){if(q.isArray(A.options.displayFormatRaw)){A.options.displayFormatRaw=A.options.displayFormatRaw[0]}else{A.options.displayFormatRaw=null}}A.options.displayFormatRaw=(A.options.displayFormatRaw==="yes"||A.options.displayFormatRaw===true)}q.extend(A,frosmo.EventHandler);A.callbacks={on:{click:[],close:[],display:[],login:[]}};if(typeof B.afterDisplay==="function"){A.bind("display",function(){B.afterDisplay.call(z,A)},z)}if(typeof B.afterClose==="function"){A.bind("close",function(){B.afterClose.call(z,A)},z)}if(typeof B.afterClick==="function"){A.bind("click",function(D,C){B.afterClick.call(z,A,D,C)},z)}if(typeof B.afterLogin==="function"){A.bind("login",function(C){B.afterLogin.call(z,A,C)},z)}A.bind("click",function(D,C){if(w(z,A.callbacks.on.click,[D,C])){b("Run callbacks in message.callbacks.on.click","message.on.click()")}},z);A.bind("close",function(){if(w(z,A.callbacks.on.close)){b("Run callbacks in message.callbacks.on.close","message.on.close()")}},z);A.bind("display",function(){if(w(z,A.callbacks.on.display)){b("Run callbacks in message.callbacks.on.display","message.on.display()")}},z);A.bind("login",function(C){if(w(z,A.callbacks.on.login,[C])){b("Run callbacks in message.callbacks.on.login","message.on.login()")}},z);A.bind("all",function(D){var E=["message."+D,A],C=Array.prototype.slice.call(arguments,1);z.trigger.apply(z,E.concat(C))});A.on={click:function(D,C){A.trigger("click",D,C)},close:function(){A.trigger("close")},display:function(){A.trigger("display")},login:function(C){A.trigger("login",C)}};if(A.template){try{z.parseMessageTemplate(A)}catch(x){z.requesting=false;f(x,"frosmo.messageApi.handleResponseSuccess()");return}}if(A.content){a(A)}z.incrementMessageCount();z.addMessage(A);z.message=A;z.requesting=false;if(u===d.INLINE){b("Display inline message","frosmo.messageApi.handleResponseSuccess()");z.inlineMessage.call(z,A,t)}else{z.popupMessage.call(z,A,t)}}else{f("No response from server","frosmo.messageApi.handleResponseSuccess()")}},parseMessageTemplate:function(t){if(typeof frosmo.template==="undefined"){throw new Error("frosmo.template.js not found")}if(typeof frosmo.template.VERSION==="undefined"){throw new Error("frosmo.template.js version is deprecated")}if(!l("0.2",frosmo.template.VERSION)){throw new Error("frosmo.template.js version is not supported")}if(t.template&&t.template.name){if(typeof t.originalContent==="undefined"){t.originalContent=t.content}t.content=frosmo.template.render(t.template.name,{template:t.content})}}};return p}());frosmo.pageContext=(function(){var b={},h="",d=null,g=function(n){return JSON.parse(JSON.stringify(n))},l=function(){return b.productId},m=function(n){b=(function(o){var q=frosmo.validator.validateProductAttribute,p={};frosmo.utils.each(o,function(s,r){var t=q(r,s);if(t){p[r]=t.value}});return p}(n));if(l()){frosmo.api.setProductData(l(),b)}},j=function(){return g(b)},e=function(n){h=n},f=function(n){if(n.match(/[a-z]{2,3}(_[A-Z]{2})?/)){d=n}else{throw new Error("Invalid locale string: "+n)}},k=function(){var n=g(b);n.path=h;if(typeof d!=="undefined"&&d!==null&&d!==""){n.locale=d}return n},c=function(){if(!l()){frosmo.console.error("productId not defined");return}frosmo.api.viewProduct(frosmo.user.getUserId(),null,l())},i=function(o,n,p,q){if(!l()){frosmo.console.error("productId not defined");return}frosmo.api.buyProduct(frosmo.user.getUserId(),null,l(),o,n,p,q)},a=function(){if(!l()){frosmo.console.error("productId not defined");return}frosmo.api.recommendProduct(frosmo.user.getUserId(),null,l())};return{setProductAttributes:m,getProductAttributes:j,setPath:e,getPath:function(){return h},setLocale:f,getLocale:function(){return d},getProductId:l,getContextAttributes:k,viewProduct:c,buyProduct:i,recommendProduct:a}}());(function(){var q="1.2.0",a,j,k,e=function(r,s){if(s){frosmo.console.log(s+": "+r)}else{frosmo.console.log("frosmo.popup: "+r)}},l=function(r,s){if(s){frosmo.console.error(s+": "+r)}else{frosmo.console.error("frosmo.popup: "+r)}},d=function(){if(a){a=null}},g=function(){if(a&&a.is(":visible")){return true}else{return false}},p=function(t,u){var s=jQuery(window),v,r,y={},x={horizontal:true,vertical:true,margin:frosmo.config.popup.centerIncludeMargins};t=jQuery(t);u=jQuery.extend(x,u);if(u.horizontal){if(u.margin){v=t.outerWidth({margin:true})}else{v=t.width()}y.left=Math.floor(Math.max((s.width()-v)/2,0))}if(u.vertical){if(u.margin){r=t.outerHeight({margin:true})}else{r=t.height()}y.top=Math.floor(Math.max((s.height()-r)/2,0))}if(y){y.position="fixed";t.css(y)}},c=function(s){if(!a){l("No popup found to hide","frosmo.popup.hide()");return}var t={hideBackground:true},r=function(){if(s.hideBackground){e("Hide background","frosmo.popup.hide()");k.hide()}if(s&&typeof s.afterClose==="function"){e("Calling afterClose callback function","frosmo.popup.hide()");s.afterClose.call(window)}};s=jQuery.extend(t,s);e("Hide popup","frosmo.popup.hide()");if(g()){e("Popup is visible, hiding it","frosmo.popup.hide()");if(typeof frosmo.config.popup.hide==="function"){frosmo.config.popup.hide.call(window,a,r)}else{if(frosmo.config.popup.animationSpeed>0){a.hide(frosmo.config.popup.animationSpeed,r)}else{a.hide();r()}}}else{e("Popup is already hidden","frosmo.popup.hide()");r()}},m=function(t){var r=this,s;e("Showing popup","frosmo.popup.show()");a.find(".frosmoPopupClose").click(function(u){u.preventDefault();e("User clicked close button in popup","frosmo.popup.show()");r.hide(t)});if(t&&t.closeOnBgClick){jQuery("#frosmoPopupBackground").bind("click.bg",function(u){u.preventDefault();e("User clicked background in popup","frosmo.popup.show()");r.hide(t);k.unbind("click.bg")})}if(t&&t.closeOnEsc){jQuery(document).bind("keyup.esc",function(u){if(u.keyCode===27){u.preventDefault();e("User pressed esc","frosmo.popup.show()");r.hide(t);jQuery(document).unbind("keyup.esc")}})}if(t&&t.center){e("Center popup","frosmo.popup.show()");frosmo.popup.center(a,t.centerOptions||null);jQuery(window).resize(function(u){frosmo.popup.center(a,t.centerOptions)})}if(t&&typeof t.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(w){w.preventDefault();e("User clicked a link in the popup","frosmo.popup.show()");var v=jQuery(this),u=this.href;t.afterClick.call(window,w,function(){e("Link afterClick complete callback, update window.location","frosmo.popup.show()");v.unbind(w);if(u){window.location.href=u}})});a.find("form").bind("submit",function(v){v.preventDefault();e("User submitted a form in the popup","frosmo.popup.show()");var u=jQuery(this);t.afterClick.call(window,v,function(){e("From afterClick complete callback, submit form data","frosmo.popup.show()");u.unbind(v);u.submit()})});if(frosmo.fbWrapper){e("Add event listeners to Facebook buttons","frosmo.popup.show()");frosmo.fbWrapper.bindButtonClicks(a.get(0),t.afterClick)}}if(window.FB){e("Parse XFBML elements in popup","frosmo.popup.show()");FB.XFBML.parse(a.get(0))}s=function(){if(t&&typeof t.afterShow==="function"){e("Calling afterShow callback function","frosmo.popup.show()");t.afterShow.call(window)}};k.show();if(g()){e("Message is already visible","frosmo.popup.show()");s()}else{e("Displaying message","frosmo.popup.show()");if(typeof frosmo.config.popup.show==="function"){frosmo.config.popup.show.call(window,a,s)}else{if(frosmo.config.popup.animationSpeed>0){a.show(frosmo.config.popup.animationSpeed,s)}else{a.show();s()}}}},n=function(r){if(typeof r!=="string"){r=""}var s=frosmo.config.popup.closeButtonAltText?frosmo.config.popup.closeButtonAltText:frosmo.config.popup.closeButtonText;return'<div id="frosmoPopupHeader">'+r+'<a href="#" id="frosmoPopupClose" class="frosmoPopupClose" title="'+s+'">'+frosmo.config.popup.closeButtonText+"</a></div>"},f=function(r){if(typeof r!=="string"){r=""}return'<div id="frosmoPopupContent">'+r+"</div>"},b=function(r){if(typeof r!=="string"){r=""}return'<div id="frosmoPopupFooter">'+r+"</div>"},h=function(r){a=jQuery(r);if(!j){e("Append popup container to the document","frosmo.popup.set()");j=jQuery('<div id="frosmoPopupContainer"></div>');jQuery("body").append(j)}if(!k){e("Append popup background to the document","frosmo.popup.set()");k=jQuery('<div id="frosmoPopupBackground"></div>');jQuery("body").append(k)}e("Appending popup HTML","frosmo.popup.set()");j.html(a)},i=function(){if(g()){return a}else{return null}},o=function(v,u,y,z,B){var A=this,r=A.header(u),w=A.content(v),x=A.footer(y),s='<div id="frosmoPopup">'+r+w+x+"</div>",t={closeExisting:false,center:frosmo.config.popup.center,closeOnBgClick:frosmo.config.popup.closeOnBgClick,closeOnEsc:frosmo.config.popup.closeOnEsc};B=jQuery.extend(t,B);if(z){e("Created popup and displaying it","frosmo.popup.create()");if(B.closeExisting&&g()){e("Hide existing popup before replacing it","frosmo.popup.create()");A.hide({hideBackground:false,afterClose:function(){A.set(s);if(B&&typeof B.afterRender==="function"){B.afterRender.call(A)}A.show(B)}})}else{A.set(s);if(B&&typeof B.afterRender==="function"){B.afterRender.call(A)}A.show(B)}return a}else{e("Created popup and returned HTML","frosmo.popup.create()");return s}};if(!window.frosmo){window.frosmo={}}if(!window.frosmo.config){window.frosmo.config={}}window.frosmo.popup={VERSION:q,header:n,content:f,footer:b,create:o,visible:g,center:p,set:h,get:i,show:m,hide:c};window.frosmo.config.popup={animationSpeed:200,closeButtonText:"Close",center:false,closeOnBgClick:false,closeOnEsc:false,centerIncludeMargins:false}}());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.session=(function(){var F={cookie_name:"frosmo.session",persistent_cookie_id:"frosmo.id",duration:30},g="session.cid",H=null,s,w=null,l=null,B=function(){if(!frosmo.cookies){throw"frosmo.cookies library is not loaded"}var K,L=frosmo.utils.parseDate;if(H===null){K=frosmo.cookies.get(F.cookie_name);if(K&&K!=="null"){H=JSON.parse(K);if(typeof H.loginTime==="string"){H.loginTime=L(H.loginTime)}if(typeof H.startTime==="string"){H.startTime=L(H.startTime)}if(typeof H.lastActivityTime==="string"){H.lastActivityTime=L(H.lastActivityTime)}}}if(H===null){H={}}},o=function(){if(!frosmo.cookies){throw"frosmo.cookies library is not loaded"}frosmo.cookies.set(F.cookie_name,JSON.stringify(H))},J=function(){B();return H.source},I=function(){B();return H.referer},f=function(K){B();H.source=K;if(!H.referer){H.referer=K}o();return this},D=function(){B();return H.loginTime},k=function(K){if(K instanceof Date){B();H.loginTime=K;o()}else{throw"Invalid argument, setLoginTime expects Date object"}return this},y=function(K){K=K||{};if(K.source&&!J()){f(K.source)}if(!D()){k(new Date())}return this},z=function(){B();return H.lastActivityTime},u=function(K){B();H.lastActivityTime=K;o();return this},d=function(){frosmo.console.log("frosmo.session.updateLastActivityTime(): updating last activity time");B();H.lastActivityTime=new Date();o();return this},e=function(){var K=new Date(),L=z();if(L){return K.getTime()-L.getTime()}else{return null}},h=function(){B();return H.startTime},v=function(){B();if(!H.startTime){frosmo.console.log("frosmo.session.setStartTime(): Set session start time");H.startTime=new Date();o()}},n=function(){var K=new Date(),L=h();if(L){return K.getTime()-L.getTime()}else{return null}},E=function(M){var K=2166136261,L;for(L=0;L<M.length;L+=1){K+=(K<<1)+(K<<4)+(K<<7)+(K<<8)+(K<<24);K^=M.charCodeAt(L)}return K&2147483647},i=function(L){var K=new RegExp("\\w+\\.\\w+");if(typeof L==="undefined"){return false}if(L===null||L===""){return false}return K.test(L)},x=function(K){frosmo.cookies.set(F.persistent_cookie_id,K,null,3650)},b=function(){var K=frosmo.cookies.get(F.persistent_cookie_id);if(i(K)){return K}return null},r=function(){var K=b();if(K===null){return false}else{return true}},p=function(){return r()},C=function(K){if(i(K)){frosmo.console.log("frosmo.session.setPersistentId(): setting persistentId to "+K);x(K)}else{frosmo.error.log("frosmo.session.setPersistentId(): invalid persistentId: "+K,frosmo.error.SESSION_INVALID_CID)}},m=function(){var L,K=h();if(typeof K==="undefined"||K===null){frosmo.error.log("frosmo.session.getPersistentId(): session startTime not defined",frosmo.error.SESSION_UNDEFINED_STARTTIME);K=new Date()}L=E(navigator.userAgent).toString(36)+"."+K.getTime().toString(36);return L},q=function(){if(!frosmo.cookies){frosmo.console.error("frosmo.session.getPersistentId(): frosmo.cookies library is not loaded");return null}if(r()===false){C(m())}return b()},A=function(){frosmo.console.log("frosmo.session.js -- Reset persistent cookie");x(null)},a=function(L){var M=new RegExp("https?://((?:[\\w\\-]+)(?:\\.[\\w\\-]+)*)/?"),K=M.exec(L);if(K){return K[1]}else{return null}},j=function(L){var M=new RegExp("[\\w\\-]+\\.[\\w\\-]+$"),K=M.exec(L);if(K){return K[0]}else{return null}},t=function(L){var K=new RegExp("\\d+\\.\\d+");if(K.test(L)){return false}return true},c=function(O){frosmo.console.log("frosmo.session.detectSource(): Detecting user source.");if(J()){frosmo.console.log("frosmo.session.detectSource(): Old source present, don't overwrite");return}var Q,P,L,K,N,M;if(O){if(typeof O==="string"){frosmo.console.log("frosmo.session.detectSource(): Source supplied, using "+O);f(O);return}else{if(typeof O==="function"){frosmo.console.log("frosmo.session.detectSource(): Getting source from custom function");Q=O.call(window);if(Q){frosmo.console.log('frosmo.session.detectSource(): Custom function returned "'+Q+'", setting source');f(Q);return}else{frosmo.console.log("frosmo.session.detectSource(): Custom function returned empty value, autodetecting")}}}}if(frosmo.utils){P=frosmo.utils.getUrlParams();if(P.fssrc){frosmo.console.log('frosmo.session.detectSource(): Using url param "fssrc", setting source to "'+P.fssrc+'"');f(P.fssrc);return}}K=(w!==null?w:document.referrer);M=(l!==null?l:document.location.hostname);if(K){frosmo.console.log("frosmo.session.detectSource(): Checking if referrer is different from current domain.");L=(function(){var R=a(K),S;if(R){S=j(R);if(S){return S}}return null}());N=(function(){var R=j(M);if(R){return R}return null}());if(N&&L&&N!==L){if(t(L)){O=L;if(L.indexOf("google.")===0){O="google"}else{if(L==="facebook.com"){O="fb"}}frosmo.console.log('frosmo.session.detectSource(): Setting source based on referrer to "'+O+'"');f(O);return}}frosmo.console.log('frosmo.session.detectSource(): Ambigous referrer, setting source to "direct"');f("direct")}else{frosmo.console.log('frosmo.session.detectSource(): No referrer, setting source to "direct"');f("direct")}},G=function(M){frosmo.console.log("frosmo.session: Initializing...");if(typeof frosmo.cookies==="undefined"){throw new Error("frosmo.cookies.js not loaded (required by frosmo.session.js)")}if(typeof frosmo.event==="undefined"){throw new Error("frosmo.event.js not loaded (required by frosmo.session.js)")}if(typeof frosmo.jstorage==="undefined"){throw new Error("frosmo.jstorage.js not loaded (required by frosmo.session.js)")}frosmo.console.log("frosmo.session.init(): init");var K=e(),L;v();if(r()){if(K===null){frosmo.console.log("frosmo.session.init(): New session, acquiring source.");f(null);c(M);frosmo.event.returningVisitor(J())}else{if(K>F.duration*60*1000){frosmo.console.log("frosmo.session.init(): User inactive over "+F.duration+"min, acquiring source.");f(null);c(M);frosmo.event.returningVisitor(J())}else{frosmo.console.log("frosmo.session.init(): user has not been inactive over "+F.duration+"min, inactivityTime:"+K)}}}else{L=q();if(L){frosmo.console.log("frosmo.session.init(): Create and send new persistentId to Optimizer API");c(M);frosmo.event.newVisitor(J(),I())}else{frosmo.console.error("frosmo.session.init(): Failed to create new persistentId")}}d()};if(window.frosmo.test){window.frosmo.test.session={configuration:F,setStartTime:function(K){B();H.startTime=K;o()},setReferrer:function(K){w=K},setHostname:function(K){l=K},reset:function(){if(!frosmo.cookies){frosmo.console.error("frosmo.cookies.js not loaded")}H=null;frosmo.cookies.set(F.cookie_name,null);A()}}}s={init:G,login:y,getSource:J,getReferer:I,setSource:f,getDuration:n,getStartTime:h,setLoginTime:k,getLoginTime:D,hasPersistentId:p,getPersistentId:q,resetPersistentId:A,setPersistentId:C,update:d,setLastActivityTime:u};if(window.frosmo.test){s.getHostnameFromUrl=a;s.getDomainFromHostname=j;s.detectSource=c;s.isValidDomain=t}return s}());frosmo.validator=(function(){var e={user:{userId:["string",32],country:["string",4],language:["string",5],gender:["string",1],email:["string",96],dob:["date",null],source:["string",32],city:["string",16],displayname:["string",20],firstname:["string",16],lastname:["string",16],facebookId:["integer",Math.pow(2,64)-1],linkedinId:["string",10],registrationTime:["datetime",null]},product:{productId:["string",128],productType:["string",32],productName:["string",64],productUrn:["string",32],productCategory:["string",32],productCampaign:["string",32],productArea:["string",32],productCountry:["string",32],productCity:["string",32],productVenue:["string",64],productCompany:["string",32],productManufacturer:["string",32],productModel:["string",32],productSubCategory:["string",32]},segment:{family:["list",["other","family"]],travelType:["list",["flex","charter"]],season:["list",["summer","winter"]]},customUserData:{teamCount:["integer",32767],accountBalance:["decimal",null],tradesLeft:["integer",32767]},apiParameters:{segmentName:["regexp",new RegExp("[a-z][a-zA-Z]{0,63}")],segmentValue:["regexp",new RegExp("[a-zA-Z][a-zA-Z0-9]{0,63}")]}},j=function(l,m){for(var k=0;k<m.length;k+=1){if(m[k]===l){return true}}return false},f=function(l,k){l=l.toString();if(l.length>k){return{value:l.substr(0,k),warning:"too long"}}else{return{value:l,warning:false}}},h=function(m,l){m=m.toString();var k=m.match(l);if(k){return{value:k[0],warning:false}}else{return null}},c=function(l,k){l=parseFloat(l.toString());if(isNaN(l)){return null}else{return{value:l,warning:false}}},g=function(l,k){l=parseInt(l.toString(),10);if(isNaN(l)){return null}else{return{value:l,warning:false}}},i=function(m,l){m=m.toString();var k=m.match(/(19|20)\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])/);if(k){return{value:k[0],warning:false}}else{return null}},a=function(m,l){m=m.toString();var k=m.match(/(19|20)\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1]) (0\d|1\d|2[0-3]):(0\d|[1-5]\d):(0\d|[1-5]\d)/);if(k){return{value:k[0],warning:false}}else{return null}},b=function(l,k){l=l.toString();if(!j(l,k)){return null}else{return{value:l,warning:false}}},d=function(n,l,p){var o=n[l],m,k;if(o===undefined){frosmo.console.error("Invalid attribute name: '"+l+"'");return null}if(p===null){frosmo.console.error("attribute value can't be null ("+l+")");return null}m=o[0];k=o[1];switch(m){case"string":return f(p,k);case"decimal":return c(p,k);case"integer":return g(p,k);case"date":return i(p,k);case"datetime":return a(p,k);case"list":return b(p,k);case"regexp":return h(p,k)}};return{validateProductAttribute:function(k,l){return d(e.product,k,l)},validateSegmentAttribute:function(l,n){var k,m;if(l in e.segment){return d(e.segment,l,n)}else{k=d(e.apiParameters,"segmentName",l);if(k===null||k.warning){frosmo.console.error("Segment name validation failed");return null}k=d(e.apiParameters,"segmentValue",n);if(k===null||k.warning){frosmo.console.error("Segment name validation failed");return null}m=frosmo.segment.getValidationDefinition();return d(m,l,n)}},validateUserAttribute:function(k,l){return d(e.user,k,l)},validateApiParameter:function(k,l){return d(e.apiParameters,k,l)},testGetDictionary:function(){return e}}}());frosmo.user=(function(){var j,q=[],a="userData",n={id:null,country:null,gender:null,dob:null,city:null,email:null,displayname:null,firstname:null,lastname:null,facebookId:null,linkedinId:null,loginId:null,language:null,registrationTime:null},i=function(s){if(!n.hasOwnProperty(s)){return false}if(typeof n[s]==="undefined"){return false}return true},c=function(s){return"segment"+s.charAt(0).toUpperCase()+s.slice(1)},f=function(t,u){t=c(t);var s=frosmo.jstorage.get("segments",{});s[t]=u;frosmo.jstorage.set("segments",s)},o=false,g=function(){var s;if(o){return n}else{s=frosmo.jstorage.get(a,{});frosmo.utils.each(s,function(u,t){if(t==="source"){return}if(i(t)){n[t]=u}else{frosmo.console.error("trying to set unknown user data from jstorage: "+t+"="+u)}});o=true;return n}},b=function(){var s=g();return s.id},r=function(x){var w=frosmo.jstorage.get("userIdRelations",[]),u,s,t,v;for(u=0,s=w.length;u<s;u=u+1){t=w[u];v=t.facebookId?t.facebookId.toString():null;if(t.id===x||v===x||t.loginId===x){return t.id}}return null},p=function(v){var s=g(),t,u;u=s.facebookId?s.facebookId.toString():null;if(u&&u===v){return s.id}if(s.loginId===v){return s.id}t=r(v);return t||s.id||v},h=function(s){var y=frosmo.jstorage.get("userIdRelations",[]),w,u,x,v,t=false;for(w=0,u=y.length;w<u;w=w+1){v=y[w];x=v.facebookId?v.facebookId.toString():null;if(v.id===s.id||x===s.id||v.loginId===s.id){y[w]=s;t=true}}if(!t){y.push(s)}frosmo.jstorage.set("userIdRelations",y)},e=function(s){frosmo.jstorage.set(a,s);h(s);n=s;o=true;return n},k=function(s,t){if(s==="id"||s==="loginId"){s="userId"}return frosmo.validator.validateUserAttribute(s,t)},d=function(u){var t,s=frosmo.utils.clone(u);delete s.loginId;delete s.id;if(frosmo.config.user.anonymize){delete s.displayname;delete s.firstname;delete s.lastname;delete s.email;if(s.dob){s.dob=s.dob.replace(/-\d{2}/g,"-01")}}frosmo.utils.each(s,function(w,v){if(w===null){delete s[v]}});s.source=frosmo.session?frosmo.session.getSource():null;frosmo.api.setUserData(u.id,s)},l=function(w,t,y){var v=frosmo.utils.clone(n),x,u,s;x=k("userId",w);if(x){v.id=p(x.value)||x.value}frosmo.console.log("user.id from auth:"+p(x.value));s=frosmo.utils.clone(t);if(typeof s.id!=="undefined"){delete s.id}frosmo.utils.each(s,function(A,z){if(i(z)){x=k(z,A);if(x){v[z]=x.value}}else{frosmo.console.error("trying to set unknown user data: "+z+"="+A)}});if(v.id){d(v)}return e(v)},m=function(){var s={};frosmo.utils.each(frosmo.utils.objectKeys(n),function(t){s[t]=null});frosmo.jstorage.set(a,s);n=s;return n};j={setSegment:f,deleteSegment:function(t){var u=c(t),s=frosmo.jstorage.get("segments",{});delete s[u];frosmo.jstorage.set("segments",s);if(frosmo.utils.contains(q,t)){frosmo.api.clearCustomAttribute(b(),t)}else{frosmo.api.clearUserSegment(b(),t)}},setSegments:function(t){var u,v,s={},w=false;for(u in t){if(t.hasOwnProperty(u)){v=t[u];f(u,v);if(frosmo.utils.contains(q,u)){s[u]=v;w=true}else{frosmo.api.setUserSegment(b(),u,v)}}}if(w){frosmo.api.setCustomUserData(b(),s)}},setState:function(t,v){var s=frosmo.jstorage.get("states",{}),u=function(w){return"state"+w.charAt(0).toUpperCase()+w.slice(1)};t=u(t);s[t]=v;frosmo.jstorage.set("states",s)},getSegments:function(){return frosmo.jstorage.get("segments",{})},getStates:function(){return frosmo.jstorage.get("states",{})},setUserData:l,getUserData:g,getUserId:b,deleteUserData:m,getUserIdWithAuthId:p};if(window.frosmo.test){j.reset=function(){m();frosmo.jstorage.set(a,{});o=false};j.saveUserData=e;j.saveUserIdRelations=h;j.getUserIdFromRelations=r}return j}());frosmo.contextIdentifier=(function(){var m={separator:"|"},b=function(n,o){if(o){frosmo.console.log(o+": "+n)}else{frosmo.console.log("frosmo.contextIdentifier: "+n)}},g=function(n,o){if(o){frosmo.console.error(o+": "+n)}else{frosmo.console.error("frosmo.contextIdentifier: "+n)}},e=function(n){if(frosmo.utils.isRegExp(n)){return"regexp"}else{if(frosmo.utils.isArray(n)){return"array"}else{if(typeof n==="object"){return"object"}else{if(typeof n==="string"){return"string"}}}}g("unknown param type!"+typeof n);return null},d={context:{referrer:function(n){if(document.referrer.match(n)){return true}return false},path:function(p){var o=window.location.pathname,n;n=function(t,u){var q=false,y,x,w,z,v,s=[],r=0;switch(e(t)){case"string":return u===t?u:null;case"regexp":return t.test(u)?u||true:null;case"array":for(w=0;w<t.length;w=w+1){z=n(t[w],u);if(z){return z}}return null;case"object":y=frosmo.utils.getUrlPath(t);y.shift();x=y.length;for(w in t){if(t.hasOwnProperty(w)){r=r+1;v=w;if(w==="first"){v=0}else{if(w==="last"){v=x-1}}if(t[w]===true||t[w]===null){q=y[v]||null}else{if(t[w]===false){q=y[v]?null:true}else{q=n(t[w],y[v])}}if(q){s.push(q)}q=false}}if(s.length>0&&s.length===r){return s}return null;default:g("path param type not supported: "+typeof t);return null}};return n(p,o)},urlParam:function(r){var o=frosmo.utils.getUrlParams(),p,q,n;n=function(x,s){var v,u,t,w=false;switch(e(x)){case"string":if(typeof s==="object"){return s[x]||null}return s===x;case"regexp":return x.test(s)?s:null;case"array":for(v=0;v<x.length;v=v+1){q=n(x[v],s);if(q){return q}}return null;case"object":u=[];t=0;for(v in x){if(x.hasOwnProperty(v)){t=t+1;if(x[v]===true){w=s[v]?s[v]:null}else{if(x[v]===false){w=typeof(s[v])!=="undefined"?null:true}else{if(s[v]){w=n(x[v],s[v])}}}if(w){u.push(w)}w=false}}if(u.length>0&&u.length===t){return u}return null;default:g("urlParam param type not supported: "+typeof x);return null}};return n(r,o)||null},hash:function(q){var p=window.location.hash,o=q.length-1,n;if(p.length>0){p=p.substring(1)}n=function(t){var r,s;switch(e(t)){case"string":return(t===p)?p:null;case"regexp":return t.test(p)?(p||true):null;case"array":for(r=0;r<t.length;r=r+1){s=n(t[r]);if(s){return s}}return null;case"object":g("hash param can not be Object!");return null;default:g("path param type not supported: "+typeof t);return null}};return n(q)||null},jquery:function(p){var n,o;if(!window.jQuery){g("jQuery is not loaded. Can not match jquery param!");return null}o=function(w,r){var u,q,t=[],s=0,v=false;switch(e(w)){case"string":if(r&&jQuery(r).length>0){return jQuery.trim(jQuery(r).text())===w||null}return(jQuery(w).length>0)?(jQuery.trim(jQuery(w).text())||true):null;case"regexp":g("jquery param can not be Regular Expression!");return null;case"array":for(u=0;u<w.length;u=u+1){v=o(w[u]);if(v){return v}}return null;case"object":if(typeof w.html==="function"){return(w.length>0)?(jQuery.trim(w.text())||true):null}else{for(q in w){if(w.hasOwnProperty(q)){s=s+1;if(w[q]===true){v=(jQuery(q).length>0)?(jQuery.trim(jQuery(q).text())||true):null}else{if(w[q]===false){v=(jQuery(q).length===0)?true:null}else{v=o(w[q],q)}}if(v){t.push(v)}v=false}}if(t.length>0&&t.length===s){return t}return null}return null;default:g("jquery param type not supported: "+typeof w);return null}};return o(p)||null},meta:function(p){var r=document.getElementsByTagName("meta"),q,o,n;n=function(y,w,x){var v,u=[],t,s;switch(e(y)){case"string":if(!x){x=y.match(/^og/)?"property":"name"}for(q=0;q<w.length;q=q+1){if(w[q][x]===y){return w[q].content}}return null;case"regexp":for(q=0;q<w.length;q=q+1){if(x){if(y.test(w[q][x])){return w[q].content}}else{if(y.test(w[q].name)||y.test(w[q].property)){return w[q].content}}}return null;case"array":for(q=0;q<y.length;q=q+1){v=n(y[q],w,x);if(v){return v}}return null;case"object":u=[];t=0;for(s in y){if(y.hasOwnProperty(s)){t=t+1;x=s.match(/^og/)?"property":"name";for(o=0;o<w.length;o=o+1){if(w[o].getAttribute(x)===s){v=n(y[s],[w[o]],"content");if(v){u.push(v)}}}}}if(u.length>0&&u.length===t){return u}return null;default:g("path param type not supported: "+typeof y);return null}return null};return n(p,r)||null}}},i=function(o,p){var n,q;if(!p.identifier){g("no context identifier for context "+o);return null}n=p.identifier;q=function(r){var x,v,u,t,w,s;if(frosmo.utils.isArray(r)){for(v=0;v<r.length;v=v+1){s=q(r[v]);if(s){return s}}return false}else{if(typeof r==="object"){u=0;t=0;for(x in r){if(r.hasOwnProperty(x)){w=r[x];if(!d.context[x]){g("invalid identifier: "+x);continue}u=u+1;if(d.context[x](w)){t=t+1}}}if(t>0&&u===t){return true}return false}else{g("invalid identifier type: "+typeof r);return false}}};return q(n)||false},j=function(n){return n.shift()},k=function(q){var n,p={},o=[];for(n in q){if(i(n,q[n])){p=q[n];p.name=n;o.push(p)}}if(o.length>0){return j(o)}return null},c=function(n){var o,q=m.separator||"|",p=m.decorateLowerCase||false;o=function(r){var v,t,u,s=[];if(typeof r==="string"){return r}else{if(frosmo.utils.isArray(r)){for(u=0;u<r.length;u=u+1){t=o(u);if(t){return t}}}else{if(typeof r==="object"){for(v in r){if(r.hasOwnProperty(v)){t=r[v];if(v==="text"){s.push(t);continue}if(!d.context[v]){g("invalid identifier: "+v);continue}t=d.context[v](t);if(t){s.push(t)}}}frosmo.utils.each(s,function(y,w,x){if(frosmo.utils.isArray(y)){x[w]=y.join(q)}});if(s.length>0){if(p){return s.join(q).toLowerCase()}return s.join(q)}}}}};return o(n)},a=function(o){if(!o.product){return}var q=o.product,r={},n,p;for(n in q){if(q.hasOwnProperty(n)){q[n]=c(q[n])}}frosmo.pageContext.setProductAttributes(q)},f=function(t){if(!t.events){return}var s=t.events,q,o,n,u,r,p;o=function(w,v){if(typeof w!=="function"){g("Event must be function!");return}w(v)};for(p in s){if(s.hasOwnProperty(p)){n=s[p];if(frosmo.event[p]){u=frosmo.event[p]}else{if(frosmo.site.event&&frosmo.site.event[p]){u=frosmo.site.event[p]}else{g("invalid event called! No event found: "+p);continue}}if(frosmo.utils.isArray(n)){for(r=0;r<n.length;r=r+1){o(u,n[r])}}else{if(typeof n==="object"){o(u,n)}else{g("tried to call event with invalid options type:"+typeof n);continue}}}}},h=function(n){var o;o=n.path?n.path:n.name;frosmo.console.log("setting path:"+o);frosmo.pageContext.setPath(o)},l=function(p,o){var n;if(o){frosmo.utils.extend(m,o)}p=p||frosmo.site.contexts;if(!p){g("no contexts defined!")}n=k(p);if(n){b("found context: "+n.name);h(n);a(n);f(n)}else{b("no context")}return n};return{init:l,getContext:k,handleProductData:a}}());frosmo.product=(function(){var e={version:"0.2"},k={},g=null,d={},h={api:null,origin:null,productCache:true,sessionStorage:false},a=function(){try{return !!sessionStorage.getItem}catch(l){return false}},f,c,b,j=function(l){return(l.substring(0,7)==="product")},i;i=function(m,l){this.id=null;this.attributes={};this.updated=null;this.setId(m);this.setAttributes(l)};i.prototype={setId:function(n){var l=n.toString(),m=frosmo.validator.validateProductAttribute("productId",l);if(m){this.id=l}else{frosmo.console.log("Invalid productId: "+n)}},setAttributes:function(m){var l=this,s=frosmo.validator.validateProductAttribute,q,n,o,p,r;for(n in m){if(m.hasOwnProperty(n)){q=m[n];if(j(n)){p=n;o=n.charAt(7).toLowerCase()+n.slice(8)}else{p="product"+n.charAt(0).toUpperCase()+n.slice(1);o=n}if(q===null){l.attributes[o]=null}else{r=s(p,q);if(r){if(r.warning){frosmo.console.log("Product attribute '"+n+"' validation failed: value '"+q+"' "+r.warning)}l.attributes[o]=r.value}else{frosmo.console.log("Product attribute '"+n+"' validation failed: value '"+q+"' is not valid")}}}}},getAttributes:function(){var m,n,l={};for(m in this.attributes){if(this.attributes.hasOwnProperty(m)){n="product"+m.charAt(0).toUpperCase()+m.slice(1);l[n]=this.attributes[m]}}return l},getAttribute:function(l){if(l in this.attributes){return this.attributes[l]}else{return null}}};f=function(){if(d.sessionStorage){try{g=JSON.parse(sessionStorage.getItem("frosmo.products"))||{}}catch(l){g={}}}else{g={}}};c=function(){if(d.sessionStorage){try{sessionStorage.setItem("frosmo.products",JSON.stringify(g))}catch(l){return}}};b=function(n,m){var l=this;if(!d.api){m.error.call(l,"API configuration missing");return}if(!d.origin){m.error.call(l,"Site origin missing");return}if(typeof d.api==="function"){m.success.call(l,d.api.call(l,{origin:d.origin,productId:n,version:e.version}))}else{frosmo.request.jsonp(d.api,{params:{origin:d.origin,productId:n,version:e.version},on:{success:function(o){if(typeof o==="object"){if(o.error){m.error.call(l,o.error)}else{m.success.call(l,o)}}else{m.error.call(l,"Invalid response")}},timeout:function(){m.error.call(l,"Request timed out")}}})}};e.reset=function(){d=h;k={};g={};try{sessionStorage.removeItem("frosmo.products")}catch(l){}};e.init=function(l){if(typeof l!=="object"){throw new Error("Argument must be valid object")}frosmo.utils.extend(d,h);frosmo.utils.extend(d,l);if(d.sessionStorage){frosmo.console.log("Session storage enabled")}else{frosmo.console.log("Session storage disabled")}if(d.productCache){frosmo.console.log("Product cache enabled");f()}else{frosmo.console.log("Product cache disabled")}};e.fetch=function(n,m){var l=this,o=e.get(n);m=m||{};if(o===null){b(n,{success:function(r){var q,p={};if(r.hasOwnProperty("productId")){delete r.productId}if(r.hasOwnProperty("version")){delete r.version}if(r.productAttributes){p=r.productAttributes;delete r.productAttributes}if(r.productName){p.name=r.productName;delete r.productName}if(r.productType){p.type=r.productType;delete r.productType}for(q in r){if(r.hasOwnProperty(q)){frosmo.console.log("Unknown attribute in product data response: "+q)}}o=new i(n,p);o.updated=new Date();if(o instanceof i){e.add(o);if(m.success){m.success.call(l,o)}}else{if(m.error){m.error.call(l,"Failed to create new product")}}},error:function(p){frosmo.console.error(p);if(m.error){m.error.call(l,p)}}})}else{if(typeof m.success==="function"){m.success.call(l,o)}}};e.get=function(l){var m;if(l in k&&k.hasOwnProperty(l)){return k[l]}else{if(d.productCache&&g){if(l in g&&g.hasOwnProperty(l)){m=new i(l,g[l]);if(m instanceof i){k[l]=m;return m}}}return null}};e.add=function(m){var l=m.id;if(l){k[l]=m;if(d.productCache&&g){g[l]=m.attributes;c()}return true}else{throw new Error("Product ID missing")}};e.create=function(m,l){var n=new i(m,l);if(n.id){k[n.id]=n;return n}else{throw new Error("Product ID missing or not valid")}};e.save=function(l){if(l instanceof i){frosmo.console.log("Save product data for productId "+l.id);frosmo.api.setProductData(l.id,l.getAttributes());l.updated=new Date()}};e.push=function(){var l,m;for(l in k){if(k.hasOwnProperty(l)){m=k[l];if(m.updated===null){e.save(m)}}}};h.sessionStorage=a();frosmo.Product=i;return e}());frosmo.segment=(function(){var c=this,g="1.1.0",f=c.frosmo,b=f.utils,a,e={},d={};d.VERSION=g;d.reset=function(){e={}};d.init=function(h){h=h||{};if(h.definition){b.each(h.definition,function(i,j){d.addDefinition(j,i)})}};d.addDefinition=function(i,h){if(b.isArray(h)){e[i]=h}else{e[i]=b.objectKeys(h)}};d.getDefinition=function(h){if(h in e){return e[h]}else{return null}};d.getSupportedSegments=function(){return b.objectKeys(e)};d.isSupportedSegment=function(h){if(d.getDefinition(h)===null){return false}else{return true}};d.validate=function(h,i){if(h in e){if(i===null){return"null value for segment '"+h+"' is not allowed"}if(!b.contains(e[h],i)){return"segment '"+h+"' value '"+i+"' not supported"}}else{return"segment '"+h+"' not defined"}};d.getValidationDefinition=function(){var h={};b.each(e,function(i,j){h[j]=["list",i]});return h};d.getSegment=function(i){var h,j;if(!d.isSupportedSegment(i)){throw new Error("Unsupported segment: "+i)}j="segment"+i.charAt(0).toUpperCase()+i.slice(1);h=f.user.getSegments();if(b.keyExists(j,h)){return h[j]}else{return null}};d.setSegment=function(j,h){var k={},i;i=d.validate(j,h);if(i){f.console.error("Validation error: "+i);return false}k[j]=h;f.console.log("setting segment: "+j+": "+h);f.user.setSegments(k);d.trigger("change",j,h)};d.get=d.getSegment;d.set=d.setSegment;f.utils.extend(d,f.EventHandler);return d}());frosmo.segment.counter=(function(){var c={},b=frosmo.utils,a,f,e,d;e=function(){return a||5};d=function(){return f||null};c.init=function(g){if(g.limit){a=g.limit}if(g.firstLimit){f=g.firstLimit}};c.getDefaultSegmentObject=function(){var g={};b.each(frosmo.segment.getSupportedSegments(),function(i){var j={},h=frosmo.segment.getDefinition(i);b.each(h,function(k){j[k]=0});g[i]=j});return g};c.getMaxAttrByCounter=function(k){var j=frosmo.utils.clone(k),i="",h="",g={};frosmo.utils.each(j,function(m,l){if(!h){h=l;i=m}else{if(m>i){h=l;i=m}}});if(!h){return null}g[h]=i;return[h,i]};c.sortSegmentByCounter=function(m){var h,l=frosmo.utils.clone(m),k=frosmo.utils.objectKeys(l).length,g=[],j;frosmo.console.log("length: "+k);frosmo.console.log(m);for(h=0;h<k;h=h+1){j=c.getMaxAttrByCounter(l);if(frosmo.utils.isArray(j)){g.push(j);delete l[j[0]]}}frosmo.console.log("result: "+g);return g};c.addSegmentCounter=function(p,t,m,s){var j=frosmo.jstorage.get("frosmo_segment_counter"),o,q,r,n,l=false,h,k=m||e(),g=s||d()||null;q=frosmo.segment.validate(t,p);if(q){frosmo.console.error("Validation error: "+q);return}if(!j){frosmo.console.error("no segment counters, create object");o=c.getDefaultSegmentObject()}else{if(!j.hasOwnProperty(t)){frosmo.console.error("no segment counter for "+t);o=j;o[t]=c.getDefaultSegmentObject()[t]}else{o=j}}if(!frosmo.utils.keyExists(t,o)){frosmo.console.error("no segmentType:"+t);return}if(!frosmo.utils.keyExists(p,o[t])){frosmo.console.error("no segment:"+p);return}o[t][p]=o[t][p]+1;h=c.sortSegmentByCounter(o[t]);frosmo.console.log("sorted >>>>>>>>");frosmo.console.log(h);if(g&&(!frosmo.segment.getSegment(t))){if((h[0][1]>=g)){l=true}}else{if((h[0][1]-h[1][1])>=k){l=true}}if(l){frosmo.segment.set(t,p);for(n in o[t]){if(o[t][n]!==0){o[t][n]=0}}frosmo.jstorage.set("frosmo_segment_set",true)}frosmo.jstorage.set("frosmo_segment_counter",o)};c.clearSegmentCounter=function(i){frosmo.console.log("Clearing frosmo segment counter from cookie and db");var h=frosmo.jstorage.get("frosmo_segment_counter"),g=c.getDefaultSegmentObject();if(typeof g[i]!=="object"){frosmo.console.log("clearSegmentCounter: unknown segment type");return null}h[i]=g[i];frosmo.jstorage.set("frosmo_segment_counter",h);frosmo.user.deleteSegment(i);return true};return c}());(function(g){if(!g||!(g.toJSON||Object.toJSON||window.JSON)){throw new Error("jQuery, MooTools or Prototype needs to be loaded before jStorage!")}var h={},e={__frosmo:"{}"},i=null,k=0,m=g.toJSON||Object.toJSON||(window.JSON&&(JSON.encode||JSON.stringify)),f=g.evalJSON||(window.JSON&&(JSON.decode||JSON.parse))||function(n){return String(n).evalJSON()},j=false,d={isXML:function(o){var n=(o?o.ownerDocument||o:0).documentElement;return n?n.nodeName!=="HTML":false},encode:function(o){if(!this.isXML(o)){return false}try{return new XMLSerializer().serializeToString(o)}catch(n){try{return o.xml}catch(p){}}return false},decode:function(o){var n=("DOMParser" in window&&(new DOMParser()).parseFromString)||(window.ActiveXObject&&function(q){var r=new ActiveXObject("Microsoft.XMLDOM");r.async="false";r.loadXML(q);return r}),p;if(!n){return false}p=n.call("DOMParser" in window&&(new DOMParser())||window,o,"text/xml");return this.isXML(p)?p:false}};function l(){var n=false;if("localStorage" in window){try{window.localStorage.setItem("_tmptest","tmpval");n=true;window.localStorage.removeItem("_tmptest")}catch(o){}}if(n){try{if(window.localStorage){e=window.localStorage;j="localStorage"}}catch(s){}}else{if("globalStorage" in window){try{if(window.globalStorage){e=window.globalStorage[window.location.hostname];j="globalStorage"}}catch(r){}}else{i=document.createElement("link");if(i.addBehavior){i.style.behavior="url(#default#userData)";document.getElementsByTagName("head")[0].appendChild(i);i.load("__frosmo");var q="{}";try{q=i.getAttribute("__frosmo")}catch(p){}e.__frosmo=q;j="userDataBehavior"}else{i=null;return}}}b()}function b(){if(e.__frosmo){try{h=f(String(e.__frosmo))}catch(n){e.__frosmo="{}"}}else{e.__frosmo="{}"}k=e.__frosmo?String(e.__frosmo).length:0}function c(){try{e.__frosmo=m(h);if(i){i.setAttribute("__frosmo",e.__frosmo);i.save("__frosmo")}k=e.__frosmo?String(e.__frosmo).length:0}catch(n){}}function a(n){if(!n||(typeof n!="string"&&typeof n!="number")){throw new TypeError("Key name must be string or numeric")}return true}frosmo.jstorage={version:"0.1.5.0",set:function(n,o){a(n);if(d.isXML(o)){o={_is_xml:true,xml:d.encode(o)}}h[n]=o;c();return o},get:function(n,o){a(n);if(n in h){if(typeof h[n]=="object"&&h[n]._is_xml&&h[n]._is_xml){return d.decode(h[n].xml)}else{return h[n]}}return typeof(o)=="undefined"?null:o},deleteKey:function(n){a(n);if(n in h){delete h[n];c();return true}return false},flush:function(){h={};c();try{window.localStorage.clear()}catch(n){}return true},storageObj:function(){function n(){}n.prototype=h;return new n()},index:function(){var n=[],o;for(o in h){if(h.hasOwnProperty(o)){n.push(o)}}return n},storageSize:function(){return k},currentBackend:function(){return j},storageAvailable:function(){return !!j},reInit:function(){var n,p;if(i&&i.addBehavior){n=document.createElement("link");i.parentNode.replaceChild(n,i);i=n;i.style.behavior="url(#default#userData)";document.getElementsByTagName("head")[0].appendChild(i);i.load("__frosmo");p="{}";try{p=i.getAttribute("__frosmo")}catch(o){}e.__frosmo=p;j="userDataBehavior"}b()}};l()})(window.jQuery||window.$);(function(){var a={api:{server:"https://optimizer.frosmo.com/optimizerApi?"},fbWrapper:{locale:"fi_FI",oauth:true,fbAppId:"53ec27f0fcfeda09b6af9bf3ea60a252"},segment:{definition:{payingUser:["payinguser1","payinguser2","payinguser3"],loyalUser:["loyaluser1","loyaluser2"]},unchangables:["loyaluser2","payinguser3"]},debug:false,origin:"5laps",cookies:{domain:"fi.5laps.com"},message:{rpc:"https://optimizer.frosmo.com/messageApi"}};a.version=1;frosmo.site.config=a}());(function(){var a={};if(window.location.hostname.match(/^en\.5laps\.com/)){frosmo.site.config.fbWrapper.locale="en_US";frosmo.site.config.origin="5laps-international";frosmo.site.config.cookies.domain="en.5laps.com"}}());if(!frosmo.site.event){frosmo.site.event={}}frosmo.site.event.login=function(){frosmo.console.log("in frosmo.site.event.login()")};frosmo.site.event.logout=function(){frosmo.console.log("in frosmo.site.event.logout()")};frosmo.site.event.newVisitor=function(){frosmo.console.log("in frosmo.site.event.newVisitor()");frosmo.message.display()};frosmo.site.event.returningVisitor=function(){frosmo.console.log("in frosmo.site.event.returningVisitor()")};frosmo.site.event["segment.change"]=function(b){var a=frosmo.segment.getSegment(b.segmentType);if(a&&frosmo.utils.inArray(a,frosmo.site.config.segment.unchangables)){frosmo.console.log("segment.change >>>User cannot change from "+a+" to "+b.segment);return}frosmo.segment.counter.addSegmentCounter(b.segment,b.segmentType,b.forceLimit,b.firstLimit)};frosmo.site.event["purchase.tournament"]=function(){var a="loyaluser1",c=3,b=3;if(frosmo.segment.getSegment("loyalUser")==="loyaluser1"){a="loyaluser2";c=7;b=7}frosmo.site.event["segment.change"]({segment:a,segmentType:"loyalUser",forceLimit:c,firstLimit:b})};frosmo.site.event["purchase.order"]=function(){var a="payinguser1",d=1,c=1,b=frosmo.segment.getSegment("payingUser");if(b==="payinguser1"){a="payinguser2";d=10;c=10}else{if(b==="payinguser2"){a="payinguser3";d=50;c=50}}frosmo.site.event["segment.change"]({segment:a,segmentType:"payingUser",forceLimit:d,firstLimit:c})};(function(){var a=frosmo.site.config,c,d,b,e={fbFeedClickChecker:function(f){if(document.referrer.match(/^http:\/\/www\.facebook\.com\/l\.php/)){frosmo.api.clickFeed(f,frosmo.user.getUserId())}},trimWithLength:function(f,g){f=f.replace(/^\s+|\s+$/g,"");if(!g){g=f.length}return f.substr(0,g)},loadFbBox:function(){var g=jQuery("#fb-box"),k,i,f,h,l="http://www.facebook.com/pages/5Lapscom/179002885453086",j="fi.5laps.com";if(g.length===0){frosmo.console.log("fb-box unavailable to load fb Activity and fb-likebox. *****************Error");return false}jQuery(g).css({padding:"20px","padding-left":"40px",margin:"auto"});jQuery(g).append('<div id="fbActivity" />');jQuery(g).append('<div id="fbLikeBox" />');k=jQuery("#fbActivity")[0];i=jQuery("#fbLikeBox")[0];jQuery(k).css({"float":"left"});if(frosmo.site.helper.functions.locale==="en_US"){l="http://www.facebook.com/pages/5lapscom-International/194402597247120";j="en.5laps.com"}f='<fb:like-box href="'+l+'" colorscheme="light" width="440" height="180" show_faces="true" stream="false" header="false"></fb:like-box>';h='<fb:activity site="'+j+'" width="440" height="180" header="true" font="" border_color="" recommendations="false"></fb:activity>';jQuery(i).append(f);jQuery(k).append(h);return true},locale:(function(){var f="fi_FI";if(window.location.href.substr(0,15).match(/en/i)){f="en_US"}return f}()),getFunnelFlag:function(){var f=frosmo.cookies.get("__funnelflag");if(f===""){f=0}else{f=parseInt(f,10)}return f},profileProduct:function(){var h,g=frosmo.site.helper.functions.trimWithLength,f={productName:g(jQuery("title").html().replace(/\s*-\s*5laps\s?$/,""),64),productUrn:window.location.pathname},i={productId:window.location.pathname.match(/\d+$/)[0],productAttributes:{}};f.productType=window.location.pathname.match(/^\/[^\/]+\//)[0].replace(/\//g,"");if(f.productType==="challenges"){if(jQuery("#challenge_infocontainer").html().match(/\d+\s*krediitt/)){i.priceType=jQuery("#challenge_infocontainer").html().match(/\d+\s*krediitt/)[0]}}else{if(f.productType==="news"){f.productType="pages";f.productCategory="news"}else{if(f.productType==="tournaments"){f.productCategory=jQuery("#tournament_type div").html();i.priceType=jQuery("#tournament_fee div").html();i.licenceType=jQuery("#tournament_license div").html()}else{if(f.productType==="leagues"){f.productType="leagues"}}}}h=f.productUrn.search(/\//)+1;f.productUrn=f.productUrn.substr(h,f.productUrn.length);f.productUrn=g(f.productUrn,32);if(i.priceType){i.price=parseFloat(i.priceType);if(isNaN(i.price)){i.price=0}}i.productAttributes=f;i.productAttributes.productId=i.productId;return i}};c={functions:e};window.frosmo.site.helper=c}());if(!window.frosmo){window.frosmo={site:{}}}frosmo.site.auth=(function(){var c="",b=function(){var d=document.createElement("iframe");d.id="ifr-user";d.style.display="none";d.src=window.location.protocol+"//"+window.location.host+"/users/"+c+"/edit";document.body.appendChild(d);jQuery("#ifr-user").bind("load",function(){var e={email:jQuery('input[name="user[email]"]',this.contentWindow.document).attr("value"),displayname:c};frosmo.event.login(c,e);frosmo.jstorage.set("loggedin",true);frosmo.console.log("**********User data set****************");document.body.removeChild(this)})},a=function(){frosmo.console.log("frosmo.site.auth::Init");if(jQuery("#profile_data a")[0]){c=jQuery("#profile_data a")[0];if(c.href.match(/\/users\/new/)||c.innerHTML.match(/skype/i)){c=""}else{c=frosmo.site.helper.functions.trimWithLength(c.innerHTML,32)}}if(c){if(!frosmo.jstorage.get("loggedin")){b()}else{frosmo.console.log("**********User data already set****************")}}else{frosmo.console.log("**********User not logged in****************");if(frosmo.jstorage.get("loggedin")){frosmo.user.deleteUserData();frosmo.console.log("**********Clearing user data****************");frosmo.jstorage.set("loggedin",false)}}};return{init:a}}());frosmo.site.context=(function(){var a={path_home:{run:function(c){frosmo.console.log("**************Home page -- tracking page View**************");if(c!=="preview"){frosmo.pageContext.setProductAttributes({productId:"homepage",productType:"pages",productUrn:"homepage",productName:"homepage"});frosmo.pageContext.viewProduct();frosmo.pageContext.setPath("path_home");frosmo.message.display()}}},path_challenges:{run:function(f){var e=window.location.pathname,d,c,g;frosmo.console.log("*********Challenge path -- tracking challenge view and purchase*******");if(e.match(/\d+$/)){d=frosmo.site.helper.functions.profileProduct();if(typeof d==="object"&&d.productId){if(f!=="preview"){frosmo.console.log("*********Successful tracking product*******");frosmo.pageContext.viewProduct();frosmo.pageContext.setProductAttributes(d.productAttributes)}}else{frosmo.console.log("*********Unsuccessful tracking product*******")}c=jQuery('a[title="Käynnistä peli"]',jQuery("#challenge_stintbox").parent());g=function(){frosmo.console.log("*******Tracking buy challenge *****'");frosmo.pageContext.buyProduct(d.price,0,0,"click");jQuery(this).unbind("click",g)};if(c.length===1){if(f!=="preview"){c.bind("click",g)}}frosmo.pageContext.setPath("path_challenges");if(f!=="preview"){frosmo.message.display()}}else{if(e.match(/^\/challenges$/)){frosmo.pageContext.setPath("path_challenges_main");if(f!=="preview"){frosmo.message.display()}}}}},path_tournaments:{run:function(f){var k=window.location.pathname,e="tournaments",j="",c=function(){if(j&&typeof j==="object"){frosmo.pageContext.recommendProduct()}},h=function(){c()},d=function(){frosmo.site.helper.functions.fbFeedClickChecker(e);var l=jQuery("#fb-like")[0];jQuery(l).css({"margin-bottom":"22px"});jQuery("#fb-like").html('<fb:like action="recommend" ref="'+e+'" href="'+window.location.href+'" show_faces="false"></fb:like>');frosmo.fbWrapper.addElementCallback({element:"like",params:{ref:e}},function(){h()})},g=function(n){var l=jQuery('input[alt^="Osa"]'),m=jQuery('input[alt^="Parti"]'),o;o=function(){frosmo.console.log("*******Tracking buy product *****'");frosmo.pageContext.buyProduct(n.price,0,0,"click");jQuery(this).unbind("click",o);frosmo.site.event["purchase.tournament"]()};if(l.length===1){l.bind("click",o)}else{if(m.length===1){m.bind("click",o)}}},i=function(l){if(typeof l==="object"&&l.productId){frosmo.pageContext.setProductAttributes(l.productAttributes);frosmo.pageContext.viewProduct();frosmo.console.log("*********Successful tracking product*******")}else{frosmo.console.log("*********Unsuccessful tracking product*******")}};if(k.match(/^\/tournaments$/)){frosmo.console.log("*********Tournaments home page -*******");frosmo.pageContext.setPath("path_tournaments_main");if(f!=="preview"){frosmo.pageContext.setProductAttributes({productId:"tournaments",productType:"pages",productUrn:window.location.pathname,productName:"tournaments"});frosmo.pageContext.viewProduct();frosmo.message.display()}}else{if(k.match(/\d+$/)){frosmo.console.log("*********Tournament path -- tracking this tournament view and purchase*******");frosmo.pageContext.setPath("path_tournaments");if(f!=="preview"){j=frosmo.site.helper.functions.profileProduct();j=j;i(j);g(j);frosmo.message.display()}d()}}}},path_leagues:{run:function(i){var d="leagues",e="",h=function(){if(e&&typeof e==="object"){frosmo.pageContext.recommendProduct()}},c=function(){h()},j=function(){frosmo.site.helper.functions.fbFeedClickChecker(d);var k=jQuery("#fb-like")[0];jQuery(k).css({"margin-bottom":"22px"});jQuery("#fb-like").html('<fb:like action="recommend" ref="'+d+'" href="'+window.location.href+'" show_faces="false"></fb:like>');frosmo.fbWrapper.addElementCallback({element:"like",params:{ref:d}},function(){c()})},g=function(){if(typeof e==="object"&&e.productId){frosmo.pageContext.setProductAttributes(e.productAttributes);frosmo.pageContext.viewProduct();frosmo.console.log("*********Successful tracking leagues *******")}else{frosmo.console.log("*********Unsuccessful tracking leagues product*******")}},f=window.location.pathname;if(f.match(/^\/leagues$/)){frosmo.console.log("*********Leagues index page -*******");frosmo.pageContext.setPath("path_leagues_main");if(i!=="preview"){frosmo.pageContext.viewProduct();frosmo.message.display()}}else{if(f.match(/\d+$/)){frosmo.console.log("*********Leagues path -- tracking this league view*******");e=frosmo.site.helper.functions.profileProduct();e=e;j();frosmo.pageContext.setPath("path_leagues");if(i!=="preview"){g();frosmo.message.display()}}}}},path_news:{run:function(i){frosmo.console.log("*********News Path*******");var d="news",f="",h=function(){f=frosmo.site.helper.functions.profileProduct();if(f&&typeof f==="object"){frosmo.pageContext.setProductAttributes(f.productAttributes)}},g=function(){if(f&&typeof f==="object"){frosmo.pageContext.recommendProduct()}},c=function(){h();g()},e=function(){var j=jQuery("#fb-like")[0];jQuery(j).css({"margin-bottom":"22px"});jQuery("#fb-like").html('<fb:like action="recommend" ref="'+d+'" href="'+window.location.href+'" show_faces="false"></fb:like>');frosmo.fbWrapper.addElementCallback({element:"like",params:{ref:d}},function(){c()})};if(window.location.pathname.match(/\d$/)){frosmo.console.log("****************Each News********");e();frosmo.site.helper.functions.fbFeedClickChecker(d)}}},path_orders:{run:function(d){var c=window.location.pathname;frosmo.console.log("*********Order path *******");if(c.match(/^\/orders$/)){frosmo.console.log("******Begin order*******")}else{if(c.match(/^\/orders\/cancel/)){frosmo.console.log("******Cancel order *******")}else{if(document.referrer.match(/\/orders\/\d+\/transactions\/\d+\/(success|delayed)/)){frosmo.console.log("******Purchase order *******");frosmo.site.event["purchase.order"]()}else{if(c.match(/^\/orders\/new/)){c=c.replace(/^\/orders\/new\//,"");switch(c){case"customer":frosmo.console.log("******State 1*******");break;case"overview":frosmo.console.log("******State 2*******");break;case"cart":frosmo.console.log("******State 0*******");break;default:break}}}}}}}},b=function(){var c="",d=window.location.pathname;frosmo.addCss(window.location.protocol+"//optimizer.s3.amazonaws.com/5laps/release/frosmo.5laps.css");if(d.match(/^\/$/)){c="path_home"}else{if(d.match(/^\/(private_)?tournaments/)){c="path_tournaments"}else{if(d.match(/^\/users/)){c="path_users"}else{if(d.match(/^\/challenges/)){c="path_challenges"}else{if(d.match(/^\/order/)){c="path_orders"}else{if(d.match(/^\/news/)){c="path_news"}else{if(d.match(/^\/leagues/)){c="path_leagues"}}}}}}}if(a[c]!==undefined){return{init:a[c].run}}else{frosmo.console.log("***********Untracked path type*************")}return{init:function(){frosmo.console.log("frosmo.site.context.getCurrentContext() example!")}}};return{getCurrentContext:b}}());(function(){var a=function(c){var b;frosmo.console.log("site Initialize");frosmo.config.popup.closeButtonText="X";if(window.location.pathname.match(/^\/users/)){frosmo.console.log("Exclude pages");return false}frosmo.site.auth.init();frosmo.fbWrapper.init(frosmo.config.fbWrapper.fbAppId,function(){frosmo.console.log("___________FB init complete____________")});frosmo.console.log("**************Loading frosmo box***************");frosmo.site.helper.functions.loadFbBox();c()};frosmo.site.init=a}());frosmo.init=(function(){var e=[],c=function(o){var n=this,l="1.4.3",m=document.createElement("script"),k=false;m.type="text/javascript";m.charset="utf-8";m.src=("https:"===document.location.protocol?"https://":"http://")+"ajax.googleapis.com/ajax/libs/jquery/"+l+"/jquery.min.js";m.onload=function(){if(!k){jQuery.noConflict();k=true;o.call(n)}};m.onreadystatechange=function(){if(!k){if(("loaded"===m.readyState||"complete"===m.readyState)){jQuery.noConflict();k=true;o.call(n)}}};document.getElementsByTagName("head")[0].appendChild(m)},d=function(l){var k=window.location.hostname;return k.match(l+"$")},g=function(){if(typeof frosmo.utils==="undefined"){throw new Error("frosmo.utils.js not loaded (required by frosmo.init.js)")}if(typeof frosmo.cookies==="undefined"){throw new Error("frosmo.cookies.js not loaded (required by frosmo.init.js)")}if(typeof frosmo.session==="undefined"){throw new Error("frosmo.session.js not loaded (required by frosmo.init.js)")}if(typeof frosmo.event==="undefined"){throw new Error("frosmo.session.js not loaded (required by frosmo.init.js)")}if(typeof frosmo.site==="undefined"){throw new Error("frosmo.site not defined")}if(typeof frosmo.site.init==="undefined"){throw new Error("frosmo.site.init() not defined")}},a=function(k){if(!k.cookies||!k.cookies.domain){frosmo.console.error("Required site configuration variable domain missing");return false}if(!k.origin){frosmo.console.error("Required site configuration variable origin missing");return false}if(!k.message||!k.message.rpc){frosmo.console.error("Required site configuration variable message.rpc missing");return false}if(!k.api||!k.api.server){frosmo.console.error("Required site configuration variable origin missing");return false}if(!k.api.server.match(/\?$/)){frosmo.console.error("Invalid Optimizer API URL: "+k.api.server);return false}return true},j=function(k){var l={};if(typeof k.debug!=="undefined"){frosmo.config.debug=k.debug}if(typeof k.fbLoginTimeout!=="undefined"){frosmo.console.error("Config attribute 'fbLoginTimeout' is deprecated, use 'fbWrapper.fbLoginTimeout' instead");frosmo.config.fbWrapper.loginTimeout=k.fbLoginTimeout}if(typeof k.fbUseOAuth!=="undefined"){frosmo.console.error("Config attribute 'fbUseOAuth' is deprecated, use 'fbWrapper.fbUseOAuth' instead");frosmo.config.fbWrapper.oauth=k.fbUseOAuth}if(typeof k.fbAppId!=="undefined"){frosmo.console.error("Config attribute 'fbAppId' is deprecated, use 'fbWrapper.fbAppId' instead");frosmo.config.fbWrapper.fbAppId=k.fbAppId}if(typeof k.origin!=="undefined"){frosmo.config.origin=k.origin}if(typeof k.messageRpc!=="undefined"){frosmo.console.error("Config attribute 'messageRpc' is deprecated, use 'message.rpc' instead");frosmo.config.message.rpc=k.messageRpc}if(typeof k.apiRpc!=="undefined"){frosmo.console.error("Config attribute 'apiRpc' is deprecated, use 'api.server' instead");frosmo.config.api.server=k.apiRpc}if(typeof k.domain!=="undefined"){frosmo.config.domain=k.domain;frosmo.config.cookies.domain=k.domain}frosmo.utils.each(frosmo.utils.objectKeys(frosmo.config),function(m){if(frosmo.utils.keyExists(m,k)){l[m]=k[m]}});frosmo.utils.extend(frosmo.config,l)},b=function(m,l){var k=[];if(typeof m==="undefined"||m===null){l(k);return}if(frosmo.utils.isArray(m)){frosmo.utils.each(m,function(n){frosmo.addCss(n,function(o){k.push(o);if(k.length===m.length){frosmo.console.log("frosmo.init.js -- all CSS files loaded");if(l){l(k)}}})})}else{frosmo.addCss(m,function(n){k.push(n);frosmo.console.log("frosmo.init.js -- all CSS files loaded");if(l){l(k)}})}},f=function(){frosmo.site.context.getCurrentContext().init();if(e.length>0){frosmo.console.log("afterInitFunctions.length: "+e.length);for(var k=0;k<e.length;k=k+1){e[k].call(window)}}},h=function(){if(!frosmo.site.config){frosmo.console.error("no frosmo.site.config defined!");return}var k=frosmo.site.config;if(frosmo.config.message.rpc!==null){frosmo.console.error("Message API defined before site configuration")}j(k);frosmo.console.log("frosmo.init.js -- load()");if(!a(frosmo.config)){frosmo.console.error("Site configuration check failed");return}if(!d(frosmo.config.cookies.domain)){frosmo.console.error("Site domain check failed.");return}if(typeof jQuery==="undefined"){throw new Error("jQuery not loaded (required by frosmo.init.js)")}try{g()}catch(l){frosmo.console.error("Error required frosmo namespace(s) missing: "+l)}if(k.css){(function(o){frosmo.utils.domReady(function(){b(o,function(p){frosmo.console.log("frosmo.init.js -- "+p.length+" CSS file(s) loaded")})})}(k.css))}k.init=k.init||{};frosmo.config.message={origin:frosmo.config.origin,rpc:frosmo.config.message.rpc};if(frosmo.admin){frosmo.admin.init()}frosmo.event.init();try{frosmo.session.init()}catch(n){frosmo.console.error(n);frosmo.error.log("session: init failed",frosmo.error.INIT_SESSION_FAILED);return}frosmo.api.init(frosmo.config.api.server,frosmo.config.origin);if(!frosmo.session.hasPersistentId()){frosmo.error.log("session: cookie missing",frosmo.error.INIT_CID_MISSING);return}if(!frosmo.jstorage.storageAvailable()){frosmo.error.log("jstorage: no backend available",frosmo.error.INIT_JSTORAGE_MISSING_BACKEND)}if(frosmo.segment){frosmo.segment.init(k.segment)}if(frosmo.product){frosmo.product.init({api:frosmo.config.product.rpc,origin:frosmo.config.origin})}if(frosmo.message){frosmo.console.log("frosmo.init.js -- initializing frosmo.message library");try{if(k.init.message){if(typeof(k.init.message)==="function"){frosmo.message.init(k.init.message())}else{if(typeof(k.init.message)==="object"){frosmo.message.init(k.init.message)}}}else{frosmo.message.init()}}catch(m){frosmo.console.error("frosmo.init.js -- failed to initialize frosmo.message.js: "+m);return}}else{frosmo.console.log("frosmo.init.js -- frosmo.message is not enabled")}frosmo.site.init(f)},i=function(){if(window.jQuery){h()}else{c(h)}};return{init:i,afterInit:function(k){e.push(k)}}}());frosmo.loader.ready(frosmo.init.init);
