function BannerRotator(p_dir,p_target,p_count,p_delay)
{
	var o=this;
	
	// variables;
	o.dir;		// directory of banners
	o.$target;	// target element
	o.delay;	// delay between rotates
	o.count;	// number of banner pages
	o.current;	// current banner page
	o.dontRotate; // if set, dont rotate
	o.timer;	// timer id
	
	// methods
	
	o.rotate=function()
	{
		if(++o.current==o.count) o.current=0;
		$.get("banner_rotator/index.php?prefix="+o.dir+"&p="+o.current,null,
			function(data)
			{
				/*
				o.$target.fadeOut(200,
					function()
					{
						o.$target.html(data);
						o.$target.fadeIn(200,
							function()
							{
								o.timer_reset();
							}
						);
					}
				);
				*/
				o.$target.css("display","none");
				o.$target.html(data);
				o.$target.fadeIn(500,
					function()
					{
						if(o.count>1)
						{
							o.timer_reset();
						}
					}
				);
			}
		);
		
		
	}
	
	o.timer_reset=function()
	{
		o.timer_stop();
		o.timer=setTimeout(o.rotate,o.delay);
	}
	
	o.timer_stop=function()
	{
		if(o.timer) clearTimeout(o.timer);
	}
	
	// constructor
	o.dir=p_dir;
	o.$target=$(p_target);
	o.count=p_count;
	o.delay=p_delay;
	o.current=-1;
	o.dontRotate=false;
	
	if(o.count>1)
	{
		o.$target.hover(
			function()
			{
				o.dontRotate=true;
				o.timer_stop();
			},
			function()
			{
				o.dontRotate=false;
				o.rotate();
			}
		);
	}
	
	o.rotate();

}

