(function($){
	$.fn.jMarquee = function(options) {
		options = $.extend({
			initpause: 1500,
			speed: 1,
			intervalspeed: 20,
			overpause: true,
			height: 200,
			width: 150
		}, options || {});
		
		return this.each(function(){
			var div = $(this), marquee1, marquee2, interval, copyspeed = options.speed, actualheight = div.height();
			
			div.css({position:"relative",width:options.width,height:options.height,overflow:"hidden"});
			marquee1 = $("<div></div>").css({position:"absolute",left:0,top:0,width:"100%"}).html(div.html());
			marquee2 = marquee1.clone().css({top:actualheight});
			
			div.html(marquee1).append(marquee2);
			
			if (options.overpause) {
				div.hover(function(){
					copyspeed = 0;
				},function(){
					copyspeed = options.speed;
				});
			};
			
			function scrollMarquee() {
				if (parseInt(marquee1.css("top")) < -actualheight) {
					marquee1.css("top", (parseInt(marquee2.css("top")) + actualheight));
				}
				if (parseInt(marquee2.css("top")) < -actualheight) {
					marquee2.css("top", (parseInt(marquee1.css("top")) + actualheight));
				}
				marquee2.css("top", parseInt(marquee2.css("top")) - copyspeed);
				marquee1.css("top", parseInt(marquee1.css("top")) - copyspeed);
			};
			
			setTimeout(function(){
				interval = setInterval(scrollMarquee, options.intervalspeed);
			}, options.initpause);
		});
	};
})(jQuery);
