function ApriFinestra(url,ref,wdt,hgt,top,lft,tool) { 
	var hb = (screen.width - wdt) / 2;
	var vb = (screen.height - hgt) / 2;
	window.open(url,ref,"toolbar=" + tool + ",location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=" + wdt + ",height=" + hgt + ",top=" + vb + ",left=" + hb); 
} 
function controlla_ricerca()
{
	//alert(document.ricerca.cognome.value  + " " + document.ricerca.nome.value);
	if (document.ricerca.cognome.value == "" && document.ricerca.nome.value == "" && document.ricerca.facolta.value == "" && document.ricerca.insegnamento.value == "" && document.ricerca.area.value == "" && document.ricerca.interesse.value == "" && document.ricerca.allegato.value == "")
	{
		alert("Inserire almeno un criterio di ricerca !");
		return false;
	}
	/*if (document.ricerca.cognome.value == "" && document.ricerca.nome.value != '')
	{
		alert("Specificare anche il cognome!");
		return false;
	}
	else
		return true;*/
}
function controlla_campi()
{
	if (document.THEFORM.allegato.value == '') 
	{
		alert('Nessuna foto inserita !');
		return false;
	}
	else
	{
		m1 = /.jpg/;
		m2 = /.gif/;
		//m3 = /.jpeg/;
		//m4 = /.jpe/;
		res1=m1.exec(document.THEFORM.allegato.value.toLowerCase());
		res2=m2.exec(document.THEFORM.allegato.value.toLowerCase());
		//res3=m3.exec(document.THEFORM.AttachFoto_1.value.toLowerCase());
		//res4=m4.exec(document.THEFORM.AttachFoto_1.value.toLowerCase());
		if (!res1 && !res2)
		{
			alert('Il file selezionato non è un\'immagine ! Effuettuare nuovamente la selezione.');
			return false;
		}
		else
		{
			document.THEFORM.submit();
		}
	}
}
function controlla_campi_link()
{
	if ((document.voci_mod.titolo.value == '') || (document.voci_mod.descrizione.value == '')) 
	{
		alert('Inserire tutti i campi !');
		return false;
	}
	else
	{
		return true;
	}
}
function controlla_campi_avvisi()
{
	if ((document.voci_mod.titolo_avviso.value == '')) 
	{
		alert('E\' obbligatorio inserire un titolo per l\'avviso !');
		return false;
	}
	else
	{
		return true;
	}
}
function controlla_campi_allegati()
{
	m1 = /.exe$/;
	m2 = /.com$/;
	m3 = /\"/;
	m4 = / /;
	var i, j;
	i = 0;
	j = 1;
	while (j<document.voci_mod.allegato.value.length)
	{
		if (document.voci_mod.allegato.value.charAt(j) == '\\') i++;
		j++;
	}
	res1=m1.exec(document.voci_mod.allegato.value);
	res2=m2.exec(document.voci_mod.allegato.value);
	res3=m3.exec(document.voci_mod.all_descr.value);
	res4=m3.exec(document.voci_mod.allegato.value);
	if (!res1 && !res2 && !res3 && !res4 && i<=4) 
	{
		if (document.voci_mod.op.value == 'INS')
		{
			if (document.voci_mod.all_descr.value == '' || document.voci_mod.allegato.value == '') 
			{
				alert('Campi "Descrizione allegato" e "File allegato" obbligatori: reinserire.');
				return false;
			}
			else
			{
				seconda();
				document.voci_mod.submit();
			}
		}
		else
		{
			if (document.voci_mod.allegato.value == '')
			{
				seconda();
				return false;
			}
			else
			{
				seconda();
				document.voci_mod.submit();
			}
		}
	}
	else
	{
		if (res1 || res2) alert('Impossibile inviare file eseguibili !');
		if (res3) alert('Impossibile specificare una descrizione con il carattere \" !');
		if (res4) alert('Il pathname del file da allegare non può contenere le doppie virgolette !');
		//if (i>4) alert('Collocare il file da inviare in un\'apposita directory c:\\ALLEGATI');
		return false;
	}
}
function controlla_campi_allegati2()
{
	m1 = /.exe$/;
	m2 = /.com$/;
	res1=m1.exec(document.voci_mod.allegato.value);
	res2=m2.exec(document.voci_mod.allegato.value);
	if (!res1 && !res2) 
	{
			if (document.voci_mod.allegato.value == '') 
			{
				alert('Campo "File allegato" obbligatorio: reinserire.');
				return false;
			}
			else
			{
				seconda2();
				document.voci_mod.submit();
			}
	}
	else
	{
		alert('Impossibile inviare file eseguibili !');
		return false;
	}
}
function chiedi_conferma(doc)
{
	if(confirm('La foto sta per essere eliminata. Continuare ?'))
	{
		window.open('/unicatt/seed/unicatt_docenti_g2.h_delete_campo?id_doc='+doc+'&campo=foto_1','_self');
		return true;
	} 
	else
	{
		return false;
	}
}
function mime()
{
	/*for (i=0; i < navigator.mimeTypes.length; i++) 
	{   document.writeln("<TR VALIGN=TOP><TD>",i,      
		"<TD>",navigator.mimeTypes[i].type,      
		"<TD>",navigator.mimeTypes[i].description,      
		"<TD>",navigator.mimeTypes[i].suffixes)   
	if (navigator.mimeTypes[i].enabledPlugin==null) 
	{      document.writeln(      
		"<TD>None",      "</TR>")   
	} else 
	{      
		document.writeln(      
		"<TD>",navigator.mimeTypes[i].enabledPlugin.name,      
	"</TR>")   
	}*/
	alert(navigator.mimeTypes[3].type);
}
function link_docente(URL)
{
	var features =
        'width='        + screen.availWidth +
        ',height='      + screen.availHeight +
        ',location' +
        ',menubar' +
        ',scrollbars' +
        ',status' +
	',resizable' +
        ',toolbar';
	doc_win1=window.open(URL, "link", features);
	//doc_win1.resizeTo(screen.availWidth,screen.availHeight);
	//alert(screen.availWidth + " " + screen.availHeight);
	doc_win1.focus();
}   
function info_docente(URL)
{
	doc_win=window.open(URL, "info", "width=800,height=600,toolbar,scrollbars,resizable,location,status,menubar,personal,top=0,left=0,screenX=0,screenY=0");
	doc_win.resizeTo(screen.availWidth,screen.availHeight);
	doc_win.focus();
}   
function preview_docente(URL)
{
	doc_win=window.open(URL, "preview", "width=800,height=600,toolbar,scrollbars,location,status,menubar,personal,top=0,left=0,screenX=0,screenY=0");
	doc_win.resizeTo(screen.availWidth,screen.availHeight);
	doc_win.focus();
}   
function info_docente_close()
{
	document.doc_win=null;	
	self.close();
}
function finestra_modifica(URL)
{
	doc_win=window.open(URL, "mod", "width=800,height=600,toolbar=no,location=no,status=yes,menubar=no,personal=no,scrollbars=yes,top=0,left=0,screenX=0,screenY=0");
	doc_win.resizeTo(screen.availWidth,screen.availHeight);
	doc_win.focus();
}
function finestra_modifica2(URL)
{
	doc_win=window.open(URL, "mod", "width=800,height=250,toolbar=no,location=no,status=no,menubar=no,personal=no,scrollbars=yes,top=0,left=0,screenX=0,screenY=0");
	doc_win.resizeTo(screen.availWidth,250);
	doc_win.focus();
}
function seconda()
{
	var i;
	if (document.voci_mod.PI[0].checked) i = 0;
	else i = 1;
	//alert(i);
	//window.location.href="/unicatt/seed/unicatt_docenti_g.ins_mod_allegati?op=INS&all_descr='+document.voci_mod.all_descr.value+'&id_doc='+document.voci_mod.id_doc.value+'&tipi=&lista_nomi=&path_rel='+document.voci_mod.path_rel.value";
	window.open('/pls/docenti/unicatt_docenti_g.ins_mod_allegati?op='+document.voci_mod.op.value+'&id_tema='+document.voci_mod.id_tema.value+'&id_voce='+document.voci_mod.id_voce.value+'&all_descr='+document.voci_mod.all_descr.value+'&id_doc='+document.voci_mod.id_doc.value+'&lingua='+document.voci_mod.lingua.value+'&tipi=&lista_nomi=&path_rel='+document.voci_mod.path_rel.value+'&file='+document.voci_mod.allegato.value+'&posizione='+document.voci_mod.posizione.value+'&pi='+i+'', '');
}
function seconda2()
{
	var i;
	if (document.voci_mod.PI[0].checked) i = 0;
	else i = 1;
	//alert(document.voci_mod.lingua.value);
	//window.location.href="/unicatt/seed/unicatt_docenti_g.ins_mod_allegati?op=INS&all_descr='+document.voci_mod.all_descr.value+'&id_doc='+document.voci_mod.id_doc.value+'&tipi=&lista_nomi=&path_rel='+document.voci_mod.path_rel.value";
	window.open('/pls/docenti/unicatt_docenti_g.ins_programma?id_doc='+document.voci_mod.id_doc.value+'&tipi=&lista_nomi=&id_corso='+document.voci_mod.id_corso.value+'&path_rel='+document.voci_mod.path_rel.value+'&file='+document.voci_mod.allegato.value+'&pi='+i+'&anno='+document.voci_mod.anno.value+'&sede='+document.voci_mod.sede.value+'&lingua='+document.voci_mod.lingua.value+'&utente='+document.voci_mod.utente.value+'&password='+document.voci_mod.password.value, '');
}
function showLayer(layer)
{
	if (navigator.appName=='Microsoft Internet Explorer')
	{
		object=eval("document.all."+layer+".style");
		object.visibility="visible";
	}
	else
	{
		object=eval("document."+layer);
		object.visibility="show";
	}
}
function hideLayer(layer)
{
	if (navigator.appName=='Microsoft Internet Explorer')
	{
		object=eval("document.all."+layer+".style");
		object.visibility="hidden";
	}
	else
	{
		object=eval("document."+layer);
		object.visibility="hide";
	}
}
function hideLayers()
{
	hideLayer('Layer3');
	hideLayer('Layer4');
	hideLayer('Layer5');
	hideLayer('Layer6');
	hideLayer('Layer7');
}
function controlla_date()
{
	ds1      = document.reload.data1.value;
        ds2      = document.reload.data2.value;
        //giorno1 = document.forma.data_ora_1.options[ds1].text.split(" ");
        d1      = ds1.split("/");
        //giorno2 = document.forma.data_ora_2.options[ds2].text.split(" ");
        d2      = ds2.split("/");
 	//alert(d1[0]+" "+d1[1]+" "+d2[0]+" "+d2[1]);
        //alert(document.forma.data_1.options[ds1].text);
        if ((d1[0] > d2[0] && d1[1] >= d2[1]) || (d1[1] > d2[1]))
	{
        	alert('La 1ª data é maggiore della 2ª');
		return false;
	}
	else
        	document.reload.submit();
}