/**
 * Load common scripts for MaxPlayer templates
 * 
 * @copyright Copyright © 2009 Max Digital Broadcasting Corporation. All rights reserved.
 * @version $Id: includes.js 263 2009-08-14 20:50:58Z wthompson $
 */

var jsLoader = {
	/**
	 * Include list of javascripts in the order they are specified (note
	 * that the Ajax method will ensure that the scripts are loaded in order
	 * but cannot guarantee when the procedure will complete and should not be
	 * used for including files that are required in a timely fashion).
	 * 
	 * @param Array(String) includes List of script hrefs
	 */
	include: function(includes, scriptBase, useAjax) {
		if(!scriptBase) scriptBase = '';
		if(includes.length) {
			if(typeof useAjax != 'undefined' && useAjax && typeof jQuery != 'undefined') {
				// Shift the first element off the list of includes
				var href = scriptBase+includes.shift();
				// Use jQuery to load the current script via Ajax and use a
				// callback to load the remaining scripts once the current
				// one has been loaded
				$.getScript(href, function() {
					jsLoader.include(includes, scriptBase, useAjax);
				});
			} else {
				// Loop over include files and insert script tags using document
				// write (friendlier for debugging utilities)
				for(var idx = 0; idx < includes.length; idx++) {
					var href = scriptBase+includes[idx];
					document.write('<script type="text/javascript" src="'+href+'"></script>');
				}
			}
		}
	}
}

/**
 * List of standard includes for the MaxPlayer
 */
var MaxIncludes = [
	'jquery/jquery.query-2.0.1.js',
	'jquery/jquery.sprintf.js',
	'player/jquery.console.js',
	'common.js',
	'jquery.ui/ui.core.js',
	'jquery.ui/ui.draggable.js',
	'jquery.ui/ui.slider.js',
	'jquery.ui/ui.tabs.js',
	'player/jquery.misc.js',
	'player/jquery.platform.js',
	'player/jquery.imagebutton.js',
	'player/jquery.statebutton.js',
	'player/common.js',
	'player/WindowsMediaFrame.js',
	'player/MaxClass.js',
	'player/MaxCollection.js',
	'player/MaxPlayer.js',
	'player/MaxMediaPlayer.js',
	'player/MaxVideoPlayer.js',
	'player/MaxWMP.js',
	'player/MaxMediaControlPanel.js',
	'player/MaxMediaControl.js',
	'player/MaxMediaControlHandlers.js',
	'player/MaxTabNavigationHandlers.js',
	'player/MaxTab.js',
	'player/MaxTabLabel.js',
	'player/MaxTabNavigation.js',
	'player/MaxTabReference.js',
	'player/MaxTabReferenceCollection.js',
	'player/MaxConfig.js',
	'player/MaxPlayerConfig.js',
	'player/MaxTabConfig.js',
	'player/MaxContentPanel.js',
	'player/MaxSessionListPanel.js',
	'player/MaxTopicListPanel.js',
	'player/MaxPresentationPanel.js',
	'player/MaxEmbedHtmlPanel.js',
	'player/MaxSessionHtmlPanel.js',
	'player/MaxVideoInformationPanel.js',
	'player/MaxContentType.js', // Panel classes must be loaded before here
	'player/MaxSlide.js',
	'player/MaxSlideCounter.js',
	'player/MaxSlideControl.js',
	'player/MaxPresentation.js',
	'player/MaxMedia.js',
	'player/MaxMediaUri.js',
	'player/MaxTopic.js',
	'player/MaxSession.js',
	'player/MaxSessionCollection.js',
	'player/MaxSessionGroup.js',
	'player/MaxSessionManager.js',
	'player/MaxScriptHandlers.js',
	'player/MaxDictionary.js'
];
