var nit_caroucel = Class.extend({

	init: function(obj)
	{
		this.count 	= obj.count || 0;
		this.width 	= obj.width || 500;
		this.parent = obj.parent;
		this.next 	= obj.next_class || '.carousel_next';
		this.prev 	= obj.prev_class || '.carousel_prev';
		this.numofelements = $(this.parent).children('li').length - 1;

		var self = this;

		$(this.next).click(function(event){
			self.slide_to('next');
		});
		$(this.prev).click(function(event){
			self.slide_to('prev');
		});

		if(obj.start_index)
			self.slide_to(obj.start_index);

	},

	slide_to: function(index)
	{
		if(index == 'next')
		{
			if(this.count < this.numofelements)
				this.count = this.count + 1;
		}
		else if(index == 'prev')
		{
			if(this.count > 0)
				this.count = this.count - 1;
		}
		else
		{
			this.count = parseInt(index);
		}
		this.slide(this.count);
	},

	slide: function(index)
	{
		var lft = index * this.width;
		$(this.parent).animate({left:'-'+lft+'px'});
	}

});
