function init(){

	$("#vetrina").scrollIt({elStep:2, el:"dl", extra:5, elVis:1});
}



/* plugin scrolling
- - - - - - - - - - - - - - - - - - - - */
(function($) {
  $.fn.scrollIt = function(options) {
		var opts = $.extend({}, $.fn.scrollIt.defaults, options);
				
		
		return this.each(function() {
			$this = $(this);
						
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
			
			var elWidth = $this.find(o.el).width() + o.extra;

			var elTot = $this.find(o.el).size();
			var current = 0;
			var $scroll = $this.find(".scroll");
			var $wrap = $this.find(".wrap");
			var $sx = $this.find(".scroll_sx");
			var $dx = $this.find(".scroll_dx");
			
			$wrap.css({width:(elWidth*elTot) + "px"});
			if (elTot <= o.elVis) {
				$sx.hide();
				$dx.hide();
			} else {
			
				if (($wrap.width()+o.extra) < $scroll.width()) {
					// eliminare scroll e padding
					$sx.hide();
					$dx.hide();
					$wrap.width($this.width());
					$scroll.width($this.width());
					$wrap.css({paddingLeft:"10px"});
				} else {
							
					function muovi(current){
						$wrap.animate({marginLeft:(o.elStep*elWidth*(-current))+"px"},400);
					}
					
					$sx.click(function(){
						if (current != 0) {
							current = current-1;
						}
						muovi(current);
						return false;
					});
					
					$dx.click(function(){
						if (current < (elTot-o.elVis-(o.elStep/o.elVis))) {
							current=current+1;
						}
						muovi(current);
						return false;
					});
					
				}
				
			}
		});
  };
	
	// default
	$.fn.scrollIt.defaults = {
		elVis : 2,
		elStep : 1,
		el : "div",
		extra : 0
  };
})(jQuery);





/* LANCIA INIT */
if(typeof($)=="function"){
	path_assoluto = location.href;
	$(document).ready (init);

}

