var imagescroll = {
	Playing: false,
	Pos: 1,
	Current: 0,
	Record: 0,
	Control: {},
	Wait: 5000,
	init: function() {
		var w = $( window ).width();
		this.Current = this.Pos;
		if(w > 450) {
			this.play();
		}
	},
	stop: function() {
		clearTimeout(this.Control);
		this.Playing = false;
	},
	play: function() {
		this.Playing = true;
		this.delay();
	},
	delay: function() {
		if(this.Playing) this.Control = setTimeout('imagescroll.next();', this.Wait);
	},
	next: function() {
		this.Pos = (this.Pos != this.Record) ? this.Pos+1 : 1;
		this.change();
	},
	change: function() {
		$( '#imagescroll_button_' + this.Current ).removeClass( 'imagescroll-button-current' ).addClass( 'imagescroll-button-none' );
		$( '#imagescroll_scroller' ).fadeOut(100, function(){imagescroll.hide();});
	},
	hide: function() {
		$( '#imagescroll_scroller' ).removeClass();
		this.show();
	},
	show: function() {
		this.Current = this.Pos;
		$( '#imagescroll_button_' + this.Pos ).removeClass( 'imagescroll-button-none' ).addClass( 'imagescroll-button-current' );
		$( '#imagescroll_scroller' ).addClass( 'imagescroll-images-' + this.Pos ).fadeIn(500);
		if(this.Playing) this.delay();
	},
	select: function( p ) {
		if(this.Playing) this.stop();
		if(this.Pos != p) {
			this.Pos = p;
			this.change();
		}
		return false;
	}
};
