var paso=6;
var tiempoPaso=10;
var cursor=0;
var idInterval;
var minimo;
var maximo;

$(document).ready(function () {
	$('.menu li ul li').mouseover(function(){
		$(this).addClass('menuOver');
	});
	$('.menu li ul li').mouseout(function(){
		$(this).removeClass('menuOver');
	});	
 
		
	$(".alineacion_v img").load(function(){
		$(this).css('margin-top',-($(this).height()/2));
		$(this).css('top','50%');
		$(this).css('position','absolute');
	});
	
	scrollear();
	

});

function scrollear(){
	
	anchoScroll = $("#scroll_fotos div").size() * 237;
	anchoContenedor = $(".fotos_categoria").width();
	
	if (anchoContenedor < anchoScroll){
		minimo = anchoContenedor-anchoScroll;
	
		$("#scroll_fotos").addClass("scroll");
		$("#scroll_fotos").css('width',anchoScroll);
		$(".fotos_categoria").css('height','146px');
				
		$("#flechaIzda").mouseover(function(){
			idInterval = setInterval("mover(1)",tiempoPaso); 
		});
		$("#flechaIzda").mouseout(function(){
			clearInterval(idInterval);
		});
		
		$("#flechaDcha").mouseover(function(){
			idInterval = setInterval("mover(-1)",tiempoPaso); 
		});
		$("#flechaDcha").mouseout(function(){
			clearInterval(idInterval);
		});	
		
		$("#flechaIzda").show();
		$("#flechaDcha").show();
	}		
	

}

function mover(direccion){
	movimiento = direccion*paso;
	if (cursor+movimiento<minimo){
		movimiento = minimo-cursor;
	}
	if (cursor+movimiento>0){
		movimiento = 0-cursor;
	}
	cursor = cursor + movimiento;
	
	$("#scroll_fotos").animate({left: '+=' + movimiento}, tiempoPaso);
}

