

 //script para calcular las tres medias                    
        function compute(form){
			E =80;  //total números
			N = 0;
			SUM = 0.0;
			var theList = new Array();
			//calcula la media aritmética
			// Lee todos los datos, añade los que tienen valores válidos
			// Corregir! Si el dato es una letra no da error!!!!
			for(i = 0; i < E; i++) {
				if(!isNaN(parseFloat(form.elements[i].value))) { 
					SUM += parseFloat(form.elements[i].value);
					theList[N]=parseFloat(form.elements[i].value);
					N++;  
					}
                }

			if(N<=1) { 
				alert("Insuficientes datos."); }
			else { 
				// Hace las cuentas
				x = SUM / N;
				z = Math.round(10000000*x)/10000000;
				form.MEAN.value = z; 
				
				//Calcula la media geométrica				
				// Lee todos los datos, para ver si todos son positivos, Si uno es negativo o cero para
				// Corregir! Si el dato es una letra no da error!!!!
       			var GM=0;
				var error = 0;
				for(i = 0; i<theList.length; i++) {               
					if(theList[i]<0) {
						error++;
						}
					}
				var error0 = 0;
				for(i = 0; i<theList.length; i++) {               
					if(theList[i]==0) {
						error0++;
						}
					}
				var G1 = 0;
				if(error>0) {
					form.GM.value = "No existe para valores negativos"; }
				else {
				if(error0>0) {
					form.GM.value ="0"; }
				else {
					// Hace las cuentas
					for(i = 0; i<theList.length; i++) { 
						G1 += Math.log(theList[i]);                   
                        }
					GM = G1/N;
					var e = 2.7182818284590452353602874712;
					var GM2 = Math.pow(e,GM);
					GM2 = Math.round(10000000*GM2)/10000000;
					form.GM.value = GM2;
					}
        		
				}
				
				//calcula la media Armónica				
				// Lee todos los datos, para ver si todos son positivos, Si uno es negativo o cero para
				// Corregir! Si el dato es una letra no da error!!!!
				
        		var error2 = 0;
				for(i = 0; i<theList.length; i++) {               
					if(theList[i]==0) {
						error2++;
						}
					}
				var H1=0;
				if(error2>0) {
					form.HM.value = "No existe para valor cero"; }
				else {
				// Hace las cuentas
					for(i = 0; i<theList.length; i++) { 
					   H1 += 1/(theList[i]);                   
                       }
					if(H1==0) {
						form.HM.value = "NO existe"; }
					else  {
						var HM = N/H1;
						var HM1 = Math.round(10000000*HM)/10000000;
						form.HM.value = HM1;
						}
					}
				
			} //Mira para insuficientes datos
		}


        
