// l'indice a scomparsa è inizialmente chiuso
menuOpen = false;

//funzione per apertura/chiusura indice a scomparsa
function ShowHide(){  // nasconde e scopre il menu
	if (menuOpen)
	{	 
		MM_showHideLayers('menu','','hide');
		menuOpen = false;
	}
	else
		{MM_showHideLayers('menu','','show');
		menuOpen = true;
 	}
}

//funzioni varie per apertura popup, precarimento e scambio immagine, mostra/nascondi layer ecc.
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//variabile per settare a null il popup
var PopInfo_ = null;

//funzione per aprire il popup di help
function open_help()
{
	if (PopInfo_ == null)
	{
		var aw = screen.availWidth;
		var ah = screen.availHeight;
 		var tw = aw/2-350;
 		var th = ah/2-200;
 		var w  = 700;
 		var h  = 400;
 		var ciRo = 'width='+w+',height='+h+',left='+tw+',top='+th+',screenX='+tw+',screenY='+th+'menu=no,status=no,location=no,resizable=no,scrollbars=yes';
		PopInfo_ = window.open('../help/help.html','help',ciRo);
		PopInfo_.focus();	
	}
	else
	{
		PopInfo_.close();
		var aw = screen.availWidth;
		var ah = screen.availHeight;
 		var tw = aw/2-350;
 		var th = ah/2-200;
 		var w  = 700;
 		var h  = 400;
 		var ciRo = 'width='+w+',height='+h+',left='+tw+',top='+th+',screenX='+tw+',screenY='+th+'menu=no,status=no,location=no,resizable=no,scrollbars=yes';
		PopInfo_ = window.open('../help/help.html','help',ciRo);
		PopInfo_.focus();
	}
}

//funzione per aprire il popup delle esercitazioni
function open_ese()
{
	if (PopInfo_ == null)
	{
		var aw = screen.availWidth;
		var ah = screen.availHeight;
 		var tw = aw/2-320;
 		var th = ah/2-240;
 		var w  = 640;
 		var h  = 480;
 		var ciRo = 'width='+w+',height='+h+',left='+tw+',top='+th+',screenX='+tw+',screenY='+th+'menu=no,status=no,location=no,resizable=no,scrollbars=no';
		PopInfo_ = window.open(ese_,'esercitazione',ciRo);
		PopInfo_.focus();	
	}
	else
	{
		PopInfo_.close();
		var aw = screen.availWidth;
		var ah = screen.availHeight;
 		var tw = aw/2-320;
 		var th = ah/2-240;
 		var w  = 640;
 		var h  = 480;
 		var ciRo = 'width='+w+',height='+h+',left='+tw+',top='+th+',screenX='+tw+',screenY='+th+'menu=no,status=no,location=no,resizable=no,scrollbars=no';
		PopInfo_ = window.open(ese_,'esercitazione',ciRo);
		PopInfo_.focus();
	}
}

//funzione per pagina stampabile
function open_printable() 
{
	if (PopInfo_ == null)
	{
		var aw = screen.availWidth;
		var ah = screen.availHeight;
 		var tw = aw/2-240;
 		var th = ah/2-150;
 		var w  = 487;
 		var h  = 300;
 		var ciRo = 'width='+w+',height='+h+',left='+tw+',top='+th+',screenX='+tw+',screenY='+th+'menu=no,status=no,location=no,resizable=no,scrollbars=yes';
		PopInfo_ = window.open(stampabile_, 'stampa', ciRo);
		PopInfo_.focus();	
	}
	else
	{
		PopInfo_.close();
		var aw = screen.availWidth;
		var ah = screen.availHeight;
 		var tw = aw/2-240;
 		var th = ah/2-150;
 		var w  = 487;
 		var h  = 300;
 		var ciRo = 'width='+w+',height='+h+',left='+tw+',top='+th+',screenX='+tw+',screenY='+th+'menu=no,status=no,location=no,resizable=no,scrollbars=yes';
		PopInfo_ = window.open(stampabile_, 'stampa', ciRo);
		PopInfo_.focus();
	}
}

//funzione per aprire suggerimento
function open_suggerimento(sugg_) 
{
	if (PopInfo_ == null)
	{
		var aw = screen.availWidth;
		var ah = screen.availHeight;
 		var tw = aw/2-240;
 		var th = ah/2-150;
 		var w  = 487;
 		var h  = 300;
 		var ciRo = 'width='+w+',height='+h+',left='+tw+',top='+th+',screenX='+tw+',screenY='+th+'menu=no,status=no,location=no,resizable=no,scrollbars=yes';
		PopInfo_ = window.open(sugg_, 'sugg', ciRo);
		PopInfo_.focus();	
	}
	else
	{
		PopInfo_.close();
		var aw = screen.availWidth;
		var ah = screen.availHeight;
 		var tw = aw/2-240;
 		var th = ah/2-150;
 		var w  = 487;
 		var h  = 300;
 		var ciRo = 'width='+w+',height='+h+',left='+tw+',top='+th+',screenX='+tw+',screenY='+th+'menu=no,status=no,location=no,resizable=no,scrollbars=yes';
		PopInfo_ = window.open(sugg_, 'sugg', ciRo);
		PopInfo_.focus();
	}
}

//funzione per aprire il popup di ripasso dal feedback MCH
function open_lnk(lnk_)
{
	if (PopInfo_ == null)
	{
		var aw = screen.availWidth;
		var ah = screen.availHeight;
 		var tw = aw/2-325;
 		var th = ah/2-264;
 		var w  = 651;
 		var h  = 528;
 		var ciRo = 'width='+w+',height='+h+',left='+tw+',top='+th+',screenX='+tw+',screenY='+th+'menu=no,status=no,location=no,resizable=no,scrollbars=no';
		PopInfo_ = window.open(lnk_,'lnk',ciRo);
		PopInfo_.focus();	
	}
	else
	{
		PopInfo_.close();
		var aw = screen.availWidth;
		var ah = screen.availHeight;
 		var tw = aw/2-325;
 		var th = ah/2-264;
 		var w  = 651;
 		var h  = 528;
 		var ciRo = 'width='+w+',height='+h+',left='+tw+',top='+th+',screenX='+tw+',screenY='+th+'menu=no,status=no,location=no,resizable=no,scrollbars=no';
		PopInfo_ = window.open(lnk_,'lnk',ciRo);
		PopInfo_.focus();
	}
}

//Funzioni stampa
var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 

function printPage(frame, arg) {
  if (frame == window) {
    printThis();
  } else {
    link = arg; // a global variable 
    printFrame(frame);
  }
  return false;
}

function printThis() {
  if (pr) { // NS4, IE5
    window.print();
  } else if (da && !mac) { // IE4 (Windows)
    vbPrintPage();
  } else { // other browsers
    alert("Sorry, your browser doesn't support this feature.");
  }
}

function printFrame(frame) {
  if (pr && da) { // IE5
    frame.focus();
    window.print();
    link.focus();
  } else if (pr) { // NS4
    frame.print();
  } else if (da && !mac) { // IE4 (Windows)
    frame.focus();
    setTimeout("vbPrintPage(); link.focus();", 100);
  } else { // other browsers
    alert("Sorry, your browser doesn't support this feature.");
  }
}

if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}

//Funzione per ritorno alla home page del modulo
function backHome()
{
	top.tree.location.href = "../menu_tree.html";
}

//Controlli per audio singolo in formato SWF
function PlayFlashMovie ()
{
	if (navigator.userAgent.indexOf('Gecko') != -1)
	{
	flashMovie=window.document.flashMovie
	flashMovie.Play();
	}
	else
	{
	flashMovie.Play();
	}
}

function StopFlashMovie ()
{
	if (navigator.userAgent.indexOf('Gecko') != -1)
	{
	flashMovie=window.document.flashMovie
	flashMovie.Stop();
	}
	else
	{
	flashMovie.Stop();
	}
}

//funzione abilitazione navigazione per tipologie vincolate
function abilitaNextVincolato ()
{
	Pos_= parent.lessonlocation_.indexOf("|");
	idx = parent.lessonlocation_.substring(0, Pos_);
	
	//page = parent.lessonlocation_.substring(Pos_+1, Pos_ + parent.lessonlocation_.length);
	if (eval(idx) > eval(idnode)){
		var fake = avanti1.style.visibility;
		MM_showHideLayers('avanti1','','show');
	}
}

//funzioni mostra/nascondi simulazione
function showSimul () {
	scriviSimul ();
	MM_showHideLayers('simul','','show');
	MM_showHideLayers('chiudiSimul','','show');
}

function hideSimul () {
	if (navigator.userAgent.indexOf('Mac') != -1)
	{
	simulazione_=eval('window.document.simulazione');
	simulazione_.StopPlay();
	//chiamaMetodo(1);
	}
	else
	simulazione.Stop();
	//chiamaMetodo(1);
	MM_showHideLayers('simul','','hide');
	MM_showHideLayers('chiudiSimul','','hide');
}

function mostra(simulazione)
{
	document.getElementById("simul").innerHTML = simulazione;
	MM_showHideLayers('simul','','show');
	MM_showHideLayers('chiudiSimul','','show');
}

function nascondi(simulazione)
{
	document.getElementById("simul").innerHTML = simulazione;
	MM_showHideLayers('simul','','hide');
	MM_showHideLayers('chiudiSimul','','hide');
}

//funzione abilitazione navigazione per tipologie libere
function abilitaNextLibero ()
{
		var fake = avanti1.style.visibility;
		MM_showHideLayers('avanti1','','show');
}


//funzioni apertura e chiusura div a scomparsa
function showPrint () {
	MM_showHideLayers('printpopup','','show');
	MM_showHideLayers('helppopup','','hide');
	MM_showHideLayers('suggpopup','','hide');
}

function hidePrint () {
	MM_showHideLayers('printpopup','','hide');
}

function showHelp () {
	MM_showHideLayers('helppopup','','show');
	MM_showHideLayers('printpopup','','hide');
	MM_showHideLayers('suggpopup','','hide');
}

function hideHelp () {
	MM_showHideLayers('helppopup','','hide');
}

function showSugg () {
	MM_showHideLayers('suggpopup','','show');
	MM_showHideLayers('printpopup','','hide');
	MM_showHideLayers('helppopup','','hide');
}

function hideSugg () {
	MM_showHideLayers('suggpopup','','hide');
}

function showRipasso () {
	MM_showHideLayers('ripassopopup','','show');
}

function hideRipasso () {
	MM_showHideLayers('ripassopopup','','hide');
}

function showEse () {
	MM_showHideLayers('esepopup','','show');
	MM_showHideLayers('esepopuptop','','show');
}

function hideEse () {
	MM_showHideLayers('esepopup','','hide');
	MM_showHideLayers('esepopuptop','','hide');
}

//----------- INIZIO SEZIONE FUNZIONI ESERCIZI MCH -----------

//funzione preload e rollover immagini risposta giusta/sbagliata per esercizi MCH
if(document.images)//+ preload immagini
{
	ghost_ = new Image();
	ghost_.src = "../img/ghost.gif";
	
	rok_ = new Image();
	rok_.src = "../img/true.gif";
	
	rko_ = new Image();
	rko_.src = "../img/false.gif";
	
}

function Rolle(x_, y_)//+ rollover immagini
{
	if(document.images)
	{
		document.images[x_].src = eval(y_ + ".src");
		//document.images[x_].alt = eval(y_ + ".alt");
	}
}

//funzione selezione risposta esercizi MCH (sia OR che AND)
flag_=new Array(6);
for (var i=1; i < 10; i++) {
flag_[i]=0;
}

img_grr = new Array(10);
for (var i=1; i < 10; i++) {
   img_grr[i] = new Array(10)
      for (var j=1; j < 10; j++) {
            img_grr[i][j] = '../img/' +'select' + j + '.gif';
            //alert(img_grr[i][j]);
            }
	}
	
RispostaData_ = new Array(10)
for (var i=1; i < 10; i++) {
	RispostaData_[i] = 0;
}

//funzione di selezione MCH OR
function SelezioneUtente(i,j)
{
	for (var l=1; l < 10; l++) {
		flag_[l]=0;
	}
	flag_[j]=1;
	if (RispostaData_[i] != j){	
		img_grr[i][j] = '../img/' + 'select'+ j +'.png';
		MM_swapImage('select'+ j,'','../img/mch0' + j + '_on.png',1)
		temp_="../img/mch_on.png";
		tmp_='selected' + j;
		MM_swapImage(tmp_,'',temp_,1)
		RispostaData_[i] = j;
	      	for (var k=1; k < 10; k++) {
	            if (RispostaData_[i] != k)
	            {
	            	img_grr[i][k] = '../img/' + 'select'+ k +'.png';
			MM_swapImage('select'+ k,'','../img/mch0' + k + '.png',1)
			tmp3_='selected' + k;
			MM_swapImage(tmp3_,'','../img/mch.png',1)
	            }
	        }
	}
}

//funzione di selezione MCH AND
function SelezioneUtenteAnd(i,j)
{
	if (flag_[j] !=1) {
	flag_[j]=1;
	if (RispostaData_[i] != j){	
		img_grr[i][j] = '../img/' + 'select'+ j +'.png';
		MM_swapImage('select'+ j,'','../img/mch0' + j + '_on.png',1)
		temp_="../img/mch_on.png";
		tmp_='selected' + j;
		MM_swapImage(tmp_,'',temp_,1)
		RispostaData_[i] = j;
	      	for (var k=1; k < 10; k++) {
	            if (RispostaData_[i] != k)
	            {
	            	img_grr[i][k] = '../img/' + 'select'+ k +'.png';
			//MM_swapImage('select'+ k,'','../img/mch0' + k + '.png',1)
			tmp3_='selected' + k;
			//MM_swapImage(tmp3_,'','../img/mch.png',1)
	            }
	        }
	}
    }
    else
    {
    	img_grr[i][j] = '../img/' + 'select'+ j +'.png';
	MM_swapImage('select'+ j,'','../img/mch0' + j + '.png',1)
	tmp3_='selected' + j;
	MM_swapImage(tmp3_,'','../img/mch.png',1)
	flag_[j]=0;
	RispostaData_[i] = 0;
	for (var k=1; k < 10; k++) 
	{
		if (flag_[k]!=0) 
			{
			RispostaData_[i] = 1;
			break
			}
	}
     }	
}

//funzione di set del risultato esercizi
function setresult(r)
{
	if (once_ == false){
	parent.result = parent.result+r;
	once_ = true;
	}
}

//funzione di set dei vari parametri (tempo, punteggio, location) alla piattaforma
function setta_parametri()
{
if (ultima == true){
			//alert('ultima pagina, punteggio: ' + parent.result);
			parent.time_= parent.TimeManager();
			//parent.SetScore(parent.result); 
			//modifica per attestato.
			// parent.initPage(pageType, lesLoc);
			parent.initPage("0", lesLoc);
		}
else {
			//alert('non è l\'ultima pagina, punteggio: ' + parent.result);
			parent.time_= parent.TimeManager();
			//parent.SetScore(parent.result);  
			parent.initPage(pageType, lesLoc);
}		
}

//funzione controllo soluzioni MCH ORsenza tracciamento
function ControllaSoluzioni()
{
	var Svolto_ = 1;
	if (EsercizioEseguito_ == 0)
	{
		PunteggioEsercizio_ = 0;
		for (i_ = 1; i_ < NumeroGruppi_ + 1; i_++)
		{
				if (RispostaData_[i_] == 0)
				{
					Svolto_=0; 
				}
		}
		if (Svolto_ != 1)
		{
			alert ("Completa l'esercizio.")
		}
		else
		{
			for (i_ = 0; i_ < NumeroGruppi_; i_++)
			{
				var PunteggioParziale_ = 0;
				var RiuscitaGruppo_ = 0;
				
				n_ = i_ + 1;
				PunteggiGruppo_ = eval("PunteggiGruppo" + n_ + "_");
				for (ii_ = 0; ii_ < PunteggiGruppo_.length; ii_++)
				{
					nn_ = ii_ + 1;
					if (RispostaData_[n_]==nn_)
					{
						PunteggioEsercizio_ = 0 + PunteggioEsercizio_ + PunteggiGruppo_[ii_];
						PunteggioParziale_ = 0 + PunteggioParziale_ + PunteggiGruppo_[ii_];
					}
				}
				
				RollSoluzione_ = eval("RollSoluzioni" + n_ + "_");
				for (ii_ = 0; ii_ < RollSoluzione_.length; ii_++)
				{
					nn_ = ii_ + 1;
					Roll_ = "gr" + n_ + "r" + nn_;
					//Roll_ = "selected" +n_ + nn_;
					
					if (RollSoluzione_[ii_] == 1)
					{
						Rolle(Roll_, "rok_");
					}
					else if (RispostaData_[n_]==nn_)
					{
						Rolle(Roll_, "rko_");
						MM_showHideLayers('feedback','','show')
					}
					
				}
				//!r20010907 DOVE LA RIUSCITA DEL GRUPPO È UGUALE AL MAGGIORE DEI PUNTEGGI DEL GRUPPO
				var Max_ = 0;
				for (ii_ = 0; ii_ < PunteggiGruppo_.length; ii_++)
				{
					if (Max_ < PunteggiGruppo_[ii_])
					{
						Max_ = PunteggiGruppo_[ii_];
					}
				}
				RiuscitaGruppo_ = Max_;
				
				
			}
			//#############################
			//setresult(PunteggioEsercizio_)
			//setta_parametri();
			//alert (PunteggioEsercizio_);
			//#############################
			//if (ultima == false){MM_showHideLayers('avanti1','','show')}			
			EsercizioEseguito_ = 1;
		}
	}
}

//funzione controllo soluzioni MCH OR con tracciamento punteggio
function ControllaSoluzioniPunteggio()
{
	var Svolto_ = 1;
	if (EsercizioEseguito_ == 0)
	{
		PunteggioEsercizio_ = 0;
		for (i_ = 1; i_ < NumeroGruppi_ + 1; i_++)
		{
				if (RispostaData_[i_] == 0)
				{
					Svolto_=0; 
				}
		}
		if (Svolto_ != 1)
		{
			alert ("Completa l'esercizio.")
		}
		else
		{
			for (i_ = 0; i_ < NumeroGruppi_; i_++)
			{
				var PunteggioParziale_ = 0;
				var RiuscitaGruppo_ = 0;
				
				n_ = i_ + 1;
				PunteggiGruppo_ = eval("PunteggiGruppo" + n_ + "_");
				for (ii_ = 0; ii_ < PunteggiGruppo_.length; ii_++)
				{
					nn_ = ii_ + 1;
					if (RispostaData_[n_]==nn_)
					{
						PunteggioEsercizio_ = 0 + PunteggioEsercizio_ + PunteggiGruppo_[ii_];
						PunteggioParziale_ = 0 + PunteggioParziale_ + PunteggiGruppo_[ii_];
					}
				}
				
				RollSoluzione_ = eval("RollSoluzioni" + n_ + "_");
				for (ii_ = 0; ii_ < RollSoluzione_.length; ii_++)
				{
					nn_ = ii_ + 1;
					Roll_ = "gr" + n_ + "r" + nn_;
					//Roll_ = "selected" +n_ + nn_;
					
					if (RollSoluzione_[ii_] == 1)
					{
						Rolle(Roll_, "rok_");
					}
					else if (RispostaData_[n_]==nn_)
					{
						Rolle(Roll_, "rko_");
					}
					
				}
				//!r20010907 DOVE LA RIUSCITA DEL GRUPPO È UGUALE AL MAGGIORE DEI PUNTEGGI DEL GRUPPO
				var Max_ = 0;
				for (ii_ = 0; ii_ < PunteggiGruppo_.length; ii_++)
				{
					if (Max_ < PunteggiGruppo_[ii_])
					{
						Max_ = PunteggiGruppo_[ii_];
					}
				}
				RiuscitaGruppo_ = Max_;
				
				
			}
			//#############################
			setresult(PunteggioEsercizio_)
			setta_parametri();
			//alert (PunteggioEsercizio_);
			//#############################
			EsercizioEseguito_ = 1;				
			if (pageType == 4){
				parent.SetScore(parent.result);
			}/*else {*/
				if (parent.result > 100 )
					parent.result=100;
				/*alert ("il tuo punteggio è "+ parent.result)
				if (parent.result >= 70){
					document.location.replace("attestato.html");
					}
				}*/
		}
	}
}

//funzione controllo soluzioni MCH AND senza tracciamento
function ControllaSoluzioniAnd()
{
	var Svolto_ = 1;
	if (EsercizioEseguito_ == 0)
	{
		PunteggioEsercizio_ = 0;
		for (i_ = 1; i_ < NumeroGruppi_ + 1; i_++)
		{
				if (RispostaData_[i_] == 0)
				{
					Svolto_=0; 
				}
		}
		if (Svolto_ != 1)
		{
			alert ("Completa l'esercizio.")
		}
		else
		{
			for (i_ = 0; i_ < NumeroGruppi_; i_++)
			{
				var PunteggioParziale_ = 0;
				var RiuscitaGruppo_ = 0;
				
				n_ = i_ + 1;
				PunteggiGruppo_ = eval("PunteggiGruppo" + n_ + "_");
				for (ii_ = 0; ii_ < PunteggiGruppo_.length; ii_++)
				{
					nn_ = ii_ + 1;
					if (RispostaData_[n_]==nn_)
					{
						PunteggioEsercizio_ = 0 + PunteggioEsercizio_ + PunteggiGruppo_[ii_];
						PunteggioParziale_ = 0 + PunteggioParziale_ + PunteggiGruppo_[ii_];
					}
				}
				
				RollSoluzione_ = eval("RollSoluzioni" + n_ + "_");
				for (ii_ = 0; ii_ < RollSoluzione_.length; ii_++)
				{
					nn_ = ii_ + 1;
					Roll_ = "gr" + n_ + "r" + nn_;
					//Roll_ = "selected" +n_ + nn_;
					
					if (RollSoluzione_[ii_] == 1)
					{
						Rolle(Roll_, "rok_");
					}
					else if (RollSoluzione_[ii_] == 0 && flag_[nn_]==1)
					{
						Rolle(Roll_, "rko_");
						MM_showHideLayers('feedback','','show')
					}
					
				}
				//!r20010907 DOVE LA RIUSCITA DEL GRUPPO È UGUALE AL MAGGIORE DEI PUNTEGGI DEL GRUPPO
				var Max_ = 0;
				for (ii_ = 0; ii_ < PunteggiGruppo_.length; ii_++)
				{
					if (Max_ < PunteggiGruppo_[ii_])
					{
						Max_ = PunteggiGruppo_[ii_];
					}
				}
				RiuscitaGruppo_ = Max_;
				
				
			}
			//#############################
			//setresult(PunteggioEsercizio_)
			//setta_parametri();
			//alert (PunteggioEsercizio_);
			//#############################
			//if (ultima == false){MM_showHideLayers('avanti1','','show')}			
			EsercizioEseguito_ = 1;
		}
	}
}

//funzione controllo soluzioni MCH AND con tracciamento punteggio
function ControllaSoluzioniAndPunteggio()
{
	var Svolto_ = 1;
	if (EsercizioEseguito_ == 0)
	{
		PunteggioEsercizio_ = 0;
		for (i_ = 1; i_ < NumeroGruppi_ + 1; i_++)
		{
				if (RispostaData_[i_] == 0)
				{
					Svolto_=0; 
				}
		}
		if (Svolto_ != 1)
		{
			alert ("Completa l'esercizio.")
		}
		else
		{
			for (i_ = 0; i_ < NumeroGruppi_; i_++)
			{
				var PunteggioParziale_ = 0;
				var RiuscitaGruppo_ = 0;
				
				n_ = i_ + 1;
				PunteggiGruppo_ = eval("PunteggiGruppo" + n_ + "_");
				for (ii_ = 0; ii_ < PunteggiGruppo_.length; ii_++)
				{
					nn_ = ii_ + 1;
					if (RispostaData_[n_]==nn_)
					{
						PunteggioEsercizio_ = 0 + PunteggioEsercizio_ + PunteggiGruppo_[ii_];
						PunteggioParziale_ = 0 + PunteggioParziale_ + PunteggiGruppo_[ii_];
					}
				}
				
				RollSoluzione_ = eval("RollSoluzioni" + n_ + "_");
				for (ii_ = 0; ii_ < RollSoluzione_.length; ii_++)
				{
					nn_ = ii_ + 1;
					Roll_ = "gr" + n_ + "r" + nn_;
					//Roll_ = "selected" +n_ + nn_;
					
					if (RollSoluzione_[ii_] == 1)
					{
						Rolle(Roll_, "rok_");
					}
					else if (RollSoluzione_[ii_] == 0 && flag_[nn_]==1)
					{
						Rolle(Roll_, "rko_");
					}
					
				}
				//!r20010907 DOVE LA RIUSCITA DEL GRUPPO È UGUALE AL MAGGIORE DEI PUNTEGGI DEL GRUPPO
				var Max_ = 0;
				for (ii_ = 0; ii_ < PunteggiGruppo_.length; ii_++)
				{
					if (Max_ < PunteggiGruppo_[ii_])
					{
						Max_ = PunteggiGruppo_[ii_];
					}
				}
				RiuscitaGruppo_ = Max_;
				
				
			}
			//#############################
			setresult(PunteggioEsercizio_)
			setta_parametri();
			//alert (PunteggioEsercizio_);
			//#############################
			EsercizioEseguito_ = 1;				
			if (pageType == 4){
				parent.SetScore(parent.result);
			}/*else {*/
				if (parent.result > 100 )
					parent.result=100;
				/*alert ("il tuo punteggio è "+ parent.result)
				if (parent.result >= 70){
					document.location.replace("attestato.html");
					}
				}*/
		}
	}
}

//funzione avanzamento alla pagina successiva
function CambiaEsercizio()
{
	if (EsercizioEseguito_ == 1)
	{
		parent.goNext(id_next_);
	}
	else
	{
		alert("Completa l'esercizio per passare al seguente.");
	}
}

function jump_ese(ese){
	if(EsercizioEseguito_==1){
	document.location.replace(ese);
	}
	else{
	alert("Completa l'esercizio prima di andare avanti.");
	}
}

//----------- INIZIO SEZIONE FUNZIONI ESERCIZI FIB -----------

//funzione controllo soluzioni FIB senza tracciamento punteggio
function ControllaSoluzioniFib()
{
	var Svolto_ = 0;
	var NumeroCampi_ = 0;
	
	if (EsercizioEseguito_ == 0)
	{
		PunteggioEsercizio_ = 0;
		
		for (i_ = 0; i_ < NumeroGruppi_; i_++)
		{
			n_ = i_ + 1;
			PunteggiGruppo_ = eval("PunteggiGruppo" + n_ + "_");
			for (ii_ = 0; ii_ < PunteggiGruppo_.length; ii_++)
			{
				nn_ = ii_ + 1;
				Risposta_ = eval("document.gruppi.gr" + n_ + "op" + nn_);
				//alert ("document.gruppi.gr" + n_ + "op" + nn_);
				if (Risposta_.value.length > 0)
				{
					Svolto_++; 
				}
				NumeroCampi_++;
			}
		}
		
		//alert (NumeroCampi_);
		if (Svolto_ != NumeroCampi_)
		{
			alert ("Completa l'esercizio.")
		}
		else
		{
			for (i_ = 0; i_ < NumeroGruppi_; i_++)
			{
				var PunteggioParziale_ = 0;
				var RiuscitaGruppo_ = 0;
				
				n_ = i_ + 1;
				PunteggiGruppo_ = eval("PunteggiGruppo" + n_ + "_");
				for (ii_ = 0; ii_ < PunteggiGruppo_.length; ii_++)
				{
					nn_ = ii_ + 1;
					Risposta_ = eval("document.gruppi.gr" + n_ + "op" + nn_);
					
					//26-10
					while(''+Risposta_.value.charAt(0)==' ') Risposta_.value=Risposta_.value.substring(1,Risposta_.value.length)
					while(''+Risposta_.value.charAt(Risposta_.value.length-1)==' ') Risposta_.value=Risposta_.value.substring(0,Risposta_.value.length-1)
					//
					words=new Array();
					words=Risposta_.value.split(/\s+/);
					Risposta_.value=words.join(' ');
					Soluzione_ = eval("SoluzioniGruppo" + n_ + "_[" + ii_ + "]");
					//26-10
					while(''+Soluzione_.charAt(0)==' ') Soluzione_=Soluzione_.substring(1,Soluzione_.length)
					while(''+Soluzione_.charAt(Soluzione_.length-1)==' ') Soluzione_=Soluzione_.substring(0,Soluzione_.length-1)
					words=new Array();
					words=Soluzione_.split(/\s+/);
					Soluzione_=words.join(' ');
					//
					
					
					if (document.all)
					{
						VediRisposta_ = eval("document.all['soluzione'].document.soluzioni.gr" + n_ + "sol" + nn_);
						VediRisposta_.value = Soluzione_;
					}
					else if (document.layers)
					{
						VediRisposta_ = eval("document.layers['soluzione'].document.soluzioni.gr" + n_ + "sol" + nn_);
						VediRisposta_.value = Soluzione_;
					}
					else if (document.getElementsByTagName && document.getElementById)
					{
						var styleObject = document.getElementById("gr" + n_ + "sol" + nn_);
						if (styleObject != null)
						{
							styleObject.value = Soluzione_;
						}
					}
					
					SoluzioneAlt_ = new Array();
					var de_ = 0;
					var FattoBene_ = false;
					var flag_punto;
					var lungh_=Soluzione_.length-1;
					if (Soluzione_.charAt(lungh_)==".")
						flag_punto=true;
					else 
						flag_punto=false;
					
					for (ed_ = 0; ed_ <= Soluzione_.length; ed_++)
					{
						if (Soluzione_.charAt(ed_) == "#" || ed_ == Soluzione_.length)
						{
							SoluzioneAlt_[ed_] = Soluzione_.substring(de_, ed_);
							//alert (SoluzioneAlt_[ed_]);
							de_ = ed_ + 1;
							lunghrisp_=Risposta_.value.length-1;
							
							if (Risposta_.value.charAt(lunghrisp_)!="." && flag_punto==true)
								Risposta_.value+=".";
							if (Risposta_.value.charAt(lunghrisp_)=="." && flag_punto==false)
								Risposta_.value=Risposta_.value.substring(0,lunghrisp_);
							
								
							if (Risposta_.value.toUpperCase() == SoluzioneAlt_[ed_].toUpperCase())
							{
								FattoBene_ = true;
							}
						}
					}
					
					Roll_ = "gr" + n_ + "r" + nn_;
					if (FattoBene_)
					{
						//alert ("Ok");
						PunteggioEsercizio_ = 0 + PunteggioEsercizio_ + PunteggiGruppo_[ii_];
						PunteggioParziale_ = 0 + PunteggioParziale_ + PunteggiGruppo_[ii_];
						Rolle(Roll_, "rok_");
					}
					else
					{
						//alert ("Ko");
						Rolle(Roll_, "rko_");
					}
				}
				
				if (document.all)
				{
					document.all["soluzione"].style.visibility = "visible";
				}
				else if (document.layers)
				{
					document.layers["soluzione"].visibility = "show";
				}
				else if (document.getElementsByTagName && document.getElementById)
				{
					var styleObject = document.getElementById("soluzione");
					if (styleObject != null)
					{
						styleObject = styleObject.style;
						styleObject["visibility"] = "visible";
					}
				}
				//!r20010907 DOVE LA RIUSCITA DEL GRUPPO È UGUALE ALLA SOMMA DEI PUNTEGGI DEL GRUPPO
				for (ii_ = 0; ii_ < PunteggiGruppo_.length; ii_++)
				{
					RiuscitaGruppo_ = RiuscitaGruppo_ + PunteggiGruppo_[ii_];
				}
				
				//!r20010907 CONFRONTA IL PUNTEGGIO OTTENUTO CON QUELLO NECESSARIO ALLA RIUSCITA DEL GRUPPO
				if (PunteggioParziale_ == RiuscitaGruppo_)
				{
					parent.EserciziRiusciti_ = parent.EserciziRiusciti_ + 1;
				}
			}
			if (ultima == false){MM_showHideLayers('avanti1','','show')}
			EsercizioEseguito_ = 1;

		}
	}
// < !r20010925
	// alert("Punteggio: " + PunteggioEsercizio_);
}
