$(function(){
	var maximos = {"res_abrasion": 4, "res_corte": 5, "res_rasgado": 4, "res_perforacion": 4, "inflam": 4, "cal_contacto": 4, "cal_convectivo": 4, "cal_radiante": 4, "salp_metal": 4, "masas_metal": 4, "res_frio_convectivo": 4, "res_frio_contacto": 4, "imperm_agua": 4};
	/*
	 * Al seleccionar un test modificamos el desplegable de niveles asociado
	 */
	$("div#lateral dl dd.rendimiento select.test").change(function(){
		var $test = $(this);
		var num = $test.attr("name").match(/^rendimiento\[(\d+)\]\[test\]$/)[1];
		var $nivel = $("div#lateral dl dd.rendimiento select.nivel[name=rendimiento\\[" + num + "\\]\\[nivel\\]]");

		$nivel.fadeOut("fast").empty().append('<option value=""></option>');
		for(var i=1; i<=maximos[$test.val()]; i++){
			$nivel.append('<option value="' + i + '">' + i + "</option>");
		}
		$nivel.fadeIn("fast");
	});
});

