/**
 * SPINBOX (http://www.newxdesign.com)
 * A jQuery plugin for creating spinboxes form a list of elements.
 * 
 * Version 1.0
 * April 3th, 2009
 *
 * Copyright (c) 2009 newxdesign (http://www.newxdesign.com)
 * Dual licensed under the MIT and GPL licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/gpl-license.php
 *
 **/ 
(function($){ 
    jQuery.fn.archivelist = function() {
				var element = this;
				var menosi = -1;
				var maisi = 0;
				var elemento = new Array();
				var vel = 0;
				var	roling = false;
				var	mright = 0;
				var	mleft = 0;
				var movimento = 0;
				var carrossel = $(element).children();
				var container_w = $(element).width()
				var car_w = $(element).children().width();
				var item_w = $(carrossel).children().width();
				var posicao = $(element).children().position();
				
				$(element).addClass("archivelist_main");
				$(carrossel).addClass("archivelist_roler");
				$(element).children().children().each(function(){
					elemento.push($(this).html());	
				});
			
			//$('a[rel*=facebox]').facebox();
				$(element).bind('mouseout',function(){ 
						clearInterval(movimento)
						roling = false;	
				  })
				  .bind('mouseover',function(e){
						if(!roling) { 
							evento = e; 
							movimento = setInterval(anda,10); 
						}
				  })
				  .bind('mousemove', function(e){
						meio = (e.clientX-($(element).width()/2));
						vel = meio / 30;
				  });
		
			
		
		function anda() {
			roling = true;
			container_w = $(element).width()
			car_w = $(element).children().width();
			posicao = $(element).children().position();
			stoppos = car_w*(-1) - container_w*(-1);
			var pos = posicao['left'];
			pos -= parseInt(vel/4);
			//pos = parseInt(pos);
			if((pos < 0) && (pos > stoppos)) {	
				$("#posi").html(parseInt(vel/4));
				$(carrossel).css("left", pos+"px");
			}
	 	};	
	}
})(jQuery); 
