;(function($){
	$.fn.marquee = function(options) {
		// create a new marquee for each object found
		return this.each(function (){
			new $.Marquee(this, options);
		});
	};
	$.Marquee = function (marquee, options){
		options = $.extend({}, $.Marquee.defaults, options);
		var pausespeed=(!options.pause)?options.speed:0, scrollspeed = options.speed, top = options.top,
			$marquee = $(marquee).wrap("<div/>").parent().css({"position":"absolute","left":0,"top":top,"width":"100%"});
		$marquee.wrap("<div/>").parent()
			.css({"position":"relative","width":options.width,"height":options.height,"overflow":"hidden"})
			.hover(pause,resume);
		
		setInterval(scroll,options.interval);

		function pause(){
			scrollspeed=pausespeed
		}
		
		function resume(){
			scrollspeed=options.speed
		}

		function scroll(e){
			if ($marquee.position().top > $marquee.outerHeight()*(-1))
				$marquee.css("top",($marquee.position().top-scrollspeed)+"px")
			else
				$marquee.css("top",options.height)
		}
	};
	
	$.Marquee.defaults = {
		width: "230px",
		height: "202px",
		speed: 1,
		pause: 1,
		interval: 60,
		top: 0
	};

})(jQuery);
