function NewsRotator (_container, _settings) {
		
	this.$container = $(_container);
	this.settings = $.extend({
		url:"media/json/newsRotator.txt",
		rotationDelay:3
	}, _settings || {});
	this.currentPanel = 0;
	this.iid = -1;
	this.animating = false;
	
	this.init = function() {
		// Put the structure in the panel
		this.$container.html('<ul class="nrTabs"></ul><div class="nrPanelContainer"></div>');
		
		// Ask for the panel content
		$.ajax( {
			url:this.settings.url,
			type:'GET',
			//data:'ts='+ new Date().getTime(),
			dataType:'json',
			callingObject: this,
			success:function(data, textStatus) {
					this.callingObject.stories = data.stories;
					this.callingObject.createStories();
				},
			error:function (XMLHttpRequest, textStatus, errorThrown) {
					alert("basket.init\nError:\n" + XMLHttpRequest + "\n" + textStatus + "\n" + errorThrown);
				}
		} );		
		
	};
	
	this.createStories = function () {
		var i, ilen, 
			tabCount = this.stories.length, 
			tabHeight;
			
		// Build the tabs and panels
		for (i=0, ilen=this.stories.length; i<ilen; i++) {
			$('<li><a href="#nrPanel'+i+'">'+this.stories[i].title+'</a></li>').appendTo($('.nrTabs', this.$container));
			$('<div class="nrPanel"><a name="nrPanel'+i+'"></a>' +
			  '<img src="'+this.stories[i].photo+'">' +
			  '<div class="nrCaption">'+this.stories[i].caption +
			  ' <a href="'+this.stories[i].link+'">more</a></div></div>').appendTo($('.nrPanelContainer', this.$container));
		}
		
		// Resize tabs based on how many there are
		tabHeight = Math.ceil((this.$container.height() - tabCount + 1) / tabCount);
		if (tabCount < 6) {
			$('.nrTabs li a', this.$container).css({height:tabHeight-12});
		} else {
			$('.nrTabs li a', this.$container).css({height:tabHeight-4,'padding-top':4});
		}
		
		// Activate the panels and show the first
		this.activate();
		$('.nrPanel', this.$container).hide();
		$('.nrTabs li:first a', this.$container).trigger('click');
		
		// Start rotation as long as there is more than one panel
		if (tabCount > 1) {
			this.$container
				.bind('mouseenter', {nr:this}, function(e){ e.data.nr.stopRotation(); })
				.bind('mouseleave', {nr:this}, function(e){ e.data.nr.startRotation(); });
			this.startRotation();
		}
	};
	
	/*=================================================================
		Set tab click actions
	=================================================================*/
	this.activate = function () {
		$('.nrTabs li a', this.$container).bind('click', {nr:this}, function(e){
			var panelName = $(this).attr('href').replace(/^.*#/, '');
			if ($(this).parent().hasClass('selected')) { return false; }
			if (e.data.nr.animating) { return false; }
			e.data.nr.animating = true;
			e.data.nr.stopRotation();
			e.data.nr.currentPanel = parseInt($(this).attr('href').replace(/^.*#nrPanel/, ''));
			$('.nrTabs li', e.data.nr.$container).removeClass('selected');
			$(this).parent().addClass('selected');
			$('a[name='+panelName+']', e.data.nr.$container).parent()
				.hide()
				.appendTo($('.nrPanelContainer', e.data.nr.$container))
				.fadeIn( function(){ $('.nrPanel', e.data.nr.$container).not(this).hide(); e.data.nr.animating = false; } )
			.children('.nrCaption')
				.css({opacity:0})
				.delay(200)
				.animate({opacity:0.85}, 500);
			return false;
		});
	};
	
	/*=================================================================
		Create Rotator
	=================================================================*/
	this.startRotation = function () {
		var nr = this;
		this.iid = setInterval( function(){ nr.nextSlide(); }, nr.settings.rotationDelay * 1000 );
	};
	
	this.stopRotation = function () {
		clearInterval(this.iid);
	};
	
	this.nextSlide = function () {
		var nextPanel = this.currentPanel + 1;
		this.stopRotation();
		if (nextPanel >= this.stories.length) { nextPanel = 0; }
		$('.nrTabs a[href=#nrPanel'+nextPanel+']', this.$container).trigger('click');
		this.startRotation();
	};
	
	/*=================================================================
		Make rocket go now!
	=================================================================*/
	
	this.init();
	
}
