var LW_Carousel = function(lw_carouselpanel,lw_carouselitem,lw_leftarrow,lw_rightarrow,lw_speed,lw_movewhen,lw_margin) {
	this.carouselpanel = lw_carouselpanel
	this.carouselitem = lw_carouselitem
	this.leftarrow = lw_leftarrow
	this.rightarrow = lw_rightarrow
	this.speed = lw_speed
	this.movewhen = lw_movewhen
	this.itemmargin = lw_margin
	this.curTimer = 0;
	$("." + this.carouselpanel + " ." + this.carouselitem + ":first").before($("." + this.carouselpanel + " ." + this.carouselitem + ":last"))
	if (lw_movewhen=='onclick') {
		this.OverCarouselLeft = 1;
		this.OverCarouselRight = 1;
		$("." + this.rightarrow + " img").click(function(){
			self.OverCarouselRight = 1;
			self.MoveCarouselRight();
			//get the width of the items ( i like making the jquery part dynamic, so if you change the width in the css you won't have o change it here too ) '
		});
		$("." + this.leftarrow + " img").click(function(){
			self.OverCarouselLeft = 1;
			self.MoveCarouselLeft();
		});
	} else {
		this.OverCarouselLeft = 0;
		this.OverCarouselRight = 0;
		$("." + this.rightarrow + " img").mouseover(function(){
			self.OverCarouselRight = 1;
			self.MoveCarouselRight();
			//get the width of the items ( i like making the jquery part dynamic, so if you change the width in the css you won't have o change it here too ) '
		});
		$("." + this.rightarrow + " img").mouseout(function(){
			self.OverCarouselRight = 0;
		});
		
		$("." + this.leftarrow + " img").mouseover(function(){
			self.OverCarouselLeft = 1;
			self.MoveCarouselLeft();
		});
		$("." + this.leftarrow + " img").mouseout(function(){
			self.OverCarouselLeft = 0;
		});
	}
	this.MoveCarouselLeft = function() {
		if (self.OverCarouselLeft == 1) {
			var item_width = $("." + self.carouselpanel + " ." + self.carouselitem + ":first").outerWidth()+self.itemmargin;
			var left_indent = parseInt($("." + self.carouselpanel).css('left')) + item_width;
			$("." + self.carouselpanel + ":not(:animated)").animate({'left' : left_indent},self.speed,function(){    
				$("." + self.carouselpanel + " ." + self.carouselitem + ":first").before($("." + self.carouselpanel + " ." + self.carouselitem + ":last")); 
				$("." + self.carouselpanel).css({'left' : parseInt($("." + self.carouselpanel).css('left')) - item_width +'px'});
			});
			if (self.movewhen!='onclick') {
				self.curTimer = setTimeout(self.MoveCarouselLeft,1);
			}
		}
	}
				
	this.MoveCarouselRight = function() {
		if (self.OverCarouselRight == 1) {
			var item_width = $("." + self.carouselpanel + " ." + self.carouselitem + ":first").outerWidth()+self.itemmargin;
			var left_indent = parseInt($("." + self.carouselpanel).css('left')) - item_width;
			$("." + self.carouselpanel + ":not(:animated)").animate({'left' : left_indent},self.speed,function(){    
				$("." + self.carouselpanel + " ." + self.carouselitem + ":last").after($("." + self.carouselpanel + " ." + self.carouselitem + ":first")); 
				$("." + self.carouselpanel).css({'left' : parseInt($("." + self.carouselpanel).css('left')) + item_width +'px'});
			}); 
			if (self.movewhen!='onclick') {
				self.curTimer = setTimeout(self.MoveCarouselRight,1);
			}
		}
	}
	var self = this;
	
}