slider = {
	viewport: null,
	viewport_id: null,
	set_viewport: function( data ) {
		this.viewport_id = data;
	},
	reel: null,
	reel_id: null,
	set_reel: function( data ) {
		this.reel_id = data;
	},
	image: null,
	image_id: null,
	set_image: function( data ) {
		this.image_id = data;
	},
	nav: null,
	nav_id: null,
	set_nav: function( data ) {
		this.nav_id = data;
	},
	nav_sel_id: null,
	set_nav_sel: function( data ) {
		this.nav_sel_id = data;
	},
	directions: {
		UP_DOWN: 1,
		LEFT_RIGHT: 2
	},
	direction: null,
	set_direction: function( direction ) {
		this.direction = direction;
	},
	view_time: 5, //seconds
	set_view_time: function( data ) {
		this.view_time = data;
	},
	slide_time: 0.5, //seconds
	set_slide_time: function( data ) {
		this.slide_time = data;
	},
	total_images: null,
	active: null,
	timer: null,
	rotate: function() {
		var slide_amount = ( this.active.attr('rel') - 1 );
		if ( this.direction == this.directions.LEFT_RIGHT ) {
			var reel_position = ( slide_amount * this.viewport.width() );
		}
		else {
			var reel_position = ( slide_amount * this.viewport.height() );
		}
		$(this.nav_id + ' a').removeClass(this.nav_sel_id);
		this.active.addClass(this.nav_sel_id);
		if ( this.direction == this.directions.LEFT_RIGHT ) {
			this.reel.animate({
				left: -reel_position
			},(this.slide_time * 1000));
		}
		else {
			this.reel.animate({
				top: -reel_position
			},(this.slide_time * 1000));
		}
	},
	setup: function() {
		this.viewport = $(this.viewport_id);
		this.reel = $(this.viewport_id + ' ' + this.reel_id);
		this.image = $(this.image_id);
		this.total_images = $(this.viewport_id + ' ' + this.reel_id + ' ' + this.image_id + ' img').size();
		if ( this.direction == this.directions.LEFT_RIGHT ) {
			this.image.css('float','left');
			this.reel.css('width',( this.viewport.width() * this.total_images ));
		}
		else {
			this.reel.css('height',( this.viewport.height() * this.total_images ));
		}
		var parent = this;
		/*this.reel.hover(function() {
			clearInterval(parent.timer);
		},
		function() {
			parent.go();
		});*/
		$(this.nav_id + ' a').click(function() {
			parent.active = $(this);
			clearInterval(parent.timer);
			parent.rotate();
			parent.go();
			return false;
		});
	},
	go: function() {
		this.setup();
		var parent = this;
		this.timer = setInterval(function() {
			parent.active = $(parent.nav_id + ' a.' + parent.nav_sel_id).next();
			if ( parent.active.length === 0 ) {
				parent.active = $(parent.nav_id + ' a:first');
			}
			parent.rotate();
		},( this.view_time * 1000 ));
	}
}
$(document).ready(function() {
	slider.set_viewport('#index-rotating-image-container');
	slider.set_reel('#index-rotating-image-reel');
	slider.set_image('.rotating_image');
	slider.set_direction( slider.directions.LEFT_RIGHT );
	slider.set_nav('#index-rotating-image-nav');
	slider.set_nav_sel('irin_entry_selected');
	slider.go();
});
