function HeadlineScroller(div, milliseconds)
{
	var self = this;
	this.browser = navigator.userAgent;
	this.delay = milliseconds;
	this.divContainer = "#" + div;
	this.bottomHeight = 0;
	
	this.entryLeftPadding = parseInt($(".entry:first").css("padding-left"));
	this.entryRightPadding = parseInt($(".entry:first").css("padding-right"));
	this.entryTopPadding = parseInt($(".entry:first").css("padding-top"));
	this.entryBottomPadding = parseInt($(".entry:first").css("padding-bottom"));
	this.padding = "5px";
		
	this.run = function()
	{
		// grab all the entries, and calculate the total height
		var elems = $(".entry");
		var totalHeight = 0;
		
		for (i = 0; i < elems.length; i++)
		{
			var h = elems[i].offsetHeight;
			totalHeight += h;
		}

		var reducedHeight = totalHeight - h;
		this.bottomHeight = h;
				
		// if the total height is not greater than the containg div, 
		// there is no need to scroll
		if (reducedHeight > parseInt($(this.divContainer).css("height")))
		{
			this.startLoop();
		}
		else
		{
			elems.css({'visibility' : 'visible'});
		}
	}
	
	this.startLoop = function() 
	{
		var elems = $(".entry");
		var totalHeight = 0;
		
		for (i = 0; i < elems.length; i++)
		{
			var h = elems[i].offsetHeight;
			totalHeight += h;
		}
		
		this.bottomHeight = h - parseInt(this.padding) * 2 - 1;
		
		// need to calculate the height of the last element, before we rotate it to the top
		/*if ((this.browser).indexOf('MSIE') > -1)
		{
			this.bottomHeight = $(this.divContainer + " > .entry:last").height();
		}
		else
		{
			this.bottomHeight = $(this.divContainer + " > .entry:last").height();
		}*/
		
		
		// now we have the height of the last entry, we hide it
		this.hideBottomText();
		
		// now, after the appropriate, call method to move the (now hidden) last entry 
		// into the top position
		setTimeout(function() {
			self.slideUp();
		}, self.delay);
	}
	
	this.slideUp = function()
	{
		// move the last element to the top position
		this.moveToTop();
		
		// now we can animate the reappearance of the top entry
		// note, we stored the height of the bottom entry, and it;s padding values,
		// so now we reinstate these also
		$(this.divContainer + " > .entry:first").animate({
			'height' : this.bottomHeight,
			//'padding-left' : this.entryLeftPadding + 'px',
			//'padding-top' : this.entryTopPadding + 'px',
			//'padding-right' : this.entryRightPadding + 'px',
			//'padding-bottom' : this.entryBottomPadding + 'px'
			'padding' : this.padding
		}, 1000);
		
		// initially, the entries are all (optionally, in the html) hidden, so on the first rotation, 
		//they also need to be made visible
		$(this.divContainer + " > .entry:first").css({'visibility' : 'visible'});
		
		// 
		setTimeout(function() {
			self.showTopText();
		}, 1500);
		
		
		setTimeout(function() {
			self.startLoop();
		}, self.delay);
	}
	
	this.moveToTop = function()
	{
		// here we take the last element, and insert it at the top of the entry list
		// note, currently this element takes up zero space
		$(this.divContainer + " > .entry:last").remove().insertBefore(this.divContainer + " > .entry:first");
	}
	
	this.hideBottomText = function()
	{
		// in order to maximize smoothness, we need to explicitly remove the padding, as hide() does 
		// not do this, causing some choppiness
		$(this.divContainer + " > .entry:last").css({
			'padding' : '0px',
			'height' : '0px'
		});
		
		$(this.divContainer + " > .entry:last > .entry-headline").css({
			'display' : 'none',
			'opacity' : '0'
		});
	}
	
	this.showTopText = function()
	{
		$(this.divContainer + " > .entry:first > .entry-headline").css({'display':'block'});
		$(this.divContainer + " > .entry:first > .entry-headline").animate({'opacity':'1'}, 500);
	}
}
