 
		//-------------------------------------------------------------------------
		// Nome:
		//	checkvaluecampo
		//
		// Descrizione:
		//	Confronta che il campo non sia vuoto
		//-------------------------------------------------------------------------	
		function checkvaluecampo(obj, nome)
		{
				if (obj == "")
				{
					alert("Fill the field " + nome +"!");
					return true;
				}else{
				    return false;
				}	
		}
		
		//-------------------------------------------------------------------------
		// Nome:
		//	checklenghtcampo
		//
		// Descrizione:
		//	Confronta la lunghezza di un campo
		//-------------------------------------------------------------------------	
		function checklenghtcampo(obj, nome, lunghezza)
		{
				if (obj > lunghezza)
				{
					alert("The field " + nome + " exceeded\nthe maximum length of " +
							 lunghezza + " characters!");
					return true;
				}else{
				    return false;
				}	
		}
		

		
		//-------------------------------------------------------------------------
		// Nome:
		//	checklenghtcampo
		//
		// Descrizione:
		//	Confronta la lunghezza di un campo
		//-------------------------------------------------------------------------
			
		function checkLunghezzaCampo(campo, nomeCampo, lunghezzaMax){
				
						
			if (campo.value.length > lunghezzaMax){
			    alert("The field " + nomeCampo + " exceeded\nthe maximum length of " + lunghezza + " characters!");
			    return false;
			}else{
			    return true;
			}	
		}
		
		//-------------------------------------------------------------------------
		// Nome:
		//	checkConfrontaCampi
		//
		// Descrizione:
		//	Confronta che non siano diversi due campi
		//-------------------------------------------------------------------------
		function checkConfrontaCampi(obj1, obj2, messaggio)
		{
				if (obj1 != obj2)
				{	
					alert(messaggio);
					return true;
				}else{
				    return false;
				}	
		}
		
		
		//-------------------------------------------------------------------------
		// Nome:
		//	checkFloat
		//
		// Descrizione:
		//	Controlla che nel campo sia stato inserito un valore a virgola mobile
		//-------------------------------------------------------------------------
		function checkFloat(campo, nome_campo) {
			var num = 0;
			var len = 0;
			num = campo;
			len = campo.length;
			i = 0;
			do {
				if (!isNaN(parseFloat(num.substr(i,i+1))))
					i=i+1;
				else
					return("Inserire un valore numerico in " + nome_campo);
			}
			while (i<len);
			return("-1");
		}
		
		
		//-------------------------------------------------------------------------
		// Nome:
		//	controlla
		//
		// Descrizione:
		//	Controlla che il campo passato come parametro contenga valori numerici.
		//-------------------------------------------------------------------------
		function controlla(obj,obj_name)
		{
			if (obj.value!="")
			{
				var numero = obj.value.replace(',','.');
				if ((tmpStr=checkFloat(numero,obj_name))!="-1")
				{
					alert(tmpStr);
					obj.focus();
				}
			}
		}
		
	//-------------------------------------------------------------------------
	// Nome: valDate
	//
	// Descrizione: Controlla che la data sia valida.
	//-------------------------------------------------------------------------	
	  function valDate(D, M, Y)
	  {
    	  Months= new Array(31,28,31,30,31,30,31,31,30,31,30,31);
    	  Leap  = false;
          
          if(!isNumeric(D) || !isNumeric(M) || !isNumeric(Y))
            return(false);
    	  
    	  if((Y % 4 == 0) && ((Y % 100 != 0) || (Y % 400 == 0)))
    	    Leap = true;
    	  
    	  if((D < 1) || (D > 31) || (M < 1) || (M > 12) || (Y < 0))
    	    return(false);
    	  
    	  if((D > Months[M-1]) && !((M == 2) && (D > 28)))
    	    return(false);
    	  
    	  if(!(Leap) && (M == 2) && (D > 28))
    	    return(false);
    	  
    	  if((Leap)  && (M == 2) && (D > 29))
    	    return(false);
    	  
    	  return true;
	  }
	
	
	
	  //DATA-------------------------------------------------------------------------
		// 
		//	valDate	//
		// Descrizione:
		//	Formatta la data
		//-------------------------------------------------------------------------
	
	function printData(dataNear){
	data = dataNear;
	l = data.length;
	year = data.substr(0,4);
	mm	 = data.substr(5,2);
	dd	 = data.substr(8,2);
	ora  = data.substr(10,6);
	document.write(dd+"-"+mm+"-"+year+"&nbsp;<BR>"+ora);
	}
	
	function printDate(dataNear){
	data = dataNear;
	l = data.length;
	year = data.substr(0,4);
	mm	 = data.substr(5,2);
	dd	 = data.substr(8,2);
	ora  = data.substr(10,6);
	document.write(dd+"-"+mm+"-"+year+"&nbsp;&nbsp;&nbsp;"+ora);
	}
	
	
	function printDataIntera(dataNear){
	data = dataNear;
	l = data.length;
	year = data.substr(0,4);
	mm	 = data.substr(5,2);
	dd	 = data.substr(8,2);

        if(year == "1900" ){
         data ="";
        }
        else{
	data = ""+dd+"-"+mm+"-"+year;
        }

	//data = ""+dd+"-"+mm+"-"+year;
	document.manage_ticket.data_chiusura_prevista.value = data;
	document.manage_ticket.data_chiusura_prevista1.value = data;
	
	}
	
	
	function printDataSenzaOra(dataNear){
	data = dataNear;
	l = data.length;
	year = data.substr(0,4);
	mm	 = data.substr(5,2);
	dd	 = data.substr(8,2);
	ora  = data.substr(10,6);
	document.write(dd+"-"+mm+"-"+year);
	}


//-ceckTelefono------------------------------------------------------------------------
// Nome:
//	checkTelefono        
//
// Descrizione:
//	Parserizza il numero di telefono.
//-------------------------------------------------------------------------

	
	
function checkTelefono(elemento){
	if (elemento == "fax"){
		if ((document.insert_ticket.fax.value!="") && (document.insert_ticket.prefFax.value=="")){
		alert("Insert the prefix");
		document.insert_ticket.prefFax.focus();
		}
	else{
			var fax =  document.insert_ticket.fax.value;
			var prefFax =  document.insert_ticket.prefFax.value;
			var faxParsed = ""+prefFax+"/"+fax ;
			document.insert_ticket.opt_fax.value = faxParsed ;
		}
	}
	
	if (elemento == "telefono"){ 
	if ((document.insert_ticket.telefono.value!="") && (document.insert_ticket.prefTelefono.value=="")){
		alert("Insert the prefix");
		document.insert_ticket.prefTelefono.focus();
		}
		
	
	else{ 
			var telefono =  document.insert_ticket.telefono.value;
			var prefTelefono =  document.insert_ticket.prefTelefono.value;
			var telParsed = ""+prefTelefono+"/"+telefono;
			document.insert_ticket.opt_telefono.value = telParsed;
			//alert(telParsed);
		}
	}
				
	 if (elemento == "prefTelefono"){
	 
	 if((document.insert_ticket.telefono.value=="") && (document.insert_ticket.prefTelefono.value!=""))
		{
			document.insert_ticket.telefono.focus();
		}	
	 }
	 
	  if (elemento == "prefFax"){
	 
	 if((document.insert_ticket.fax.value=="") && (document.insert_ticket.prefFax.value!=""))
		{
			document.insert_ticket.fax.focus();
		}	
	 }
}



	
function checkTelefonoUtente(elemento){
	if (elemento == "visFax"){
		if ((document.insert_utente.visFax.value!="") && (document.insert_utente.prefFax.value=="")){
		alert("Insert the prefix");
		document.insert_utente.prefFax.focus();
		}
	else{
			var fax =  document.insert_utente.visFax.value;
			var prefFax =  document.insert_utente.prefFax.value;
			var faxParsed = ""+prefFax+"/"+fax ;
			document.insert_utente.fax.value = faxParsed ;
		}
	}
	
	if (elemento == "telefono_fisso"){ 
	if ((document.insert_utente.telefono_fisso.value!="") && (document.insert_utente.pref_tel_fisso.value=="")){
		alert("Insert the prefix");
		document.insert_utente.pref_tel_fisso.focus();
		}
		
	 
	else{ 
			var telefono =  document.insert_utente.telefono_fisso.value;
			var prefTelefono =  document.insert_utente.pref_tel_fisso.value;
			var telParsed = ""+prefTelefono+"/"+telefono;
			document.insert_utente.tel_fisso.value = telParsed;
		}
	}
	
	if (elemento == "telefono_cell"){ 
	if ((document.insert_utente.telefono_cell.value!="") && (document.insert_utente.pref_tel_cell.value=="")){
		alert("Insert the prefix");
		document.insert_utente.pref_tel_cell.focus();
		}
		
	
	else{ 
			var telefono =  document.insert_utente.telefono_cell.value;
			var prefTelefono =  document.insert_utente.pref_tel_cell.value;
			var telParsed = ""+prefTelefono+"/"+telefono;
			document.insert_utente.telefono_cell.value = telParsed;
		}
	}
				
	 if (elemento == "prefTelefono"){
	 
	 if((document.insert_utente.telefono.value=="") && (document.insert_utente.prefTelefono.value!=""))
		{
			document.insert_utente.telefono.focus();
		}	
	 }
	 
//	  if (elemento == "prefFax"){
	 
//     if((document.insert_utente.fax.value=="") && (document.insert_utente.prefFax.value!=""))
//	 	{
//			document.insert_utente.fax.focus();
//		}	
//	 }
	 
	
//	if (elemento =="pref_tel_cell"){
	 
//	 if((document.insert_utente.telefono_cell.value=="") && (document.insert_utente.pref_tel_cell.value!=""))
//		{
//			document.insert_utente.fax.focus();
//		}	
//	 }
}




function parseTelefono(){
	var telefono = "";
	
}
							
							

  //-------------------------------------------------------------------------
  // Nome:
  //	valDate
  //
  // Descrizione:
  //	Controlla che la data in italiano sia valida.
  //-------------------------------------------------------------------------
	
	
	function formatDate(dateForm){
	   cDate = trim(dateForm.value);
	  

	   dSize = cDate.length;
	   sCount= 0;
	 
	    if(cDate=='') return true;

	   	//replace "/" char with "-" and goes on.
	   	while( cDate.indexOf("/")!="-1" )
	   	{   
	      	ind = cDate.indexOf("/");
	      	cDate = cDate.substr(0,ind)+ "-" +cDate.substr(ind+1,dSize);
	   	}
	   	
	   //Check out the dashes
	   for(var i=0; i < dSize; i++)
	      (cDate.substr(i,1) == "-") ? sCount++ : sCount;
	   
	   
	   
	   if (sCount != 2){
	      alert("Il formato della data deve essere \n ''dd-mm-yyyy''");
	      dateForm.select();
		  //dateForm.value = "";
	      return(false);
	   };
	   //Check if the year is a 2 or 4 digits string
	   ySize = cDate.substring(cDate.lastIndexOf("-")+1,dSize).length
	   if(ySize<2 || ySize>4 || ySize == 3){
         //alert('year '+ySize);
	     alert('Data non valida!');
	     dateForm.select();
		 //dateForm.value = "";
	     return false;
	   };
	   //Cut the date string into three parts (Month, Day & Year)
	   idxBarI = cDate.indexOf("-");
	   idxBarII= cDate.lastIndexOf("-");
	   strD    = cDate.substring(0,idxBarI);
	   strM    = cDate.substring(idxBarI+1,idxBarII);
	   strY    = cDate.substring(idxBarII+1,dSize);

	   strM = (strM.length < 2 ? '0'+strM : strM);   
	   strD = (strD.length < 2 ? '0'+strD : strD);
	   if(strY.length == 2)
	      strY = (strY > 50  ? '19'+strY : '20'+strY);
	   dateForm.value = strD+'-'+strM+'-'+strY;
       ok = valDate(strD, strM, strY);
	   if(ok==false )
	   { 
	     // alert(strD+','+strM+','+strY);
		  alert("Data non valida!");
	      dateForm.select();
		  //dateForm.value = "";
		  return false;	
	   }
		return true;
};

//-------------------------------------------------------------------------
  // Nome:
  //	valDate
  //
  // Descrizione:
  //	Controlla che la data in inglese sia valida.
  //-------------------------------------------------------------------------
	
	
	function formatDateUs(dateForm){
	   cDate = dateForm.value;
	  

	   dSize = cDate.length;
	   sCount= 0;
	 
	    if(cDate=='') return;

	   	//replace "/" char with "-" and goes on.
	   	while( cDate.indexOf("/")!="-1" )
	   	{   
	      	ind = cDate.indexOf("/");
	      	cDate = cDate.substr(0,ind)+ "-" +cDate.substr(ind+1,dSize);
	   	}
	   	
	   //Check out the dashes
	   for(var i=0; i < dSize; i++)
	      (cDate.substr(i,1) == "-") ? sCount++ : sCount;
	   
	   
	   
	   if (sCount != 2){
	      alert("Date must be in 'mm-dd-yyyy' format");
	      dateForm.select();
		  dateForm.value = "";
	      return(false);
	   };
	   //Check if the year is a 2 or 4 digits string
	   ySize = cDate.substring(cDate.lastIndexOf("-")+1,dSize).length
	   if(ySize<2 || ySize>4 || ySize == 3){
	     alert('Data non valida!');
	     dateForm.select();
		 dateForm.value = "";
	     return false;
	   };
	   //Cut the date string into three parts (Month, Day & Year)
	   idxBarI = cDate.indexOf("-");
	   idxBarII= cDate.lastIndexOf("-");
	   strD    = cDate.substring(0,idxBarI);
	   strM    = cDate.substring(idxBarI+1,idxBarII);
	   strY    = cDate.substring(idxBarII+1,dSize);

	   strM = (strM.length < 2 ? '0'+strM : strM);   
	   strD = (strD.length < 2 ? '0'+strD : strD);
	   if(strY.length == 2)
	      strY = (strY > 50  ? '19'+strY : '20'+strY);
	   dateForm.value = strD+'-'+strM+'-'+strY;
       ok = valDate(strM, strD, strY);
	   if(ok==false )
	   { 
	      alert("Date must be in 'mm-dd-yyyy' format");
	      dateForm.select();
		  dateForm.value = "";
		  return false;	
	   }
		return true;
};



function formatDateConSeparatore(dateForm, separatore){
	   
	   
	   cDate = dateForm.value;
	  
	   dSize = cDate.length;
	   sCount= 0;
	 
	   if(cDate=='') return;

	   	//replace "-" char with "/" and goes on.
	   	while( cDate.indexOf("-")!="-1" )  
	   	{   
	      	ind = cDate.indexOf("-");
	      	cDate = cDate.substr(0,ind)+ "/" +cDate.substr(ind+1,dSize);
	   	}
	   	
	   //Check out the dashes
	   for(var i=0; i < dSize; i++)
	      (cDate.substr(i,1) == "/") ? sCount++ : sCount;
	   
	     
	   if (sCount != 2){
	      alert("Il formato della data deve essere \n ''dd-mm-yyyy''");
	      dateForm.select();
		  dateForm.value = "";
	      return(false);
	   };
	   //Check if the year is a 2 or 4 digits string
	   ySize = cDate.substring(cDate.lastIndexOf("/")+1,dSize).length
	   if(ySize<2 || ySize>4 || ySize == 3){
	     alert('Data non valida!');
	     dateForm.select();
		 dateForm.value = "";
	     return false;
	   };
	   //Cut the date string into three parts (Month, Day & Year)
	   idxBarI = cDate.indexOf("/");
	   idxBarII= cDate.lastIndexOf("/");
	   strD    = cDate.substring(0,idxBarI);
	   strM    = cDate.substring(idxBarI+1,idxBarII);
	   strY    = cDate.substring(idxBarII+1,dSize);

	   strM = (strM.length < 2 ? '0'+strM : strM);   
	   strD = (strD.length < 2 ? '0'+strD : strD);
	   if(strY.length == 2)
	      strY = (strY > 50  ? '19'+strY : '20'+strY);
	   
	   dateForm.value = strD.toString() + separatore.toString() + strM.toString() +  separatore.toString() + strY.toString();
	   
	   
	   ok = valDate(strD, strM, strY);
	   
	   if(ok==false ) { 
	      alert("Data non valida!");
	      dateForm.select();
		  dateForm.value = "";
	      return false;	
	   }
		return true;
	};

function isAlphabetical(obj)
{
	var val= new String(obj.value);
	val = val.toLowerCase();
	for(var i=0; i<val.length; i++ )
	{
		var num = val.charAt(i);
		
		if ( num =='a' || num =='b' || num =='c' || num =='d' || num =='e' 
		  || num =='f' || num =='g' || num =='h' || num =='i' || num =='j' 
		  || num =='l' || num =='m' || num =='n' || num =='o' || num =='p' 
		  || num =='q' || num =='r' || num =='s' || num =='t' || num =='u' 
		  || num =='v' || num =='z' || num =='w' || num =='y' || num =='k' 
		  || num =='x' )
		
			ok = 1;
		else
			return false;
	}	
	if (ok == 1)
			return true;
		else
			return false;		
}

function isAlphanumerical(obj)
{
	var val= new String(obj.value);
	val = val.toLowerCase();
	for(var i=0; i<val.length; i++ )
	{
				var num = val.charAt(i);
				
				if ( num =='a' || num =='b' || num =='c' || num =='d' || num =='e' || num =='f' 
				|| num =='g' || num =='h' || num =='i' || num =='j' || num =='l' || num =='m' 
						|| num =='n' || num =='o' 
						|| num =='p' || num =='q' || num =='r' || num =='s' || num =='t' || num =='u' 
						|| num =='v' || num =='z'
						|| num =='w' || num =='y' || num =='k' || num =='x' 
						|| num =='0' || num =='1' || num =='2' || num =='3' || num =='4' || num =='5' || num =='6' || num =='7' || num =='8' || num =='9')
				
						ok = 1;
				else
					return false;
	}	
	if (ok == 1)
			return true;
		else
			return false;		
}

	
function isNumeric(v)
{
		var ok = 0;
		val = new String(v);
		if (val == null || val.length == 0 )
			return false;
		
		//alert('val.length'+val.length)
					
		for ( i=0; i < val.length; i++ )
		{
				var num = val.charAt(i);
				if ( num =='0' || num =='1' || num =='2' || num =='3' || num =='4' || num =='5' || num =='6' || num =='7' || num =='8' || num =='9' || num==',' || num=='.')
					ok = 1;
				else
					return false;
				 
		}
		if (ok == 1)
			return true;
		else
			return false;
}

function isFloat(v)
{
		var ok = 0;
		var virgola=0;
		val = new String(v);
		if(val.length==0)		
			return false;
		else
    		for ( i=0; i < val.length; i++ )
    		{
    			var num = val.charAt(i);
    			if (num=='.')
    				virgola++;
    			if (num==','){
    				val = v.replace(',','.');	
    				virgola++;
    			}
    			if (num =='0' || num =='1' || num =='2' || num =='3' || num =='4' || num =='5' || num =='6' || num =='7' || num =='8' || num =='9' || (i>0 && i<val.length-1 && virgola==1 && (num=='.' || num==',')) || (i==0 && i<val.length-1 && num=='-'))
    				ok++;							
    			else
    				return false;
    		}
		return true;
}



//funzione utilizzata da funzioni.jsp
function safeAlert (s)
{
	var f = null;
	
	if (eval ("typeof (" + s + ")") != "undefined")
		alert (eval (s));
	else
		alert ("DEVELOPER WARNING!!!\n\nThe client-side resource\n'" + s + "'\nwas not found!!!");
}


/******************************************************************************
validates an e-mail. this is a generic check - not fool- or lie-proof.
if the email is invalid and an error message is supplied, it is alerted to
the user. if a return field is supplied, the fxn focuses the field
******************************************************************************/
function checkEmail (sEmail, sMsg, oFld)
{
	var fOK, re;
	
	// allow user to enter spaces at the left and right and the mailto: prefix
	// later, we will remove it when the form submition takes place
	
	re = /\s*(mailto:)?[\w|\-|_]+([\.|\w|\-|_]+)*@[\w|\-|_]+(\.[\w|\-|_]+)*(\.\w{2,3})+\s*/gi;
	
	fOK = (sEmail.replace (re, "") == "");

	if (!fOK)			// something wrong?
	{
		if (sMsg && sMsg != "")		// can we alert the user?
			safeAlert (sMsg);
		if (g_fFocus && oFld)	// do we have a field to focus?
		{
			oFld.value = "";
			oFld.focus ();
		}
	}
		
	if (fOK)
		if (g_fSetValid)
			oFld.value = getEmail (sEmail);
	
	return (fOK);
}

/******************************************************************************
returns the email from the passed string
******************************************************************************/
function getEmail (sEmail)
{
	var re = /^(mailto:)/gi;
	sEmail = trim (sEmail);
	sEmail = sEmail.replace (re, "");
	return (sEmail);
}


 //-------------------------------------------------------------------------
  // Nome:
  //	Sostituisci(el,prima,dopo)
  //
  // Descrizione:
  //	Controlla che la data sia valida.
  //-------------------------------------------------------------------------


	function sostituisci(el,dopo)
	{	        
        cEl=el;    
		while( cEl.indexOf("(") != -1 )
	   	{   
                        if( cEl.indexOf(",")!= -1 )
			cEl=cEl.replace(",",dopo);
	      		idx1 = cEl.indexOf("(");
                        idx2 = cEl.indexOf(")");
			if(idx2 >= idx1)	
                           len = idx2 - idx1;

                        separa = cEl.substr(idx1,len+1);

                        cEl=cEl.replace( separa," "); 		     	
	   	}			
		//alert(" sostituisci?");			
		return cEl;
	}
/*
	funzione per arrotondare il valore di un campo alla cifra decimale scelta
*/
	function arrotondaCampo(valForm,decimali)
	{
		v=valForm.value;
		if(isFloat(v))
		{
			divid = 1;
			for(i=0; i<decimali;i++)
			{
				divid = (divid*10);
			}	
			valore = (Math.round(val*divid))/divid;
			valForm.value=valore;
		}	
	}	
/*
	funzione per arrotondare il valore di un campo alla cifra decimale scelta
*/
	function arrotondaCampoPositivo(valForm,decimali)
	{
		v=valForm.value;
		if(isFloat(v) && v>0)
		{
			divid = 1;
			for(i=0; i<decimali;i++)
			{
				divid = (divid*10);
			}	
			valore = (Math.round(val*divid))/divid;
			if(valore<0)
			    valore=0;
			valForm.value=valore;
		}
		else 
		    return (0);		
	}	
/*
	funzione per arrotondare un valore alla cifra decimale scelta
*/	
	function arrotondaNumero(val,decimali)
	{
		if(isFloat(val))
		{
			g = 1;
			for(i=0; i<decimali;i++)
			{
				g = g*10;
			}	
			valore = (Math.round(val*g))/g;
			return (valore);
		}	
	}
/*
	funzione per arrotondare un valore alla cifra decimale scelta
*/	
	function arrotondaNumeroPositivo(val,decimali)
	{
		if(isFloat(val) && val>0)
		{
			g = 1;
			for(i=0; i<decimali;i++)
			{
				g = g*10;
			}	
			valore = (Math.round(val*g))/g;
			if(valore<0)
			    valore = 0;
			return (valore);
		}
		else 
		    return (0);	
	}
/******************************************************************************************
    Funzione per richiamare la pagina del calendario e selezionare una data.
    IMPORTANTE come campo bisogna passare il nome del form oltre al nome del campo in cui riportare la data.
    ES: javascript:calendario(root,'nomeForm.nomeCampoData');
*/
	
	function calendario(root,campo)
    {
        window.open(root+'/includes/calendario.jsp?field='+campo,'date','width=239,height=170,toolbar=no,location=no,menubar=no,resizable=no');
    }		
    
    
/**
*  getFieldNext 
*  serve per ottenere il focus su un field successivo,
*  quando il field corrente ha raggiunto una certa lunghezza
*/

function getFieldNext(field, fieldNext, lunghezza ) {
    if ( field.value.length == lunghezza ) {
        fieldNext.focus();
    }
}


/**
*  aggiungiCaratteriIniziali
*  serve per normalizzare la lunghezza delle stringhe,
*  aggiunge un carattere specificato fino a raggiungere la lunghezza desiderata
*/

function aggiungiCaratteriIniziali(carattere, stringa, lunghezza ){
    while ( stringa.length < lunghezza ) {
        stringa ="" + carattere.toString() + stringa;
    }
    return stringa;
}    



//Eliminazione di possibili spazi in testa e in coda ad una stringa
function trim(stringa)
{
  str=stringa;
  //elimino gli spazi all'inizio della stringa
  while( ( str.charAt(0)==" " ) || ( str.charCodeAt(0)==255 ) || ( str.charAt(0)=="\t" ))
  {
    str=str.substr(1);
  }
  //elimino gli spazi in fondo alla stringa
  while( ( str.charAt(str.length-1)==" " ) || ( str.charCodeAt(str.length-1)==255 ) || ( str.charAt(str.length-1)=="\t" ))
  {
    str=str.substr(0,str.length-1);
  }
  //restituisco la stringa
 //if(trim.arguments[1]) stringa.value=str;
  return str;
}

function trimcrlf(stringa)
{
  srt=stringa;
  while( ( str.charCodeAt(0)==10 ) || ( str.charCodeAt(0)==13 ) || ( str.charAt(0)==" " ) || ( str.charCodeAt(0)==255 ) || ( str.charAt(0)=="\t" ))
  {
    str=str.substr(1);
  }
  //elimino gli spazi in fondo alla stringa
  while( ( str.charCodeAt(str.length-1)==10 ) || ( str.charCodeAt(str.length-1)==13 ) || ( str.charAt(str.length-1)==" " ) || ( str.charCodeAt(str.length-1)==255 ) || ( str.charAt(str.length-1)=="\t" ))
  {
    str=str.substr(0,str.length-1);
  }
  //restituisco la stringa
  //if(trim.arguments[1])stringa.value=str;
  return str;
}

