
function flashNews()
{
	this.$flash_news = $("#flash_news");

	if (this.$flash_news.length > 0) {
		if ($.browser.msie && $.browser.version <= 7) {
			this.$flash_news.css({
				'width':'630px'				
					});
		}

		this.current = 0;
		this.$item = false;
		this.top = 0;

		var my = this;

		this.next = function()
		{
			if (this.current >= this.$flash_news.find('.flash_slide').length - 1)
				this.select(0);
			else
				this.select(this.current + 1);
		};

		this.prev = function()
		{
			if (this.current == 0)
				this.select(this.$flash_news.find('.flash_slide').length - 1);
			else
				this.select(this.current - 1);
		};

		this.select = function(i)
		{
			this.$item = this.$flash_news.find('.flash_slide:eq(' + i + ')');
			if (this.$item.length < 1) {
				i = 0;
			}
			if (this.$item.length > 0) {
				this.current = i;
				this.top = my.$item.position().top;
				this.$flash_news.find('#flash_tape').animate({
					top : -my.top
				});
			}
		};

		setInterval(function()
		{
			my.next();
		}, 5000);

		if (this.$flash_news.find('.flash_slide').length > 1) {

			this.$flash_news.find('#flash_down').click(function()
			{
				my.next();
				return false;
			});
			this.$flash_news.find('#flash_up').click(function()
			{
				my.prev();
				return false;
			});
		} else {
			this.$flash_news.find('#flash_down').hide();
			this.$flash_news.find('#flash_up').hide();
		}
	}
}

$(document).ready(function()
{
	new flashNews();
});
