Ext.ux.ManagedIFrame=function(){var C=Array.prototype.slice.call(arguments,0),D=Ext.get(C[0]),B=C[0];if(D&&D.dom&&D.dom.tagName=="IFRAME"){B=C[1]||{};}else{B=C[0]||C[1]||{};D=B.autoCreate?Ext.get(Ext.DomHelper.append(B.autoCreate.parent||document.body,Ext.apply({tag:"iframe",src:(Ext.isIE&&Ext.isSecure)?Ext.SSL_SECURE_URL:""},B.autoCreate))):null;}if(!D||D.dom.tagName!="IFRAME"){return D;}!!D.dom.name.length||(D.dom.name=D.dom.id);this.addEvents({"domready":true,"documentloaded":true,"exception":true,"message":true});if(B.listeners){this.listeners=B.listeners;Ext.ux.ManagedIFrame.superclass.constructor.call(this);}Ext.apply(D,this);D.addClass("x-managed-iframe");if(B.style){D.applyStyles(B.style);}D._maskEl=D.parent(".x-managed-iframe-mask")||D.parent().addClass("x-managed-iframe-mask");Ext.apply(D,{disableMessaging:B.disableMessaging===true,loadMask:Ext.apply({msg:"Loading..",msgCls:"x-mask-loading",maskEl:D._maskEl,hideOnReady:true,disabled:!B.loadMask},B.loadMask),_eventName:Ext.isIE?"onreadystatechange":"onload",_windowContext:null,eventsFollowFrameLinks:typeof B.eventsFollowFrameLinks=="undefined"?true:B.eventsFollowFrameLinks});D.dom[D._eventName]=D.loadHandler.createDelegate(D);if(document.addEventListener){Ext.EventManager.on(window,"DOMFrameContentLoaded",D.dom[D._eventName]);}var A=D.updateManager=new Ext.UpdateManager(D,true);A.showLoadIndicator=B.showLoadIndicator||false;if(B.src){D.setSrc(B.src);}else{var E=B.html||B.content||false;if(E){D.update.defer(10,D,[E]);}}return Ext.ux.ManagedIFrame.Manager.register(D);};Ext.extend(Ext.ux.ManagedIFrame,Ext.util.Observable,{src:null,setSrc:function(A,C,E){var B=Ext.isIE&&Ext.isSecure?Ext.SSL_SECURE_URL:"";var D=A||this.src||B;if(Ext.isOpera){this.dom.src=B;}this._windowContext=null;this._hooked=this._domReady=this._domFired=false;this._callBack=E||false;this.showMask();(function(){var G=typeof D=="function"?D()||"":D;try{this._frameAction=true;this.dom.src=G;this.frameInit=true;this.checkDOM();}catch(F){this.fireEvent("exception",this,F);}}).defer(10,this);if(C!==true){this.src=D;}return this;},reset:function(A,B){this.setSrc(A||(Ext.isIE&&Ext.isSecure?Ext.SSL_SECURE_URL:""),true,B);},scriptRE:/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/gi,update:function(B,A,D){A=A||this.getUpdateManager().loadScripts||false;B=Ext.DomHelper.markup(B||"");B=A===true?B:B.replace(this.scriptRE,"");var C;if(C=this.getDocument()){this._frameAction=!!B.length;this._windowContext=this.src=null;this._callBack=D||false;this._hooked=this._domReady=this._domFired=false;this.showMask();C.open();C.write(B);C.close();this.frameInit=true;if(this._frameAction){this.checkDOM();}else{this.hideMask(true);if(this._callBack){this._callBack();}}}else{this.hideMask(true);if(this._callBack){this._callBack();}}return this;},disableMessaging:true,_XFrameMessaging:function(){var A={"$":[]};var B=function(D,C){return D===null||D===undefined||(!C?D==="":false);};window.sendMessage=function(K,L,J){var F;if(F=arguments.callee.manager){if(K._fromHost){var I,M;var C=K.tag||L||null;var D=!B(C)?A[C.toLowerCase()]||[]:A["$"];for(var G=0,E=D.length;G<E;G++){if(I=D[G]){M=I.apply(I.__scope,arguments)===false?false:M;if(I.__single){D[G]=null;}if(M===false){break;}}}return M;}else{K={type:B(L)?"message":"message:"+L.toLowerCase().replace(/^\s+|\s+$/g,""),data:K,domain:J||document.domain,uri:document.documentURI,source:window,tag:B(L)?null:L.toLowerCase()};try{return F.disableMessaging!==true?F.fireEvent.call(F,K.type,F,K):null;}catch(H){}return null;}}};window.onhostmessage=function(F,E,G,C){if(typeof F=="function"){if(!B(F.__index)){throw"onhostmessage: duplicate handler definition"+(C?" for tag:"+C:"");}var D=B(C)?"$":C.toLowerCase();A[D]||(A[D]=[]);Ext.apply(F,{__tag:D,__single:G||false,__scope:E||window,__index:A[D].length});A[D].push(F);}else{throw"onhostmessage: function required";}};window.unhostmessage=function(D){if(typeof D=="function"&&typeof D.__index!="undefined"){var C=D.__tag||"$";A[C][D.__index]=null;}};},_renderHook:function(){this._windowContext=null;this._hooked=false;try{if(this.writeScript('(function(){(window.hostMIF = parent.Ext.get("'+this.dom.id+'"))._windowContext='+(Ext.isIE?"window":"{eval:function(s){return eval(s);}}")+";})();")){if(this.disableMessaging!==true){this.loadFunction({name:"XMessage",fn:this._XFrameMessaging},false,true);var B;if(B=this.getWindow().sendMessage){B.manager=this;}}}return this.domWritable();}catch(A){}return false;},sendMessage:function(C,A,B){var D;if(this.disableMessaging!==true&&(D=this.getWindow())){A||(A=C.tag||"");A=A.toLowerCase();C=Ext.applyIf(C.data?C:{data:C},{type:Ext.isEmpty(A)?"message":"message:"+A,domain:B||document.domain,uri:document.documentURI,source:window,tag:A||null,_fromHost:this});return D.sendMessage?D.sendMessage.call(null,C,A,B):null;}return null;},_windowContext:null,getDocument:function(){return this.getWindow()?this.getWindow().document:null;},getDocumentURI:function(){var A;try{A=this.src?this.getDocument().location.href:null;}catch(B){}return A||this.src;},getWindow:function(){var A=this.dom;return A?A.contentWindow||window.frames[A.name]:null;},print:function(){try{var B=this.getWindow();if(Ext.isIE){B.focus();}B.print();}catch(A){throw"print exception: "+(A.description||A.message||A);}},destroy:function(){this.removeAllListeners();if(this.dom){if(document.addEventListener){Ext.EventManager.un(window,"DOMFrameContentLoaded",this.dom[this._eventName]);}this.dom[this._eventName]=null;this._windowContext=null;if(Ext.isIE&&this.dom.src){this.dom.src="javascript:false";}this._maskEl=null;Ext.removeNode(this.dom);}Ext.apply(this.loadMask,{masker:null,maskEl:null});Ext.ux.ManagedIFrame.Manager.deRegister(this);},domWritable:function(){return !!this._windowContext;},execScript:function(block,useDOM){try{if(this.domWritable()){if(useDOM){this.writeScript(block);}else{return this._windowContext.eval(block);}}else{throw"execScript:non-secure context";}}catch(ex){this.fireEvent("exception",this,ex);return false;}return true;},writeScript:function(G,B){B=Ext.apply({},B||{},{type:"text/javascript",text:G});try{var D,A,F=this.getDocument();if(F&&F.getElementsByTagName){if(!(D=F.getElementsByTagName("head")[0])){D=F.createElement("head");F.getElementsByTagName("html")[0].appendChild(D);}if(D&&(A=F.createElement("script"))){for(var E in B){if(B.hasOwnProperty(E)&&E in A){A[E]=B[E];}}return !!D.appendChild(A);}}}catch(C){this.fireEvent("exception",this,C);}return false;},loadFunction:function(D,B,C){var A=D.name||D;var D=D.fn||window[D];this.execScript(A+"="+D,B);if(C){this.execScript(A+"()");}},showMask:function(D,C,B){var A;if((A=this.loadMask)&&(!A.disabled||B)){if(A._vis){return ;}A.masker||(A.masker=Ext.get(A.maskEl||this.dom.parentNode||this.wrap({tag:"div",style:{position:"relative"}})));A._vis=true;A.masker.mask.defer(A.delay||5,A.masker,[D||A.msg,C||A.msgCls]);}},hideMask:function(B){var A;if((A=this.loadMask)&&!A.disabled&&A.masker){if(!B&&(A.hideOnReady!==true&&this._domReady)){return ;}A._vis=false;A.masker.unmask.defer(A.delay||5,A.masker);}},loadHandler:function(B){if(!this.frameInit||(!this._frameAction&&!this.eventsFollowFrameLinks)){return ;}var A=(B&&typeof B.type!=="undefined"?B.type:this.dom.readyState);switch(A){case"loading":case"interactive":break;case"DOMFrameContentLoaded":if(this._domFired||(B&&B.target!==this.dom)){return ;}case"domready":if(this._domFired){return ;}if(this._domFired=this._hooked=this._renderHook()){this._frameAction=(this.fireEvent("domready",this)===false?false:this._frameAction);}case"domfail":this._domReady=true;this.hideMask();break;case"load":case"complete":if(!this._domFired){this.loadHandler({type:"domready"});}this.hideMask(true);if(this._frameAction||this.eventsFollowFrameLinks){this.fireEvent.defer(50,this,["documentloaded",this]);}this._frameAction=false;if(this.eventsFollowFrameLinks){this._domFired=this._domReady=false;}if(this._callBack){this._callBack(this);}break;default:}},checkDOM:function(D){if(Ext.isOpera){return ;}var F=0,D=D||this.getWindow(),C=this,B=false,A=100;var E=function(){try{B=false;var I=D.document,G;if(!C._domReady){B=(I&&I.getElementsByTagName);B=B&&(G=I.getElementsByTagName("body")[0])&&!!G.innerHTML.length;}}catch(H){F=A;}if(!C._frameAction||C._domReady){return ;}if(F++<A&&!B){setTimeout(arguments.callee,10);return ;}C.loadHandler({type:B?"domready":"domfail"});};setTimeout(E,50);}});Ext.ux.ManagedIFrame.Manager=function(){var B={},A={};return{shimCls:"x-frame-shim",register:function(C){C.manager=this;return B[C.id]=A[C.dom.name||C.id]=C;},deRegister:function(C){delete B[C.id];delete A[C.dom.name||C.id];},hideDragMask:function(){if(!this.shimApplied){return ;}Ext.select("."+this.shimCls,true).removeClass(this.shimCls+"-on");this.shimApplied=false;},showDragMask:function(){if(!this.shimApplied){this.shimApplied=true;Ext.select("."+this.shimCls,true).addClass(this.shimCls+"-on");}},getFrameById:function(C){return B[C]||null;},getFrameByName:function(C){return A[C]||null;}};}();Ext.ux.ManagedIframePanel=Ext.extend(Ext.Panel,{defaultSrc:null,bodyStyle:{height:"100%",width:"100%",position:"relative"},frameStyle:{overflow:"auto"},frameConfig:null,hideMode:!Ext.isIE?"nosize":"display",shimCls:Ext.ux.ManagedIFrame.Manager.shimCls,shimUrl:null,loadMask:false,animCollapse:Ext.isIE,autoScroll:false,closable:true,ctype:"Ext.ux.ManagedIframePanel",showLoadIndicator:false,unsupportedText:"Inline frames are NOT enabled/supported by your browser.",initComponent:function(){var A=this.unsupportedText?{html:this.unsupportedText}:false;this.bodyCfg||(this.bodyCfg={tag:"div",cls:"x-panel-body",children:[{cls:"x-managed-iframe-mask",children:[Ext.apply(Ext.apply({tag:"iframe",frameborder:0,cls:"x-managed-iframe",style:this.frameStyle||null},this.frameConfig),A,Ext.isIE&&Ext.isSecure?{src:Ext.SSL_SECURE_URL}:false),{tag:"img",src:this.shimUrl||Ext.BLANK_IMAGE_URL,cls:this.shimCls}]}]});this.autoScroll=false;this.items=null;if(this.stateful!==false){this.stateEvents||(this.stateEvents=["documentloaded"]);}Ext.ux.ManagedIframePanel.superclass.initComponent.call(this);this.monitorResize||(this.monitorResize=this.fitToParent);this.addEvents({documentloaded:true,domready:true,message:true,exception:true});this.addListener=this.on;},doLayout:function(){if(this.fitToParent&&!this.ownerCt){var B=this.getPosition(),A=(Ext.get(this.fitToParent)||this.getEl().parent()).getViewSize();this.setSize(A.width-B[0],A.height-B[1]);}Ext.ux.ManagedIframePanel.superclass.doLayout.apply(this,arguments);},beforeDestroy:function(){if(this.rendered){if(this.tools){for(var A in this.tools){Ext.destroy(this.tools[A]);}}if(this.header&&this.headerAsText){var B;if(B=this.header.child("span")){B.remove();}this.header.update("");}Ext.each(["iframe","header","topToolbar","bottomToolbar","footer","loadMask","body","bwrap"],function(C){if(this[C]){if(typeof this[C].destroy=="function"){this[C].destroy();}else{Ext.destroy(this[C]);}this[C]=null;delete this[C];}},this);}Ext.ux.ManagedIframePanel.superclass.beforeDestroy.call(this);},onDestroy:function(){Ext.Panel.superclass.onDestroy.call(this);},onRender:function(B,A){Ext.ux.ManagedIframePanel.superclass.onRender.call(this,B,A);if(this.iframe=this.body.child("iframe.x-managed-iframe")){var D=Ext.Element;var E=D[this.hideMode.toUpperCase()]||"x-hide-nosize";Ext.each([this[this.collapseEl],this.floating?null:this.getActionEl(),this.iframe],function(F){if(F){F.setVisibilityMode(E);}},this);if(this.loadMask){this.loadMask=Ext.apply({disabled:false,maskEl:this.body,hideOnReady:true},this.loadMask);}if(this.iframe=new Ext.ux.ManagedIFrame(this.iframe,{loadMask:this.loadMask,showLoadIndicator:this.showLoadIndicator,disableMessaging:this.disableMessaging,style:this.frameStyle})){this.loadMask=this.iframe.loadMask;this.iframe.ownerCt=this;this.relayEvents(this.iframe,["documentloaded","domready","exception","message"].concat(this._msgTagHandlers||[]));delete this._msgTagHandlers;}this.getUpdater().showLoadIndicator=this.showLoadIndicator||false;var C=this.ownerCt;while(C){C.on("afterlayout",function(F,I){var G=Ext.ux.ManagedIFrame.Manager,H=false;Ext.each(["north","south","east","west"],function(K){var J;if((J=I[K])&&J.splitEl){H=true;if(!J.split._splitTrapped){J.split.on("beforeresize",G.showDragMask,G);J.split._splitTrapped=true;}}},this);if(H&&!this._splitTrapped){this.on("resize",G.hideDragMask,G);this._splitTrapped=true;}},this,{single:true});C=C.ownerCt;}}this.shim=Ext.get(this.body.child(".x-frame-shim"));},toggleShim:function(){if(this.shim&&this.shimCls){this.shim.toggleClass(this.shimCls);}},afterRender:function(A){var B=this.html;delete this.html;Ext.ux.ManagedIframePanel.superclass.afterRender.call(this);if(this.iframe){if(this.defaultSrc){this.setSrc();}else{if(B){this.iframe.update(typeof B=="object"?Ext.DomHelper.markup(B):B);}}}},sendMessage:function(){if(this.iframe){this.iframe.sendMessage.apply(this.iframe,arguments);}},on:function(B){var D=/^message\:/i,C=null;if(typeof B=="object"){for(var A in B){if(!this.filterOptRe.test(A)&&D.test(A)){C||(C=[]);C.push(A.toLowerCase());}}}else{if(D.test(B)){C=[B.toLowerCase()];}}if(this.getFrame()&&C){this.relayEvents(this.iframe,C);}else{this._msgTagHandlers||(this._msgTagHandlers=[]);if(C){this._msgTagHandlers=this._msgTagHandlers.concat(C);}}Ext.ux.ManagedIframePanel.superclass.on.apply(this,arguments);},setSrc:function(A,B,D){A=A||this.defaultSrc||false;if(!A){return this;}if(A.url){D=A.callback||false;B=A.discardUrl||false;A=A.url||false;}var C=A||(Ext.isIE&&Ext.isSecure?Ext.SSL_SECURE_URL:"");if(this.rendered&&this.iframe){this.iframe.setSrc(C,B,D);}return this;},getState:function(){var A=this.iframe?this.iframe.getDocumentURI()||null:null;return Ext.apply(Ext.ux.ManagedIframePanel.superclass.getState.call(this)||{},A?{defaultSrc:typeof A=="function"?A():A}:null);},getUpdater:function(){return this.rendered?(this.iframe||this.body).getUpdater():null;},getFrame:function(){return this.rendered?this.iframe:null;},getFrameWindow:function(){return this.rendered&&this.iframe?this.iframe.getWindow():null;},getFrameDocument:function(){return this.rendered&&this.iframe?this.iframe.getDocument():null;},load:function(B){var A;if(A=this.getUpdater()){if(B&&B.renderer){A.setRenderer(B.renderer);delete B.renderer;}A.update.apply(A,arguments);}return this;},doAutoLoad:function(){this.load(typeof this.autoLoad=="object"?this.autoLoad:{url:this.autoLoad});}});Ext.reg("iframepanel",Ext.ux.ManagedIframePanel);Ext.ux.ManagedIframePortlet=Ext.extend(Ext.ux.ManagedIframePanel,{anchor:"100%",frame:true,collapseEl:"bwrap",collapsible:true,draggable:true,cls:"x-portlet"});Ext.reg("iframeportlet",Ext.ux.ManagedIframePortlet);Ext.apply(Ext.Element.prototype,{setVisible:function(D,A){if(!A||!Ext.lib.Anim){if(this.visibilityMode==Ext.Element.DISPLAY){this.setDisplayed(D);}else{if(this.visibilityMode==Ext.Element.VISIBILITY){this.fixDisplay();this.dom.style.visibility=D?"visible":"hidden";}else{this[D?"removeClass":"addClass"](String(this.visibilityMode));}}}else{var C=this.dom;var B=this.visibilityMode;if(D){this.setOpacity(0.01);this.setVisible(true);}this.anim({opacity:{to:(D?1:0)}},this.preanim(arguments,1),null,0.35,"easeIn",function(){if(!D){if(B==Ext.Element.DISPLAY){C.style.display="none";}else{if(B==Ext.Element.VISIBILITY){C.style.visibility="hidden";}else{Ext.get(C).addClass(String(B));}}Ext.get(C).setOpacity(1);}});}return this;},isVisible:function(A){var B=!(this.getStyle("visibility")=="hidden"||this.getStyle("display")=="none"||this.hasClass(this.visibilityMode));if(A!==true||!B){return B;}var C=this.dom.parentNode;while(C&&C.tagName.toLowerCase()!="body"){if(!Ext.fly(C,"_isVisible").isVisible()){return false;}C=C.parentNode;}return true;}});Ext.onReady(function(){var A=Ext.util.CSS,B=[];A.getRule(".x-managed-iframe")||(B.push(".x-managed-iframe {height:100%;width:100%;overflow:auto;}"));A.getRule(".x-managed-iframe-mask")||(B.push(".x-managed-iframe-mask{width:100%;height:100%;position:relative;}"));if(!A.getRule(".x-frame-shim")){B.push(".x-frame-shim {z-index:9000;position:absolute;top:0px;left:0px;background:transparent!important;overflow:hidden;display:none;}");B.push(".x-frame-shim-on{width:100%;height:100%;display:block;zoom:1;}");B.push(".ext-ie6 .x-frame-shim{margin-left:5px;margin-top:3px;}");}A.getRule(".x-hide-nosize")||(B.push(".x-hide-nosize,.x-hide-nosize object,.x-hide-nosize iframe{height:0px!important;width:0px!important;border:none;}"));if(!!B.length){A.createStyleSheet(B.join(" "));}});