var h,k=this,l=function(a,b){var c=a.split("."),d=k;c[0]in d||!d.execScript||d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)c.length||void 0===b?d=d[e]?d[e]:d[e]={}:d[e]=b},aa=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&
!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"==b&&"undefined"==typeof a.call)return"object";return b},m=function(a){var b=aa(a);return"array"==b||"object"==b&&"number"==typeof a.length},n=function(a){return"string"==typeof a};Math.random();
var p=function(a,b){function c(){}c.prototype=b.prototype;a.v=b.prototype;a.prototype=new c};var ba=function(a,b){for(var c=a.split("%s"),d="",e=Array.prototype.slice.call(arguments,1);e.length&&1<c.length;)d+=c.shift()+e.shift();return d+c.join("%s")};Math.random();var q,r,s,t,u,w=function(){return k.navigator?k.navigator.userAgent:null};u=t=s=r=q=!1;var y;if(y=w()){var ca=k.navigator;q=0==y.lastIndexOf("Opera",0);r=!q&&(-1!=y.indexOf("MSIE")||-1!=y.indexOf("Trident"));t=(s=!q&&-1!=y.indexOf("WebKit"))&&-1!=y.indexOf("Mobile");u=!q&&!s&&!r&&"Gecko"==ca.product}var da=r,ea=u,z=s,fa=t;var A;if(q&&k.opera){var B=k.opera.version;"function"==typeof B&&B()}else ea?A=/rv\:([^\);]+)(\)|;)/:da?A=/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/:z&&(A=/WebKit\/(\S+)/),A&&A.exec(w());var C;C=!1;var D=w();D&&(-1!=D.indexOf("Firefox")||-1!=D.indexOf("Camino")||-1!=D.indexOf("iPhone")||-1!=D.indexOf("iPod")||-1!=D.indexOf("iPad")||-1!=D.indexOf("Chrome")||-1!=D.indexOf("Android")||-1!=D.indexOf("Safari")&&(C=!0));var ga=C;var E=function(a){var b=window;if(fa&&ga&&a){a.focus();var c=0,d=null,d=a.setInterval(function(){b.closed||5==c?a.clearInterval(d):(b.close(),c++)},150)}else b.close()};var F=function(a){Error.captureStackTrace?Error.captureStackTrace(this,F):this.stack=Error().stack||"";a&&(this.message=String(a))};p(F,Error);var H=function(a,b){b.unshift(a);F.call(this,ba.apply(null,b));b.shift()};p(H,F);var ia=function(a,b,c){if(!a){var d=Array.prototype.slice.call(arguments,2),e="Assertion failed";if(b)var e=e+(": "+b),f=d;throw new H(""+e,f||[]);}};var I=Array.prototype,ja=I.forEach?function(a,b,c){ia(null!=a.length);I.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=n(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)},J=function(a){return I.concat.apply(I,arguments)},ka=function(a){var b=a.length;if(0<b){for(var c=Array(b),d=0;d<b;d++)c[d]=a[d];return c}return[]};var K="StopIteration"in k?k.StopIteration:Error("StopIteration"),L=function(){};L.prototype.next=function(){throw K;};L.prototype.t=function(){return this};var M=function(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b},N=function(a){var b=[],c=0,d;for(d in a)b[c++]=d;return b};var O=function(a,b){this.h={};this.c=[];this.n=this.b=0;var c=arguments.length;if(1<c){if(c%2)throw Error("Uneven number of arguments");for(var d=0;d<c;d+=2)this.set(arguments[d],arguments[d+1])}else if(a){a instanceof O?(c=a.i(),d=a.g()):(c=N(a),d=M(a));for(var e=0;e<c.length;e++)this.set(c[e],d[e])}};O.prototype.g=function(){Q(this);for(var a=[],b=0;b<this.c.length;b++)a.push(this.h[this.c[b]]);return a};O.prototype.i=function(){Q(this);return this.c.concat()};
O.prototype.k=function(a){return R(this.h,a)};O.prototype.remove=function(a){return R(this.h,a)?(delete this.h[a],this.b--,this.n++,this.c.length>2*this.b&&Q(this),!0):!1};var Q=function(a){if(a.b!=a.c.length){for(var b=0,c=0;b<a.c.length;){var d=a.c[b];R(a.h,d)&&(a.c[c++]=d);b++}a.c.length=c}if(a.b!=a.c.length){for(var e={},c=b=0;b<a.c.length;)d=a.c[b],R(e,d)||(a.c[c++]=d,e[d]=1),b++;a.c.length=c}};O.prototype.get=function(a,b){return R(this.h,a)?this.h[a]:b};
O.prototype.set=function(a,b){R(this.h,a)||(this.b++,this.c.push(a),this.n++);this.h[a]=b};O.prototype.m=function(){return new O(this)};O.prototype.t=function(a){Q(this);var b=0,c=this.c,d=this.h,e=this.n,f=this,g=new L;g.next=function(){for(;;){if(e!=f.n)throw Error("The map has changed since the iterator was created");if(b>=c.length)throw K;var g=c[b++];return a?g:d[g]}};return g};var R=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};var la=function(a){if("function"==typeof a.g)return a.g();if(n(a))return a.split("");if(m(a)){for(var b=[],c=a.length,d=0;d<c;d++)b.push(a[d]);return b}return M(a)},ma=function(a,b,c){if("function"==typeof a.forEach)a.forEach(b,c);else if(m(a)||n(a))ja(a,b,c);else{var d;if("function"==typeof a.i)d=a.i();else if("function"!=typeof a.g)if(m(a)||n(a)){d=[];for(var e=a.length,f=0;f<e;f++)d.push(f)}else d=N(a);else d=void 0;for(var e=la(a),f=e.length,g=0;g<f;g++)b.call(c,e[g],d&&d[g],a)}};var na=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#(.*))?$"),T=function(a){if(S){S=!1;var b=k.location;if(b){var c=b.href;if(c&&(c=(c=T(c)[3]||null)&&decodeURIComponent(c))&&c!=b.hostname)throw S=!0,Error();}}return a.match(na)},S=z;var U=function(a,b){var c;if(a instanceof U)this.d=void 0!==b?b:a.d,V(this,a.j),c=a.r,W(this),this.r=c,c=a.l,W(this),this.l=c,oa(this,a.q),c=a.p,W(this),this.p=c,pa(this,a.f.m()),c=a.o,W(this),this.o=c;else if(a&&(c=T(String(a)))){this.d=!!b;V(this,c[1]||"",!0);var d=c[2]||"";W(this);this.r=d?decodeURIComponent(d):"";d=c[3]||"";W(this);this.l=d?decodeURIComponent(d):"";oa(this,c[4]);d=c[5]||"";W(this);this.p=d?decodeURIComponent(d):"";pa(this,c[6]||"",!0);c=c[7]||"";W(this);this.o=c?decodeURIComponent(c):
""}else this.d=!!b,this.f=new X(null,0,this.d)};h=U.prototype;h.j="";h.r="";h.l="";h.q=null;h.p="";h.o="";h.u=!1;h.d=!1;h.toString=function(){var a=[],b=this.j;b&&a.push(Y(b,qa),":");if(b=this.l){a.push("//");var c=this.r;c&&a.push(Y(c,qa),"@");a.push(encodeURIComponent(String(b)));b=this.q;null!=b&&a.push(":",String(b))}if(b=this.p)this.l&&"/"!=b.charAt(0)&&a.push("/"),a.push(Y(b,"/"==b.charAt(0)?ra:sa));(b=this.f.toString())&&a.push("?",b);(b=this.o)&&a.push("#",Y(b,ta));return a.join("")};
h.m=function(){return new U(this)};var V=function(a,b,c){W(a);a.j=c?b?decodeURIComponent(b):"":b;a.j&&(a.j=a.j.replace(/:$/,""))},oa=function(a,b){W(a);if(b){b=Number(b);if(isNaN(b)||0>b)throw Error("Bad port number "+b);a.q=b}else a.q=null},pa=function(a,b,c){W(a);b instanceof X?(a.f=b,a.f.s(a.d)):(c||(b=Y(b,ua)),a.f=new X(b,0,a.d))},W=function(a){if(a.u)throw Error("Tried to modify a read-only Uri");};U.prototype.s=function(a){this.d=a;this.f&&this.f.s(a);return this};
var Y=function(a,b){return n(a)?encodeURI(a).replace(b,va):null},va=function(a){a=a.charCodeAt(0);return"%"+(a>>4&15).toString(16)+(a&15).toString(16)},qa=/[#\/\?@]/g,sa=/[\#\?:]/g,ra=/[\#\?]/g,ua=/[\#\?@]/g,ta=/#/g,X=function(a,b,c){this.e=a||null;this.d=!!c},$=function(a){if(!a.a&&(a.a=new O,a.b=0,a.e))for(var b=a.e.split("&"),c=0;c<b.length;c++){var d=b[c].indexOf("="),e=null,f=null;0<=d?(e=b[c].substring(0,d),f=b[c].substring(d+1)):e=b[c];e=decodeURIComponent(e.replace(/\+/g," "));e=Z(a,e);a.add(e,
f?decodeURIComponent(f.replace(/\+/g," ")):"")}};h=X.prototype;h.a=null;h.b=null;h.add=function(a,b){$(this);this.e=null;a=Z(this,a);var c=this.a.get(a);c||this.a.set(a,c=[]);c.push(b);this.b++;return this};h.remove=function(a){$(this);a=Z(this,a);return this.a.k(a)?(this.e=null,this.b-=this.a.get(a).length,this.a.remove(a)):!1};h.k=function(a){$(this);a=Z(this,a);return this.a.k(a)};
h.i=function(){$(this);for(var a=this.a.g(),b=this.a.i(),c=[],d=0;d<b.length;d++)for(var e=a[d],f=0;f<e.length;f++)c.push(b[d]);return c};h.g=function(a){$(this);var b=[];if(n(a))this.k(a)&&(b=J(b,this.a.get(Z(this,a))));else{a=this.a.g();for(var c=0;c<a.length;c++)b=J(b,a[c])}return b};h.set=function(a,b){$(this);this.e=null;a=Z(this,a);this.k(a)&&(this.b-=this.a.get(a).length);this.a.set(a,[b]);this.b++;return this};h.get=function(a,b){var c=a?this.g(a):[];return 0<c.length?String(c[0]):b};
h.toString=function(){if(this.e)return this.e;if(!this.a)return"";for(var a=[],b=this.a.i(),c=0;c<b.length;c++)for(var d=b[c],e=encodeURIComponent(String(d)),d=this.g(d),f=0;f<d.length;f++){var g=e;""!==d[f]&&(g+="="+encodeURIComponent(String(d[f])));a.push(g)}return this.e=a.join("&")};h.m=function(){var a=new X;a.e=this.e;this.a&&(a.a=this.a.m(),a.b=this.b);return a};var Z=function(a,b){var c=String(b);a.d&&(c=c.toLowerCase());return c};
X.prototype.s=function(a){a&&!this.d&&($(this),this.e=null,ma(this.a,function(a,c){var d=c.toLowerCase();c!=d&&(this.remove(c),this.remove(d),0<a.length&&(this.e=null,this.a.set(Z(this,d),ka(a)),this.b+=a.length))},this));this.d=a};var wa=function(a){a=new U(a);var b="&"+window.name;W(a);a.f.set(b,!0);b=a.f.g("parent");W(a);a.f.remove("parent");1==b.length&&(b=gadgets.rpc.getOrigin(String(b[0])),W(a),a.f.set("parent",b));b="&"+window.name;W(a);a.f.remove(b);return a.toString()},xa=function(a,b,c,d,e,f,g){if(!d||!d.document.domain)return!1;var v=wa(String(d.document.location.href));if(v.substr(0,c.length)!=c)return!1;c=gadgets.util.getUrlParameters(v);if(!b||!c.parent||b!=gadgets.rpc.getOrigin(String(c.parent)))return!1;if(!e)return l("oauth2callbackUrl",
a),d.oauth2verify.call(d,String(window.name),g)?!0:!1;d.oauth2callback.call(d,a);try{f()}catch(x){}return!0},ya=function(){try{return window.parent!=window}catch(a){}return!0},za=function(){try{return!!window.opener}catch(a){}return!0},Aa=function(a,b,c,d,e){try{var f=ya(),g=!f&&za(),v=!0,x=null,P=function(){v&&E(x)};if(!f&&!g)return;var v=(g||!f)&&"keep_open"!==e,x=g?window.opener:window.parent,ha=wa(b+"?parent="+encodeURIComponent(c))+"#";try{var G;if(d&&(G=x.frames[d],xa(a,c,ha,G,!g,P,e)))return;
for(b=0;b<x.frames.length;++b)if(G=x.frames[b],xa(a,c,ha,G,!g,P,e)){v=!1;break}}catch(Ba){}}catch(Ca){}P()};
l("postmessage.onLoad",function(){window.name="pmh"+String(2147483647*shindig.random()|0);var a=document.createElement("div"),b="true"==document.getElementById("error").value,c=gadgets.rpc.getOrigin(document.getElementById("origin").value),b=c+(b?"?":"#")+document.getElementById("response-form-encoded").value,d=document.getElementById("relay-endpoint").value,e=null,f=document.getElementById("proxy");f&&f.value&&(e=f.value);var f=document.getElementById("after-redirect"),g=null;f&&f.value&&(g=f.value);
a.appendChild(document.createTextNode(b));a.setAttribute("id","postmessage-hello");Aa(b,d,c,e,g)});l("postmessage.closePopup",function(){var a=null;try{var b=ya(),c=!b&&za();if(!b&&!c)return;a=c?window.opener:window.parent}catch(d){}E(a)});
