function Carousel(element) {
	var me = this;
	
	me.marginTop = 0;
	me.marginLeft = 0;
	me.columns = 7;
	me.duration = 1500;
	
	setCarouselElement(element);
	initialize();
	
	function initialize() {
		$jq(me.element).trigger('firstset');
		$jq(me.element).bind('lastset', function() { });
		$jq(me.element).bind('firstset', function() { });
	}
	function setSpeed(duration) {
		me.duration = duration;
		
		return me;
	}
	function setHeight(height) {
		me.height = height;
		
		return me;
	}
	function setWidth(width) {
		me.width = width;
		
		return me;
	}
	function slideUp() {

	}
	function slideDown() {

	}
	function slideLeft() {
		if (me.slideWidth == undefined) { throw 'No slide width is defined.'; }
		
		if ((me.marginLeft - (me.slideWidth * me.columns)) > (me.width * -1)) {
			me.marginLeft = me.marginLeft - (me.slideWidth * me.columns);
			
			var listElement = me.element + ' ul';
			$jq(listElement).stop();
			$jq(listElement).animate({marginLeft: me.marginLeft + 'px'}, me.duration,
				function() {
					if ((me.marginLeft - (me.slideWidth * me.columns)) <= (me.width * -1)) { $jq(me.element).trigger('lastset'); }
				});
		}
		
		return me;
	}
	function slideRight() {
		if (me.slideWidth == undefined) { throw 'No slide width is defined.'; }
		
		if ((me.marginLeft + (me.slideWidth * me.columns)) <= 0) {
			me.marginLeft = me.marginLeft + (me.slideWidth * me.columns);
			
			var listElement = me.element + ' ul';
			$jq(listElement).stop();
			$jq(listElement).animate({marginLeft: me.marginLeft + 'px'}, me.duration,
				function() {
					if (me.marginLeft == 0) { $jq(me.element).trigger('firstset'); }
				});
		}
		return me;
	}
	function setCarouselElement(element) {
		me.element = element;
		
		setElements(element + ' ul li');
		
		return me;
	}
	function setElements(elements) {
		me.elements = elements;
		
		return me;
	}
	function updateSize() {
		me.margins = {};
		
		var length	= $jq(me.elements).length;
		if (length > 0) {
			/(\d+)px/.test($jq(me.elements).css('margin-left')); me.margins.left = RegExp.$1;		
			/(\d+)px/.test($jq(me.elements).css('margin-right')); me.margins.right = RegExp.$1;
			/(\d+)px/.test($jq(me.elements).css('margin-top')); me.margins.top = RegExp.$1;
			/(\d+)px/.test($jq(me.elements).css('margin-bottom')); me.margins.bottom = RegExp.$1;
			
			var imageElement = $jq(me.elements)[0].getElementsByTagName('img')[0];
			var height	= imageElement.height;
			var width	= imageElement.width;
			
			setHeight(Math.round((length * height) / 7));
			setWidth((width * length) + (me.margins.left * length) + (me.margins.right * length));
			
			log(length + ' ' + height + ' ' + width);
		}
		
		return me;
	}
	function setSlideDirection(direction) {
		if (me.elements == undefined) { throw 'No elements are defined.'; }
		
		switch (direction) {
			case 'vertical':
				break;
			case 'horizontal':
				var ul = $jq(me.elements)[0].parentNode;
				$jq(ul).width(me.width);
				
				var imageElement = $jq(me.elements)[0].getElementsByTagName('img')[0];
				var width	= imageElement.width;
				
				me.slideWidth = parseInt(width) + parseInt(me.margins.left) + parseInt(me.margins.right);
				setColumns(parseInt($jq(me.element + ' div.viewport').width() / me.slideWidth));
				break;
			default:
				throw 'Direction given is not valid, should be "vertical" or "horizontal".'; 
		}
		me.slideDirection = direction;
		
		return me;
	}
	function setOptions(options) {
		$jq(options).each(function(item, index) { alert(index); });
	}
	function setColumns(columns) {
		me.columns = columns;
		
		return me;
	}
	function setSlideWidth(width) {
		me.slideWidth = width;
		
		return me;
	}
	function log(text) {
		try {
			if (console) { console.log(text); }
		} catch (e) {}
	}
	this.updateSize = updateSize;
	this.initialize = initialize;
	this.setCarouselElement = setCarouselElement;
	this.setOptions = setOptions;
	this.setSlideDirection = setSlideDirection;
	this.setSlideWidth = setSlideWidth;
	this.setColumns = setColumns;
	this.log = log;
	this.setElements = setElements;
	this.setSpeed = setSpeed;
	this.setHeight = setHeight;
	this.setWidth = setWidth;
	this.slideLeft = slideLeft;
	this.slideRight = slideRight;
	this.slideUp = slideUp;
	this.slideDown = slideDown;
}