if(typeof Series =="undefined") {
	var Series = new Object();
}
Series.Helpers = [];
Series.library = function() {
	var jsBase = "/site/weeds/season6/js";
	var KEY_IN = '/site/weeds/';
	var KEY_OUT = '.do';
	var TOKEN = '_';
	var library =  {
		music: [
			'MusicUIHelp'
		],
		carousel: [
			'CarouselUIHelp'
		],
		episodes: [
			'EpisodesUIHelp'
		],
		feeds: [
			//'RelatedVideos',
			'CommunityFeeds'
		],
		schedule: [
			'ScheduleData'
		],
		video: [
			'brightcove',
			'title'
		]
	};
	
	/* =:Startup
	--------------------------------------------------------------------------------------------*/
	function init() {
		if( document.location.search.toString().indexOf('noscript') > -1 ) return;
		document.write( "\n" );
		//loadModule ( library.global, 'global' );
		//loadModule ( library.components, 'components' );
		loadModule ( library.feeds, 'feeds' );
		loadModule ( library.carousel, 'carousel');
		parseLocation();
	}
	function parseLocation() {
		var urlStr = document.location.pathname;
		var str1 = urlStr.substr( urlStr.indexOf( KEY_IN ) + KEY_IN.length );
		var str2 = str1.substr( 0, str1.indexOf( KEY_OUT )).replace(/-/, '_');
		var path = str2.split('/');
		// check for flattened homepage
		/*if( document.location.pathname.indexOf('/index.html') !== -1 ) {
			importModules ( ['home'] );
		}
		else*/importModules ( path );
	}
	function importModules ( path ) {
		var m = "";
		for (var i=0; i < path.length; i++) {
			m += path[i];
			if( typeof library[ m ] == "object" &&  library[ m ] !== null ) {
				loadModule( library[ m ], path[0] );
			}
			m+=TOKEN;
		}
	}
	function loadModule( mod, package ) {
		package = ( package == false ) ? '' : '/' + package;
		for (var i=0; i < mod.length; i++) {
			document.write('<script language="javascript" src="'+ jsBase + package + '/'+ mod [i] + '.js"></script>'+"\n" );
		}
	}
	/* Reveal public methods
	-------------------------*/
	return {
		deploy:init
	}
}();
Series.library.deploy();