// Ex. document.forms[0]['xxxx'].value.trim();

if (navigator.appName.indexOf('Microsoft') != -1){
		clientNavigator = "IE";
	 } else {
		clientNavigator = "Other";
	 }

var opcoesJanelaPequena = 'width=700,height=600,top=5,left=15,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes';
var opcoesJanelaGrande = 'width=700,height=650,top=5,left=15,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes';
var opcoesJanelaGrandeImpressao = 'width=800,height=600,top=5,left=15,toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes';
var opcoesJanelaPequenaImpressao = 'width=600,height=400,top=5,left=15,toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes';
var opcoesJanelaParte = 'top=10,left=10,width=750,height=550,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes';
var opcoesJanelaCEP = 'top=5, left=5, width=790,height=450,scrollbars=1,border=0';
var opcoesCadastroApenso = 'width=800,height=600,top=5,left=15,toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes';

String.prototype.rtrim = function() {
    return this.replace(/\s*$/g, "");
}

String.prototype.ltrim = function() {
    return this.replace(/^\s*/g, "");
}

String.prototype.trim = function() {
    return this.replace(/^\s*|\s*$/g, "");
}

String.prototype.alltrim = function() {
    return this.replace(/\s/g, "");
}

String.prototype.ntrim = function() {
    return this.replace(/\s{2,}/g,' ').trim();
}

    
function posicionaCombo(combo, texto){
    var tam = combo.length;
    for (var i = 0; i < tam; i++) {
        if (combo.options[i].value == texto) {
            combo.options[i].selected = true;
            break;
        }
    }
}    
    
function retirarCaracteresInvalidos(vetor, texto) {
    for (var i=0; i < vetor.length; i++) {
        for (var j=0; j < texto.length; j++) {
            texto = texto.replace(vetor[i], '');
        }  
    }
    return texto;
}

//Ex: onKeyPress = " return soNumeros(event);"

function soNumeros(e) {
    var key;
   var keychar;
   var reg;

   if(window.event) {
      // for IE, e.keyCode or window.event.keyCode podem ser usados
      key = e.keyCode;
   }
   else if(e.which) {
      // Firefox e Netscape
      key = e.which;
   }
   else {
      return true;
   }
    keychar = String.fromCharCode(key);
   reg = /\d/;  // checa se contem caracteres alfa
   if (key != 8) // No Firefox ignora a tecla BACKSPACE

   return (key == 13 || reg.test(keychar));   // retorna somente numericos
}

//Função para realizar a mudança dos cursores
  function cursor(element,local,tipo){
     element.getElementsByTagName(local).item(0).style.cursor = tipo;     
  }

function proximo(atual, next){
	var element = document.getElementById(atual);
	maxchr = element.getAttribute("maxlength");
	if (element.value.length >= maxchr){ 
	        document.getElementById(next).focus();        
	}
}