/**
 * Configure Akamai's DLM.js
 */
var DLMCSS = false, DLMCID = 89538, INSTALL_CP_CODE = 89538;

/**
 * Extra Modernizr Tests
 */
(function (Modernizr) {
	var i;
	
	if (Modernizr) {
	// Modernizr.datauri
	// based on http://weston.ruter.net/2009/05/07/detecting-support-for-data-uris/
		i = new Image();
		i.onload = i.onerror = function () {
			var r = i.width === 1 && i.height === 1;
			Modernizr.addTest("datauri", function () { return r;});
			i.onload = i.onerror = null;
		};
		i.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
	// Modernizr.textoverflow
		Modernizr.addTest('textoverflow', function () {
			var s = document.documentElement.style;
			return "textOverflow" in s || "OTextOverflows" in s;
		});
	}
}(window.Modernizr));

/**
 * Stub a console if it doesn't exist
 */
(function (win) {
	function emptyFunction() {}
	
	if (!win.console) {
		win.console = {
			log: emptyFunction,
			warn: emptyFunction,
			info: emptyFunction,
			error: emptyFunction
		};	
	}
}(window));

/**
 * Load YUI if it's not on the page, then add NFL dependencies
 */
(function () {
	var i, l, 
		SITE_URL = window.nfl && nfl.constants && nfl.constants.SITE_URL ? nfl.constants.SITE_URL : 'http://www.nfl.com', // 'http://local.nfl.com:8080',
		YUI_DOMAIN = window.nfl && nfl.constants && nfl.constants.YUI_DOMAIN ? nfl.constants.YUI_DOMAIN : 'http://www.nfl.com'; //'http://test.www.nfl.com';
	
	function setUpDependencies() {
		var YUI_config = window.YUI_config = window.YUI_config || {},
			NFL_config = window.NFL_config = window.NFL_config || {},
			nfl = window.nfl || {}, Y,
			SITELIFE_URL = nfl.constants.SITELIFE_URL;

		if (nfl.constants.YUI_ENABLED && typeof YUI_config.filter === 'undefined') {
			YUI_config.comboBase = nfl.constants.YUI_DOMAIN;
			YUI_config.filter = {
				searchExp: "&3",
				replaceStr: ",3"
			};
		}
		NFL_config.modules = NFL_config.modules || {};
		YUI_config.modules = YUI_config.modules || {};

		// now that we have YUI_config, create our Y instance
		Y = YUI();
		Y.namespace('local');
		window.Y = Y;
		
		try {
			document.domain = 'nfl.com';
		}
		catch(e) {
			Y.log('WARNING: Could not set document.domain to nfl.com - ' + e.message);
		}
		
		// populate window.nfl
		nfl = window.nfl = Y.merge(nfl, {
			namespace: YUI.namespace,
			constants: Y.merge(nfl.constants || {}, {
				SEARCH_ADS: true,
				COMMENTS:   true,
				AD_RANDOM:  Math.random() * 10000000000000000
			}),
			/**
			 * Adds module dependencies to the global YUI config
			 * and returns a Y instance for chaining. Y is a shared
			 * YUI instance - use over YUI().use only if you want the
			 * shared instance.
		     *
		     * nfl.use('my-module', {
		     *   path: 'my-module.js',
		     *   requires: ['node']
		     * }, 'widget', function (Y) {
		     *   Y.MyModule.doSomething();
		     * });
			 */
			use: function() {
				var args = Array.prototype.slice.call(arguments, 0),
					dependencies = args.shift();

				// if we've defined any dependencies, add them to the global config
				if (Y.Lang.isObject(dependencies)) {
					nfl.addModules(dependencies);
					args = Y.Object.keys(dependencies).concat(args);
				}
				else if (! Y.Lang.isUndefined(dependencies)) {
					args.unshift(dependencies);
				}

				if (args.length) {
					Y.use.apply(Y, args);
				}
				return Y;
			},
			/**
			 * Adds a module to the YUI dependency tree.
			 * 
			 * Examples are below. The later syntax is preferred.
			 * 
			 * nfl.addModule('my-module', {
			 *   path: 'my-module.js',
			 *   requires: ['node']
			 * });
			 * 
			 * Module dependencies can be added at any time, however,
			 * they cannot use absolute paths. If an absolute path is
			 * necesary, use nfl.addExternal.
			 */
			addModule: function (name, config) {
				NFL_config.modules[name] = config;
				Y.applyConfig({ groups: YUI_config.groups });
			},
			/**
			 * Adds multiple module definitions.
			 */
			addModules: function (dependencies) {
				NFL_config.modules = Y.merge(NFL_config.modules, dependencies);
				Y.applyConfig({ groups: YUI_config.groups });
			},
			/**
			 * Global Events
			 * 
			 * This element provides a global event notification method compatible with
			 * both YUI and Prototype.
			 *
			 * Usage:
			 * 
			 *    nfl.events.fire("myprefix:customevent", { param1: "value", param2: "value" }, "myElementId");
			 **/
			events: Y.merge(nfl.events || {}, {
				fire: function (type, memo, dispatcher) {
					Y.use('event-custom', 'node', function (Y) {
						var publisher;

						if (Y.Lang.isString(dispatcher)) {
							publisher = Y.one(dispatcher.indexOf('#') === -1 ? '#' + dispatcher : dispatcher);
						}
						else if (dispatcher) {
							publisher = dispatcher;
						}
						else {
							publisher = new Y.EventTarget();
							publisher.name = "nfl.events.publisher";
						}
						publisher.publish(type, {
							broadcast: 2, // global notification
							emitFacade: true 
						});
						publisher.fire(type, memo);
					});
				},
				available: function () {
					return true;
				}
			}),
			/**
			 * Deprecated
			 */
			addYUICallback: function (newModules, callback) {
				console.warn('nfl.addYUICallback is obsolete, use nfl.use instead', newModules, callback);
				if (Y.Lang.isString(newModules)) {
					newModules = [newModules];
				}
				newModules.push(callback);
				nfl.use.apply(null, newModules);
			},
			/**
			 * Deprecated.
			 */
			executeYUICallbacks: function () {
				console.warn('nfl.executeYUICallbacks is obsolete');
			}
		});
		
		// enable third-party dependencies with YUI
		(function () {
			var thirdPartyModules, moduleTest, cfg;

			function emptyFunction() {}
			function addMatches(match) { // match looks like ",facebook,"
				var module = match.substring(1, match.length - 1); // e.g. "facebook"
				YUI.add(module, emptyFunction);
			}

			// third party modules you want to load with loader
			thirdPartyModules = {
				"facebook": { fullpath: "http://connect.facebook.net/en_US/all.js#xfbml=1" },
				"akamai-dlm": { fullpath: "http://client.akamai.com/dlm/dlm.js" },
				"gigya-socialize": { fullpath: "http://cdn.gigya.com/JS/socialize.js?apikey=" + encodeURIComponent(nfl.constants.GIGYA_CONF.APIKey) },
				"pluck": { fullpath: SITELIFE_URL + "/ver1.0/content/direct/scripts/directproxyfast.js" },
				"plucksdk": { fullpath: SITELIFE_URL + "/ver1.0/Direct/JavascriptSDKProxy" },
				"twitter-widgets": { fullpath: "http://platform.twitter.com/widgets.js" },
				"twitteranywhere": { fullpath: "http://platform.twitter.com/anywhere.js?v=1&id=" + nfl.constants.TWITTER_ID }
			};

			// only available/necessary in 3.4.1
			if (Y.Env._loader) {
				// RegExp that tests whether a module was loaded e.g. /,(facebook|twitter-widgets|twitteranywhere),/
				moduleTest = new RegExp(",(" + Y.Object.keys(thirdPartyModules).join("|") + "),", "g");

				// listen for the onSuccess even from loader
				Y.Env._loader.onSuccess = function(event) {
					var matches = ("," + event.data.join(",") + ",").match(moduleTest);

					// if any matches were loaded, call YUI.add for each match
					if (matches) {
						Y.Array.each(matches, addMatches);
					}
				};
			}

			// add these modules to the global config
			YUI_config.groups.thirdParty = {
				combine: false,
				modules: thirdPartyModules
			};

			// apply global config to this Y instance
			Y.applyConfig(cfg);
			
		}());
				
		// add big door to every page in the site
		Y.use("node-base", "event-custom", function () {
			Y.on("domready", function (event) {
				Y.one("body").insert("<div id=\"bd-quest-container\"></div><div id=\"bd-nav-container\"></div>", 0);
				Y.Get.script("http://static.bigdoor.com/5136/nfl.com/trunk/1/js/load.min.js", {
					onSuccess: function () {
						Y.BDM = Y.config.win.BDM;
						Y.BDM.load(5136, 'nfl.com', 1);
					}
				});
			});
		});
		
		// add dependencies now
		nfl.addModules({
			"activity-visualization": { path: "activity-visualization/activity-visualization.js", requires: ["array-extras", "base-build", "charts", "nfl-lang", "plucksdk", "transition", "widget"], skinnable: true },
			"audio-player": { path: "audio-player/audio-player.js", requires: ["base-build", "soundmanager", "widget", "transition"], skinnable: true },
			'base-generate': { path: 'deprecated/base-utilities.js', requires: ['base-build'] },
			'browser-panels': {path: "global/browser-panels.js", requires: ['base-build','base','node','array-extras','event','event-custom']},

      // lots 'o buzz modules
			"buzz-meta-cache": { path: "buzz-meta-cache/buzz-meta-cache.js", requires:["array-extras", "base-build", "jsonp", "jsonp-url"]},
      "buzz-player-trends": { path: "buzz-player-trends/buzz-player-trends.js", requires: ["array-invoke", "base-build", "event-mouseenter", "prettify-number", "transition", "widget", "widget-node-builder", "widget-parent", "widget-child", "widget-stdmod"], skinnable: true },
      "buzz-poller": { path: "buzz-poller/buzz-poller.js", requires: ["base-build", "base-base", "datasource-get", "querystring-stringify-simple"] },
      "buzz-stream": { path: "buzz-stream/buzz-stream2.js", requires: ["array-extras", "base-build", "date", "json-stringify", "stylesheet", "twitter-linkify", "widget", "widget-child", "widget-node-builder", "widget-parent", "widget-stdmod"] },
      "buzz-tabview": { path: "buzz-tabview/buzz-tabview.js", requires: ["base-build", "buzz-meta-cache", "buzz-poller", "buzz-stream", "buzz-player-trends", "buzz-trending-topics", "tabview", "widget-stdmod"] },
      "buzz-tabview-sb-skin": { fullpath: nfl.constants.STYLE_PATH + "/styles/superbowl/46/buzz-tabview-sb-skin/buzz-tabview-sb-skin.css", type: "css" },
      "buzz-trending-topics": { path: "buzz-trending-topics/buzz-trending-topics.js", requires: ["base-build", "stylesheet", "widget", "widget-node-builder", "widget-child", "widget-parent", "widget-stdmod", "prettify-number"] },
      "buzz-watermark": { path: "buzz-watermark/buzz-watermark.js", requires: ["buzz-stream"] },
      "buzz-widget": { path: "buzz-widget/buzz-widget.js", requires: ["base-build", "buzz-meta-cache", "buzz-stream", "buzz-poller", "buzz-player-trends", "buzz-trending-topics", "widget", "widget-node-builder", "widget-stdmod"] },
      "buzz-widget-sb-skin": { fullpath: nfl.constants.STYLE_PATH + "/styles/superbowl/46/buzz-widget-skin/buzz-widget-skin.css", type: "css"},
      
			"comment-styles": { fullpath: nfl.constants.STYLE_PATH + '/styles/comments.css', type: 'css'},
			"commentform": { path: 'sitelife.commenting-yui.js', requires: ['base', 'pluckbatcher', 'plugin', 'nfl-user', 'substitute'] },
			"commentlist": { path: 'sitelife.commenting-yui.js', requires: ['base', 'widget', 'pluckbatcher', 'substitute', 'nfl-lang', 'array-extras', 'event-delegate', 'nfl-user', 'date', 'report-form', 'smoothlyresizingboxplugin'] },
			"commentmodule": { path: 'sitelife.commenting-yui.js', requires: ['base', 'widget', 'commentform', 'commentlist', 'commentsorter', 'nfl-pagination', 'comment-styles', "nfl-omniture"] },
			"commentsorter": { path: 'sitelife.commenting-yui.js', requires: ['base', 'widget', 'commentlist', 'event-delegate'] },
			"customscrollbar": { path: 'global/customscrollbar.js', requires: ["plugin", "node", 'dd-constrain', 'event-mousewheel', 'event-mouseenter', 'anim-scroll'] },
			"data-teams": { path: "data-teams/data-teams.js", requires: ["base"]},
			"datasource-randomize": { path: 'global/datasource-extras.js', requires: ['oop','datasource','datasource-io','datasource-local','datasource-polling']},
			"datasource-incrementable": { path: 'global/datasource-extras.js', requires: ['oop','datasource','datasource-local','datasource-polling']},
			"datasource-get-multi": { path: 'global/datasource-extras.js', requires: ['base-generate','datasource-polling','datasource-randomize', 'datasource-get','event-custom']},
			"datasource-io-multi": { path: 'global/datasource-extras.js', requires: ['base-generate','datasource-polling','datasource-randomize', 'datasource-io','event-custom']},
			"date": { path: "global/date.js" },
			"fantasy-user": { path: "global/fantasy-user.js" },
			"fantasy-landing": { path: "fantasy/fantasy.js" },
			"geocode": { path: "geocode/geocode.js", requires: ["event-custom", "io"]},
			'modal-video' : { path: 'modal-video/modal-video.js', requires: ['base-build', 'anim', 'widget', 'widget-position', 'widget-position-align', 'widget-stack', 'nfl-video', "transition"]},
			"netsession-installer": { path: 'global/video.js', requires: ['akamai-dlm', 'base', 'widget', 'widget-position', 'widget-position-align', 'widget-stack']},
			'netsession-window': { path: 'videos/downloader.js', requires: ['akamai-dlm', 'base-build', 'widget']},
			"nfl-ad": { path: "nfl-ad/nfl-ad.js", requires: ["base-build", "plugin", "widget"] },
			'nfl-ads': { path: 'global/decorator.js', requires: ['node', 'array-extras', 'base', 'querystring', 'nfl-lang', 'substitute']  },
			'ads-v2': { path: 'global/ads.js', requires: ['event','node', 'widget','plugin','array-extras', 'base', 'substitute']  },
			'nfl-carousel': { path: 'global/nfl.js', requires: ['plugin', 'base-build', 'nfl-lang', 'array-extras'], optional: 'anim'  },
			'nfl-centerpiece': { path: 'global/nfl.js', requires: ['node', 'anim', 'widget', 'base-build', 'nfl-lang', 'nfl-carousel', 'nfl-subnav' ], optional: ['nfl-video']  },
			'nfl-ddn': { path: 'global/decorator.js', requires: ['event-mouseenter', 'node', 'widget', 'anim'] },
			'nfl-header': { path: 'global/decorator.js', requires: ['nfl-ddn', "nfl-sign-in-links", 'nfl-fantasy-myteams', 'nfl-searchbox', 'base', 'node', 'swf', 'nfl-user', 'array-extras']  },
			'nfl-headlines': { path: 'global/nfl.js', requires: ['array-extras', 'widget', 'node', 'nfl-subnav', 'base-build', 'nfl-lang', 'sitelife', 'substitute']  },
			'nfl-iframe': { path: 'global/nfl.js', requires: ['plugin', 'base-build', 'node', 'io'] },
			'nfl-lang': { path: 'global/nfl.js', requires: ['querystring']  },
			'nfl-fantasy-myteams': { path: 'global/decorator.js', requires: ['nfl-template-plugin', 'nfl-user', 'base']  },
			'nfl-module-css': {fullpath: nfl.constants.STYLE_PATH +'/styles/2010/module.css',type:'css'},
			'nfl-news-articletools':{ path: 'news/articles.js', requires: ["anim", "array-extras", "base", "event-mouseenter", "io-form", "nfl-carousel", "nfl-pagination", "plucksdk", "sitelife", "substitute", "widget"] },
			'nfl-news-headlines':{ path: 'deprecated/nfl-news-headlines.js', requires: ['array-extras', 'widget', 'node', 'base-generate', 'sitelife', 'substitute','event-custom']},
			'nfl-omniture': { path: 'nfl-omniture/nfl-omniture.js', requires: ['base', 'node', 'event-delegate', 'querystring-parse'] },
			'nfl-pagination': { path: 'global/nfl.js', requires: ['plugin', 'base-build', 'nfl-lang']  },
			'nfl-player-card':{ path: 'global/player-card.js', requires: ['event-custom','widget','node','base','io','nfl-module-css']},
			'nfl-searchbox': { path: 'global/decorator.js', requires: ['widget', 'base-build'] },
			'nfl-ss-events-css': {fullpath: nfl.constants.STYLE_PATH +'/styles/ss-events.css',type:'css'},
			"nfl-share": { path: 'global/share.js', requires: ["widget", "base-generate", 'event-delegate', "nfl-lang", 'array-extras'] },
			'nfl-share-widget': { path: 'global/share.js', requires: ["widget", "base-generate", 'nfl-share', 'event-delegate', "nfl-lang", 'array-extras'] },
			"nfl-sign-in-links": { path: "nfl-sign-in-links/nfl-sign-in-links.js", requires: ["array-extras", "base-build", "nfl-user", "substitute", "widget"], skinnable: true },
			'nfl-spotlight': { path: 'nfl-spotlight/nfl-spotlight.js', requires: ["nfl-pagination", "node", "transition", "pluck-comment-counts"] },
			'nfl-subnav': { path: 'global/nfl.js', requires: [ 'node', 'plugin', 'base-build', 'classnamemanager', 'array-extras' ], optional: ['nfl-history-manager']  },
			"nfl-user-fantasy": { path: "global/fantasy-user.js", requires: ['plugin', 'base-generate', 'datasource-get','datasource-polling','datasource-randomize','datasource-get-multi'] },
			'nfl-template': { path: 'deprecated/nfl-template.js', requires: ['node', 'substitute', 'plugin', 'base-build'] },
			'nfl-template-plugin': { path: 'global/nfl.js', requires: ['node', 'substitute', 'plugin', 'base-build'] },
			'nfl-user': { path: 'global/nfl.js', requires: ['array-extras', 'base-build', 'cookie', 'querystring', 'datasource-local', 'datasource-get', 'nfl-lang']  },
			'nfl-subscriptions': { path: 'global/nfl.js', requires: ['array-extras', 'base-build', 'cookie','datasource-get', 'nfl-lang','nfl-user']},
			"nfl-video": { path: 'global/video.js', requires: ['base', 'widget', 'swf', 'plugin', 'nfl-omniture', 'event-custom', 'array-extras', 'substitute', 'transition', 'querystring-parse'] },
			'nfl-video-html5': {
				path: 'global/video-html5.js',
				requires: ['nfl-video-html5-styles','base','plugin','node','json-parse','widget','dd-drag','dd-constrain','dd-proxy','cookie','array-extras', 'event-custom', 'substitute','datasource-io','datasource-local','dataschema-xml', 'dataschema-json'],
				condition: {
					trigger: 'nfl-video',
					test: function (Y) {
						return Y.UA.ipad || Y.UA.android >= 3 || true;
					},
					when: 'before'
				}
			},
			'nfl-video-html5-styles': {fullpath: nfl.constants.STYLE_PATH + '/styles/video-html5.css', type: 'css'},
			'node-getouterhtml': { path: 'yui/node-getouterhtml', requires: ['node']},
			"node-parallax": { path: "node-parallax/node-parallax.js", requires: ["node", "node-screen", "plugin", "base-build"] },
			"photoessay": { path: 'photoessay/photoessay.js', requires: ['widget','widget-parent', 'widget-child', 'transition', 'nfl-omniture', 'querystring-stringify-simple'], skinnable: true },
			'photoessay-history': {
				path: 'photoessay-history/photoessay-history.js',
				requires: ['history-hash', 'querystring-stringify-simple'],
				condition: {
					trigger: 'photoessay',
					test: function (Y) {
						return Y.UA.ie !== 7;
					},
					when: 'after'
				}
			},
			'photoessay-history-ie': {
				path: 'photoessay-history-ie/photoessay-history-ie.js',
				requires: ['querystring-stringify'],
				condition: {
					trigger: 'photoessay',
					test: function (Y) {
						return Y.UA.ie === 7;
					},
					when: 'after'
				}
			},
			"pluck-comment-counts": { path: "pluck-comment-counts/pluck-comment-counts.js", requires: ["base-build", "base-base", "node", "plucksdk"] },
			"pluck-helper": { path: "pluck-helper/pluck-helper.js"},
			'pluckbatcher': { path: 'sitelife.commenting-yui.js', requires: ['plucksdk']},
			"plucksync": { path: 'sitelife.commenting-yui.js', requires: ['array-extras', 'pluckbatcher'] },
			"prettify-number": { path: "prettify-number/prettify-number.js" },
			'prototype-compat': { path: 'global/prototype-compat.js', requires: ['node', 'array-extras', 'querystring'] },
			"report-form": { path: 'sitelife.commenting-yui.js', requires: ['base', 'pluckbatcher', 'widget', 'substitute'] },
			'retweet-button': { path: "global/twitter.js", requires: ['node','plugin', 'twitteranywhere','nfl-constants','base-generate'] },
			'scoreboard': { path: 'global/scoreboard.js', requires: ['scoreboard-css','base','oop','json-parse','widget','datasource-io','datasource-polling','datasource-randomize','dataschema-xml','substitute','array-extras','event-custom']},
			'scoreboard-css':{fullpath: nfl.constants.STYLE_PATH +'/styles/scoreboard.css',type:'css'},
			"scorestrip-factory": {},
			"scorestrip": { path: 'scorestrip/scorestrip.js', requires: ["base-build", "node-screen", "widget", "widget-parent", "widget-child", "substitute", "array-extras", "transition", "datasource-io", "dataschema-xml", "querystring", "json-stringify"], skinnable: true,
				condition: {
					name: "scorestrip",
					trigger: "scorestrip-factory",
					test: function (Y) {
						return !nfl.constants.SS_TYPE || (nfl.constants.SS_TYPE != 'PLAYOFF' && nfl.constants.SS_TYPE != 'PRO' && nfl.constants.SS_TYPE != 'SB');
					},
					when: "instead"
				}
			},
			"scorestrip-playoff": { path: 'scorestrip-playoff/scorestrip-playoff.js', requires: ["base-build", "node-base", "scorestrip"], skinnable: true,
				condition: {
					name: "scorestrip-playoff",
					trigger: "scorestrip-factory",
					test: function (Y) {
						return nfl.constants.SS_TYPE && nfl.constants.SS_TYPE == 'PLAYOFF';
					},
					when: "instead"
				}
			},
			"scorestrip-event": { path: 'scorestrip-event/scorestrip-event.js', requires: ['base-build', 'node-base', 'node-screen', 'widget','async-queue','datasource-io','json-parse','datasource-polling','datasource-randomize','dataschema-xml','substitute','array-extras','transition'], skinnable: true,
				condition: {
					name: "scorestrip-event",
					trigger: "scorestrip-factory",
					test: function (Y) {
						return nfl.constants.SS_TYPE && (nfl.constants.SS_TYPE == 'PRO' || nfl.constants.SS_TYPE == 'SB');
					},
					when: "instead"
				}
			},
			"scorestrip-iframe": {
				path: "scorestrip-iframe/scorestrip-iframe.js",
				requires: ["base-build", "widget-base", "node-screen", "event-base"],
				skinnable: true,
				condition: { /* passing trigger module as an array doesn't work only for partner page for some reason */
					trigger: (nfl.constants.SS_TYPE == 'PRO' || nfl.constants.SS_TYPE == 'SB') ? "scorestrip-event" : (nfl.constants.SS_TYPE == 'PLAYOFF' ? "scorestrip-playoff" : "scorestrip"),
					test: function (Y) {
						var loc = Y.config.win.location,
							url = nfl.constants.SITE_URL;
						return url && [loc.protocol, loc.host].join("//") !== url && loc.pathname !== "/partner/scorestrip";
					},
					when: "instead"
				}
			},
			"sitelife": { path: 'sitelife-yui.js', requires: ['pluck', 'event-custom','substitute', 'array-extras'] },
			"sitelife-commenting": { path: 'sitelife.commenting-yui.js', requires: ['plucksdk','base','event-custom', 'nfl-omniture']},
			"smoothlyresizingboxplugin": { path: 'sitelife.commenting-yui.js', requires: ['base', 'node', 'plugin', 'transition', 'array-extras'] },
			'test-target': { path: 'analytics/mbox.js'},
			'tabview-deeplinker': {path: 'global/ui-extras.js', requires: ['plugin','history', 'base','event-custom','node']},
			"twitter": { path: "global/twitter.js" },
			"twitter-box": { path: "global/twitter.js",requires: ['node', 'widget','event','event-key','twitteranywhere'] },
			"twitter-linkify": { path: "twitter-linkify/twitter-linkify.js" },
			"twitter-feed": { path: "global/twitter.js", requires: ['date', 'widget','twitter-linkify', 'json', 'substitute','io','datasource-io','datasource-randomize','datasource-polling','base-generate'] },
			"ui-extras": { path: 'global/ui-extras.js' },
			"ui-scrollbar": { path: 'global/ui-extras.js', requires: ['plugin', 'base-generate','slider','event','event-custom','node','async-queue']},
			"ui-scrollable": {path: 'global/ui-extras.js', requires: ['plugin','base','node','array-extras']},
			"ui-tabset": { path: 'global/ui-extras.js', requires: ['plugin', 'base-generate','event-custom','node']},
			'node-loader': { path: 'global/ui-extras.js', requires: ['plugin', 'base','event-custom','node','datasource-io']},
			"video-thumbnailer": { path: 'video-thumbnailer/video-thumbnailer.js', requires: ['base', 'widget', 'swf','nfl-omniture']},
			'widget-fold': { path: 'global/nfl.js', requires: ['widget'] },
			'nfl-xhr-centerpiece': { path: 'partners/XHR-centerpiece.js', requires: ['base','json-parse','jsonp','widget','datasource-io','dataschema-xml','substitute','array-extras','event-custom']},
			"share-bar-style": { fullpath: nfl.constants.STYLE_PATH + '/styles/share-bar.css', type: 'css'},
			"share-bar": { path: "global/share-bar.js", requires: ['base', 'widget', 'array-extras', 'share-bar-style'], optional: ['gigya-socialize']},
			"soundmanager": { path: "third-party/soundmanager2/soundmanager2-nodebug-jsmin.js", requires: ["swfdetect"]},
			"soundmanager-debug": {
				path: "third-party/soundmanager2/soundmanager2-jsmin.js",
				requires: ["swfdetect"],
				condition: {
					trigger: "soundmanager",
					test: function (Y) {
						return Y.config.win.location.search.indexOf("DEBUG") !== -1;
					},
					when: "instead"
				}
			},
			"widget-node-builder": { path: "widget-node-builder/widget-node-builder.js", requires: ["node-base"]}
		});
		
		// load prototype compat if Prototype is available
		if (window.Prototype) {
			Y.use('prototype-compat');
		}
		
		// TODO: Remove Prototype compatibility layer
		(function () {
			// if this already exists, it's because Prototype video players are on the page.
			// use those
			if (! nfl.videoPlayers) {
				nfl.videoPlayers = {};
				nfl.createVideoPlayer = function (config) {
					nfl.use('nfl-video', function (Y) {
						var video;
						config.render = "#" + config.uniqid;
						video = new Y.NFL.Video.Player(config);
						nfl.videoPlayers[video.get('uniqid')] = video;
						video.once(Y.NFL.Video.PlayerEvent.INITIALIZED, function () {
							Y.one(config.render).setStyle("visibility", "visible");
						});
					});
				};
				nfl.widgets = nfl.widgets || {};
				nfl.widgets.VideoPlayer = nfl.widgets.VideoPlayer || {};
				nfl.widgets.VideoPlayer.installNetSession = function (code) {
					nfl.use('netsession-installer', function (Y) {
						Y.NetSessionInstaller.installNetSession(code);
					});
				};
			}
		}());
		
		// TODO: remove backward compatibility
		(function () {
			nfl.bandages = nfl.bandages || {};
			nfl.bandages.IE6FooterFixes = function () { /* Yay! No more IE6 */ };

			nfl.ads = {
				createAd: function (div, params, options, Y) {
					var isPathOnly = false, hasAdDeps = false, ad;
					if(typeof options !== 'undefined'){
						if(options.pathOnly){ isPathOnly = true; }
					}
					try{
						if(typeof Y !== 'undefined' && typeof Y.NFL.Ads.Ad !== 'undefined'){ hasAdDeps = true; }
					}catch(e){ console.error(' ad dependency error',e); }
					if(hasAdDeps){
						// has access to ad code
						ad = new Y.NFL.Ads.Ad(
							Y.merge(options || {}, {
								srcNode: '#' + div,
								params: params.replace('#{tile}', '{tile}')
							})
						);
						nfl.ads.instances[ad.get('slot')] = ad;
						
						if(typeof Y !== 'undefined' && typeof Y.NFL.Ads.Ad !== 'undefined' && isPathOnly){
							return ad.getURLParams();
						}
						ad.render();
						return ad;
					}
	
					// loaded outside of yui instance with ads
					if(isPathOnly){
						console.warn('when using "returnAdPathOnly" option on ad tags in YUI only pages the ad call must appear within the nfl.use statement.');
						return false;
					}
					
					nfl.use('nfl-ads', function (Y) {
						var ad;
						try {
							ad = new Y.NFL.Ads.Ad(Y.merge(options || {}, {
								srcNode: '#' + div,
								params: params.replace('#{tile}', '{tile}')
							}));
							nfl.ads.instances[ad.get('slot')] = ad;
							ad.render();
						} catch (e) {
							console.error('ad error: ', e);
						}
						return ad;
					});
				},
				rotation: {},
				resizable: {},
				instances: {},
				tilesOnPage: function () {
					return nfl.use().Object.size(nfl.ads.instances);
				}
			};
		}());
	}
	
	if (!window.YUI) {
		document.write('<script type="text/javascript" src="' + YUI_DEPLOY_URL + '/3.4.1/build/yui/yui-min.js' + '"></script' + '>');
	}
	if (window.nfl && nfl.constants && typeof nfl.constants.SCRIPT_PATH !== "undefined") {
		setUpDependencies();
		if (window.dependencyQueue) {
			for (i = 0, l = window.dependencyQueue.length; i < l; i += 1) {
				window.dependencyQueue[i]();
			}
			window.dependencyQueue.length = 0;
		}
	}
	else {
		if (!window.dependencyQueue) {
			window.dependencyQueue = [];
		}
		window.dependencyQueue.unshift(setUpDependencies);
		document.write('<script type="text/javascript" src="' + SITE_URL + '/widget/partner/constants' + '"></script' + '>');
	}
}());

