function TrimStringa (stringa_appo)
{
 indice = 0;
 lun = stringa_appo.length;
 appo = stringa_appo;
 temp = "";
 
 for (; indice < lun; indice++)
 {
 	if (appo.charAt(indice) == ' ')
	 continue;
	else
	 break; 
 } 

 switch (indice)
 {
 	case (0):
			 temp = appo;
			 break;
	case (lun - 1):
			 if (appo.charAt(indice) == ' ')
			 		 return ("");
			 else
			 		 return (appo.substring(indice));		
	default:
			 temp = appo.substring(indice);		
			 break;		 
 }

 lun = temp.length;
 indice = lun - 1;

 for (; indice >= 0; indice--)
 {
 	if (temp.charAt(indice) == ' ')
		 continue
	else
		 break;	 
 } 


 switch (indice)
 {
 	case (lun - 1):
			 return (temp);
	default:
			 return (temp.substring(0, indice + 1));
 }
}


function ShrinksSpaces ( stringa_appo )
{
 var temp = "";
 var appo;
 var sp;
 var l = 0, idx = 0;
 var found = 0;
 
 appo = TrimStringa (stringa_appo);
 sp = appo.indexOf (" ");
 
 if (sp == -1)
 		return (appo);

 l = appo.length;
 for (; idx < l; idx++)
 {
 	if (appo.charAt(idx) != ' ')
	{	 
		 if (found == 1)
		 {
		 		temp = temp + " ";
				found = 0;
		 }		
		 temp = temp + appo.substring(idx, idx + 1);
	}	 
	else
			found = 1;	 
 }
 return (temp);			
}