// Intialize the DTM Loader
if(window.DTM_LOADER === undefined) {
	var DTM_LOADER = {};
	DTM_LOADER.widgets = {};
	DTM_LOADER.queue = [];
	// Define action to take once yui loader is present on the page
	DTM_LOADER.startup = function() {
		var startup = new YAHOO.util.YUILoader();
		startup.require(['event', 'dom']);
		startup.loadOptional = false;
		startup.insert({
			onSuccess:function() {
				DTM_LOADER.available = true;
//        YAHOO.util.Event.on(window, "load", DTM_LOADER.clearQueue);
        YAHOO.util.Event.onDOMReady(DTM_LOADER.clearQueue);
			}
		});
	}
	DTM_LOADER.addToQueue = function(widget) {
		DTM_LOADER.queue.push(widget);
	}
	DTM_LOADER.clearQueue = function() {
		if(DTM_LOADER.queue.length > 0) {
			var widget = DTM_LOADER.queue.shift();
			DTM_LOADER.load(widget);
			DTM_LOADER.clearQueue();
		}
	}
	DTM_LOADER.register = function(widget) {
		DTM_LOADER.addToQueue(widget);
		if(DTM_LOADER.available) {
			DTM_LOADER.clearQueue();
		}
	}
	DTM_LOADER.load = function(widget) {
		var module, requires = DTM_LOADER.widgets[widget].requires;
		DTM_LOADER.widgets[widget].loader = new YAHOO.util.YUILoader();
		for(var i=0; i<DTM_LOADER.widgets[widget].modules.length; i++) {
			module = DTM_LOADER.widgets[widget].modules[i];
			requires.push(module.name);
			DTM_LOADER.widgets[widget].loader.addModule(module);
		}
		DTM_LOADER.widgets[widget].loader.require(requires);
		DTM_LOADER.widgets[widget].loader.loadOptional = false;
		DTM_LOADER.widgets[widget].loader.data = DTM_LOADER.widgets[widget].launcher;
		DTM_LOADER.widgets[widget].loader.combine = true;
		DTM_LOADER.widgets[widget].loader.insert({
			onSuccess:function(launcher) {
				launcher.data();
			}
		});
	}
	DTM_LOADER.poll = function() {
		if(window.YAHOO !== undefined && YAHOO.util !== undefined && YAHOO.util.YUILoader !== undefined) {
			DTM_LOADER.startup();
		} else {
			window.setTimeout(DTM_LOADER.poll,10);
		}
	}
	// Add the Loader to the page if it is not defined
	if(window.YAHOO === undefined || YAHOO.util === undefined || YAHOO.util.YUILoader === undefined) {
		DTM_LOADER.yuiloader = function() {
			var s = document.createElement('script');
			s.setAttribute('type','text/javascript');
			s.setAttribute('src','http://yui.yahooapis.com/2.8.0r4/build/yuiloader/yuiloader-min.js');
			document.getElementsByTagName('head')[0].appendChild(s);
		}();
	}
	DTM_LOADER.poll();
}

if(DTM_LOADER.widgets.blogRssListing === undefined) {
	DTM_LOADER.widgets.blogRssListing = {};
	DTM_LOADER.widgets.blogRssListing.domClass 	= "dtm-blog-rss-listing-1521";
	DTM_LOADER.widgets.blogRssListing.feedURL 	= "http://partners.dogtime.com//network/cached_feeds/blog-rss-listing.js";
	DTM_LOADER.widgets.blogRssListing.assetURL 	= "http://partners.dogtime.com/network/0.0.1/assets/001/521/blog-rss-listing/current/";
	DTM_LOADER.widgets.blogRssListing.coreURL 	= "http://partners.dogtime.com/network/0.0.1/core/blog-rss-listing/";
	DTM_LOADER.widgets.blogRssListing.modules 	= [	{ name : 'DTM.widget.blogRSSListing', type : 'js', fullpath : (DTM_LOADER.widgets.blogRssListing.coreURL + 'j/dtm-blog-rss-listing.js') },
																									{ name : 'DTM.widget.blogRSSListingCSS', type : 'css', fullpath : (DTM_LOADER.widgets.blogRssListing.assetURL + 'c/dtm-blog-rss-listing.css') } ];
	DTM_LOADER.widgets.blogRssListing.requires 	= ['dom', 'element', 'event', 'json', 'animation'];																			
	DTM_LOADER.widgets.blogRssListing.launcher = function() { 
		DTM.widget.blogRSSListing.init({ domClass : DTM_LOADER.widgets.blogRssListing.domClass, url : DTM_LOADER.widgets.blogRssListing.feedURL, coreURL : DTM_LOADER.widgets.blogRssListing.coreURL, assetURL : DTM_LOADER.widgets.blogRssListing.assetURL });
	};
	DTM_LOADER.register('blogRssListing');
}
