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(C,B){if(C<gadgets.log.logLevelThreshold_||!window.console){return}var A=window.console.log;if(C==gadgets.log.WARNING&&window.console.warn){A=window.console.warn}else{if(C==gadgets.log.ERROR&&window.console.error){A=window.console.error}}A(B)};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 E=[];var D=0;var C;function B(H){var F=[];for(var I=0,G=H.length;I<G;++I){F.push(encodeURIComponent(gadgets.json_.stringify(H[I])))}return F.join("&")}function A(I){var G;for(var F=E.length-1;F>=0;--F){var J=E[F];try{if(J&&(J.recyclable||J.readyState==="complete")){J.parentNode.removeChild(J);if(window.ActiveXObject){E[F]=J=null;E.splice(F,1)}else{J.recyclable=false;G=J;break}}}catch(H){}}if(!G){G=document.createElement("iframe");G.style.border=G.style.width=G.style.height="0px";G.style.visibility="hidden";G.style.position="absolute";G.onload=function(){this.recyclable=true};E.push(G)}G.src=I;setTimeout(function(){document.body.appendChild(G)},0)}return{getCode:function(){return"ifpc"},isParentVerifiable:function(){return true},init:function(F,G){C=G;C("..",true);return true},setup:function(G,F){C(G,true);return true},call:function(F,K,I){var J=gadgets.rpc.getRelayUrl(F);++D;if(!J){gadgets.warn("No relay file assigned for IFPC");return}var H=null;if(I.l){var G=I.a;H=[J,"#",B([K,D,1,0,B([K,I.s,"","",K].concat(G))])].join("")}else{H=[J,"#",F,"&",K,"@",D,"&1&0&",encodeURIComponent(gadgets.json_.stringify(I))].join("")}A(H);return true}}}();var gadgets=gadgets||{};gadgets.rpctx=gadgets.rpctx||{};gadgets.rpctx.nix=function(){var C="GRPC____NIXVBS_wrapper";var D="GRPC____NIXVBS_get_wrapper";var F="GRPC____NIXVBS_handle_message";var B="GRPC____NIXVBS_create_channel";var A=10;var J=500;var I={};var H;var G=0;function E(){var L=I[".."];if(L){return}if(++G>A){gadgets.warn("Nix transport setup failed, falling back...");H("..",false);return}if(!L&&window.opener&&"GetAuthToken" in window.opener){L=window.opener;if(L.GetAuthToken()==gadgets.rpc.getAuthToken("..")){var K=gadgets.rpc.getAuthToken("..");L.CreateChannel(window[D]("..",K),K);I[".."]=L;window.opener=null;H("..",true);return}}window.setTimeout(function(){E()},J)}return{getCode:function(){return"nix"},isParentVerifiable:function(){return false},init:function(L,M){H=M;if(typeof window[D]!=="unknown"){window[F]=function(O){window.setTimeout(function(){L(gadgets.json_.parse(O))},0)};window[B]=function(O,Q,P){if(gadgets.rpc.getAuthToken(O)===P){I[O]=Q;H(O,true)}};var K="Class "+C+"\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 "+B+"(m_Intended, channel, auth)\nEnd Sub\nEnd Class\nFunction "+D+"(name, auth)\nDim wrap\nSet wrap = New "+C+"\nwrap.SetIntendedName name\nwrap.SetAuth auth\nSet "+D+" = wrap\nEnd Function";try{window.execScript(K,"vbscript")}catch(N){return false}}return true},setup:function(O,K){if(O===".."){E();return true}try{var M=document.getElementById(O);var N=window[D](O,K);M.contentWindow.opener=N}catch(L){return false}return true},call:function(K,N,M){try{if(I[K]){I[K].SendMessage(gadgets.json_.stringify(M))}else{return false}}catch(L){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(B,D){A=D;var C=function(E){B(gadgets.json_.parse(E.data))};if(!window.addEventListener){window.attachEvent("onmessage",C)}else{window.addEventListener("message",C,false)}A("..",true);return true},setup:function(C,B){if(C===".."){gadgets.rpc.call(C,gadgets.rpc.ACK)}return true},call:function(B,F,D){var C=B===".."?parent:window.frames[B];var E=gadgets.rpc.getRelayUrl(B);if(E){C.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 M="__cb";var L="";var E="__ack";var K=500;var F=10;var B={};var C={};var Q={};var G={};var I=0;var Y={};var P={};var D={};var W={};var H={};var O={};var R=(window.top!==window.self);var X=gadgets.rpctx.Ifpc;if(gadgets.util){W=gadgets.util.getUrlParameters()}G[".."]=W.rpctoken||W.ifpctok||0;var S=(W.rpc_earlyq==="1");function A(){return typeof window.postMessage==="function"?gadgets.rpctx.wpm:window.ActiveXObject?(typeof window.postMessage==="object"?gadgets.rpctx.wpm:gadgets.rpctx.nix):gadgets.rpctx.Ifpc}function T(e,c){var a=U;if(!c){a=X}H[e]=a;var Z=O[e]||[];for(var b=0;b<Z.length;++b){var d=Z[b];d.t=gadgets.rpc.getAuthToken(e);a.call(e,d.f,d)}O[e]=[]}function N(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){U=gadgets.rpctx.nix}}if(typeof G[a.f]!=="undefined"){if(G[a.f]!=a.t){throw new Error("Invalid auth token. "+G[a.f]+" vs "+a.t)}}else{gadgets.rpc.setAuthToken(a.f,"0")}if(a.s===E){window.setTimeout(function(){T(a.f,true)},0);return}if(a.c){a.callback=function(b){b=[a.c,b];gadgets.rpc.call(a.f,M,null,b)};a.a.push(a.callback)}var Z=(B[a.s]||B[L]).apply(a,a.a);if(a.c&&typeof Z!=="undefined"){gadgets.rpc.call(a.f,M,null,[a.c,Z])}}}function V(b){if(!b){return""}b=b.toLowerCase();if(b.indexOf("//")==0){b=window.location.protocol+":"+b}if(b.indexOf("http://")!=0&&b.indexOf("https://")!=0){b=window.location.protocol+"://"+b}var c=b.substring(b.indexOf("://")+3);var Z=c.indexOf("/");if(Z!=-1){c=c.substring(0,Z)}var e=b.substring(0,b.indexOf("://"));var d="";var f=c.indexOf(":");if(f!=-1){var a=c.substring(f+1);c=c.substring(0,f);if((e==="http"&&a!=="80")||(e==="https"&&a!=="443")){d=":"+a}}return e+"://"+c+d}var U=A();B[L]=function(){gadgets.warn("Unknown RPC service: "+this.s)};B[M]=function(a,Z){var b=Y[a];if(b){delete Y[a];b(Z)}};function J(b,Z){if(P[b]===true){return}if(typeof P[b]==="undefined"){P[b]=0}var a=document.getElementById(b);if(b===".."||a!=null){if(U.setup(b,Z)===true){P[b]=true;return}}if(P[b]!==true&&P[b]++<F){window.setTimeout(function(){J(b,Z)},K)}else{U=X;P[b]=true}}if(R){if(U.setup("..")===false){U=X}}return{register:function(a,Z){if(a===M||a===E){throw new Error("Cannot overwrite callback/ack service")}if(a===L){throw new Error("Cannot overwrite default service: use registerDefault")}B[a]=Z},unregister:function(Z){if(Z===M||Z===E){throw new Error("Cannot delete callback/ack service")}if(Z===L){throw new Error("Cannot delete default service: use unregisterDefault")}delete B[Z]},registerDefault:function(Z){B[L]=Z},unregisterDefault:function(){delete B[L]},forceParentVerifiable:function(){if(!U.isParentVerifiable()){U=gadgets.rpctx.Ifpc}},forceIfpc:function(){U=gadgets.rpctx.Ifpc},call:function(Z,a,f,d){Z=Z||"..";var e="..";if(Z===".."){e=window.name}++I;if(f){Y[I]=f}var c={s:a,f:e,c:f?I:0,a:d,t:G[Z],l:Q[Z]};var b=S?H[Z]:U;if(!b){if(!O[Z]){O[Z]=[c]}else{O[Z].push(c)}return}if(Q[Z]){b=gadgets.rpctx.Ifpc}if(b.call(Z,e,c)===false){X.call(Z,e,c)}},getRelayUrl:function(a){var Z=C[a];if(Z&&Z.indexOf("//")==0){Z=document.location.protocol+Z}if(!Z){Z="http://api.msappspace.com/OpenSocial/rpc_relay.aspx"}return Z},setRelayUrl:function(a,Z,b){C[a]=Z;Q[a]=!!b},setAuthToken:function(Z,a){a=a||"";G[Z]=String(a);J(Z,a)},getAuthToken:function(Z){return G[Z]},getRelayChannel:function(){return U.getCode()},receive:function(Z){if(Z.length>4){N(gadgets.json_.parse(decodeURIComponent(Z[Z.length-1])))}},getOrigin:V,init:function(){if(U.init(N,T)===false){U=X}},ACK:E}}();gadgets.rpc.init();gadgets.IFPCSHIM={call:function(B,C,F,D,G,A,E){gadgets.rpc.call("..",C,G,F)},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(F,D){if(typeof ifpc_current_surface==="undefined"){ifpc_current_surface=null}if(D<=1&&D>0&&"canvas"===ifpc_current_surface){var C=document.body.scrollHeight;var B=document.documentElement.clientHeight;var E=document.documentElement.scrollHeight;C=((C>E)?C:E);D=Math.floor((((C>B)?C:B)-295)*D)}else{if(D<1){D=0}else{switch(ifpc_current_surface){case"canvas":max_widget_height=1000000;break;default:max_widget_height=1000;break}if(D>max_widget_height){D=max_widget_height}}}var A=document.getElementById(F);A.style.height=D;A.height=D}_IFPC.registerService("resizeWidget",ifpc_widget_resize);function ifpc_widget_requestLocale(){return[ifpc_locale.country,ifpc_locale.lang]}_IFPC.registerService("requestLocale",ifpc_widget_requestLocale);
