var RolloverPanel = Class.create(  {
	initialize: function(objectid) {
	    this.objectid  = objectid;
		this.container = $(this.objectid);
		this.current = 0;
		this.paused = false;
		
		this.contents = this.container.select('.object-rollover-panel-feature');
		this.links = this.container.select('.object-rollover-panel-thumb');
				
		this.attachEvents();
		// setTimeout(this.autoPlay.bind(this),10000);
	}
	
	,attachEvents: function(){
		var c = this;
		c.links.each(function(a,j) {
			a.observe('mouseover',function(e) { Event.stop(e); c.paused = true; c.showFeature(j); })
		});
		return this
	}
	
	,showFeature:function(j) {
		var c = this.contents;
		var l = this.links;
		c.each(function(a,i) {
			if(i == j) a.show();
			else a.hide();
		});
		l.each(function(a,i) {
			if(i == j) a.addClassName('thumb-on');
			else a.removeClassName('thumb-on');
		});
		this.current = j;
		return this
	}

	,next:function() {
		var l = this.contents;
		var c = this.current;
		var i = l[c+1]?(c+1):0;
		return this.showFeature(i)
	}
	
	,autoPlay:function() {
		if(!this.paused) { this.next(); }
		setTimeout(this.autoPlay.bind(this),10000);
	}
});
