// mostra riquadro di anteprima
function anteprima(textarea,w,h) {
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;	
	//var inf = document.form.testo.value;
	var inf = document.getElementById(textarea).value;
	inf = inf.split(/\n/).join("<br />");
	var win = window.open(", ", "popup", "width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition+",scrollbars=yes");
	win.document.open();	
	win.document.writeln("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>");
	win.document.writeln("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>");
	win.document.writeln("<head><title>Anteprima</title>");	
	win.document.writeln("<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />");
	win.document.writeln("<link href='inc/style.css' rel='stylesheet' type='text/css' />");
	win.document.writeln("</head><body>");
	win.document.writeln("<div style='text-align:right; margin-bottom:20px;'><a href='javascript:window.close()'>Chiudi</A></div>");
	win.document.writeln("" + inf + "");
	win.document.writeln('</body></html>');
	win.document.close();
}


//popup
var win = null;
function popup(mypage,w,h){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	h = h + 10;
	w = w + 10;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+'no'+',resizable'
	winName = 'winName'+w+h;
	window.open(mypage,winName,settings);
}


//toggle
function toggle(obj,tipo) {
	var el = document.getElementById(obj);
	if (!tipo) {
		if ( el.style.display != 'block' ) {
			el.style.display = 'block';
		}	else {
			el.style.display = 'none';
		}
	} else if (tipo == 'mostra') { el.style.display = 'block';
	} else if (tipo == 'nascondi') { el.style.display = 'none'; }
}


//	Funzione usata da emilio nella gestione dell'occupazione 
//	http://new.lucense.it/formazione/registrazione.php?id=37
//	E' la stessa cosa ma con le guardie invertite.
function toggle2(obj,tipo) {
	var el = document.getElementById(obj);
	if (!tipo) {
		if ( el.style.display != 'none' ) {
			el.style.display = 'none';
		}	else {
			el.style.display = 'block';
		}
	} else if (tipo == 'mostra') { el.style.display = 'block';
	} else if (tipo == 'nascondi') { el.style.display = 'none'; }
}

/*V*/
function controllaMail(EmailAddr){
 Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
 if (Filtro.test(EmailAddr))
    return true;
 else
    return false;
}
