dojo._xdResourceLoaded({
depends: [["provide", "blogscope.TitlePaneX"],
["require", "dijit.TitlePane"]],
defineResource: function(dojo){
	if(!dojo._hasResource["blogscope.TitlePaneX"]){ 
		dojo._hasResource["blogscope.TitlePaneX"] = true;
		dojo.provide("blogscope.TitlePaneX");
		dojo.require("dijit.TitlePane");
		dojo.declare(
		"blogscope.TitlePaneX",
		[dijit.TitlePane],
		{
			// executeScripts: Boolean
			//		Execute (eval) scripts that is found in the content
			executeScripts: true,
			_downloadExternalContent: function(){
			// copied with modifications from http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/TitlePane.js
				this._onUnloadHandler();
		
				// display loading message
				this._setContent(
					this.onDownloadStart.call(this)
				);
		
				var self = this;
				var getArgs = {
					preventCache: (this.preventCache || this.refreshOnShow),
					url: this.href,
					handleAs: "text"
				};
				if(dojo.isObject(this.ioArgs)){
					dojo.mixin(getArgs, this.ioArgs);
				}
		
				this._xhrDfd = (this.ioMethod || dojo.xhrGet)(getArgs);
				var hand = this._xhrDfd;
				 
				hand.addCallback(function(html){
					try{
						//adding an extra callback handler for scripts
						self.onHrefDownloadEnd.call(self, html);
						self.onDownloadEnd.call(self);
						self._isDownloaded = true;
						self.setContent.call(self, html); // onload event is called from here
					}catch(err){
						console.error("error "+err);
						self._onError.call(self, 'Content', err); // onContentError
					}
					delete self._xhrDfd;
					return html;
				});
		
				hand.addErrback(function(err){
					if(!hand.cancelled){
						// show error message in the pane
						self._onError.call(self, 'Download', err); // onDownloadError
					}
					delete self._xhrDfd;
					return err;
				});
			},
			onHrefDownloadEnd: function(currentContent) {
				// console.log("Download complete. Content is "+currentContent);
				// next part inspired from http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/layout/ContentPane.js
				if(this.executeScripts){
					var _t = this, code, byRef = {
						downloadRemote: true,
						errBack:function(e){
							_t._onError.call(_t, 'Exec', 'Error downloading remote script in "'+_t.id+'"', e);
						}
					};
					currentContent = this.snarfScripts(currentContent, byRef);
					code = byRef.code;
					try{
						this.evalInGlobal(code, (this.containerNode || this.domNode));
					}catch(e){
						this._onError('Exec', 'Error eval script in '+this.id+', '+e.message, e);
					}
				}
			},
			snarfScripts: function(cont, byRef){
				// summary
				//		strips out script tags from cont
				// invoke with 
				//	byRef = {errBack:function(){/*add your download error code here*/, downloadRemote: true(default false)}}
				//	byRef will have {code: 'jscode'} when this scope leaves
				// copied with modifications from http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/layout/ContentPane.js
				byRef.code = "";
		
				function download(src){
					if(byRef.downloadRemote){
						// console.debug('downloading',src);
						dojo.xhrGet({
							url: src,
							sync: true,
							load: function(code){
								byRef.code += code+";";
							},
							error: byRef.errBack
						});
					}
				}
				
				// match <script>, <script type="text/..., but not <script type="dojo(/method)...
				return cont.replace(/<script\s*(?![^>]*type=['"]?dojo)(?:[^>]*?(?:src=(['"]?)([^>]*?)\1[^>]*)?)*>([\s\S]*?)<\/script>/gi,
					function(ignore, delim, src, code){
						if(src){
							download(src);
						}else{
							byRef.code += code;
						}
						return "";
					}
				);
			},
			evalInGlobal: function(code, appendNode){
				// we do our own eval here as dojo.eval doesn't eval in global crossbrowser
				// This work X browser but but it relies on a DOM
				// plus it doesn't return anything, thats unrelevant here but not for dojo core
				// copied from http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/layout/ContentPane.js
				appendNode = appendNode || dojo.doc.body;
				var n = appendNode.ownerDocument.createElement('script');
				n.type = "text/javascript";
				appendNode.appendChild(n);
				n.text = code; // DOM 1 says this should work
			}
		}
	);
	}
}});
