function tut_reset_pwd_confirm(target_url)
{
if (confirm("Attenzione!\nLa password dell'utente sta per essere resettata.\n "))
	{
	location.href= target_url;
	}
}


function validazione(){

with(document.modulo) {
	if(mat_title.value=="") {
	alert("Inserire il titolo del materiale");
	mat_title.focus();
	return false;
	}
	if(mat_description.value=="") {
	alert("Inserire la descrizione");
	mat_description.focus();
	return false;
	}
	if(mat_file.value=="") {
	alert("Inserire il file da inviare");
	mat_file.focus();
	return false;
	}

}

return true;
}

function chiudi_formazione(c_id,area){
popupWin =window.open('index.php?action=tutor_chiudi_formazione&c_id='+c_id+'&area_t='+area+'','chiudi_formazione','width=300,height=140,left=10,top=10,scrollbars=no,resizable=YES');
}


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 hideSchedaLink(name){
	document.getElementById('open_'+name).style.display = 'none';
	document.getElementById('close_'+name).style.display = 'block';
}

function showSchedaLink(name){
	document.getElementById('open_'+name).style.display = 'block';
	document.getElementById('close_'+name).style.display = 'none';
}

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 changecolor(theRow, newColor){
    var theCells = null;
	var c = null;

    // 1. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

	  // 2 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    var rowCellsCnt  = theCells.length;
	// 3 ... with DOM compatible browsers except Opera
	if (domDetect) {
		for (c = 0; c < rowCellsCnt; c++) {
			theCells[c].setAttribute('bgcolor', newColor, 0);
		} // end for
	}
	// 4 ... with other browsers
	else {
		for (c = 0; c < rowCellsCnt; c++) {
			theCells[c].style.backgroundColor = newColor;
		}
	}
}

function materie(obj){
	mat_win=window.open('materie.php?obj='+obj,'mat', "status=no,toolbar=no,directories=no,menubar=no,width=350,height=400,resizable=yes,scrollbars=yes,top=200,left=250");
	mat_win.focus();
}

// sara 28-09-2004 - cerca nome, cognome, cod fiscale, u_id di direttore di corso o e-tutor in base al profilo (prf) e all'area (area)
function tut_dir(obj1,obj2,obj3,obj4,prf){

	//var index = document.dati_corso.elements[0].selectedIndex;
	//var area = document.dati_corso.elements[0][index].value;
	var area = document.dati_corso.elements[0].value;
	window.status='tut_dir.php?obj1='+obj1+'&obj2='+obj2+'&prf='+prf+'&area='+area;

	dir_tut_win=window.open('tut_dir.php?obj1='+obj1+'&obj2='+obj2+'&obj3='+obj3+'&obj4='+obj4+'&prf='+prf+'&area='+area,'dir_tut', "status=no,toolbar=no,directories=no,menubar=no,width=410,height=430,resizable=yes,scrollbars=yes,top=500,left=250");
	dir_tut_win.focus();
}

// >> sara - 26 sett 08 - prese da ATA
function materie(obj){
	mat_win=window.open('materie.php?obj='+obj,'mat', "status=no,toolbar=no,directories=no,menubar=no,width=350,height=400,resizable=yes,scrollbars=yes,top=200,left=250");
	mat_win.focus();
}

function show_legenda_profili(){
	prof_win=window.open('dsp_legenda_profili.php','prof', "status=no,toolbar=no,directories=no,menubar=no,width=350,height=400,resizable=yes,scrollbars=yes,top=200,left=250");
	prof_win.focus();
}

function show_legenda_aree(){
	aree_win=window.open('dsp_legenda_aree.php','aree', "status=no,toolbar=no,directories=no,menubar=no,width=400,height=400,resizable=yes,scrollbars=yes,top=200,left=250");
	aree_win.focus();
}

function openWindow(url, name) {
  popupWin = window.open(url, name, 'width=700,height=550,left=0,top=0,scrollbars=yes,resizable=yes,toolbar=no');
}
// << sara - 26 sett 08 - prese da ATA



function win_resize(what){
		var screen_width=window.screen.width;
		var screen_height=window.screen.height;
		winame='OpeWin';
		win_witdth=screen_width-15;
		win_height=screen_height-60;
		how='width='+win_witdth+',height='+win_height+',top=2,left=2,scrollbars=1,toolbar=0,alwaysRaised=1,dependent=1';
		var err=java_test();
		if	(err=0) {
				window.open(what,winame,how);
				}
			else {
				self.location.replace('javaerr.html');
		}
}


function java_test() {
	var strVer=navigator.userAgent;
	var reply;
	var err;
	if (!window.navigator.javaEnabled()) {
			err=1;
			}
		else {
			err=0;
	}
	return err;
}

//////////////////////////////gio  23/01/2004

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 aprinews(url){
	window.open(url, 'news', 'toolbar=no,directories=no,menubar=no,width=750,height=350,resizable=yes,scrollbars=yes,top=10,left=30');
}

function apri(url){
	window.open(url, 'news', 'toolbar=no,directories=no,menubar=no,width=800,height=650,resizable=yes,scrollbars=yes,top=10,left=30');
}

function apri_repository(url){
	window.open(url, 'repository', 'toolbar=no,directories=no,menubar=no,width=800,height=650,resizable=yes,scrollbars=yes,top=10,left=30');
}

function apri_form(url,quant,id_prof_cms){
	var quant = document.lo.quantity.value;
	var id_prof_cms = document.lo.id_prof_cms.value;
	window.open(url +'?num='+ quant +'&id_prof_cms='+id_prof_cms, 'news', 'toolbar=no,directories=no,menubar=no,width=400,height=300,resizable=yes,scrollbars=yes,top=10,left=30');
}

function apri_libreria(url){
	window.open(url, 'libreria', 'toolbar=no,directories=no,menubar=no,width=600,height=500,resizable=yes,scrollbars=yes,top=10,left=30');
}

function apri_box(url){
	window.open(url, 'box', 'toolbar=no,directories=no,menubar=no,width=700,height=550,resizable=yes,scrollbars=yes,top=10,left=30');
}

function apri_small(url){
	window.open(url, 'libreria', 'toolbar=no,directories=no,menubar=no,width=350,height=300,resizable=yes,scrollbars=yes,top=10,left=30');
}

function apri_libreria_add(url){
	window.open(url, 'libreria', 'toolbar=no,directories=no,menubar=no,width=600,height=500,resizable=yes,scrollbars=yes,top=10,left=30');
}

function apri_ftp(url){
	window.open(url, 'ftp', 'toolbar=no,directories=no,menubar=no,width="90%",height=500px,resizable=yes,scrollbars=yes,top=5,left=5');
}

function apri_avviso_home(url, name) {
  popupWin =window.open(url,name,'width=752,height=400,left=30,top=30,scrollbars=no,resizable=yes');
}

function apri_avviso_tutor(url, name) {
  popupWin =window.open(url,name,'width=452,height=300,left=30,top=30,scrollbars=no,resizable=yes');
}

function del_coll_atvt(id_atvt,id_atvt_coll){
popupWin =window.open('index.php?action=atvt_del_collega&id_atvt='+id_atvt+'&id_atvt_coll=' + id_atvt_coll,'pubbl','width=8,height=6,left=30,top=30,scrollbars=no,resizable=no');
}

function aggiorna_crediti(u_id,a_id){
popupWin =window.open('index.php?action=tutor_dsp_dettattivita2&u_id='+u_id + '&a_id=' + a_id,'aggiorna','width=8,height=6,left=30,top=30,scrollbars=YES,resizable=YES');
}

function pubblica_elab(id){
popupWin =window.open('index.php?action=tutor_pub_elab&id='+id,'aggiorna','width=8,height=6,left=30,top=30,scrollbars=YES,resizable=YES');
}

function no_pubblica_elab(id){
popupWin =window.open('index.php?action=tutor_no_pub_elab&id='+id,'aggiorna','width=8,height=6,left=30,top=30,scrollbars=YES,resizable=YES');
}

function print_attestato(u_id,c_id,nome,a,a_t,data_nascita,nome_tutor,cognome_tutor,dati_istituto){
popupWin =window.open('tutor_dsp_print_attestato.php?u_id='+u_id+'&c_id='+c_id+'&nome_cognome='+nome+'&area='+a+'&area_t='+a_t+'&data_nascita='+data_nascita+'&nome_tutor='+nome_tutor+'&cognome_tutor='+cognome_tutor+'&dati_istituto='+dati_istituto+'','aggiorna','width=700,height=600,left=10,top=10,scrollbars=YES,resizable=YES');
}
/*function print_attestato(u_id,a,f,m,area){
popupWin =window.open("tutor_dsp_print_attestato.php?u_id="+u_id+"&c_id="+a+"&nome_cognome="+f+"&area={NOME_AREA}&area_t="+area,"aggiorna","width=700,height=600,left=10,top=10,scrollbars=YES,resizable=YES");
}*/

function print_portfolio(u_id,a,f,m,s){
popupWin =window.open('dsp_print_modlist.php?u_id='+u_id+'&cr_atvt='+a+'&cr_forum='+f+'&cr_mat='+m+'&cr_sin='+s+'&nome_cognome={NOME} {COGNOME}&area={NOME_AREA}&area_t={AREA_T}','portfolio','width=700,height=600,left=10,top=10,scrollbars=YES,resizable=YES');
}

function print_portfolio_mat(u_id){
popupWin =window.open('dsp_print_matlist.php?u_id='+u_id+'&nome_cognome={NOME} {COGNOME}&area={NOME_AREA}&area_t={AREA_T}','portfolio','width=700,height=600,left=10,top=10,scrollbars=YES,resizable=YES');
}

function print_portfolio_atvt(u_id){
popupWin =window.open('dsp_print_atvtlist.php?u_id='+u_id+'&nome_cognome={NOME} {COGNOME}&area={NOME_AREA}&area_t={AREA_T}','portfolio','width=700,height=600,left=10,top=10,scrollbars=YES,resizable=YES');
}
//////////////////////////////fine gio  23/01/2004

////////////////////////////Marco  x simulazioni 19/3/2003

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' );

}

///////////////////////////////////////////Giovanni 15/10/2004
function forum_open(url){
		window.open(url,'forum', 'fullscreen=yes, scrollbars=yes, location=no, resizable=no' );
}

function apri_assist(id){
		window.open('{ROOT}offerta_new/index.php?action=atvt_dsp_cms_intro&id_atvt='+id+'&assist=1','atvt', 'width=700,height=500,left=20,top=20,scrollbars=yes,resizable=yes' );
}

function apri_crediti(id){
		window.open('{ROOT}offerta_new/index.php?action=atvt_dsp_cms_intro&id_atvt='+id,'atvt', 'width=780,height=500,left=20,top=20,scrollbars=yes,resizable=yes' );
}

function atvt_dsp_cms_intro(id,lms_a_id){
		window.open('{ROOT}{CACHE_CMS_DIR}/index.php?action={CACHE_CMS_ACTION}&id_atvt='+id+'&lms_a_id='+lms_a_id,'atvt', 'fullscreen=yes, location=no, resizable=no, scrollbars=yes' );
}

function knowledge(url){
		window.open(url,'ricerca', 'fullscreen=yes, location=no, resizable=no, scrollbars=yes' );
}

function atvt_dsp_html_intro(id,lms_a_id){
		window.open('{ROOT}offerta_new/index.php?action=atvt_dsp_html_intro&id_atvt='+id+'&lms_a_id='+lms_a_id,'atvt', 'fullscreen=yes, location=no, resizable=no, scrollbars=yes' );
}


function avvia_nuova_att(cms_ins,id,lms_a_id){
		window.location.href='../templates/attesa.htm';
		opener.location.href='index.php?action=atvt_dsp_'+ cms_ins +'_intro&id_atvt='+ id +'&lms_a_id='+ lms_a_id;
		}

function assistente(id){
		window.open('{ROOT}offerta_new/index.php?action=atvt_dsp_cms_intro&id_atvt='+id,'assist', 'width=800,height=500,left=20,top=20,scrollbars=yes,resizable=yes');
}

function open_community(url){
		window.open(url,'commun', 'status=no,toolbar=yes,directories=yes,menubar=yes,width=780,height=500,left=10,top=10,scrollbars=yes,resizable=yes');
}

function open_forum_tutor(url){
		window.open(url,'tut', 'status=no,toolbar=yes,directories=yes,menubar=yes,width=680,height=450,left=10,top=10,scrollbars=yes,resizable=yes');
}

function valida_forum(url){
		window.open(url,'val_forum', 'status=no,toolbar=yes,directories=yes,menubar=yes,width=580,height=250,left=10,top=10,scrollbars=yes,resizable=yes');
}

function aggiorna_crediti(url){
		window.open(url,'crediti', 'status=no,toolbar=no,directories=no,menubar=no,width=400,height=300,left=30,top=30,scrollbars=no,resizable=no');
}

function cache(url){
		window.open(url,'crediti', 'status=no,toolbar=no,directories=no,menubar=no,width=800,height=600,left=30,top=30,scrollbars=no,resizable=yes');
}

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

function atvt_dsp_cms(id){
		window.open('{ROOT}offerta_new/index.php?action=atvt_dsp_cms&id_atvt='+id,'atvt', 'fullscreen=yes, location=no, resizable=no' );
}

function atvt_dsp_html(id){
		window.open('{ROOT}offerta_new/index.php?action=atvt_dsp_html&id_atvt='+id,'atvt', 'fullscreen=yes, location=no, resizable=no' );
}

function apri_avviso(url, name) {
  popupWin =window.open(url,name,'width=400,height=250,left=400,top=10,scrollbars=no,resizable=yes');
}

function apri_help_usr(url) {
  popupWin =window.open(url,'help','width=620,height=500,left=100,top=10,scrollbars=yes,resizable=yes');
}

function apri_tutor(id,ob) {
  popupWin =window.open('{ROOT}tutor/index.php?action=form_att&id='+ id +'&id_ob='+ ob,'tutor','width=700,height=350,left=100,top=10,scrollbars=yes,resizable=yes');
}

function apri_lo(url, name) {
  popupWin =window.open(url,name,'width=500,height=500,left=400,top=30,scrollbars=no,resizable=yes');
}

function apri_news(url, name) {
  popupWin =window.open(url,name,'width=670,height=500,left=100,top=30,scrollbars=yes,resizable=yes');
}

function apri_lo_coll(id,type) {
  popupWin =window.open('{ROOT}offerta_new/index.php?action=apri_lo&a_id=' + id + '&type=' + type, 'lo_coll','width=800,height=600,left=30,top=30,scrollbars=yes,resizable=yes');
}

function apri_redact(url, name) {
  popupWin =window.open(url,name,'width=200,height=200,left=400,top=30,scrollbars=no,resizable=yes');
}
function apri_libreria(url){
	window.open(url, 'libreria', 'toolbar=no,directories=no,menubar=no,width=600,height=500,resizable=yes,scrollbars=yes,top=10,left=30');
}
function pubblica_lms(id){
popupWin =window.open('index.php?action=lms_pub&a_id='+id+'','pubbl','width=8,height=6,left=30,top=30,scrollbars=no,resizable=no');
}

function no_pubblica_lms(id){
popupWin =window.open('index.php?action=lms_no_pub&a_id='+id+'','pubbl','width=8,height=6,left=30,top=30,scrollbars=no,resizable=no');
}
function no_visibile_lms(id){
popupWin =window.open('index.php?action=lms_no_vis&a_id='+id+'','pubbl','width=8,height=6,left=30,top=30,scrollbars=no,resizable=no');
}
function pubblica_cms_1(id){
popupWin =window.open('index.php?action=cms_pub_1&a_id='+id+'&pub=1','pubbl','width=8,height=6,left=30,top=30,scrollbars=no,resizable=no');
}

function no_pubblica_cms_1(id){
popupWin =window.open('index.php?action=cms_pub_1&a_id='+id+'&pub=0','pubbl','width=8,height=6,left=30,top=30,scrollbars=no,resizable=no');
}

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

function confirmDelete(){
	var agree=confirm("Vuoi veramente eliminare questo elemento?");
	if (agree)
		return true ;
	else
		return false ;
}

function confirmDeleteDir(){
	var agree=confirm("Vuoi veramente eliminare questa cartella?");
	if (agree)
		return true ;
	else
		return false ;
}

