var Banner = function(options)
{
	this.delay = options.delay || 3000;
	this.speed = options.speed || 1200;
	
	this.effect = options.effect || 'fadeIn';
	
	if(!options.id || options.id == '') { return false; }
	
	this.root = $('#' + options.id);
	
	if(this.root.length == 0) { return false; }
	
	this.panels = this.root.find('a');
	
	if(this.panels.length == 0) { return false; }

	this.currentPanel = null;
	this.currentPanelNum = 0;
	
	var scope = this;
	
	this.timer = null;
	
	/*this.root.hover(
		function(){ scope.currentPanel.pause() },
		function(){ scope.currentPanel.resume() }
	);*/
	
	this.step();
}

Banner.prototype.step = function()
{
	var scope = this;
	this.currentPanel = $(this.panels[this.currentPanelNum])[this.effect](this.speed, function()
	{
		if(scope.lastPanel)
		{
			scope.lastPanel.css({ 'display' : 'none', 'z-index' : '99' });
		}
		scope.currentPanel.css({ 'z-index' : '0' })
		scope.lastPanel = scope.currentPanel;
		scope.currentPanelNum++;
		if(scope.currentPanelNum >= scope.panels.length) {scope.currentPanelNum = 0; }
		setTimeout(function() { scope.step() }, scope.delay);
	});
}

/* requires jquery plugin below */
//(function(){var e=jQuery,f="jQuery.pause",d=1,b=e.fn.animate,a={};function c(){return new Date().getTime()}e.fn.animate=function(k,h,j,i){var g=e.speed(h,j,i);g.complete=g.old;return this.each(function(){if(!this[f]){this[f]=d++}var l=e.extend({},g);b.apply(e(this),[k,e.extend({},l)]);a[this[f]]={run:true,prop:k,opt:l,start:c(),done:0}})};e.fn.pause=function(){return this.each(function(){if(!this[f]){this[f]=d++}var g=a[this[f]];if(g&&g.run){g.done+=c()-g.start;if(g.done>g.opt.duration){delete a[this[f]]}else{e(this).stop();g.run=false}}})};e.fn.resume=function(){return this.each(function(){if(!this[f]){this[f]=d++}var g=a[this[f]];if(g&&!g.run){g.opt.duration-=g.done;g.done=0;g.run=true;g.start=c();b.apply(e(this),[g.prop,e.extend({},g.opt)])}})}})();

