function ControllaForm(){
	var controllo=false; 
	if (document.submit_login_form.LGN_username.value == "" )
	{
	controllo=true;
	alert("Attenzione: Hai lasciato vuoto il campo username");
	}
	if (document.submit_login_form.LGN_password.value == "" )
	{
	controllo=true;
	alert("Attenzione: Hai lasciato vuoto password");
	} 
	if (controllo){return false}else{return true} 
}

function help(){
	window.open('help/help.htm','login', "status=NO,toolbar=NO,directories=no,menubar=no,width=550,height=350,resizable=yes,scrollbars=yes,top=20,left=25");
}

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];}
}

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_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
    //window.open(theURL,winName,"");
}

function MM_close_openWindow(theURL,winName,features) {
    aprichiudi=window.open(theURL,winName,features);
	aprichiudi.focus();
    //window.open(theURL,winName,"");
}


function apri_dida(){
		window.open('{ROOT}lab_simul/frameset.html?lab={A_NAME}&u_id={UTENTE_U_ID}&a_id={A_ID}&u_nome={UTENTE_NOME_ID}','finestra', 'fullscreen=yes, location=no, resizable=no' );
		
}

function close_update(){
	window.opener.location.reload();
	window.close();
}

function validateForm() {
	if		(document.forms.reg_esp("title") != null)  {
						if		(document.reg_esp.title.value=="") {	 
							alert("manca il titolo del Materiale");
							return false;
						}
	}
	if		(document.forms.reg_esp("userfile") != null)  {
						if		(document.reg_esp.userfile.value=="" )  {
								alert("Il file che illustra il Materiale è obbligatorio!");
								return false;
						}
	}
	if		(document.reg_esp.autvis[0].checked==true)  {
						if		(document.forms.reg_esp("sottotit") != null)  {
								if		(document.reg_esp.sottotit.value=="") {	 
										alert("manca il sottotitolo del Materiale");
										return false;
								}
						}
			
						if		(document.forms.reg_esp("descr_atvt[]") != null)  {
								var err;
								err=true;
								var i = null;
								for (i=1; i < document.reg_esp("descr_atvt[]").length; i++) {
										if     (document.reg_esp("descr_atvt[]").options[i].selected) {
												err=false;
										}
								}
								if     (err==true) {
											alert("scegli almeno un descrittore");
											return false;			
								}
						}
			
						if     (document.reg_esp.provincia.value==0){
							alert("scegli la  provincia");
							return false;			
						}
	}
	return true;
}
////////////////AGGIUNTO DA ME
function toggleLayer(whichLayer){
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function show(whichLayer){
	if (document.getElementById)
	{
		// this is the way the standards work
		var style1 = document.getElementById(whichLayer).style;
		style1.display = "block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style1 = document.all[whichLayer].style;
		style1.display = "block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style1 = document.layers[whichLayer].style;
		style1.display = "block";
	}
}

function hide(whichLayer){
	if (document.getElementById)
	{
		// this is the way the standards work
		var style1 = document.getElementById(whichLayer).style;
		style1.display = "none";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style1 = document.all[whichLayer].style;
		style1.display = "none";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style1 = document.layers[whichLayer].style;
		style1.display = "none";
	}
}

////////////ajax/////////////////////////////////////////////////////////
function upd_sess_active(id,val_act){
	var check_sessioneo = document.getElementById("iscriz_attiva_" + id);
	var box = document.getElementById("box_sess_" + id);
	var ajax = assegnaXMLHttpRequest();
	var risultato = '';
	if(ajax) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link = "";
	ajax.open("post", "index.php" , true);
	ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link += "action=act_upd_sessioni";
	link += "&";
	link += "id_sess=" + id;
	link += "&";
	link += "val_act=" + val_act;
	if (val_act == 1)
	{
		var dis = "";
		var color = "#35B35E"
	}
	else
	{
		var dis = "dis";
		var color = "#C85220"
	}
	ajax.send(link);
	ajax.onreadystatechange = function() {
	  if(ajax.readyState === 4) {
		  if(ajax.status == 200){
				box.style.backgroundColor = color;
				risultato = ajax.responseText;
				alert("Sessione " + dis + "attivata:" + id +"!");
			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax.status);
		  }
	  }
	}	
}

////////////////////AJAX
function assegnaXMLHttpRequest() {
	var
	 XHR = null,
	 browserUtente = navigator.userAgent.toUpperCase();
	 if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")  XHR = new XMLHttpRequest();
	 else if(window.ActiveXObject &&	  browserUtente.indexOf("MSIE 4") < 0){
		  if(browserUtente.indexOf("MSIE 5") < 0)  XHR = new ActiveXObject("Msxml2.XMLHTTP");
		  else   XHR = new ActiveXObject("Microsoft.XMLHTTP");
	 }
	 return XHR;
}


function canc_iscr(id_lms,utente,num) {
	var box_iscritto = document.getElementById("ok_" + utente + "_" + id_lms);
	var box_no_iscritto = document.getElementById("no_ok_" + utente + "_" + id_lms);
	//var utente = document.getElementById("corsista_id");
	var risorsa_check = document.getElementById("risorsa_" + id_lms);
	var risultato_query = document.getElementById("risultato_query");
	var ajax = assegnaXMLHttpRequest();
	var risultato = '';
	if(ajax) {
		}
		else
		{
		alert('Il tuo browser non è abilitato per usare questo programma\n ajax!');
	}
	var link = "";
	ajax.open("post", "index.php" , true);
	ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
	link += "action=canc_iscriz_discipline";
	link += "&";
	link += "id_lms=" + id_lms;
	link += "&";
	link += "id_utente=" + utente;
	ajax.send(link);
	ajax.onreadystatechange = function() {
	  if(ajax.readyState === 4) {
		  if(ajax.status == 200){
				box_iscritto.style.display =  "none";
				box_no_iscritto.style.display =  "block";
				//risorsa_check.checked = true;
				//box_no_iscritto.style.backgroundColor = "#C98756";
				risultato = ajax.responseText;
				//risultato_query.innerHTML = risultato;
				alert("Iscrizione cancellata!");
			}
			else
			{
				alert("Operazione fallita, errore numero " + ajax.status);
		  }
	  }
	}	
}



////////////////////FINE AJAX
if (document.layers) {
document.captureEvents(Event.ONDBLCLICK);
}

