var Carrousel = new function() {

	var _c = this;

	this.init = function() {

	    // Init properties
	    _c.elements = $(".carrousel .items .item");

	    _c.left_arrow = $(".large_carrousel").find(".nav.left");
	    _c.right_arrow = $(".large_carrousel").find(".nav.right");

	    _c.item_width = 150;
	    _c.item_marge = 0;
	    _c.item_count = _c.elements.length;
	    _c.max_visible_width = 150;
      
	    _c.total_width = (_c.item_width + (2 * _c.item_marge)) * _c.item_count;
          
	    _c.base_left = ((_c.max_visible_width - (2 * (_c.item_width + _c.item_marge))) / 2);


	    // Init styles
	    _c.elements
	      .css("width", _c.item_width + "px")
	      .css("margin", _c.item_marge + "px")
	      .css("float","left");

	    $(".carrousel .wrapper")
	      .css("position","relative")
	      .css("width",_c.item_width + "px")
	      .css("left", _c.base_left + "px");

	    $(".carrousel .items")
	      .css("position","relative")
	      .css("width",(_c.total_width +10) + "px");

	    $(".carrousel .scrollable")
	      .css("overflow","hidden");

	    $(".carrousel .nav").show();


	    // Init scroll api
	    _c.scroll_api = $(".carrousel .scrollable").scrollable({
		    horizontal:true,
		    size:1,
		    onSeek: _c.onSeek
		}).mousewheel({ api: true });
	};

	

	this.onSeek = function() {
	    
	    _c.refreshArrows();


	};

	this.refreshArrows = function() {



	    if (_c.current_index == 0) {

		_c.right_arrow.show();
		_c.left_arrow.hide();
		
	    } else if(_c.current_index + 1 >= _c.item_count) {

		_c.right_arrow.hide();
		_c.left_arrow.show();

	    } else {

		_c.right_arrow.show();
		_c.left_arrow.show();

	    }
	};
	 
    };
