YUI({gallery: 'gallery-2011.11.17-14-56'}).use('node', 'widget', 'gallery-carousel', 'substitute', 'json-parse', 'io', function(Y) {
	
	YUI.add('sheknows-whatshot', function(Y) {
		
		/**
		 * @class FeedItems
		 * @constructor
		 * @param {String/HTMLElement} el HTML element reference
		 * @param {Module} owner Parent object
		 */
		var FeedItems = function(el, owner) {
			this.element = el;
			this.owner = owner;
		};
		
		FeedItems.prototype = {
			/**
			 * Remove all items
			 * @method clear
			 */
			clear: function() {
				this.element.setContent('');
			},
			/**
			 * Test if any list items are present
			 * @method hasItems
			 * @return boolean
			 */
			hasItems: function() {
				return this.getItems().size() > 0;
			},
			/**
			 * Returns a list of all items
			 * @method getItems
			 * @return {NodeList}
			 */
			getItems: function() {
				return this.element.all('li');
			},
			/**
			 * Empties the element, then adds all the provided items
			 * @method setItems
			 */
			setItems: function(items) {
				this.clear();
				for (var i = 0, len = items.length; i<len; i++) {
					if (items[i].tagName && items[i].tagName.toUpperCase() == 'LI') {
						this.element.appendChild(items[i]);
					}
					else {
						this.addItem(items[i]);
					}
				}
			},
			/**
			 * Add an item to the list
			 * @method addItem
			 */
			addItem: function(data) {
				var li,
					tmpl = this.owner.get('itemTemplate'),
					maxLength = this.owner.get('maxLength');
						
				if (!data.text && data.title) {
					data.text = data.title;
				}
	
				if (data.text.length > maxLength) {
					data.text = data.text.substr(0, maxLength - 3).replace(/\s+\S{0,2}$/,'') + '...';
				}
				
				li = Y.Node.create('<li>' + Y.Lang.sub(tmpl, data) + '</li>');
	
				this.element.appendChild(li);
			}
		};
		
	    function WhatsHot(element, config) {
		    this.element = Y.one('#' + element);
	        WhatsHot.superclass.constructor.call(this, config);
	    }
	    
	    WhatsHot.NAME = 'whatsHot';
	    
	    WhatsHot.ATTRS = {
		    extended : {
				value: false,
				validator: Y.Lang.isBoolean
			},
			isCircular : { 
				value: true,
				validator: Y.Lang.isBoolean
			},
			itemTemplate : {
				value: '<a href="{url}">{text}</a>'
			},
			footerLink: {
				setter: function(value) {
					if (!this._footerLink) {
						this._footerLink = this.footer.one('a');
					}
					this._footerLink.setAttribute('href', value.url);

					if (!this._footerTitle) {
						this._footerTitle = this._footerLink.one('em');
					}
					this._footerTitle.setContent(value.text);
				}
			},
			title : {
				setter: function(value) {
					if (!this._title) {
						this._title = this.element.one('h2');
					}
					this._title.setContent(value);
				}
			},
			limit : {
				value: 7,
				validator: Y.Lang.isNumber
			},
			prefix : {
				value: ''
			},
			maxLength: {
				value: 30,
				validator: Y.Lang.isNumber,
				getter: function(varName, value) {
					if (!this._maxLength) {
						this._maxLength = value;
						if (this.body.ancestor('.subchannel-layout')) {
							this._maxLength = 41;
						}
					}
					return this._maxLength;
				}
			}
		};
	    
	    Y.extend(WhatsHot, Y.Widget, {
			_carousel: null,
			_feedItems: null,
			_initialLoad: true,
			
			cache: {},
			
			handleSuccessResponse: function(id, response, argument) {
				
				try {
					var data = Y.JSON.parse(response.responseText);
					
					this.updateState(data.results, argument);
				}
				catch (e) {
					// failed to load correct data
					//alert(e.message);
				}
				
			},
			
			updateState: function(items, link) {
				this.set('footerLink',{
					url: link.getAttribute('href'),
					text: link.getContent()
				});
	
				if (this.get('extended')) {
					this.set('title', link.getContent());
				}
	
				if (items) {
					if (items.length > this.get('limit')) {
						items = items.slice(0, this.get('limit'));
					}
					this._feedItems.setItems(items);
					link._feedItems = items;
				}
			},
	
			onItemSelected: function() {
				var index = this._carousel.get('selectedItem'),
					el = this._carousel.getElementForItem(index),
					link = el.one('a');
					
				if (this._initialLoad == true && this._feedItems.hasItems()) {
					this._initialLoad = false;
					
					link._feedItems = Array.prototype.slice.call(this._feedItems.getItems());
					
					return true;
				}
				
				this._initialLoad = false;
				
				if (link._feedItems && Y.Lang.isArray(link._feedItems)) {
					return this.updateState(link._feedItems, link);
				}			 
				try {
					var rawItems = link.getAttribute('data-items');
					if (rawItems && rawItems.length > 0) {
						var items = Y.JSON.parse(rawItems);
	
						return this.updateState(items, link);
					}
				}
				catch (e) {
					// just continue on
					// alert(e.message);
				}
				
				Y.io(
					link.getAttribute('data-feed'),
					{
						on: {
							success: this.handleSuccessResponse
						},
						context: this,
						arguments: link
					}
				);
			},
			
			renderUI: function() {
				var children; 
				
				this.footer = this.element.one('.ft');
				this.header = this.element.one('.hd');
				this.body = this.element.one('.bd');
				
				children = this.body.get('children');
				this.elCarousel = children.item(0);
				this.elList = children.item(1);
	
				this._feedItems = new FeedItems(this.elList, this);
	
				/*
						Carousel widget showing Sub-Channel list
				*/
				this._initCarousel(this.elCarousel);
				
				this.element.one('.yui-carousel').setStyle('visibility', 'visible');
			},
			
			_initCarousel: function(el) {
				this._carousel = new Y.Carousel({
					boundingBox: el,
					contentBox: el.one('ol'),
					numVisible: 2,
					isCircular: this.get('isCircular'),
					hidePagination: false,
					width: 217
				});
				
				el.all('a').each(function(el) {
					el.on('click', function(evt) { evt.preventDefault(); });
				});
	
				this._carousel.on('itemSelected', this.onItemSelected, this);
				this._carousel.render();
				
				el.setStyle('width', '');
				el.setStyle('height', '');
				
				this._carousel.set('selectedItem', 0);
				
				if (this._carousel.get('numItems') > this._carousel.get('numVisible')) {
					this._carousel.get('contentBox').setStyle('marginLeft', '14px');
				}
				this.onItemSelected();
			}
	    });
	    
	    Y.WhatsHot = WhatsHot;
    
    }, '1.0', {requires:['node', 'widget', 'gallery-carousel', 'substitute', 'json-parse', 'io']});
    
});YUI({gallery: 'gallery-2011.11.17-14-56'}).use('node', 'widget', 'gallery-carousel', 'overlay', 'substitute', function(Y) {
	
	var startAutoPlayEvent = "startAutoPlay";
	var stopAutoPlayEvent = "stopAutoPlay";
	var completeAutoPlayEvent = "completeAutoPlay";
	var carousel, spotlight, oChildren, modules = {}, curModule;
	
	var autoScroll = function () {
		var index, currIndex = this.get('selectedItem');
			
		if (currIndex >= this.get("numItems") - 1) {
			index = 0;
		} else {
			index = currIndex + 1;
		}
		this.scrollTo(Math.floor(index / this.get('numVisible')) * this.get('numVisible'));
		this.set('selectedItem', index);
		this.fire(completeAutoPlayEvent);
	}
	
	var createCarousel = function (el, userConfig) {
		if (!createCarousel.module) {
			var Carousel = function(userConfig) {
				Carousel.superclass.constructor.call(this, userConfig);
			};
			
			Carousel.NAME = 'carousel';
			
			Y.extend(Carousel, Y.Carousel, {
				
				/**
				 * Start auto-playing the Carousel.
				 *
				 * @method startAutoPlay
				 * @public
				 */
				startAutoPlay: function () {
					var self  = this,
						timer = this.get("autoPlayInterval");
						
					if (timer > 0) {
						if (!Y.Lang.isUndefined(this._autoPlayTimer)) {
							return;
						}
						this.fire(startAutoPlayEvent);
						this._autoPlayTimer = setTimeout(
							function () {
								delete self._autoPlayTimer;
								autoScroll.call(self);
							},
							timer
						);
					}
				},
	
				/**
				 * Stop auto-playing the Carousel.
				 *
				 * @method stopAutoPlay
				 * @public
				 */
				stopAutoPlay: function () {
					if (!Y.Lang.isUndefined(this._autoPlayTimer)) {
						clearTimeout(this._autoPlayTimer);
						this._autoPlayTimer = null;
						this.set("autoPlayInterval", 0);
						this.fire(stopAutoPlayEvent);
					}
				},
				
				focus: function() {
					// overrides default functionality which changes the browser
					// focus to the current carousel item
				}
				
			});
			
			userConfig.boundingBox = el;
			userConfig.contentBox = el.one('ol');
			createCarousel.module = Carousel;
		}
		return new createCarousel.module(userConfig);
	};
	
	function createOverlay(el) {
		var oOverlay = new Y.Overlay({
			srcNode:el,
			visible:false,
			context:spotlight
			//effect: { effect:Y.widget.ContainerEffect.FADE, duration:0.25 }
		});
	
		oOverlay.render();
		
		return oOverlay;
	};
	
	YUI.add('sheknows-flashpanel', function(Y) {
		
	    function FlashPanel(element, config) {
		    this.element = Y.one('#' + element);
	        FlashPanel.superclass.constructor.call(this, config);
	    }
	    
	    FlashPanel.NAME = 'flashPanel';
	    
	    Y.extend(FlashPanel, Y.Widget, {
		    
		    defaultConfig: {
				autoPlayInterval: 6000,
				numVisible: 4,
				isCircular: true,
				//animation: { speed: 0.5 },
				scrollIncrement: 1
			},
		    
			initializer: function(userConfig) {
				this._oConfig = Y.merge(this.defaultConfig, userConfig || {});
			},
			
			renderUI: function() {
				var element_children = this.element.get('children');
				
				var carousel = createCarousel(element_children.item(0), this._oConfig);
				
				var spotlight = element_children.item( element_children.size()-1 );
				oChildren = spotlight.get('children');
				
				oChildren.addClass('yui-overlay');
				
				carousel.on("itemSelected", this.carouselItemSelected, this);
				
				carousel.on(completeAutoPlayEvent, carousel.startAutoPlay);
				carousel.on("afterScroll", this._renderEvent);
		
				carousel.render();
				
				this.element.setStyle('width', '');
				
				carousel.startAutoPlay();
				
				this.element.on('click', carousel.stopAutoPlay, carousel);
				
				this.fp = carousel;
				
				Y.one(element_children.item(1)).get('children').setStyle('visibility', 'visible');
				Y.one(element_children.item(0)).setStyle('visibility', 'visible');
				
				// Why? Because if you don't then the last flash panel will be visible even though the first is selected
				this.fp.scrollTo(1);
				this.fp.scrollTo(0);
			},
			
			syncUI: function() {
				this.element.one('.yui3-carousel-content').wrap('<div class="yui3-carousel-wrapper"></div>');
			},
			
			_renderEvent: function() {
				if (this.get('boundingBox').ancestor('.subchannel-layout')) {
					this.get('boundingBox').setStyle('width', '');
				}
			},
			
			carouselItemSelected: function() {
				var index = this.fp.get('selectedItem');
				var oId = oChildren.item(index).getAttribute('id') || oChildren.item(index).generateID();
				
				if (!modules[oId]) {
					modules[oId] = createOverlay(oId);
				}
		
				// do nothing when same button is clicked twice
				if (curModule == modules[oId]) {
					return;
				}
		
				if (curModule) {
					curModule.hide();
				}
				
				curModule = modules[oId];
				
				oChildren.hide();
				oChildren.item(index).show();
				curModule.show();
				
				// Lazy load background image. Stays one ahead of current.
				var nextIndex = index + 1;
				if(nextIndex == oChildren.size()) {
					return; // First slide doesn't need class applied.
				}
				
				var nextPanel = oChildren.item(nextIndex);
				var className = 'slide_' + nextIndex;
				
				this.addSlideClass(nextPanel, className);
				
			},
			
			addSlideClass: function(elm, className)
			{
				// Add class for this slide if not set yet for lazy loading.
				if(!elm.hasClass(className))
				{
					elm.addClass(className);
				}
			}
			
	    });
	    
	    Y.FlashPanel = FlashPanel;
    
    }, '1.0', {requires:['node', 'widget', 'gallery-carousel', 'overlay', 'substitute']});
    
});YUI().use('node', 'node-style', 'event-base', 'event-delegate', 'event-mouseenter', 'anim', 'anim-scroll', function(Y) {
	window['MainNav'] = (function () {
		var exports = {},
			prettyDate, delayExecution, action_delay = 310, page_width = 764,
			selected_channel = null,
			Templater, clearMenu, ContentManager,
			navbar, active_channel_element, menu_el, menu_items, contentbox, channel_links, slider_container, slider_panels, slider_pagination, slider_pagination, slider_pagination_buttons, scroll_animation,
			prettyDate, isTouchSupported;
		
		/*
		 * JavaScript Pretty Date
		 * Copyright (c) 2011 John Resig (ejohn.org)
		 * Licensed under the MIT and GPL licenses.
		 */
		
		// Takes an ISO time and returns a string representing how
		// long ago the date represents.
		prettyDate = function ( time ) {
			var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
				diff = (((new Date()).getTime() - date.getTime()) / 1000),
				day_diff = Math.floor(diff / 86400);
			
			if ( isNaN(day_diff) || day_diff < 0 ) {
				return;
			}
			
			return day_diff == 0 && (
					diff < 60 && "just now" ||
					diff < 120 && "1 minute ago" ||
					diff < 3600 && Math.floor( diff / 60 ) + " minutes ago" ||
					diff < 7200 && "1 hour ago" ||
					diff < 86400 && Math.floor( diff / 3600 ) + " hours ago") ||
				day_diff == 1 && "Yesterday" ||
				day_diff < 7 && day_diff + " days ago" ||
				day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks ago" ||
				'on ' + date.toGMTString().replace(/\s\d{2}:.*/, '');
		};
		
		isTouchSupported = function ( eventName ) {
			var el = document.createElement('div');
			el.onclick = function(){};
			
			var isSupported = ('ontouchstart' in el);
			
			if (!isSupported) {
				el.setAttribute(eventName, 'return;');
				isSupported = typeof el[eventName] == 'function';
			}
			
			el = null;
			
			return isSupported;
		};
		
		delayExecution = (function () {
			
			var delay_timer = null;
			
			return function ( target_function, delay, target_args, context ) {
				
				if ( delay_timer !== null ) {
					clearTimeout( delay_timer );
					delay_timer = null;
				}
				
				if ( target_args instanceof Array === false ) {
					if ( typeof target_args !== 'undefined' ) {
						target_args = [target_args];
					} else {
						target_args = [];
					}
				}
				
				delay_timer = setTimeout(
					(function () {
						target_function.apply( context, target_args );
					}),
					delay
				);
				
			};
			
		})();
		
		Templater = (function () {
			
			var templates = {}, formatters = {};
			
			/** TEMPLATES **/
			
			templates.ArticleColumn = '<a href="/tags/{{tag}}"><img src="{{header}}" /></a>\
				<ul class="article-list">\
					{{#data}}<li>\
						{{#thumbnail}}<div class="article-image"><a href="{{url}}"> <img alt="thumb" src="{{thumbnail}}"></a></div>{{/thumbnail}}\
						<a class="article-heading" href="{{url}}">{{{title}}}</a>\
						<span class="date-posted">Posted {{prettydate}}</span>\
					</li>{{/data}}\
					<li class="more no-border center"><a href="/tags/{{tag}}" class="see-more-articles">View all articles &raquo;</a></li>\
				</ul>';
			
			templates.ContentList = '<h4>{{title}}</h4>\
				<ul class="article-list">\
					{{#data}}<li><a href="{{url}}">{{{title}}}</a></li>{{/data}}\
				</ul>';
			
			templates.Contests = '<h4>Contests</h4>\
				<a href="/contests/category/{{category}}" class="subtitle">{{human_category}}</a>\
				<ul class="article-list">\
					{{#data}}\
						<li>\
							{{#thumbnail}}<div class="article-image"><a href="{{url}}"><img alt="thumb" src="{{thumbnail}}"></a></div>{{/thumbnail}}\
							<a href="{{url}}" class="article-heading">{{{title}}}</a>\
							<span class="date-posted">Posted {{prettydate}}</span>\
						</li>\
					{{/data}}\
					<li class="bottom no-border"><a href="#" data-page="{{page}}" data-category="{{category}}" class="load-more-contests">See more contests</a><a href="/contests" class="see-more-contests">View all contests &raquo;</a></li>\
				</ul>';
			
			templates.Dare = '<h4>Dare</h4>\
			<a href="{{channel_link}}" class="subtitle">{{channel_name}}</a>\
				{{#data}}<div class="dares-container">\
					<img src="http://cdn.womensunitedonline.com/{{dirname}}/s/{{basename}}" style="float: left"/><p>{{{title}}}</p>\
					<a href="/dares/{{id}}/{{slug}}" class="button">Go</a>\
				</div>{{/data}}';
			
			templates.EditorsPick = '{{#data}}<h4>Editor\'s Pick</h4>\
				<a class="subtitle" href="{{url}}">{{{title}}}</a>\
				<div class="editor-img"><a href="{{url}}"><img src="http://cdn.womensunitedonline.com/{{dirname}}/{{basename}}"></a></div>{{/data}}';
			
			templates.ExternalLink = '{{#data}}<h4>{{{title}}}</h4>\
				<ul class="feed-item center">\
					<li class="image-container"><a href="{{url}}"><img src="http://cdn.womensunitedonline.com/{{dirname}}/{{basename}}"></a></li>\
					<li><p class="description"><a href="{{url}}">{{blurb}}</a></p></li>\
					<li class="nav-more more"><a href="{{url}}">Visit website &raquo;</a></li>\
				</ul>{{/data}}';
			
			templates.Featured = '{{#content_feed}}<h4>{{title}}</h4>{{/content_feed}}\
				{{#data}}<div class="editor-img"><a href="{{url}}"><img src="http://cdn.womensunitedonline.com/{{dirname}}/{{basename}}"></a></div>{{/data}}';
			
			templates.Galleries = '<h4>Galleries</h4>\
				<ul class="nav-photo-gallery">\
				{{#galleries}}{{#Gallery}}\
				<li>\
					<a class="gallery-image" href="{{url}}"><img src="{{thumbnail}}" border="0" alt="{{title}}"></a>\
					<a class="gallery-title" href="{{url}}">{{{title}}</a>\
					<a class="gallery-number" href="{{url}}">({{photo_count}} photos)</a>\
				</li>\
				{{/Gallery}}{{/galleries}}\
				</ul>';
			
			templates.GiftGuide = '<h4>Gift Guides</h4>\
				<a class="subtitle" href="{{channel_url}}">{{{channel_title}}}</a>\
				<ul class="nav-photo-gallery">\
				{{#data}}\
				<li>\
					<a class="gallery-image" href="{{url}}"><img src="http://cdn.womensunitedonline.com/{{dirname}}/view/{{basename}}" border="0" alt="{{title}}"></a>\
					<a class="gallery-title" href="{{url}}">{{{title}}</a>\
				</li>\
				{{/data}}\
				</ul>\
				<div class="view-all more">\
					<a href="{{channel_url}}" class="view-all">View all &raquo;</a><br />\
				</div>';
			
			templates.LatestArticles = '<h4>Latest Articles</h4>\
				<a href="{{channel_link}}" class="subtitle">{{channel_name}}</a>\
				<ul class="article-list">\
				{{#articles}}{{#Article}}<li>\
				{{#image_115x115}}<div class="article-image"><a href="{{url}}"> <img alt="thumb" src="{{image_115x115}}"></a></div>{{/image_115x115}}\
				<a href="{{url}}" class="article-heading" title="{{title_full}}">{{{title}}}</a>\
				<span class="date-posted">Posted {{prettydate}}</span>\
				</li>{{/Article}}{{/articles}}\
				<li class="bottom no-border"><a href="#" data-page="{{page}}" data-channel="{{channel_url}}" class="load-more-articles">See more articles</a><a href="{{channel_link}}" class="see-more-articles">View all articles &raquo;</a></li>\
				</ul>';
			
			templates.Printable = '<h4>Printables</h4>\
				<a class="subtitle" href="{{channel_url}}">{{{channel_title}}}</a>\
				<ul class="nav-photo-gallery">\
				{{#data}}\
				<li>\
					<a class="gallery-image" href="{{url}}"><img src="http://cdn.womensunitedonline.com/{{dirname}}/thumb/{{basename}}" border="0" alt="{{title}}"></a>\
					<a class="gallery-title" href="{{url}}">{{{title}}</a>\
				</li>\
				{{/data}}\
				</ul>\
				<div class="center more"><a class="view-all" href="/kids-activity-center/coloring-pages">View all printables &raquo;</a></div>';
			
			/*
			templates.Poll = '{{#data}}<h4>Poll</h4><strong></strong>">\
					<img src="http://cdn.womensunitedonline.com/{{dirname}}/{{basename}}" />\
					<div>\
						<span class="title">{{{title}}}</span>\
						<span class="blurb">{{{blurb}}}</span>\
					</div></a>{{/data}}';
			*/
			
			templates.Quiz = '<h4>Quizzes</h4>\
				<ul>\
				{{#data}}\
				<li>\
					<p class="question"><a href="/{{channel}}/quizzes/{{slug}}">{{{title}}}</a></p>\
				</li>\
				{{/data}}\
				</ul>\
				<div class="center no-border more">\
					<a href="/quizzes" class="view-all">View all quizzes &raquo;</a><br />\
				</div>';
			
			templates.StealTheLook = '{{#data}}<h4>Steal the Look</h4>\
					<a class="subtitle" href="/steal-the-look/{{type}}">{{{type}}}</a>\
					<a href="/steal-the-look/{{type}}/{{slug}}">\
					<img src="http://cdn.womensunitedonline.com/{{dirname}}/{{basename}}" />\
					<div>\
						<span class="title">{{{title}}}</span>\
						<span class="blurb">{{{blurb}}}</span>\
					</div></a>{{/data}}';
			
			templates.SKTVShow = '{{#data}}<ul class="nav-videos" data-feed="{{rssfeed}}" data-thumbnail="http://cdn.womensunitedonline.com/{{video_dirname}}/{{video_basename}}">\
					<li class="image-container">\
							<a href="{{url}}"><img src="{{logo}}" border="0"></a>\
					</li>\
					<li class="video-container">\
							<p class="title"><a href="{{url}}">{{video_title}}</a></p>\
							<div class="insertvideo"></div>\
					</li>\
					<li class="center more">\
						<a href="{{url}}" class="view-all">See all episodes &raquo;</a><br />\
					</li>\
				</ul>{{/data}}';
			
			templates.Videos = '{{#data}}<h4>Watch</h4>\
				<ul class="nav-videos">\
					<li class="video-container">\
						<object id="videoplayer_' + (player_id = Math.ceil(Math.random() * 10000)) + '" class="SpringboardPlayer" type="application/x-shockwave-flash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" height="115" width="180">\
							<param name="movie" value="http://cdn.springboard.gorillanation.com/mediaplayer/springboard/mediaplayer.swf?config={\'externalConfiguration\':\'http://cdn.springboard.gorillanation.com/superconfig/sk038.js\',\'playlist\':\'{{rssfeed}}?limit=1\'}">\
							<param name="allowFullScreen" value="true">\
							<param name="allowscriptaccess" value="always">\
							<param name="wmode" value="transparent">\
							<param name="autoplay" value="true">\
							<embed src="http://cdn.springboard.gorillanation.com/mediaplayer/springboard/mediaplayer.swf?config={\'externalConfiguration\':\'http://cdn.springboard.gorillanation.com/superconfig/sk038.js\',\'playlist\':\'{{rssfeed}}?limit=1\'}" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" height="115" width="180">\
						</object>\
						<p class="description"><a href="{{url}}">{{video_title}}</a></p>\
					</li>\
					<li class="image-container">\
							<a href="{{url}}"><img src="{{logo}}" border="0"></a>\
							<p class="description"><a href="{{url}}">{{description}}</a></p>\
					</li>\
				</ul>{{/data}}';
			
			/** FORMATTERS **/
			
			formatters.defaultFormatter = function ( module, channel ) {
				return Mustache.to_html(
					templates[module['name']],
					{
						data: module['data'],
						channel_name: channel.channel_name,
						channel_link: channel.articles_url
					}
				);
			};
			
			formatters.ArticleColumn = function ( module, channel ) {
				var i, articles = module['data'];
				channel = module.Channel || channel;
				
				for ( i = 0; i < articles.length; i++ ) {
					// Remove any images after the first article
					if ( i != 0 ) {
						articles[i].thumbnail = null;
						delete articles[i].thumbnail;
					}
					// Compute "pretty date"
					articles[i].prettydate = prettyDate( articles[i].date_active );
				}
				return Mustache.to_html(
					templates.ArticleColumn,
					{
						data: articles,
						tag: module['tag'],
						header: module['header']
					}
				);
			};
			
			formatters.ContentList = function ( module, channel ) {
				return Mustache.to_html(
					templates.ContentList,
					{
						category: module['category'],
						title: module['title'],
						data: module['data']
					}
				);
			};
			
			formatters.Contests = function ( module, channel ) {
				var i, contests = module['data'];
				for ( i = 0; i < contests.length; i++ ) {
					// Compute "pretty date"
					contests[i].prettydate = prettyDate( contests[i].start_date );
				}
				
				return Mustache.to_html(
					templates.Contests,
					{
						category: module['category'],
						human_category: module['human_category'],
						data: contests,
						page: module['page']
					}
				);
			};
			
			formatters.Featured = function ( module, channel ) {
				return Mustache.to_html(
					templates.Featured,
					{
						data: module['data'],
						content_feed: module['ContentFeed'],
						channel_name: channel.channel_name,
						channel_link: channel.articles_url
					}
				);
			};
			
			formatters.Galleries = function ( module, channel ) {
				var i,
					galleries = module['data'];
				for ( i = 0; i < galleries.length; i++ ) {
					// Move image into [Gallery] block
					galleries[i].Gallery.thumbnail = 'http://cdn.womensunitedonline.com/filter/s/gallery/' + galleries[i].Image.Image.basename;
					// Move image count into [Gallery] block
					galleries[i].Gallery.photo_count = galleries[i].Image.Album.albums_image_count;
				}
				return Mustache.to_html(
					templates.Galleries,
					{
						galleries: galleries,
						channel_name: channel.channel_name
					}
				);
			};
			
			formatters.GiftGuide = function ( module, channel ) {
				return Mustache.to_html(
					templates[module['name']],
					{
						data: module['data'],
						channel_title: module['channel_title'],
						channel_url: module['channel_url'],
						channel_name: channel.channel_name,
						channel_link: channel.articles_url
					}
				);
			};
			
			formatters.LatestArticles = function ( module, channel ) {
				var i, articles = module['data'];
				channel = module.Channel || channel;
					
				for ( i = 0; i < articles.length; i++ ) {
					// Remove any images after the first article
					if ( i != 0 ) {
						articles[i].Article.image_115x115 = null;
						delete articles[i].Article.image_115x115;
					}
					// Compute "pretty date"
					articles[i].Article.prettydate = prettyDate( articles[i].Article.date_active );
					
					// Does title need truncating?
					articles[i].Article.title_full = articles[i].Article.title;
					if ( i !== 0 && articles[i].Article.title.length > 60 ) {
						articles[i].Article.title = articles[i].Article.title.match( /([^\s][\s\S]{0,60}(?!=[^\s]))([\s]|$)/ )[1] + '...';
					}
				}
				
				return Mustache.to_html(
					templates.LatestArticles,
					{
						articles: articles,
						page: module['page'],
						channel_name: channel.channel_name,
						channel_url: channel.url_name,
						channel_link: channel.articles_url
					}
				);
			};
			
			formatters.Printable = function ( module, channel ) {
				return Mustache.to_html(
					templates[module['name']],
					{
						data: module['data'],
						channel_title: module['channel_title'],
						channel_url: module['channel_url'],
						channel_name: channel.channel_name,
						channel_link: channel.articles_url
					}
				);
			};
			
			formatters.StealTheLook = function ( module, channel ) {
				return Mustache.to_html(
					templates.StealTheLook,
					{
						type: module['type'],
						data: module['data']
					}
				);
			};
			
			return {
				formatModule: function ( module, channel ) {
					var module_el = document.createElement( 'DIV' );
					module_el.className = module['name'] + ' ' + ( module['class'] || '' );
					if ( formatters[module['name']] ) {
						module_el.innerHTML = formatters[module['name']]( module, channel );
					} else {
						module_el.innerHTML = formatters.defaultFormatter( module, channel );
					}
					return module_el;
				}
			};
			
		})();
		
		ContentManager = (function () {
			var exports = {}, cache = {}, request = null;
			
			getContent = function ( cache_key, data_url, callback ) {
				
				var script_tag, done = false;
				
				if ( request && request.conn && request.readyState !== 4 ) {
					request.conn.abort();
				}
				
				if ( typeof cache[cache_key] !== 'undefined' ) {
					callback( cache[cache_key] );
					return;
				}
				
				data_url = 'http://cdn.womensunitedonline.com/nav/dropdown/?r=' + data_url + '&t=' + Math.floor(new Date().getTime() / 600000); // pass through cache server
				script_tag = document.createElement( 'SCRIPT' );
				script_tag.src = data_url;
				script_tag.onload = script_tag.onreadystatechange = function () {
					if ( !done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) {
						done = true;
						cache[cache_key] = ContentManager.latest_data;
					}
				}
				document.body.appendChild( script_tag );
				
			};
			
			exports.latest_data = null;
			exports.target_module = null;
				
			exports.abort = function ( ) {
				if ( request && request.conn && request.readyState !== 4 ) request.conn.abort();
			};
			
			exports.getChannelContent = function ( channel_name, callback ) {
				var cache_key = 'channels-channel:' + channel_name,
					data_url = '/nav/' + channel_name + '.js';
				
				getContent( cache_key, data_url, callback );
				
			};
			
			exports.getArticles = function ( channel_name, page, callback ) {
				
				var cache_key = 'articles-channel:' + channel_name + '-page:' + page,
					data_url = '/nav/' + channel_name + '/articles/page:' + page + '.js';
				
				getContent( cache_key, data_url, callback );
				
			};
			
			exports.getContests = function ( category_name, page, callback ) {
				
				var cache_key = 'contests-channel:' + category_name + '-page:' + page,
					data_url = '/nav/contests/' + category_name + '/page:' + page + '.js';
				
				getContent( cache_key, data_url, callback );
				
			};
			
			exports.getSKTVShow = function ( show_slug, callback ) {
				
				var cache_key = 'sktvshow-show:' + show_slug,
					data_url = '/nav/sktvshow/' + show_slug + '.js';
				
				getContent( cache_key, data_url, callback );
				
			};
			
			exports.getStealTheLook = function ( category_slug, callback ) {
				
				var cache_key = 'stealthelook-category:' + category_slug,
					data_url = '/nav/stealthelook/' + category_slug + '.js';
				
				getContent( cache_key, data_url, callback );
				
			};
			
			exports.updateModule = function ( module_index, content ) {
				
				// Remove existing module
				slider_panels.removeChild( slider_panels.get( 'children' ).item( module_index ) );
				
				// Insert new module
				slider_panels.insertBefore( content, slider_panels.get( 'children' ).item( module_index ) );
				
			};
			
			exports.whichPanelAmI = function ( element ) {
				
				var i;
				
				element;
				//&& element.get( 'parentNode' ) !== document.body
				while ( element.get( 'parentNode') !== slider_panels ) {
					element = element.get( 'parentNode' );
				}
				/*
				if ( element.parentNode === document.body ) {
					return null;
				}
				*/
				for ( i = 0; i < slider_panels.get( 'children' ).size( ); i++ ) {
					if ( slider_panels.get( 'children' ).item( i ) === element ) {
						return i;
					}
				}
				
			};
			
			exports.selectPage = function ( page, easing, duration ) {
				if ( typeof easing === 'undefined' ) {
					easing = 'easeBoth';
				}
				if ( typeof duration === 'undefined' ) {
					duration = .5;
				}
				
				// Select the clicked button
				for ( i = 1; i < slider_pagination_buttons.get( 'children' ).size( ) - 1; i++ ) {
					if ( i === page ) {
						slider_pagination_buttons.get( 'children' ).item( i ).addClass( 'selected' );
					} else {
						slider_pagination_buttons.get( 'children' ).item( i ).removeClass( 'selected' );
					}
				}
				
				// Select page
				scroll_animation.stop( false );
				scroll_animation.set( 'to.scroll.0', (page-1) * page_width );
				scroll_animation.set( 'easing', easing );
				scroll_animation.set( 'duration', duration );
				scroll_animation.run();
				
				if ( page === 1 ) {
					slider_pagination_buttons.get( 'children' ).item( 0 ).setStyle( 'opacity', '.4' );
				} else {
					slider_pagination_buttons.get( 'children' ).item( 0 ).setStyle( 'opacity', '1' );
				}
				
				if ( page === slider_pagination_buttons.get( 'children' ).size( ) - 2 ) {
					slider_pagination_buttons.get( 'children' ).item( slider_pagination_buttons.get( 'children' ).size( ) - 1 ).setStyle( 'opacity', '.4' );
				} else {
					slider_pagination_buttons.get( 'children' ).item( slider_pagination_buttons.get( 'children' ).size( ) - 1 ).setStyle( 'opacity', '1' );
				}
				
				// Check if there are any SKTV on the new page which need "onpaginate" rendering
				var feed_url, thumbnail_url, video_container;
				for ( i = 0; i < slider_panels.get( 'children' ).size( ); i++ ) {
					if ( slider_panels.get( 'children' ).item( i ).hasClass( 'SKTVShow' ) ) {
						
						feed_url = slider_panels.get( 'children' ).item( i ).one( 'ul' ).getAttribute( 'data-feed' );
						thumbnail_url = slider_panels.get( 'children' ).item( i ).one( 'ul' ).getAttribute( 'data-thumbnail' );
						
						video_container = slider_panels.get( 'children' ).item( i ).one( '.video-container .insertvideo' )
						if ( i >= (page - 1) * 3 && i < page * 3 ) {
							video_container.setContent( '<object id="videoplayer_' + (player_id = Math.ceil(Math.random() * 10000)) + '" class="SpringboardPlayer" type="application/x-shockwave-flash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" height="153" width="239">\
								<param name="movie" value="http://cdn.springboard.gorillanation.com/mediaplayer/springboard/mediaplayer.swf?config={\'externalConfiguration\':\'http://cdn.springboard.gorillanation.com/superconfig/sk038.js\',\'playlist\':\'' + feed_url + '\'}">\
								<param name="allowFullScreen" value="true">\
								<param name="allowscriptaccess" value="always">\
								<param name="wmode" value="transparent">\
								<param name="autoplay" value="true">\
								<embed src="http://cdn.springboard.gorillanation.com/mediaplayer/springboard/mediaplayer.swf?config={\'externalConfiguration\':\'http://cdn.springboard.gorillanation.com/superconfig/sk038.js\',\'playlist\':\'' + feed_url + '\'}" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" height="153" width="239">\
							</object>' );
						} else {
							video_container.setContent( '<img src="' + thumbnail_url + '" />' );
						}
						
					}
				}
				sbhtml.createSpringboards(null); // update any new video players for mobile devices
				
			};
			
			exports.selectChannelLink = function ( link_el ) {
				var i;
				for ( i = 0; i < channel_links.get( 'children' ).size( ); i++ ) {
					if ( channel_links.get( 'children' ).item( i ) === link_el.get( 'parentNode' ) ) {
						channel_links.get( 'children' ).item( i ).addClass( 'selected' );
					} else {
						channel_links.get( 'children' ).item( i ).removeClass( 'selected' );
					}
				}
			}
			
			return exports;
		})();
		
		// Deselects currently selected menu item
		clearMenu = function ( clear_color ) {
			var i;
			selected_channel = null;
			for ( i = 0; i < menu_items.size( ); i++ ) {
				if ( menu_items.item( i ).hasClass( 'selected' ) ) {
					menu_items.item( i ).removeClass( 'selected' );
					break;
				}
			}
			if ( active_channel_element ) {
				active_channel_element.addClass( 'active' );
			}
			contentbox.setStyle( 'display', 'none' );
			slider_pagination_buttons.setStyle( 'display', 'none' );
			if ( clear_color ) {
				navbar.setStyle( 'backgroundColor',  '' );
				menu_items.setStyle( 'borderLeftColor', '' );
			}
		};
		
		exports.renderMenu = function ( subnav ) {
			var i, link_item, link_el, module, page_button, modules_width = 0;
	 		
			// Make sure this menu item is what was hovered over
			for ( i = 0; i < menu_items.size( ); i++ ) {
				if ( menu_items.item( i ).hasClass( 'selected' ) ) {
					if ( menu_items.item( i ).getAttribute( 'data-menuname' ) !== subnav.Channel.url_name ) {
						return;
					}
					break;
				}
			}
			
			ContentManager.latest_data = subnav;
			
			slider_container.removeClass( 'loading' );
			selected_channel = subnav.Channel;
			if ( contentbox.getStyle( 'display' ) === 'block' && selected_channel.colors ) {
				window.navbar = navbar;
				navbar.setStyle( 'backgroundColor',  '#' + selected_channel.colors.primary );
				menu_items.setStyle( 'borderLeftColor', '#' + selected_channel.colors.darkened );
			}
			
			// Insert new links
			for ( i = 0; i < subnav.NavItems.length; i++ ) {
				// More IE fun
				link_item = document.createElement( 'LI' );
				link_el = document.createElement( 'A' );
				
				link_el.setAttribute( 'href', subnav.NavItems[i].url );
				link_el.setAttribute( 'data-title', subnav.NavItems[i].title );
				link_el.setAttribute( 'data-blurb', subnav.NavItems[i].blurb );
				link_el.setAttribute( 'data-basename', subnav.NavItems[i].basename );
				link_el.setAttribute( 'data-dirname', subnav.NavItems[i].dirname );
				
				link_span = document.createElement( 'SPAN' );
				link_span.innerHTML = subnav.NavItems[i].title;
				link_el.appendChild( link_span );
				
				link_item.appendChild( link_el );
				
				channel_links.appendChild( link_item );
			}
			
			// Insert modules
			for ( i in subnav.Modules ) {
				if ( subnav.Modules[i].name.length === 0 ) {
					continue;
				}
				
				module = Templater.formatModule( subnav.Modules[i], selected_channel );
				if ( (parseInt(i, 10) - 1) % 3 === 0 ) {
					module.className += ' middle';
				}
				slider_panels.appendChild( module );
				
				modules_width += module.offsetWidth;
				if ( modules_width % page_width === 0 ) {
					
					// Draw a pagination button
					page_button = document.createElement( 'DIV' );
					page_button.className = ( modules_width === page_width ) ? 'button selected' : 'button';
					page_button.setAttribute( 'data-page', ( modules_width / page_width ) );
					slider_pagination_buttons.insertBefore( page_button, slider_pagination_buttons.get( 'children' ).item( slider_pagination_buttons.get( 'children' ).size( ) - 1 ) );
					
				}
			}
			
			// Update slider_panels's width (for better pagination)
			slider_panels.setStyle( 'width', modules_width + 'px' );
			slider_pagination_buttons.setStyle( 'width', ( ( modules_width / page_width ) * 17 ) + ( 32 * 2 ) + 'px' ); // each pagination button is 17px, the 2 arrows are 36px each
			slider_container.set('scrollLeft', 0 );
			if ( modules_width / page_width > 1 ) {
				slider_pagination_buttons.setStyle( 'display', 'block' );
			}
			
			// Left pagination defaults to disabled
			slider_pagination_buttons.get( 'children' ).item( 0 ).setStyle( 'opacity', '.4' );
			
			ContentManager.selectPage( 1 );
		};
		
		exports.renderModule = function ( module ) {
			ContentManager.latest_data = module;
			selected_channel = module.Channel || selected_channel;
			if ( ContentManager.target_module !== null ) {
				module = Templater.formatModule ( module, selected_channel );
				if ( (ContentManager.target_module - 1) % 3 === 0 ) {
					module.className += ' middle';
				}
				
				ContentManager.updateModule( ContentManager.target_module, module );
				ContentManager.selectPage( Math.floor( ContentManager.target_module / 3 ) + 1 );
				ContentManager.target_module = null;
			}
		};
		
		exports.selectMenu = function ( menu_item ) {
			var i, menuname = menu_item.getAttribute( 'data-menuname' );
			
			// Don't change if the target channel is already selected
			if ( selected_channel && selected_channel.url_name === menuname ) return false;
			
			// Deselect all menu items & select the current one
			clearMenu();
			if ( active_channel_element ) {
				active_channel_element.removeClass( 'active' );
			}
			
			// If this isn't a drop down menu don't select it or load content
			if ( !menuname ) {
				clearMenu( true );
				return false;
			}
			
			slider_container.set( 'className', 'slider-container ' + menuname );
			menu_item.addClass( 'selected' );
			contentbox.setStyle( 'display', 'block' );
			
			// Clear out existing content
			channel_links.setContent( '' );
			slider_panels.setContent( '' );
			
			// Clear out pagination buttons
			var children_count = slider_pagination_buttons.get( 'children' ).size();
			for ( i = 0; i < children_count - 2; i++ ) {
				slider_pagination_buttons.removeChild( slider_pagination_buttons.get( 'children' ).item( 1 ) );
			}
			
			slider_container.addClass( 'loading' );
			
			// Make content request
			ContentManager.getChannelContent( menuname, MainNav.renderMenu);
		};
		
		Y.on( 'domready', function() {
			navbar = Y.one( '#navbar' );
			if (!navbar) {
				return;
			}
			active_channel_element = navbar.one( '.ui-navbaritem.active' );
			menu_el = navbar.one( '#mainnav-menus' );
			if ( menu_el === null ) {
				return;
			}
			menu_items = menu_el.all( 'li' );
			contentbox = navbar.one( '#mainnav-contentbox' );
			channel_links = contentbox.one( '.channel-links' );
			slider_container = contentbox.one( '.slider-container' );
			slider_panels = contentbox.one( '.slider-panels' );
			slider_pagination = contentbox.one( '#mainnav_pagination' );
			slider_pagination_buttons = slider_pagination.one( '#pagination_buttons' );
			scroll_animation = new Y.Anim({
				node: slider_container,
				duration: .5,
				easing: 'easeBoth',
				to: { scroll: [0, 0] }
			});
			
			// Pagination button delegation
			slider_pagination_buttons.delegate(
				'click',
				function ( e ) {
					
					var i, next_page;
					
					ContentManager.selectPage( parseInt( e.currentTarget.getAttribute( 'data-page' ), 10 ) );
					
				},
				'div.button'
			);
			
			// Pagination arrow delegation
			slider_pagination_buttons.delegate(
				'click',
				function ( e ) {
					
					var i, next_page;
						direction = this.hasClass( 'left' ) ? -1 : 1;
					
					// What page are we going to?
					for ( i = 1; i < slider_pagination_buttons.get( 'children' ).size( ) - 1; i++ ) {
						if ( slider_pagination_buttons.get( 'children' ).item( i ).hasClass( 'selected' ) ) {
							slider_pagination_buttons.get( 'children' ).item( i ).removeClass( 'selected' );
							
							next_page = i + direction;
							if ( next_page < 1 ) {
								next_page = 1;
							} else if ( next_page === slider_pagination_buttons.get( 'children' ).size( ) - 1 ) {
								next_page = slider_pagination_buttons.get( 'children' ).size( ) - 2;
							}
							break;
						}
					}
					
					ContentManager.selectPage( next_page );
					
				},
				'div.arrow'
			);
			
			// Channel links action
			channel_links.delegate(
				'mouseenter',
				function ( e ) {
					delayExecution(
						function () {
							var channel, category, show,
								url = e.currentTarget.getAttribute('href');
							
							if ( selected_channel.url_name === 'sheknowstv' ) {
								return false; // don't update modules when on the SKTV menu
							}
							
							ContentManager.abort();
							ContentManager.selectChannelLink( e.currentTarget );
								
							if ( channel = url.match( /^(\/.*\/([a-zA-Z0-9-]+)\/articles|\/channels\/([a-zA-Z0-9-_]+))/ ) ) {
								
								// Link to an article directory page
								channel = channel[2] || channel[3];
									
								if ( selected_channel.url_name !== channel ) {
									slider_panels.get( 'children' ).item( 0 ).setContent( '<img src="http://cdn.womensunitedonline.com/interface/ajaxSpinner.gif" class="loading_spinner" />' );
								}
								
								ContentManager.target_module = 0;
								ContentManager.getArticles( channel, 1, MainNav.renderModule );
								
							} else if ( category = url.match( /\/contests\/category\/(.*)/ ) ) {
								
								// Contest category page
								category = category[1];
								slider_panels.get( 'children' ).item( 0 ).setContent( '<img src="http://cdn.womensunitedonline.com/interface/ajaxSpinner.gif" class="loading_spinner" />' );
								
								ContentManager.target_module = 0;
								ContentManager.getContests( category, 1, MainNav.renderModule );
								
							} else if ( show = url.match( /\/sheknowstv\/([a-zA-Z0-9-]+)/ ) ) {
								
								// SKTV Show
								show = show[1];
								slider_panels.get( 'children' ).item( 0 ).setContent( '<img src="http://cdn.womensunitedonline.com/interface/ajaxSpinner.gif" class="loading_spinner" />' );
								
								ContentManager.target_module = 0;
								ContentManager.getSKTVShow( show, MainNav.renderModule );
								
							} else if ( category = url.match( /\/steal-the-look\/([a-zA-Z-0-9-]+)/ ) ) {
								
								// Steal the Look
								category = category[1];
								slider_panels.get( 'children' ).item( 0 ).setContent( '<img src="http://cdn.womensunitedonline.com/interface/ajaxSpinner.gif" class="loading_spinner" />' );
								
								ContentManager.target_module = 0;
								ContentManager.getStealTheLook( category, MainNav.renderModule );
								
							} else {
								
								// ContentFeed link
								ContentManager.updateModule(
									0,
									Templater.formatModule(
										{
											'name': 'ExternalLink',
											'class': 'sk-w-5',
											'data': {
												title: e.currentTarget.getAttribute( 'data-title' ),
												url: url,
												dirname: e.currentTarget.getAttribute( 'data-dirname' ),
												basename: e.currentTarget.getAttribute( 'data-basename' ),
												blurb: e.currentTarget.getAttribute( 'data-blurb' )
											}
										},
										selected_channel
									)
								);
								
							}
						},
						action_delay
					);
				},
				'li a'
			);
			channel_links.delegate(
				'mouseleave',
				function ( e ) {
					// Clear out any existing delayed calls
					delayExecution(
						function () {},
						1
					);
				},
				'li a'
			);
			
			// "Load More Articles" action
			slider_panels.delegate(
				'click',
				function ( e ) {
					var channel, next_page;
					
					e.currentTarget.addClass( 'loading' );
					
					next_page = parseInt( e.currentTarget.getAttribute( 'data-page' ), 10 ) + 1;
					
					ContentManager.target_module = ContentManager.whichPanelAmI( e.currentTarget );
					ContentManager.getArticles( e.currentTarget.getAttribute( 'data-channel' ), next_page, MainNav.renderModule );
					
					e.preventDefault();
					e.stopPropagation();
					return false;
					
				},
				'a.load-more-articles'
			);
			
			// "Load More Contests" action
			slider_panels.delegate(
				'click',
				function ( e ) {
					
					var channel, next_page;
					
					e.currentTarget.addClass( 'loading' );
					
					next_page = parseInt( e.currentTarget.getAttribute( 'data-page' ), 10 ) + 1;
					
					ContentManager.target_module = ContentManager.whichPanelAmI( e.currentTarget );
					ContentManager.getContests( e.currentTarget.getAttribute( 'data-category' ), next_page, MainNav.renderModule );
					
					e.preventDefault();
					e.stopPropagation();
					return false;
					
				},
				'a.load-more-contests'
			);
			
			// Handle menu clicks
			menu_el.all( 'a' ).on(
				'click',
				function ( e ) {
					var i, el = e.currentTarget, block_request = true, menuname = el.get( 'parentNode' ).getAttribute( 'data-menuname' );
					
					// If this is a touch/mobile device then don't follow through
					// on the click, unless the clicked on menu is already open
					if ( isTouchSupported() && menuname ) {
						
						if ( selected_channel !== null && menuname === selected_channel.url_name ) {
							block_request = false;
						}
						
						if ( block_request ) {
							
							e.preventDefault();
							e.stopPropagation();
							return false;
							
						}
					}
				}
			);
			
			// Swipe events
			(function () {
				var is_swiping = false,
					swipe_start = null,
					start_coords = { x: null, y: null },
					last_coords = { x: null, y: null },
					change = { x: null, y: null },
					preventdefault = false,
					update;
				
				update = function ( e ) {
					
					if ( preventdefault ) {
						e.preventDefault();
					}
					
					if ( !is_swiping ) {
						return false;
					}
					
					if ( last_coords.x !== null ) {
						change.x = last_coords.x - e.touches[0].pageX;
						change.y = last_coords.y - e.touches[0].pageY;
						
						slider_container.set( 'scrollLeft', slider_container.get( 'scrollLeft' ) += change.x );
					}
					
					last_coords.x = e.touches[0].pageX;
					last_coords.y = e.touches[0].pageY;
					
				};
				
				if ( isTouchSupported() ) {
					
					slider_panels.getDOMNode().addEventListener(
						'touchstart',
						function ( e ) {
							swipe_start = new Date().getTime();
							is_swiping = true;
							start_coords.x = e.touches[0].pageX;
							start_coords.y = e.touches[0].pageY;
							update( e );
						}
					);
					
					slider_panels.getDOMNode().addEventListener(
						'touchmove',
						function ( e ) {
							preventdefault = true;
							update( e );
						}
					);
					
					slider_panels.getDOMNode().addEventListener(
						'touchend',
						function ( e ) {
							var swipe_duration, direction, target_page;
							
							// Is this a flick or a real move?
							swipe_duration = new Date().getTime() - swipe_start;
							
							if ( swipe_duration <= 350 && Math.abs(last_coords.x - start_coords.x) >= 150 ) {
								// Flick action
								direction = ( last_coords.x - start_coords.x > 0 ) ? -1 : 1;
								
								// What page are we going to?
								for ( i = 1; i < slider_pagination_buttons.get( 'children' ).size( ) - 1; i++ ) {
									if ( slider_pagination_buttons.get( 'children' ).item( i ).hasClass( 'selected' ) ) {
										slider_pagination_buttons.get( 'children' ).item( i ).removeClass( 'selected' );
										
										target_page = i + direction;
										if ( target_page < 1 ) {
											target_page = 1;
										} else if ( target_page === slider_pagination_buttons.get( 'children' ).size( ) - 1 ) {
											target_page = slider_pagination_buttons.get( 'children' ).size( ) - 2;
										}
										break;
									}
								}
								ContentManager.selectPage( target_page, 'easeNone', .1 );
								
							} else {
								
								// Not a flick, normal swipe action
								// Figure out what page the user is trying to be on
								target_page = Math.round(slider_container.scrollLeft / page_width) + 1;
								ContentManager.selectPage( target_page, 'easeNone' );
								
							}
							
							is_swiping = false;
							preventdefault = false;
							last_coords.x = last_coords.y = null;
							
						}
					);
					
				}
			})();
			
			// Setup mouseenter delegation
			Y.one( '#mainnav-menus' ).delegate(
				'mouseenter',
				function ( e ) {
					delayExecution(
						exports.selectMenu,
						action_delay,
						e.currentTarget
					);
				},
				'li'
			);
			contentbox.on(
				'mouseenter',
				function ( e ) {
					// Clear out any existing delayed calls
					delayExecution(
						function () {},
						1
					);
				}
			);
			
			// Dropdown / fold up
			menu_el.on(
				'mouseleave',
				function ( e ) {
					delayExecution(
						function ( e ) {
							
							if ( !e.relatedTarget.ancestor( '.contentbox' ) ){
								clearMenu( true );
							}
						},
						action_delay,
						e
					);
				}
			);
			contentbox.on(
				'mouseleave',
				function ( e ) {
					delayExecution(
						clearMenu,
						action_delay + 50,
						true
					);
				}
			);
		});
	
		return exports;
	
	})();
});YUI.add('skui-block', function(Y) {


var js = Y.Lang,
    dom = Y.Node;

Y.namespace('skui').Block = Y.Base.create('skui-block', Y.Widget, [Y.WidgetStdMod], {

	CSS_CLASS: 'ui-block',
	
	bindUI: function() {
        var block = this,
            tmpl = block.get('itemTemplate'),
            bd = Y.Node.create("<ul></ul>");
        
        block.set('headerContent', this.createHeader(block.get('title') || " "));

        block.get('links').each(function(link) {
            bd.append(Y.substitute(tmpl, link));
        })

        block.set('bodyContent', bd);
        
        if (this.get('image')) {
            var img = this.get('image');
            
            block.addClass(this.getClassName('image'));
            block.headerNode.setStyle('backgroundImage', 'url('+img+')');
        }
		
		block.addClass(block.CSS_CLASS);
	},
	
	createHeader: function(title) {
	  var hd;
	  
	  if (this.get('url')) {
	    hd = document.createElement('a');
	    hd.href = this.get('url');
	    hd.setAttribute('target', '_parent');
	  }
	  else {
	    hd = document.createElement('span');
	  }
	  
	  hd.className = this.getClassName('title');
	  hd.innerHTML = title;
	  
	  return hd;
	},
	
	addClass: function(name) {
		this.get('boundingBox').addClass(name);
	}
	
}, {
    ATTRS: {
		
		title: {
			
		},
		
		image: {
			setter: function(val) {
                // if (val && js.isString(val)) {
                //  dom.addClass(this.element, 'has-image');
                //  dom.setStyle(this.header.parentNode, 'background-image', 'url('+val+')');
                // }
                return val;
			}
		},
		
		url: {
		    value: null
		},
		
		links: {
		    setter: function (val) {
		        return new Y.ArrayList(val);
		    }
		},
		
		parent: {
		    setter: function (val) {
		        return this.parent = val;
		    }
		},
		
		itemTemplate: {
			value: '<li><a href="{url}" rel="nofollow">{title}</a></li>'
		},
		
		maxLength: {
			getter: function(){
				return this.parent.get('maxLength');
			}
		}
		
	}
});


Y.namespace('skui').BlockList = Y.Base.create('skui-blocklist', Y.Widget, [], {
	CSS_CLASS: 'ui-blocks',
	
	bindUI: function() {
	    var blockList = this,
	        boundingBox = blockList.get('boundingBox');
	        
		boundingBox.addClass(blockList.CSS_CLASS);
		boundingBox.addClass(blockList.get('class'))
		blockList.element = blockList.get('contentBox');

	    // immediately request the content if the document doesn't need to scroll
	    if (boundingBox.get('winHeight') >= boundingBox.get('docHeight')) {
			blockList.sendRequest();
		}
		else {
			Y.once("scroll", Y.bind(blockList.initRequest, blockList));
		}
	},
	
	initRequest: function() {
		this.sendRequest();
	},
	
	sendRequest: function() {
		var url = this.get('url'),
		    cb = {
				on: {
				    success: Y.bind(this.processResponse, this),
				    failure: Y.bind(this.processFailure, this)
				}
			};
		
		this._tid = Y.io(url, cb);
	},
	
	processResponse: function(id, o, args) {
		try {
			var data = Y.JSON.parse(o.responseText);

			this.setItems(data.results);
			
			if (this.size() > 0) {
				this.show();
			}
		}
		catch (e) {
			this.processFailure(o);
		}
	},
	
	processFailure: function(o) {
		this.hide();
	},
	
	setItems: function(items) {
		var max = Math.min(this.get('maxItems'), items.length);
		
		for (var i = 0, len = max; i < len; i++) {
			var child = this.addItem(items[i]);
			
			if (i == 0) {
				child.addClass('first-child');
			}
		}
	},
	
	addItem: function(item) {
		var block = this.get('childBlock'),
            child = new block(item);

        child.set('parent', this);
		child.render(this.element);
		
		return child;
	},
	
	size: function () {
	    return this.element.get('children').size();
	}
}, {

	
	ATTRS: {
		
		maxItems: {
			value: 8
		},
		
		maxLength: {
			value: 65
		},
		
		itemTemplate: {
			value: '<a href="{url}">{title}</a>'
		},
		
		childBlock: {
			value: Y.skui.Block
		},
		
		url: {
			value: '/blogs/entertainment-footer.json'
		},
		
		"class": {
			validator: js.isString,
			setter: function(val) {
			    if (this.element && this.element.addClass) {
					this.element.addClass(val);
				}
				
				return val;
			}
		}
		
	}
});


}, '@VERSION@' ,{requires:['node', 'io-base', 'base', 'json', 'substitute', 'widget-stdmod', 'arraylist']});
YUI().use("node", "event-mouseenter", function(Y) {
	Y.on( 'domready', function() {
		
		var subNav = Y.one('div.ui-control-select #video-nav-list');
		var node = Y.one('div.ui-control-select');
		if (node) {
			node.on('click', function(e) {
				
				if (subNav.getStyle('display') == 'none') {
					subNav.setStyle('display', 'block');
					e.preventDefault();
					e.stopPropagation();
					return false;
				} else if (subNav.getStyle('display') == 'block') {
					subNav.setStyle('display', 'none');
				}
				
			});
			
			subNav.on('mouseleave', function() {
				subNav.setStyle('display', 'none');
			});
			
			Y.one(document.body).on('click', function() {
				subNav.setStyle('display', 'none');
			});
		}
		
	});
});YUI.add('skui-rating', function(Y) {

/**
 * Display a Rating widget
 * @module rating
 */

// Referenced Objects
var Lang = Y.Lang,
    Node = Y.Node,
    Event = Y.Event,

    // Widget Constants
    WIDGET_NAME = 'skui-rating',
    CONTENT_BOX = 'contentBox',
    Rating;

/**
 * FIXME: Enter a description for the Rating class
 * @class Rating
 * @extends Widget
 * @constructor
 */
Rating = Y.Base.create(WIDGET_NAME, Y.Widget, [], {

    lastXY: [0, 0],

    running: false,

    _moveHandler: null,

    initializer: function () {
        var widget = this;

        widget.element = widget.get(CONTENT_BOX);

        widget.averageNode = widget.get('averageNode');
        widget.activeNode  = widget.get('activeNode');
        widget.totalNode   = widget.get('totalNode');
        widget.inputNode   = widget.get('inputNode');

        widget.after({
            'ratingChange':        widget._afterRatingChange,
            'averageRatingChange': widget._afterAverageRatingChange
        });
    },

    /**
     *
     * @method bindUI
     */
    bindUI: function () {
        var widget = this,
            elm    = widget.element;
		
        elm.on({
            'mouseover': Y.bind(widget._onMouseOverEvent, widget),
            'click':     Y.bind(widget._onMouseClickEvent, widget)
        });
    },

    /**
     *
     * @method _onMouseOverEvent
     * @protected
     */
    _onMouseOverEvent: function (e) {
        var widget = this,
            elm    = widget.element,
            handler;

        widget._moveHandler = elm.on('mousemove', Y.bind(widget._onMouseMoveEvent, widget));
        elm.on('mouseout', Y.bind(widget._stop, widget));

        widget.xy    = elm.getXY();
        widget.width = widget.get('width');

        widget.activeNode.show();
        widget.averageNode.hide();
    },

    /**
     *
     * @method _stop
     * @protected
     */
    _stop: function() {
        var widget = this,
            elm    = widget.element,
            timeout;

        timeout = function() {
            if (widget._moveHandler) {
                widget._moveHandler.detach();
                widget._moveHandler = null;
            }

            widget.activeNode.hide();
            widget.averageNode.show();

            widget.running = false;
        };

        //this.timeout = Lang.later( 1000, this, timeout );
        timeout.call(this);
    },

    /**
     *
     * @method _updated
     * @protected
     */
    _update: function () {
        var widget = this,
            delta,
            rating;

        if (widget.running) {
            return;
        }

        delta = [
            widget.lastXY[0] - widget.xy[0],
            widget.lastXY[1] - widget.xy[1]
        ];

        widget.set('rating', (delta[0] / widget.get('width')) * 100);
    },

    /**
     *
     * @method _onMouseClickEvent
     * @protected
     */
    _onMouseClickEvent: function (evt) {
        var widget = this,
            target = evt.target,
            el     = widget.element,
            form,
            rating;
		
        if (el.contains(target)) {
            rating = widget.inputNode;
            if (rating) {
                form = rating.ancestor('form');
                Node.getDOMNode(form).submit();
            }
        }
    },

    /**
     *
     * @method _onMouseMoveEvent
     * @protected
     */
    _onMouseMoveEvent: function(evt) {
        this.lastXY = [evt.clientX, evt.clientY];
        this._update();
    },

    /**
     *
     * @method _afterRatingChange
     * @protected
     */
    _afterRatingChange: function (e) {
        this._uiSetRating(e.newVal);
    },

    /**
     *
     * @method _afterAverageRatingChange
     * @protected
     */
    _afterAverageRatingChange: function (e) {
        this._uiSetAverageRating(e.newVal);
    },

    /**
     *
     * @method _setNode
     * @protected
     */
    _setNode: function (val, name) {
        this[name] = Y.one(val);
    },

    /**
     *
     * @method _setRating
     * @protected
     */
    _setRating: function (rating, name) {
        var widget = this,
            snapTo = widget.get('snapTo'),
            mod;

        if (rating % snapTo === 0) {
            return rating;
        }

        mod = rating % snapTo;

        if (mod > snapTo / 2 || widget.roundTo == 'ceil') {
            return Math.round(rating - mod + snapTo);
        }

        return Math.round(rating - mod);
    },

    /**
     *
     * @method _setAverageRating
     * @protected
     */
    _setAverageRating: function (val, name) {
        return val;
    },

    /**
     *
     * @method _uiSetRating
     * @protected
     */
    _uiSetRating: function (val) {
        var widget = this;

        widget._setWidth(widget.activeNode, val);

        if (!widget.inputNode) {
            return;
        }


        widget.inputNode.set('value', val);
    },

    /**
     *
     * @method _uiSetAverageRating
     * @protected
     */
    _uiSetAverageRating: function (val) {
        this._setWidth(this.averageNode, val);
    },

    /**
     *
     * @method _setWidth
     * @protected
     */
    _setWidth: function (node, width) {
        node.setStyle('width', width + '%');
    }

}, {

    NAME: WIDGET_NAME,

    /**
     * Static property used to define the default attribute configuration of
     * the Widget.
     *
     * @property ATTRS
     * @type {Object}
     * @protected
     * @static
     */
    ATTRS : {

        /**
         * Axis upon which the Slider's thumb moves.  &quot;x&quot; for
         * horizontal, &quot;y&quot; for vertical.
         *
         * @attribute snapTo
         * @type {Number}
         * @default 20
         */
        snapTo: {
            value: 20
        },

        /**
         * The rounding method to use for user supplied ratings
         ()
         * @attribute roundTo
         * @type {String}
         */
        roundTo: {
            value: 'ceil'
        },

        /**
         * @attribute averageNode
         * @type Y.Node
         * @protected
         */
        averageNode: {
            setter: "_setNode"
        },

        /**
         * @attribute totalNode
         * @type Y.Node
         * @protected
         */
        totalNode: {
            setter: "_setNode"
        },

        /**
         * @attribute activeNode
         * @type Y.Node
         * @protected
         */
        activeNode: {
            setter: "_setNode"
        },

        /**
         * @attribute inputNode
         * @type Y.Node
         * @protected
         */
        inputNode: {
            setter: "_setNode"
        },

        /**
         * @attribute width
         * @type {Number}
         * @readOnly
         * @broadcast false
         */
        width: {
            broadcast: false,
            getter: function () {
                return this.get('contentBox').get('clientWidth');
            }
        },

        /**
         * The value is associated with the rating associated
         * with the User
         *
         * @attribute rating
         * @type {Number}
         * @default (inferred from current rating)
         */
        rating: {
            setter: "_setRating"
        },

        /**
         * The value is associated with the average rating
         *
         * @attribute rating
         * @type {Number}
         * @default (inferred from average rating)
         */
        averageRating: {
            setter: "_setAverageRating"
        }

    },

    HTML_PARSER: {
        averageNode: '.rtg-stars-average',

        totalNode: '.rtg-stars-total',

        activeNode: '.rtg-stars-active',

        inputNode: function (srcNode) {
            var form = srcNode.ancestor('form');

            if (form) {
                return form.one('#RatingRating');
            }
        }
    }

});

Y.namespace('skui').Rating = Rating;


}, '@VERSION@' ,{requires:['node', 'event', 'widget', 'widget-stdmod']});
YUI.add('skui-accordion', function(Y) {

/**
 * Displays an Accordion widget
 * @module accordion
 */

// Local Constants
var Lang = Y.Lang,
    Node = Y.Node,
    SKUI = Y.skui,
    CONTENT_BOX = 'contentBox',
    WIDGET_NAME = 'skui-accordion',
    ITEM_CHOSEN = 'itemChosen';

/**
 * FIXME: Enter a description for the Accordion class
 * @class Accordion
 * @extends Widget
 * @constructor
 */
var Accordion = Y.Base.create(WIDGET_NAME, Y.Widget, [], {
    
    initializer: function (config) {
        this._initEvents();
        this.after('render', Y.bind(this._afterRender, this));
    },
    
    bindUI: function () {
        var contentBox = this.get(CONTENT_BOX);
        
        contentBox.delegate('click', Y.bind(this._onClick, this), 'li');
    },
    
    /**
     * @method hideAll
     */
    hideAll: function () {
        var contentBox = this.get(CONTENT_BOX),
            children = contentBox.get('children');
        
        children.removeClass(this.get('expandedClass'));
        return;
    },
    
    /**
     * @method _onClick
     * @param e {DOMEvent} the event object
     * @protected
     */
    _onClick: function (e) {
        var elm = e.currentTarget,
            exp = this.get('expandedClass'),
            contentBox = this.get(CONTENT_BOX),
            children = contentBox.get('children');

        if (contentBox.get('id') !== elm.get('parentNode').get('id')) {
            e.stopPropagation();
            return;
        }
        
        if (elm.hasClass(exp)) {
            this.hideAll();
        } else {
            this.hideAll();
            elm.addClass(exp);
            this.fire(ITEM_CHOSEN, {item: e.currentTarget});
        }
    },
    
    /**
     * Publish Widget events
     *
     * @method _initEvents
     * @protected
     */
    _initEvents: function () {
        this.publish(ITEM_CHOSEN, {
           defaultFn: this._onItemChosen 
        });
    },
    
    /**
     * @method _afterRender
     * @protected
     */
    _afterRender: function (e) {
        
    }
}, {
    /**
     * Static property used to define the default attribute configuration of
     * the Widget.
     *
     * @property ATTRS
     * @type {Object}
     * @protected
     * @static
     */
    ATTRS: {
        /**
         * @attribute expandedClass
         * @type {String}
         * @default &quot;expanded&quot;
         */
        expandedClass: {
            value: 'expanded' 
        }
    }
});


Y.namespace('skui').Accordion = Accordion;


}, '@VERSION@' ,{requires:['event', 'widget', 'widget-stdmod']});
/*
Why is this included? Because the YUI3 tabview [ https://raw.github.com/yui/yui3-gallery/master/build/gallery-plugin-tabview/gallery-plugin-tabview.js ]
this is from assumes a certain HTML structure we don't have. Instead of rewriting the view I made some modifications to the plugin.
*/

YUI.add('sk-tabview', function(Y) {

var ACTIVE_CLASS = 'selected';

Y.Plugin.TabView = Y.Base.create('tabview', Y.Plugin.Base, [], {

  history : null,

  initializer : function(){
    this.history = new Y.HistoryHash();
    this.renderUI();
    this.bindUI();
    this.syncUI();
  },

  renderUI : function(){
    var host = this.get('host'),
        tabS = this.get('tabSelector'),
        panelS = this.get('panelSelector'),
        tabCount = 0;

    host.addClass('tabView');
    
    host.all(tabS).each(function(tab){
      var a = tab.one('a'),
          id = null, tabId = '';
          
      if(!a || a.getAttribute('href').indexOf('#') < 0) {
        tabCount++;
        return;
      }
      
      id = a.getAttribute('name') || a.getAttribute('id');
      if(id === '' || id.indexOf('yui_') === 0) {
        tabId = tab.get('id');
        if(tabId === '' || tabId.indexOf('yui_') === 0) {
          id = tabCount;
        }else{  
          id = tabId;
        }
      }
      
      a.setAttribute('href', a.getAttribute('href').replace(/#(.)*/,'#tab=' + id));
      tabCount++;
      
    });

    host.all(panelS).each(function(panel){
      if(panel.one('*:first-child').hasClass('liner')){
        return;
      }
      var liner = Y.Node.create('<div class="liner" />'),
      c = panel.get('children').remove(),
      i, l;

      for(i=0, l=c.size(); i<l; i++){
        liner.append(c.item(i));
      }
      panel.append(liner);

    });
  },

  bindUI : function(){
    var host = this.get('host');

    host.delegate('click', function(e){
      var tab = e.currentTarget;

      e.preventDefault();
      this.history.addValue('tab', host.all(tab.get('tagName')).indexOf(tab));

    }, this.get('tabSelector') , this);

    this.history.on('change', function(e){
      if(e.changed.tab) {
	    var tab_index = parseInt(e.changed.tab.newVal, 10) >= 0 ? parseInt(e.changed.tab.newVal, 10) : 0;
        this._updateActiveTab(host.all(this.get('tabSelector')).item(tab_index));
      }
    }, this);

  },

  syncUI : function(){
    var host = this.get('host'),
    tabS = this.get('tabSelector'),
    activeTab = 0,
    hashId = null, tabSearch = null;

    if(window.location.hash) {
      hashId = window.location.hash.replace('#','');

      if(hashId.indexOf('=') > 0) {
        activeTab = hashId.substring(hashId.indexOf('=') + 1);
        tabSearch = host.all(tabS).item(activeTab);
      }else{
        tabSearch = host.one('#' + hashId + ', ' + tabS + '[name=' + hashId +'], ' + tabS + ' *[name=' + hashId + ']');
        if(tabSearch) {
          if(tabSearch.get('tagName') !== tabS.toUpperCase()) {
            tabSearch = tabSearch.ancestor(tabS);
          }
          activeTab = host.all(tabS).indexOf(tabSearch);
        }
      }
    }
    this.history.addValue('tab', activeTab);
    this._updateActiveTab(tabSearch);
  },

  _updateActiveTab : function(tab) {
    var host = this.get('host');

    if(tab.hasClass(ACTIVE_CLASS)){
      return;
    }

    host.all('.' + ACTIVE_CLASS).removeClass(ACTIVE_CLASS);

    tab.addClass(ACTIVE_CLASS);
    host.all(this.get('panelSelector')).item(
    	parseInt(tab.one('a').getAttribute('href').match(/\d+$/)[0], 10)
    ).addClass(ACTIVE_CLASS);
  }

}, {
  NS : 'tabview',
  ATTRS : {
    tabSelector : {
      value : 'dt'
    },
    panelSelector : {
      value : 'dd'
    }
  }
});


}, 'sk1.0' ,{requires:['plugin','base-build','node','event','history']});
