var m_grupos = ["AUXILIARES_DE_LA_ADMINISTRACION_GENERAL"]

var AUXILIARES_DE_LA_ADMINISTRACION_GENERAL = {"AUXILIARES_DE_LA_ADMINISTRACION_GENERAL___TEMARIO_DE_MATERIAS_COMUNES_Y_ESPECIFICAS":46,
"AUXILIARES_DE_LA_ADMINISTRACION_GENERAL___COLECCION_DE_TEST_PSICOTECNICOS":20,
"AUXILIARES_DE_LA_ADMINISTRACION_GENERAL___COLECCION_COMPLETA":66}


function calcular(){
	/*Recorremos las matrices*/
	var precio_total = 0;
	for (aux in m_grupos){
		/*Obtenemos el array*/
		m_nombres = eval(m_grupos[aux])
		
		/*Obtenemos las unidades seleccionadas*/
		var precio_total_grupo = 0
		for (campo in m_nombres){
			objInputText = eval("window.document.forms[0]." + campo);
			// Unidades seleccionadas
			unidades = objInputText.value;
			unidades = parseInt(unidades)
			if (isNaN(unidades)){
				unidades = 0;
			}
			if (unidades == 0){
				objInputText.value = "";
			}
			
			//Precio por unidad
			precio = m_nombres[campo];

			valor = unidades * precio; 
			
			//Ponemos el valor
			objTotal = document.getElementById(campo + "_TOTAL");
			if (valor != 0){
				objTotal.innerText = convertirEnDecimal(valor);
			}
			else{
				objTotal.innerText = "-";
			}
			
			//Sumamos al total
			precio_total_grupo += valor;
			
			
		}
		objAgTotal = document.getElementById(m_grupos[aux] + "_TOTAL");
		if (precio_total_grupo != 0){
			objAgTotal.innerText = convertirEnDecimal(precio_total_grupo);
		}
		else{
			objAgTotal.innerText = " ";
		}
	
	}
	
}

function convertirEnDecimal(qvalor){
	/*Ponemos tres decimales*/
	qvalor += 0.001;
	
	/*Lo convertimos en string*/
	//qvalor += "";
	var aux = new String(qvalor);
	
	/*Sustituimos el punto por una coma*/
	posicion = aux.indexOf(".");
	parteEntera = aux.substring(0, posicion)
	parteDecimal = aux.substring(posicion + 1, aux.length)
	aux = parteEntera + "," + parteDecimal;
	
	/*Eliminamos el último caracter*/
	aux = aux.substring(0, aux.length - 1);
	
	return aux;
}
