(function($){
	/* Requires jquery.flash.js plugin to function */
	if($.fn.flash) {
			$.fn.nikelodeon = function(viewport, options) {
			var opts = $.extend($.fn.nikelodeon.defaults, options);
			
/* 			if($(window.location.hash, document) && ($(location.hash, this).size() > 0))) loadVideo(decodeURIComponent($('a', $(window.location.hash, document)).attr('href'))); */
			
			return this.each(function(){
				var $this = $(this);
				$('a', $this).each(function(){
					$(this).data('loc', $(this).attr('href'));
					$(this).attr('href', '#');
				});
				
				$links = $('a', $this);
				$('a', $this).each(function(){
					$(this).data('current', false);
					$(this).click(function(){
					
						/* set $src */
						if($(this).data('loc').charAt(0) == '.') $src = decodeURIComponent($(this).data('loc').substring(1)); 
						else $src = decodeURIComponent($(this).data('loc'));
						
						/* check if current */
						$(this).data('current', true);
						if($(this).data('current')) {
							$links.removeClass('current');
							$(this).addClass('current');
						}
						
						loadVideo($src);
						return false;
					});
				});
			});
			
			function loadVideo($src) {
				$.log($src+" : "+opts.skinSrc);
				$(viewport).empty().flash({
					src: opts.playerSrc,
					width: opts.playerWidth,
					height: opts.playerHeight,
					flashvars: {
						player_source: $src,
						player_skin: opts.skinSrc
					},
					wmode: opts.wmode
				}, {
					version: 8,
					update: false
				});
			}
		};
		
		$.fn.nikelodeon.defaults = {
			playerSrc: '/videoPlayer.swf',	// runtime SWF for the FLV player
			skinSrc: '/playerSkin.swf',
			playerWidth: 440,
			playerHeight: 330,
			wmode: 'transparent',		
			progress: false,				// progress automatically through the playlist?
			loop: false						// loop the playlist, if progressing?
		};
	} else {
		$.log('Please include jQuery Flash to use this plugin: http://jquery.lukelutman.com/plugins/flash');
		return false;
	}
})(jQuery);