var gadgets=gadgets||{};gadgets.error={};gadgets.error.SUBCLASS_RESPONSIBILITY="subclass responsibility";gadgets.error.TO_BE_DONE="to be done";gadgets.log=function(A){if(window.console&&console.log){console.log(A)}else{var B=document.createElement("div");B.className="gadgets-log-entry";B.innerHTML=A;document.body.appendChild(B)}};gadgets.callAsyncAndJoin=function(E,A,D){var F=E.length;var C=[];for(var B=0;B<E.length;B++){var G=function(H){E[H].call(D,function(I){C[H]=I;if(--F==0){A(C)}})};G(B)}};gadgets.Extensible=function(){};gadgets.Extensible.prototype.setDependencies=function(A){for(var B in A){this[B]=A[B]}};gadgets.Extensible.prototype.getDependencies=function(A){return this[A]};gadgets.UserPrefStore=function(){};gadgets.UserPrefStore.prototype.getPrefs=function(A){throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY)};gadgets.UserPrefStore.prototype.savePrefs=function(A){throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY)};gadgets.DefaultUserPrefStore=function(){gadgets.UserPrefStore.call(this)};gadgets.DefaultUserPrefStore.inherits(gadgets.UserPrefStore);gadgets.DefaultUserPrefStore.prototype.getPrefs=function(A){};gadgets.DefaultUserPrefStore.prototype.savePrefs=function(A){};gadgets.GadgetService=function(){};gadgets.GadgetService.prototype.setHeight=function(B,A){throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY)};gadgets.GadgetService.prototype.setTitle=function(A,B){throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY)};gadgets.GadgetService.prototype.setUserPref=function(A){throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY)};gadgets.IfrGadgetService=function(){gadgets.GadgetService.call(this);gadgets.rpc.register("resize_iframe",this.setHeight);gadgets.rpc.register("set_pref",this.setUserPref);gadgets.rpc.register("set_title",this.setTitle);gadgets.rpc.register("requestNavigateTo",this.requestNavigateTo)};gadgets.IfrGadgetService.inherits(gadgets.GadgetService);gadgets.IfrGadgetService.prototype.setHeight=function(A){if(A>gadgets.container.maxheight_){A=gadgets.container.maxheight_}var B=document.getElementById(this.f);if(B){B.style.height=A+"px"}};gadgets.IfrGadgetService.prototype.setTitle=function(B){var A=document.getElementById(this.f+"_title");if(A){A.innerHTML=B.replace(/&/g,"&amp;").replace(/</g,"&lt;")}};gadgets.IfrGadgetService.prototype.setUserPref=function(H,C,E){var G=parseInt(this.f.match(/_([0-9]+)$/)[1],10);var F=gadgets.container.getGadget(G);var B=F.getUserPrefs();for(var D=1,A=arguments.length;D<A;D+=2){B[arguments[D]]=arguments[D+1]}F.setUserPrefs(B)};gadgets.IfrGadgetService.prototype.requestNavigateTo=function(A,E){var F=gadgets.container.gadgetService.getGadgetIdFromModuleId(this.f);var B=gadgets.container.gadgetService.getUrlForView(A);var D=gadgets.container.getGadget(F);B+="&websiteId="+D.getWebsiteId();B+="&id="+D.getAppId();if(E){var C=gadgets.json.stringify(E);if(C.length>0){B+="&appParams="+encodeURIComponent(C)}}if(B&&document.location.href.indexOf(B)==-1){document.location.href=B}};gadgets.IfrGadgetService.prototype.getUrlForView=function(A){var B=null;if(A==="canvas"){B="/application.do?"}else{if(A==="profile"){B="/user/website.do?"}}return B};gadgets.IfrGadgetService.prototype.getGadgetIdFromModuleId=function(A){return parseInt(A.match(/_([0-9]+)$/)[1],10)};gadgets.LayoutManager=function(){};gadgets.LayoutManager.prototype.getGadgetChrome=function(A){throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY)};gadgets.StaticLayoutManager=function(){gadgets.LayoutManager.call(this)};gadgets.StaticLayoutManager.inherits(gadgets.LayoutManager);gadgets.StaticLayoutManager.prototype.setGadgetChromeIds=function(A){this.gadgetChromeIds_=A};gadgets.StaticLayoutManager.prototype.getGadgetChrome=function(B){var A=this.gadgetChromeIds_[B.id];return A?document.getElementById(A):null};gadgets.FloatLeftLayoutManager=function(A){gadgets.LayoutManager.call(this);this.layoutRootId_=A};gadgets.FloatLeftLayoutManager.inherits(gadgets.LayoutManager);gadgets.FloatLeftLayoutManager.prototype.getGadgetChrome=function(C){var B=document.getElementById(this.layoutRootId_);if(B){var A=document.createElement("div");A.className="gadgets-gadget-chrome";A.style.cssFloat="left";B.appendChild(A);return A}else{return null}};gadgets.Gadget=function(B){this.userPrefs_={};if(B){for(var A in B){if(B.hasOwnProperty(A)){this[A]=B[A]}}}if(!this.secureToken){this.secureToken="john.doe:john.doe:appid:cont:url:0"}};gadgets.Gadget.prototype.getUserPrefs=function(){return this.userPrefs_};gadgets.Gadget.prototype.setUserPrefs=function(A){this.userPrefs_=A;gadgets.container.userPrefStore.savePrefs(this)};gadgets.Gadget.prototype.getUserPref=function(A){return this.userPrefs_[A]};gadgets.Gadget.prototype.setUserPref=function(A,B){this.userPrefs_[A]=B;gadgets.container.userPrefStore.savePrefs(this)};gadgets.Gadget.prototype.render=function(A){if(A){this.getContent(function(B){A.innerHTML=B})}};gadgets.Gadget.prototype.getContent=function(A){gadgets.callAsyncAndJoin([this.getTitleBarContent,this.getUserPrefsDialogContent,this.getMainContent,this.getFooterContent],function(B){A(B.join(""))},this)};gadgets.Gadget.prototype.getTitleBarContent=function(A){throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY)};gadgets.Gadget.prototype.getUserPrefsDialogContent=function(A){throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY)};gadgets.Gadget.prototype.getMainContent=function(A){throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY)};gadgets.Gadget.prototype.getAdditionalParams=function(){return""};gadgets.IfrGadget=function(A){gadgets.Gadget.call(this,A);this.serverBase_="../../";this.title_=null;this.height_=1000;this.toggle_=false;this.settings_=false;this.nocache_=true;this.appId_="";this.ownerId_="";this.viewerId_="";this.websiteId_=""};gadgets.IfrGadget.inherits(gadgets.Gadget);gadgets.IfrGadget.prototype.GADGET_IFRAME_PREFIX_="remote_iframe_";gadgets.IfrGadget.prototype.CONTAINER="minglebox";gadgets.IfrGadget.prototype.cssClassGadget="gadgets-gadget";gadgets.IfrGadget.prototype.cssClassTitleBar="gadgets-gadget-title-bar";gadgets.IfrGadget.prototype.cssClassTitle="gadgets-gadget-title";gadgets.IfrGadget.prototype.cssClassTitleButtonBar="gadgets-gadget-title-button-bar divRight txtSmall";gadgets.IfrGadget.prototype.cssClassGadgetUserPrefsDialog="gadgets-gadget-user-prefs-dialog";gadgets.IfrGadget.prototype.cssClassGadgetUserPrefsDialogActionBar="gadgets-gadget-user-prefs-dialog-action-bar";gadgets.IfrGadget.prototype.cssClassTitleButton="gadgets-gadget-title-button";gadgets.IfrGadget.prototype.cssClassGadgetContent="gadgets-gadget-content";gadgets.IfrGadget.prototype.rpcToken=(2147483647*Math.random())|0;gadgets.IfrGadget.prototype.rpcRelay="/javascript/container/rpc_relay.html";gadgets.IfrGadget.prototype.getTitleBarContent=function(A){A("")};gadgets.IfrGadget.prototype.getFooterContent=function(A){A("")};gadgets.IfrGadget.prototype.getUserPrefsDialogContent=function(A){A("")};gadgets.IfrGadget.prototype.setServerBase=function(A){this.serverBase_=A};gadgets.IfrGadget.prototype.getServerBase=function(){return this.serverBase_};gadgets.IfrGadget.prototype.setTitle=function(A){this.title_=A};gadgets.IfrGadget.prototype.getTitle=function(){return this.title_};gadgets.IfrGadget.prototype.setHeight=function(A){this.height_=A};gadgets.IfrGadget.prototype.getHeight=function(){return this.height_};gadgets.IfrGadget.prototype.setToggle=function(A){this.toggle_=A};gadgets.IfrGadget.prototype.getToggle=function(){return this.toggle_};gadgets.IfrGadget.prototype.setSettings=function(A){this.settings_=A};gadgets.IfrGadget.prototype.getSettings=function(){return this.settings_};gadgets.IfrGadget.prototype.setAppId=function(A){this.appId_=A};gadgets.IfrGadget.prototype.getAppId=function(){return this.appId_};gadgets.IfrGadget.prototype.setOwnerId=function(A){this.ownerId_=A};gadgets.IfrGadget.prototype.getOwnerId=function(){return this.ownerId_};gadgets.IfrGadget.prototype.setViewerId=function(A){this.viewerId_=A};gadgets.IfrGadget.prototype.getViewerId=function(){return this.viewerId_};gadgets.IfrGadget.prototype.setWebsiteId=function(A){this.websiteId_=A};gadgets.IfrGadget.prototype.getWebsiteId=function(){return this.websiteId_};gadgets.IfrGadget.prototype.getMainContent=function(A){var B=this.getIframeId();gadgets.rpc.setRelayUrl(B,this.serverBase_+this.rpcRelay);gadgets.rpc.setAuthToken(B,this.rpcToken);A('<div class="'+this.cssClassGadgetContent+'"><iframe id="'+B+'" name="'+B+'" class="'+this.cssClassGadget+'" src="'+this.getIframeUrl()+'" frameborder="no" scrolling="no"'+(this.height_?' height="'+this.getHeight()+'"':"")+(this.width_?' width="'+this.getWidth()+'"':"")+'></iframe></div><div class="myStyle"><!-- --></div>')};gadgets.IfrGadget.prototype.getIframeId=function(){return this.GADGET_IFRAME_PREFIX_+this.id};gadgets.IfrGadget.prototype.getUserPrefsDialogId=function(){return this.getIframeId()+"_userPrefsDialog"};gadgets.IfrGadget.prototype.getIframeUrl=function(){return this.serverBase_+"/gadgets/ifr?container="+this.CONTAINER+"&mid="+this.id+"&nocache="+gadgets.container.nocache_+"&country="+gadgets.container.country_+"&lang="+gadgets.container.language_+"&appId="+this.appId_+"&ownerId="+this.ownerId_+"&viewerId="+this.viewerId_+"&websiteId="+this.websiteId_+"&view="+gadgets.container.view_+(this.specVersion?"&v="+this.specVersion:"")+(gadgets.container.parentUrl_?"&parent="+encodeURIComponent(gadgets.container.parentUrl_):"")+(this.debug?"&debug=1":"")+this.getAdditionalParams()+this.getUserPrefsParams()+"&url="+encodeURIComponent(this.specUrl)+(this.secureToken?"&st="+this.secureToken:"")+"#rpctoken="+this.rpcToken+(this.viewParams?"&view-params="+encodeURIComponent(gadgets.json.stringify(this.viewParams)):"")+(this.hashData?"&"+this.hashData:"")};gadgets.IfrGadget.prototype.getUserPrefsParams=function(){var C="";if(this.getUserPrefs()){for(var A in this.getUserPrefs()){var B=this.getUserPref(A);C+="&up_"+encodeURIComponent(A)+"="+encodeURIComponent(B)}}return C};gadgets.IfrGadget.prototype.handleToggle=function(){var B=document.getElementById(this.getIframeId());if(B){var A=B.parentNode;var C=A.style.display;A.style.display=C?"":"none"}};gadgets.IfrGadget.prototype.handleOpenUserPrefsDialog=function(){if(this.userPrefsDialogContentLoaded){this.showUserPrefsDialog()}else{var C=this;var B="ig_callback_"+this.id;window[B]=function(D){C.userPrefsDialogContentLoaded=true;C.buildUserPrefsDialog(D);C.showUserPrefsDialog()};var A=document.createElement("script");A.src="http://gmodules.com/ig/gadgetsettings?mid="+this.id+"&output=js"+this.getUserPrefsParams()+"&url="+this.specUrl;document.body.appendChild(A)}};gadgets.IfrGadget.prototype.buildUserPrefsDialog=function(A){var B=document.getElementById(this.getUserPrefsDialogId());B.innerHTML=A+'<div class="'+this.cssClassGadgetUserPrefsDialogActionBar+'"><input type="button" value="Save" onclick="gadgets.container.getGadget('+this.id+').handleSaveUserPrefs()"> <input type="button" value="Cancel" onclick="gadgets.container.getGadget('+this.id+').handleCancelUserPrefs()"></div>';B.childNodes[0].style.display=""};gadgets.IfrGadget.prototype.showUserPrefsDialog=function(A){var B=document.getElementById(this.getUserPrefsDialogId());B.style.display=(A||A==undefined)?"":"none"};gadgets.IfrGadget.prototype.hideUserPrefsDialog=function(){this.showUserPrefsDialog(false)};gadgets.IfrGadget.prototype.handleSaveUserPrefs=function(){this.hideUserPrefsDialog();var D={};var A=document.getElementById("m_"+this.id+"_numfields").value;for(var E=0;E<A;E++){var B=document.getElementById("m_"+this.id+"_"+E);if(B.type!="hidden"){var G="m_"+this.id+"_up_";var C=B.name.substring(G.length);var F=B.value;D[C]=F}}this.setUserPrefs(D);this.refresh()};gadgets.IfrGadget.prototype.handleCancelUserPrefs=function(){this.hideUserPrefsDialog()};gadgets.IfrGadget.prototype.refresh=function(){var A=this.getIframeId();document.getElementById(A).src=this.getIframeUrl()};gadgets.Container=function(){this.gadgets_={};this.parentUrl_="http://"+document.location.host;this.country_="ALL";this.language_="ALL";this.view_="default";this.nocache_=0;this.maxheight_=2147483647};gadgets.Container.inherits(gadgets.Extensible);gadgets.Container.prototype.gadgetClass=gadgets.Gadget;gadgets.Container.prototype.userPrefStore=new gadgets.DefaultUserPrefStore();gadgets.Container.prototype.gadgetService=new gadgets.GadgetService();gadgets.Container.prototype.layoutManager=new gadgets.StaticLayoutManager();gadgets.Container.prototype.setParentUrl=function(A){this.parentUrl_=A};gadgets.Container.prototype.setCountry=function(A){this.country_=A};gadgets.Container.prototype.setNoCache=function(A){this.nocache_=A};gadgets.Container.prototype.setLanguage=function(A){this.language_=A};gadgets.Container.prototype.setView=function(A){this.view_=A};gadgets.Container.prototype.setMaxHeight=function(A){this.maxheight_=A};gadgets.Container.prototype.getGadgetKey_=function(A){return"gadget_"+A};gadgets.Container.prototype.getGadget=function(A){return this.gadgets_[this.getGadgetKey_(A)]};gadgets.Container.prototype.createGadget=function(A){return new this.gadgetClass(A)};gadgets.Container.prototype.addGadget=function(A){A.id=this.getNextGadgetInstanceId();A.setUserPrefs(this.userPrefStore.getPrefs(A));this.gadgets_[this.getGadgetKey_(A.id)]=A};gadgets.Container.prototype.addGadgets=function(A){for(var B=0;B<A.length;B++){this.addGadget(A[B])}};gadgets.Container.prototype.renderGadgets=function(){for(var A in this.gadgets_){this.renderGadget(this.gadgets_[A])}};gadgets.Container.prototype.renderGadget=function(A){throw Error(gadgets.error.SUBCLASS_RESPONSIBILITY)};gadgets.Container.prototype.nextGadgetInstanceId_=0;gadgets.Container.prototype.getNextGadgetInstanceId=function(){return this.nextGadgetInstanceId_++};gadgets.Container.prototype.refreshGadgets=function(){for(var A in this.gadgets_){this.gadgets_[A].refresh()}};gadgets.IfrContainer=function(){gadgets.Container.call(this)};gadgets.IfrContainer.inherits(gadgets.Container);gadgets.IfrContainer.prototype.gadgetClass=gadgets.IfrGadget;gadgets.IfrContainer.prototype.gadgetService=new gadgets.IfrGadgetService();gadgets.IfrContainer.prototype.setParentUrl=function(A){if(!A.match(/^http[s]?:\/\//)){A=document.location.href.match(/^[^?#]+\//)[0]+A}this.parentUrl_=A};gadgets.IfrContainer.prototype.renderGadget=function(B){var A=this.layoutManager.getGadgetChrome(B);B.render(A)};gadgets.container=new gadgets.IfrContainer();