/*
	Copyright (c) 2004-2008, The Dojo Foundation
	All Rights Reserved.

	Licensed under the Academic Free License version 2.1 or above OR the
	modified BSD license. For more information on Dojo licensing, see:

		http://dojotoolkit.org/book/dojo-book-0-9/introduction/licensing
*/


window[(typeof (djConfig)!="undefined"&&djConfig.scopeMap&&djConfig.scopeMap[0][1])||"dojo"]._xdResourceLoaded({depends:[["provide","dijit.layout.ContentPane"],["require","dijit._Widget"],["require","dijit.layout._LayoutWidget"],["require","dojo.parser"],["require","dojo.string"],["requireLocalization","dijit","loading",null,"ar,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,ROOT,nb,nl,pl,pt,pt-pt,ru,sv,tr,zh,zh-tw","ar,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,ROOT,nb,nl,pl,pt,pt-pt,ru,sv,tr,zh,zh-tw"]],defineResource:function(_1,_2,_3){if(!_1._hasResource["dijit.layout.ContentPane"]){_1._hasResource["dijit.layout.ContentPane"]=true;_1.provide("dijit.layout.ContentPane");_1.require("dijit._Widget");_1.require("dijit.layout._LayoutWidget");_1.require("dojo.parser");_1.require("dojo.string");_1.declare("dijit.layout.ContentPane",_2._Widget,{href:"",extractContent:false,parseOnLoad:true,preventCache:false,preload:false,refreshOnShow:false,loadingMessage:"<span class='dijitContentPaneLoading'>${loadingState}</span>",errorMessage:"<span class='dijitContentPaneError'>${errorState}</span>",isLoaded:false,"class":"dijitContentPane",doLayout:"auto",postCreate:function(){this.domNode.title="";if(!this.containerNode){this.containerNode=this.domNode;}if(this.preload){this._loadCheck();}var _4=_1.i18n.getLocalization("dijit","loading",this.lang);this.loadingMessage=_1.string.substitute(this.loadingMessage,_4);this.errorMessage=_1.string.substitute(this.errorMessage,_4);var _5=_2.getWaiRole(this.domNode);if(!_5){_2.setWaiRole(this.domNode,"group");}_1.addClass(this.domNode,this["class"]);},startup:function(){if(this._started){return;}if(this.doLayout!="false"&&this.doLayout!==false){this._checkIfSingleChild();if(this._singleChild){this._singleChild.startup();}}this._loadCheck();this.inherited(arguments);},_checkIfSingleChild:function(){var _6=_1.query(">",this.containerNode||this.domNode),_7=_6.filter("[widgetId]");if(_6.length==1&&_7.length==1){this.isContainer=true;this._singleChild=_2.byNode(_7[0]);}else{delete this.isContainer;delete this._singleChild;}},refresh:function(){return this._prepareLoad(true);},setHref:function(_8){this.href=_8;return this._prepareLoad();},setContent:function(_9){if(!this._isDownloaded){this.href="";this._onUnloadHandler();}this._setContent(_9||"");this._isDownloaded=false;if(this.parseOnLoad){this._createSubWidgets();}if(this.doLayout!="false"&&this.doLayout!==false){this._checkIfSingleChild();if(this._singleChild&&this._singleChild.resize){this._singleChild.startup();this._singleChild.resize(this._contentBox||_1.contentBox(this.containerNode||this.domNode));}}this._onLoadHandler();},cancel:function(){if(this._xhrDfd&&(this._xhrDfd.fired==-1)){this._xhrDfd.cancel();}delete this._xhrDfd;},destroy:function(){if(this._beingDestroyed){return;}this._onUnloadHandler();this._beingDestroyed=true;this.inherited("destroy",arguments);},resize:function(_a){_1.marginBox(this.domNode,_a);var _b=this.containerNode||this.domNode,mb=_1.mixin(_1.marginBox(_b),_a||{});this._contentBox=_2.layout.marginBox2contentBox(_b,mb);if(this._singleChild&&this._singleChild.resize){this._singleChild.resize(this._contentBox);}},_prepareLoad:function(_d){this.cancel();this.isLoaded=false;this._loadCheck(_d);},_isShown:function(){if("open" in this){return this.open;}else{var _e=this.domNode;return (_e.style.display!="none")&&(_e.style.visibility!="hidden");}},_loadCheck:function(_f){var _10=this._isShown();if(this.href&&(_f||(this.preload&&!this._xhrDfd)||(this.refreshOnShow&&_10&&!this._xhrDfd)||(!this.isLoaded&&_10&&!this._xhrDfd))){this._downloadExternalContent();}},_downloadExternalContent:function(){this._onUnloadHandler();this._setContent(this.onDownloadStart.call(this));var _11=this;var _12={preventCache:(this.preventCache||this.refreshOnShow),url:this.href,handleAs:"text"};if(_1.isObject(this.ioArgs)){_1.mixin(_12,this.ioArgs);}var _13=this._xhrDfd=(this.ioMethod||_1.xhrGet)(_12);_13.addCallback(function(_14){try{_11.onDownloadEnd.call(_11);_11._isDownloaded=true;_11.setContent.call(_11,_14);}catch(err){_11._onError.call(_11,"Content",err);}delete _11._xhrDfd;return _14;});_13.addErrback(function(err){if(!_13.cancelled){_11._onError.call(_11,"Download",err);}delete _11._xhrDfd;return err;});},_onLoadHandler:function(){this.isLoaded=true;try{this.onLoad.call(this);}catch(e){console.error("Error "+this.widgetId+" running custom onLoad code");}},_onUnloadHandler:function(){this.isLoaded=false;this.cancel();try{this.onUnload.call(this);}catch(e){console.error("Error "+this.widgetId+" running custom onUnload code");}},_setContent:function(_16){this.destroyDescendants();try{var _17=this.containerNode||this.domNode;while(_17.firstChild){_1._destroyElement(_17.firstChild);}if(typeof _16=="string"){if(this.extractContent){match=_16.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);if(match){_16=match[1];}}_17.innerHTML=_16;}else{if(_16.nodeType){_17.appendChild(_16);}else{_1.forEach(_16,function(n){_17.appendChild(n.cloneNode(true));});}}}catch(e){var _19=this.onContentError(e);try{_17.innerHTML=_19;}catch(e){console.error("Fatal "+this.id+" could not change content due to "+e.message,e);}}},_onError:function(_1a,err,_1c){var _1d=this["on"+_1a+"Error"].call(this,err);if(_1c){console.error(_1c,err);}else{if(_1d){this._setContent.call(this,_1d);}}},_createSubWidgets:function(){var _1e=this.containerNode||this.domNode;try{_1.parser.parse(_1e,true);}catch(e){this._onError("Content",e,"Couldn't create widgets in "+this.id+(this.href?" from "+this.href:""));}},onLoad:function(e){},onUnload:function(e){},onDownloadStart:function(){return this.loadingMessage;},onContentError:function(_21){},onDownloadError:function(_22){return this.errorMessage;},onDownloadEnd:function(){}});}}});
