var Marquee = Class.create
({
	element: false,
	interval: 25,
	timer: false,
	doMove: true,
	startWidth: false,
	
	parse: function()
	{
		this.element = $$('.marquee').shift();
		
		if (this.element)
		{
			this.element.observe('mouseover', this.over.bind(this));
			this.element.observe('mouseout', this.out.bind(this));
			this.timer = setInterval(this.move.bind(this), this.interval);
		}
	},
	
	over: function()
	{
		this.doMove = false;
	},
	
	out: function()
	{
		this.doMove = true;
	},
	
	move: function()
	{
		if (this.doMove)
		{
			if (!this.startWidth)
			{
				this.startWidth = this.element.getWidth();
				this.element.setStyle({ "marginLeft": $('loop').getWidth()-1 + 'px' });
			}
			
			var marginLeft = (parseInt(this.element.getStyle("marginLeft")));

			if (marginLeft < -this.startWidth )
			{
				marginLeft = this.element.up().getWidth();
			}
			
			this.element.setStyle({ "marginLeft": marginLeft-1 + 'px' });
		}
	}
});

var marquee = new Marquee();

