<!--
//*************** funzioni per la trasformazione di testo ***************

//*************** proto: function newline2BR (s) ***************
//*************** PARAM string s ***************
//*************** RETURNS string s dove: ogni "a capo" viene sostituito da un tag <BR> ***************

function newline2BR(stringa1){
var i= 0;
var stringa="";
var k=0;
var lunghezza=0; 
var codifica=0;
var tabConversione= new Array("nbsp;","&iexcl;","&cent;","&pound;","&curren;","&yen;","&brvbar;","&sect;","&uml;","&copy;","&ordf;","&laquo;","&not;","&shy;","&reg;","&macr;","&deg;","&plusmn;","&sup2;","&sup3;","&acute;","&micro;","&para;","&middot;","&cedil;","&sup1;","&ordm;","&raquo;","&frac14;","&frac12;","&frac34;","&iquest;","&Agrave;","&Aacute;","&Acirc;","&Atilde;","&Auml;","&Aring;","&AElig;","&Ccedil;","&Egrave;","&Eacute;","&Ecirc;","&Euml;","&Igrave;","&Iacute;","&Icirc;","&Iuml;","&ETH;","&Ntilde;","&Ograve;","&Oacute;","&Ocirc;","&Otilde;","&Ouml;","&times;","&Oslash;","&Ugrave;","&Uacute;","&Ucirc;","&Uuml;","&Yacute;","&THORN;","&szlig;","&agrave;","&aacute;","&acirc;","&atilde;","&auml;","&aring;","&aelig;","&ccedil;","&egrave;","&eacute;","&ecirc;","&euml;","&igrave;","&iacute;","&icirc;","&iuml;","&eth;","&ntilde;","&ograve;","&oacute;","&ocirc;","&otilde;","&ouml;","&divide;","&oslash;","&ugrave;","&uacute;","&ucirc;","&uuml;","&yacute;","&thorn;","&yuml;");
//sostituzione del codice Unicode 000A,ascii 10 (Line Feed/ Carriage Return) con il tag <BR>
	//preparazione espressione regolare per sostituzione
	stringa = stringa1;
	lunghezza = stringa.length;
	while(i<=lunghezza)
	  {codifica = stringa.charCodeAt(i);
	  	if (codifica == 10){
                  stringa =stringa.substring(0,i)+"<BR>"+stringa.substring(i+1,lunghezza);
                  lunghezza +=4;
                  i+=3
                } 
		else if (codifica == 34){ // doppio apice
                  stringa =stringa.substring(0,i)+"&quot;"+stringa.substring(i+1,lunghezza);
                  lunghezza +=6;
                  i+=5
                } 
		else if (codifica == 39){ // singolo apice
                  stringa =stringa.substring(0,i)+"&acute;"+stringa.substring(i+1,lunghezza);
                  lunghezza +=7;
                  i+=6
                } 
		else if (codifica == 92){ // slash
                  stringa =stringa.substring(0,i)+"&#92;"+stringa.substring(i+1,lunghezza);
                  lunghezza +=5;
                  i+=4
                } 
		else{ 
                  if (codifica >= 160) {//la codifica corrisponde ad un carattere speciale	
			stringa =stringa.substring(0,i)+tabConversione[codifica-160]+stringa.substring(i+1,lunghezza);
			lunghezza +=tabConversione[codifica-160].length;
			i+=tabConversione[codifica-160].length-1;
		  }//endIf
		}//endElse
		i++;
		
	 }//endwhile
	 
return (stringa)
}



function CheckForm(){

   var k;
   var NumeroForm = 0;
   var NumeroElementiForm = document.forms[NumeroForm].length;
   var ValoreElementoForm = "";
   var TipoElementoForm;

   for(k=0;k<NumeroElementiForm;k++){
      if(document.forms[NumeroForm].elements[k].type=="text" || document.forms[NumeroForm].elements[k].type=="textarea"){
         ValoreElementoForm = document.forms[NumeroForm].elements[k].value;
         ValoreElementoForm = newline2BR(ValoreElementoForm);
         document.forms[NumeroForm].elements[k].value = ValoreElementoForm;
      }
   }
}

function CheckFormName(myform){

   var k;
   var NumeroElementiForm = myform.length;
   var ValoreElementoForm = "";
   var TipoElementoForm;

   for(k=0;k<NumeroElementiForm;k++){
      if(myform.elements[k].type=="text" || myform.elements[k].type=="textarea"){
         ValoreElementoForm = myform.elements[k].value;
         ValoreElementoForm = newline2BR(ValoreElementoForm);
         myform.elements[k].value = ValoreElementoForm;
      }
   }
}

function verifica(myform){
   var username = myform.username;
   var password = myform.password;
 
   if (username.value.length == 0){
      username.focus();
      username.select();
      alert("Inserire lo Username");
      return false;
   }
   if (password.value.length == 0){
      password.focus();
      password.select();
      alert("Inserire la Password");
      return false;
   }
}

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