var gadgets=gadgets||{};gadgets.log=function(a){gadgets.log.logAtLevel(gadgets.log.INFO,a)};gadgets.warn=function(a){gadgets.log.logAtLevel(gadgets.log.WARNING,a)};gadgets.error=function(a){gadgets.log.logAtLevel(gadgets.log.ERROR,a)};gadgets.setLogLevel=function(a){gadgets.log.logLevelThreshold_=a};gadgets.log.logAtLevel=function(a,c){if(a<gadgets.log.logLevelThreshold_||!window.console){return}var b=window.console.log;if(a==gadgets.log.WARNING&&window.console.warn){b=window.console.warn}else{if(a==gadgets.log.ERROR&&window.console.error){b=window.console.error}}b(c)};gadgets.log.INFO=1;gadgets.log.WARNING=2;gadgets.log.ERROR=3;gadgets.log.NONE=4;gadgets.log.logLevelThreshold_=gadgets.log.INFO;var gadgets=gadgets||{};gadgets.json_=function(){function f(n){return n<10?"0"+n:n}Date.prototype.toJSON=function(){return[this.getUTCFullYear(),"-",f(this.getUTCMonth()+1),"-",f(this.getUTCDate()),"T",f(this.getUTCHours()),":",f(this.getUTCMinutes()),":",f(this.getUTCSeconds()),"Z"].join("")};var m={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function stringify(value){var a,i,k,l,r=/["\\\x00-\x1f\x7f-\x9f]/g,v;switch(typeof value){case"string":return r.test(value)?'"'+value.replace(r,function(a){var c=m[a];if(c){return c}c=a.charCodeAt();return"\\u00"+Math.floor(c/16).toString(16)+(c%16).toString(16)})+'"':'"'+value+'"';case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}a=[];if(typeof value.length==="number"&&!value.propertyIsEnumerable("length")){l=value.length;for(i=0;i<l;i+=1){a.push(stringify(value[i])||"null")}return"["+a.join(",")+"]"}for(k in value){if(value.hasOwnProperty(k)){if(typeof k==="string"){v=stringify(value[k]);if(v){a.push(stringify(k)+":"+v)}}}}return"{"+a.join(",")+"}"}}return{stringify:stringify,parse:function(text){if(/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/b-u]/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){return eval("("+text+")")}return false}}}();var gadgets=gadgets||{};gadgets.rpctx=gadgets.rpctx||{};gadgets.rpctx.Ifpc=function(){var d=[];var a=0;var e;function c(f){var g=[];for(var h=0,k=f.length;h<k;++h){g.push(encodeURIComponent(gadgets.json_.stringify(f[h])))}return g.join("&")}function b(k){var j;for(var g=d.length-1;g>=0;--g){var h=d[g];try{if(h&&(h.recyclable||h.readyState==="complete")){h.parentNode.removeChild(h);if(window.ActiveXObject){d[g]=h=null;d.splice(g,1)}else{h.recyclable=false;j=h;break}}}catch(f){}}if(!j){j=document.createElement("iframe");j.style.border=j.style.width=j.style.height="0px";j.style.visibility="hidden";j.style.position="absolute";j.onload=function(){this.recyclable=true};d.push(j)}j.src=k;setTimeout(function(){document.body.appendChild(j)},0)}return{getCode:function(){return"ifpc"},isParentVerifiable:function(){return true},init:function(f,g){e=g;e("..",true);return true},setup:function(f,g){if(typeof(e)=="function"){e(f,true);return true}return false},call:function(k,g,i){var h=gadgets.rpc.getRelayUrl(k);++a;if(!h){gadgets.warn("No relay file assigned for IFPC");return}var j=null;if(i.l){var f=i.a;j=[h,"#",c([g,a,1,0,c([g,i.s,"","",g].concat(f))])].join("")}else{j=[h,"#",k,"&",g,"@",a,"&1&0&",encodeURIComponent(gadgets.json_.stringify(i))].join("")}b(j);return true}}}();var gadgets=gadgets||{};gadgets.rpctx=gadgets.rpctx||{};gadgets.rpctx.nix=function(){var h="GRPC____NIXVBS_wrapper";var e="GRPC____NIXVBS_get_wrapper";var f="GRPC____NIXVBS_handle_message";var d="GRPC____NIXVBS_create_channel";var b=10;var g=500;var c={};var j;var i=0;function a(){var k=c[".."];if(k){return}if(++i>b){gadgets.warn("Nix transport setup failed, falling back...");j("..",false);return}if(!k&&window.opener&&"GetAuthToken" in window.opener){k=window.opener;if(k.GetAuthToken()==gadgets.rpc.getAuthToken("..")){var l=gadgets.rpc.getAuthToken("..");k.CreateChannel(window[e]("..",l),l);c[".."]=k;window.opener=null;j("..",true);return}}window.setTimeout(function(){a()},g)}return{getCode:function(){return"nix"},isParentVerifiable:function(){return false},init:function(l,m){j=m;if(typeof window[e]!=="unknown"){window[f]=function(o){window.setTimeout(function(){l(gadgets.json_.parse(o))},0)};window[d]=function(p,o,q){if(gadgets.rpc.getAuthToken(p)===q){c[p]=o;j(p,true)}};var n="Class "+h+"\n Private m_Intended\nPrivate m_Auth\nPublic Sub SetIntendedName(name)\n If isEmpty(m_Intended) Then\nm_Intended = name\nEnd If\nEnd Sub\nPublic Sub SetAuth(auth)\n If isEmpty(m_Auth) Then\nm_Auth = auth\nEnd If\nEnd Sub\nPublic Sub SendMessage(data)\n "+f+"(data)\nEnd Sub\nPublic Function GetAuthToken()\n GetAuthToken = m_Auth\nEnd Function\nPublic Sub CreateChannel(channel, auth)\n Call "+d+"(m_Intended, channel, auth)\nEnd Sub\nEnd Class\nFunction "+e+"(name, auth)\nDim wrap\nSet wrap = New "+h+"\nwrap.SetIntendedName name\nwrap.SetAuth auth\nSet "+e+" = wrap\nEnd Function";try{window.execScript(n,"vbscript")}catch(k){return false}}return true},setup:function(m,n){if(m===".."){a();return true}try{var l=document.getElementById(m);var o=window[e](m,n);l.contentWindow.opener=o}catch(k){return false}return true},call:function(n,l,m){try{if(c[n]){c[n].SendMessage(gadgets.json_.stringify(m))}else{return false}}catch(k){return false}return true}}}();var gadgets=gadgets||{};gadgets.rpctx=gadgets.rpctx||{};gadgets.rpctx.wpm=function(){var a;return{getCode:function(){return"wpm"},isParentVerifiable:function(){return true},init:function(c,d){a=d;var b=function(e){c(gadgets.json_.parse(e.data))};if(!window.addEventListener){window.attachEvent("onmessage",b)}else{window.addEventListener("message",b,false)}a("..",true);return true},setup:function(b,c){if(b===".."){gadgets.rpc.call(b,gadgets.rpc.ACK)}return true},call:function(e,b,d){var f=e===".."?parent:window.frames[e];var c=gadgets.rpc.getRelayUrl(e);if(c){f.postMessage(gadgets.json_.stringify(d),"*")}else{gadgets.error("No relay set, cannot send cross-domain message")}return true}}}();var gadgets=gadgets||{};gadgets.rpc=function(){var c="__cb";var f="";var a="__ack";var t=500;var s=10;var q={};var o={};var y={};var b={};var e=0;var d={};var r={};var p={};var l={};var n={};var g={};var k=(window.top!==window.self);var h=gadgets.rpctx.Ifpc;if(gadgets.util){l=gadgets.util.getUrlParameters()}b[".."]=l.rpctoken||l.ifpctok||0;var x=(l.rpc_earlyq==="1");function j(){return typeof window.postMessage==="function"?gadgets.rpctx.wpm:window.ActiveXObject?(typeof window.postMessage==="object"?gadgets.rpctx.wpm:gadgets.rpctx.nix):gadgets.rpctx.Ifpc}function w(C,B){var E=v;if(!B){E=h}n[C]=E;var z=g[C]||[];for(var A=0;A<z.length;++A){var D=z[A];D.t=gadgets.rpc.getAuthToken(C);E.call(C,D.f,D)}g[C]=[]}function m(A){if(A&&typeof A.s==="string"&&typeof A.f==="string"&&A.a instanceof Array){if(typeof A.r==="string"){gadgets.rpc.setRelayUrl(A.f,A.r);if(window.ActiveXObject){v=gadgets.rpctx.nix}}if(typeof b[A.f]!=="undefined"){if(b[A.f]!=A.t){throw new Error("Invalid auth token. "+b[A.f]+" vs "+A.t)}}else{gadgets.rpc.setAuthToken(A.f,"0")}if(A.s===a){window.setTimeout(function(){w(A.f,true)},0);return}if(A.c){A.callback=function(B){B=[A.c,B];gadgets.rpc.call(A.f,c,null,B)};A.a.push(A.callback)}var z=(q[A.s]||q[f]).apply(A,A.a);if(A.c&&typeof z!=="undefined"){gadgets.rpc.call(A.f,c,null,[A.c,z])}}}function i(F){if(!F){return""}F=F.toLowerCase();if(F.indexOf("//")==0){F=window.location.protocol+":"+F}if(F.indexOf("http://")!=0&&F.indexOf("https://")!=0){F=window.location.protocol+"://"+F}var z=F.substring(F.indexOf("://")+3);var E=z.indexOf("/");if(E!=-1){z=z.substring(0,E)}var D=F.substring(0,F.indexOf("://"));var C="";var B=z.indexOf(":");if(B!=-1){var A=z.substring(B+1);z=z.substring(0,B);if((D==="http"&&A!=="80")||(D==="https"&&A!=="443")){C=":"+A}}return D+"://"+z+C}var v=j();q[f]=function(){gadgets.warn("Unknown RPC service: "+this.s)};q[c]=function(A,B){var z=d[A];if(z){delete d[A];z(B)}};function u(z,B){if(r[z]===true){return}if(typeof r[z]==="undefined"){r[z]=0}var A=document.getElementById(z);if(z===".."||A!=null){if(v.setup(z,B)===true){r[z]=true;return}}if(r[z]!==true&&r[z]++<s){window.setTimeout(function(){u(z,B)},t)}else{v=h;r[z]=true}}if(k){if(v.setup("..")===false){v=h}}return{register:function(A,z){if(A===c||A===a){throw new Error("Cannot overwrite callback/ack service")}if(A===f){throw new Error("Cannot overwrite default service: use registerDefault")}q[A]=z},unregister:function(z){if(z===c||z===a){throw new Error("Cannot delete callback/ack service")}if(z===f){throw new Error("Cannot delete default service: use unregisterDefault")}delete q[z]},registerDefault:function(z){q[f]=z},unregisterDefault:function(){delete q[f]},forceParentVerifiable:function(){if(!v.isParentVerifiable()){v=gadgets.rpctx.Ifpc}},forceIfpc:function(){v=gadgets.rpctx.Ifpc},call:function(E,D,z,F){E=E||"..";var B="..";if(E===".."){B=window.name}++e;if(z){d[e]=z}var C={s:D,f:B,c:z?e:0,a:F,t:b[E],l:y[E]};var A=x?n[E]:v;if(!A){if(!g[E]){g[E]=[C]}else{g[E].push(C)}return}if(y[E]){A=gadgets.rpctx.Ifpc}if(A.call(E,B,C)===false){h.call(E,B,C)}},getRelayUrl:function(z){var A=o[z];if(A&&A.indexOf("//")==0){A=document.location.protocol+A}if(!A){A="http://api.msappspace.com/OpenSocial/rpc_relay.aspx"}return A},setRelayUrl:function(A,B,z){o[A]=B;y[A]=!!z},setAuthToken:function(z,A){A=A||"";b[z]=String(A);u(z,A)},getAuthToken:function(z){return b[z]},getRelayChannel:function(){return v.getCode()},receive:function(z){if(z.length>4){m(gadgets.json_.parse(decodeURIComponent(z[z.length-1])))}},getOrigin:i,init:function(){if(v.init(m,w)===false){v=h}},ACK:a}}();gadgets.rpc.init();gadgets.IFPCSHIM={call:function(d,f,a,e,b,c,g){gadgets.rpc.call("..",f,b,a)},registerService:function(b,a){gadgets.rpc.register(b,a)},handleRequest:function(a){gadgets.rpc.receive(a)}};var _IFPC=gadgets.IFPCSHIM;gadgets.IFPC_=_IFPC;function ifpc_widget_resize(h,i){if(typeof ifpc_current_surface==="undefined"){ifpc_current_surface=null}if(i<=1&&i>0&&"canvas"===ifpc_current_surface){var d=document.body.scrollHeight;var e=document.documentElement.clientHeight;var f=document.documentElement.scrollHeight;d=((d>f)?d:f);i=Math.floor((((d>e)?d:e)-295)*i)}else{if(i<1){i=0}else{switch(ifpc_current_surface){case"canvas":max_widget_height=1000000;break;default:max_widget_height=1000;break}if(i>max_widget_height){i=max_widget_height}}}var g=document.getElementById(h);g.style.height=i;g.height=i}_IFPC.registerService("resizeWidget",ifpc_widget_resize);function ifpc_widget_requestLocale(){return[ifpc_locale.country,ifpc_locale.lang]}_IFPC.registerService("requestLocale",ifpc_widget_requestLocale);
