﻿function showTestResult(testForm) {	function maxOf(ix,ar) {		for (var i = 0; i < ar.length; ++i) {			if (i != ix && ar[i] >= ar[ix]) return false;		}		return true;	}	if (testForm) {		var g1 = getCheckedRadio(testForm.g1);		var g2 = getCheckedRadio(testForm.g2);		var g3 = getCheckedRadio(testForm.g3);		var g4 = getCheckedRadio(testForm.g4);		var g5 = getCheckedRadio(testForm.g5);		var g6 = getCheckedRadio(testForm.g6);		var g7 = getCheckedRadio(testForm.g7);		var g8 = getCheckedRadio(testForm.g8);		// check form completion		if (g1 && g2 && g3 && g4 && g5 && g6 && g7 && g8) {			// sum points			var points = [ 0,0,0,0,0,0,0 ];			points[ g1 - 1 ]++;			points[ g2 - 1 ]++;			points[ g3 - 1 ]++;			points[ g4 - 1 ]++;			points[ g5 - 1 ]++;			points[ g6 - 1 ]++;			points[ g7 - 1 ]++;			points[ g8 - 1 ]++;			// check result			hideElement("formTest");			if (maxOf(0,points)) {				showElement("rr1");			} else if (maxOf(1,points)) {				showElement("rr2");			} else if (maxOf(2,points)) {				showElement("rr3");			} else {				showElement("rr4");			}		} else {			alert("Devi completare il test prima di richiedere il risultato");		}	}	return false;}
