/*
Função: TRIM(base,tipo)

Parâmetros:
base - Valor
tipo - A ==> Trim
tipo - L ==> LTrim
tipo - R ==> RTrim

Descricação:
Retorna a string sem os espaços em brando de acordo com os 
parâmetros passados.
*/

function trim(base,tipo)
{

if (tipo == "A" || tipo == "a" )
   {
	aux2 = base.length
	for (;(base.indexOf(" ")==0 && base.length!=0);)
		{
		aux = base.indexOf(" ");
	   if (aux == 0)
         {
         base = base.substring(1, aux2)
         }
       }
    aux2 = base.length
    for  (;(base.lastIndexOf(" ")==aux2-1 && base.length!=0);){
    aux = base.lastIndexOf(" ");
    if (aux == aux2-1){
    base = base.substring(0, aux2-1)

   }
aux2 = base.length
}
  }
  
    if (tipo == "L" || tipo == "l" ){
aux2 = base.length
for (;(base.indexOf(" ")==0 && base.length!=0);){
aux = base.indexOf(" ");
if (aux == 0){
base = base.substring(1, aux2)
}
}
  }
  
    if (tipo == "R" || tipo == "r" ){
aux2 = base.length
for  (;(base.lastIndexOf(" ")==aux2-1 && base.length!=0);){
aux = base.lastIndexOf(" ");
if (aux == aux2-1){
base = base.substring(0, aux2-1)
}
aux2 = base.length
}
  }
  
return base
}
