var LargeCarrousel = new function() {

	var _c = this;

	this.init = function() {

	    // Init properties
	    _c.elements = $(".large_carrousel .items .item");

	    _c.middle_bar = $(".large_carrousel .middle_bar");

	    _c.bottom_bar = $(".large_carrousel .bottom_bar")

	    _c.left_arrow = $(".large_carrousel").find(".nav.left");
	    _c.right_arrow = $(".large_carrousel").find(".nav.right");

	    _c.item_width = 85;
	    _c.item_marge = 2;
	    _c.item_count = _c.elements.length;
	    _c.max_visible_width = 314;
      
	    _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
	    $(".large_carrousel .items .infos").hide();

	    _c.elements
	      .css("width", _c.item_width + "px")
	      .css("margin", _c.item_marge + "px")
	      .css("float","left")
	      .css("opacity","0.5");

	    $(".large_carrousel .wrapper")
	      .css("position","relative")
	      .css("width",_c.item_width + "px")
	      .css("left", _c.base_left + "px");

	    $(".large_carrousel .items")
	      .css("position","relative")
	      .css("height","110px")
	      .css("width",(_c.total_width +10) + "px");

	    $(".large_carrousel .middle_bar").show();

	    $(".large_carrousel .scrollable")
	      .css("height","110px")
	      .css("overflow","hidden");

	    $(".large_carrousel .nav").show();


	    // Init scroll api
	    _c.scroll_api = $(".large_carrousel .wrapper").scrollable({
		    horizontal:true,
		    size:1,
		    onSeek: _c.onSeek
		}).mousewheel({ api: true });

	    if (_c.scroll_api) {

		// Init cursor placement
		_c.scroll_api.next();

		// Bind buttons
		_c.right_arrow.click(_c.next);
		_c.left_arrow.click(_c.prev);
	    }




	};
          
	
	this.next = function(e) {
	    _c.scroll_api.next($(".large_carrousel .wrapper li").first);
	}
	
         
	
	this.prev = function(e) {
	    _c.scroll_api.prev($(".large_carrousel .wrapper li").first)
	}
	

	this.onSeek = function() {
                    
	    _c.elements.css("opacity","0.5");
	    _c.current_index = this.getIndex();

	    var current_element = $(_c.elements[_c.current_index]).css("opacity","1");

	    _c.middle_bar.children("h4").remove();
	    _c.bottom_bar.children(".details").remove();

	    var margins = " 0 " + (_c.base_left + 2) + "px";

	    _c.middle_bar.append(current_element.find("h4").clone().css("margin",margins).show());

	    _c.bottom_bar.append(current_element.find(".details").clone().css("margin",margins).show());
	    
	    _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();

	    }
	};

	 
    }
