$(document).ready(function() {
	/*************** Autoajustar imagenes a sus contenedoras ***************/	
	$(".ajustarDimensiones").each(function(){	 
		//Esta versión ajusta la imagen a su cotenedora basándose en el ancho (puede quedar un enorme margen abajo
		//Obtener las dimensiones del padre
		var maxWidth = $(this).parent().width();	 
		var imgWidth = $(this).width();
		var imgHeight = $(this).height();
		var newWidth = maxWidth;	 	
		//Calculamos el ratio		
		var ratio = imgWidth/maxWidth;
		var newHeight = imgHeight/ratio;	 
		//Y aplicamos las nuevas dimensiones
		$(this).css({
			//height: newHeight,
			width: newWidth,
		}); 
	});
	$(".ajustarDimensionesOverflowH").each(function() {	
		//Esta versión ajusta la imagen cubriendo siempre toda la contenedora y haciendo overflow hidden al resto
		
		$(this).parent().css("overflow","hidden");
		var maxWidth = $(this).parent().width();
		var maxHeight = $(this).parent().height();
		var imgWidth = $(this).width();
		var imgHeight = $(this).height();
		var newWidth = maxWidth;	 	
		//Calculamos el ratio		
		var ratio = imgWidth/maxWidth;
		var newHeight = imgHeight/ratio;	 
		//Preguntamos si el nuevo alto es demasiado pequeño
		if (newHeight<maxHeight) {
			//En este caso, ajustamos el alto a la celda
			$(this).height(maxHeight);
			//Y ahora movemos la imagen hasta la mitad para que quede centrada
			$(this).css("position","relative");
			$(this).css("left","-"+(($(this).width()/2)-(maxWidth/2))+"px");
		}
		else {
			//Y aplicamos las nuevas dimensiones
			$(this).css({
				//height: newHeight,
				width: newWidth,
			}); 
		}
	});
	/***********************************************************************/
	//Over del menu del pie
	$('#menuInferior a').hover(
		function () {
			$(this).animate({color:'#C90019'}, {queue:false,duration:500});
		}, function () {
			$(this).animate({color:'#000000'}, {queue:false,duration:500});
		}
	);
	//Over del menu de coleccion (izquierda)
	$('.botonColeccion').hover(
		function () {
			$(this).find(".botonColeccion_texto").animate({paddingLeft:"15px"}, {queue:false,duration:500});
		}, function () {
			$(this).find(".botonColeccion_texto").animate({paddingLeft:"0px"}, {queue:false,duration:500});
		}
	);
});
/*scroll la ventana a 0*/
//setTimeout("window.scrollTo(0,0)",1500);
