	var msgError = '';
	var existError = 0;
	var labelError = 'erroR';
	var br = '<br />';
        var linkFocus =  "";

	function setUrlFaces(urlFaces){
		this.urlFaces = urlFaces 
	}
	function setExistError(error){
            this.existError = error;
	}
	function getExistError(){
            return this.existError;
	}
	function nextPage(){
            if (getExistError() == 0){
                return true;
            }
            return false;
	}
        function clearMsgError(){
            this.msgError = '';
        }
	function setMsgError(valor){
            if (getMsgError() == ''){
                this.msgError = valor;
            }else{
                this.msgError = getMsgError() + ' ' + valor;
            }
	}
	function getMsgError(){
            return this.msgError;
	}
        function fieldError(idCampo){
            //document.getElementById(idCampo).className  = document.getElementById(idCampo).className + ' fieldError';
            if (document.getElementById(idCampo).type != undefined){                
                fieldFocus(idCampo);
            }
        }
	function fieldFocus(idCampo){
            document.getElementById(idCampo).focus();
	}
	function fieldNoFocus(idCampo){
            document.getElementById(idCampo).className = document.getElementById(idCampo).className.replace(/fieldError/,"");
            document.getElementById(idCampo).className = document.getElementById(idCampo).className.replace(" ","");
            document.getElementById(labelError+idCampo).style.display  = 'none';
	}
        function existsError(idCampo, msg){
            setMsgError(msg);
            setExistError(1);
            //document.getElementById(labelError +  idCampo).innerHTML = msg;
            //document.getElementById(labelError + idCampo).className = 'msgErrorAtiva';
        }
	/*
	 * Método que valida um campo do tipo String
	*/
	function v_string(idCampo, labelCampo, minLength, maxLength){
            var erroString = 0;
            var msgString   = '';
            valorString    =  document.getElementById(idCampo).value;
            if (valorString == ''){
                msgString += '- O campo ' + labelCampo + ' é de preenchimento obrigatório.\n';
            }else{
                if ( (minLength != '' && minLength > 0) && (maxLength != '' && maxLength > 0) ){
                    if (valorString.length < minLength || valorString > maxLength){
                        msgString = '- O campo ' + labelCampo + 'deve ter no mínimo ' + minLength + ' e no máximo ' + maxLength + ' caracteres.'+ br;
                    }
                }else
                if ( (minLength == '' && maxLength  > 0) && valorString.length < maxLength){
                    msgString = '- O campo ' + labelCampo + 'deve ter ' + maxLength + ' caracteres.\n';
                }
            }
            if (msgString != ''){
                fieldError(idCampo);
                existsError(idCampo, msgString);
            }
	}
	
	function validationSelect(idCampo, labelCampo){
            valorSelectedIndex    =  document.getElementById(idCampo).selectedIndex;
            var msgSelect  = '';
            if (valorSelectedIndex == 0){
                msgSelect = '- O campo ' + labelCampo + ' nao está selecionado corretamente.\n';
                fieldError(idCampo);
                existsError(idCampo, msgSelect);
            }
	}

        /*
         *@PARAM idCampo
         *@PARAM labelCampo - campo onde a mensagem será exibida
         *@PARAM tamanho - quantidade elementos do radioButton
         */
        function validationRadio(idCampo, labelCampo, tamanho){
            /*
            var check = false;
            var linkFocus  =  "<b class='fieldFocus' onclick=fieldFocus('"+idCampo+"')>"+labelCampo+"</b> ";

            for(i=0; i < document.getElementById(getIdForm()).elements.length; i++){
                if (document.getElementById(getIdForm()).elements[i].type == 'radio' && 
                    (document.getElementById(getIdForm()).elements[i].name == (getIdForm()+idCampo)) &&
                    document.getElementById(getIdForm()).elements[i].checked == true
                ){
                    check = true;
                    i = document.getElementById(getIdForm()).elements.length + 1;
                }
            }
            if (check == false){
                msgSelect = 'O campo ' + linkFocus + ' não está selecionado corretamente.';
                fieldError(idCampo);
                existsError(idCampo, msgSelect);
            }else{
                document.getElementById(labelError + idCampo).innerHTML = '';
                fieldNoFocus(idCampo);
            }
            */
        }
        /* Description: Método para validar a data, verifica se o dia < 32 e
         * se o mês é > 0 e < 13.
         * Author: Ezequiel Tomaizni
         * Date:   01.11.2006 22:06 hs
        */
	function validationDate(idCampo, labelCampo){
            var dia = 0;
            var mes = 0;
            var ano = 0;
            if (document.getElementById(idCampo).value.length == 10){
                dia = document.getElementById(idCampo).value.substring(0,2);
                mes = document.getElementById(idCampo).value.substring(3,5);
                ano = document.getElementById(idCampo).value.substring(6,10);
            }
            if ( (dia > 0 && dia < 32) && (mes > 0 && mes < 13) && (ano > 1900)
                 && document.getElementById(idCampo).value.length == 10 ){
                msgString = '';
            }else{
                msgString = '- A data inserida no campo ' + labelCampo + ' está incorreta.\n';
                fieldError(idCampo);
                existsError(idCampo, msgString);
            }
        }
        /* Description: Método para validar a data, verifica se o dia < 32 e
         * se o mês é > 0 e < 13.
         * Author: Ezequiel Tomaizni
         * Date:   01.11.2006 22:06 hs
        */
        function validationTime(idCampo, labelCampo){
            var horas   = 0;
            var minutos = 0;
            var ano = 0;
            if (document.getElementById(idCampo).value.length == 5){
                horas   = document.getElementById(idCampo).value.substring(0,2);
                minutos = document.getElementById(idCampo).value.substring(3,5);
            }
            if ( horas > -1 && (!isNaN(minutos)) && document.getElementById(idCampo).value.length == 5 ){
                msgString = '';
            }else{
                msgString = '- A hora inserida no campo ' + labelCampo + 'está incorreta.\n';
                fieldError(idCampo);
                existsError(idCampo, msgString);
            }
        }
        /**
          * Método que verifica se as duas senhas são iguais
          */
	function validationPassword(idCampo, idCampoSenhaRepetida, tamanhoMinimo){
            var senhaA = document.getElementById(idCampo).value;
            var senhaB = document.getElementById(idCampoSenhaRepetida).value;
            if ( (senhaA == '' || senhaB == '') || (senhaA != senhaB)){
                msgString = '- As senhas não conferem. Por favor verifique.<br>';
                existsError(idCampo, msgString);
            }
        }
	/* 
	 * Máscaras 
	 */
	var isIE = (navigator.appVersion.indexOf("MSIE") > -1);

	/*
	 * Método máscara do Cep
	 * Date: 29.10.2006
	 * Author: Ezequiel Tomazini
	 * Parâmetros:  idCampo and teclaPressionada
	 * Event: onkeypress
	*/ 
	function maskCep(idCampo, keyPress){
            var code = isIE ? keyPress.keyCode : keyPress.charCode
            var digitado = String.fromCharCode(code).toUpperCase();
            if ( !isNaN(digitado) && notSpace(code) ){	
                if (document.getElementById(idCampo).value.length == 5){
                    document.getElementById(idCampo).value += '-';
                }
                return true;
            }else
            if (!validKeyCode(code)){
                return false;
            }
	}
	/*
	 * Método máscara do telefone com 13 e 12 dígitos
	 * Date: 29.10.2006
	 * Author: Ezequiel Tomazini
	 * Parâmetros:  idCampo and teclaPressionada
	 * Event: onkeypress
	*/ 
	function maskPhone(idCampo, keyPress){
            var code = isIE ? keyPress.keyCode : keyPress.charCode
            var digitado = String.fromCharCode(code).toUpperCase();
            if ( !isNaN(digitado) && notSpace(code) ){	
                if (document.getElementById(idCampo).value.length == 0){
                    document.getElementById(idCampo).value += '(';
                }
                if (document.getElementById(idCampo).value.length == 3){
                    document.getElementById(idCampo).value += ')';
                }
                if (document.getElementById(idCampo).value.length == 8){
                    document.getElementById(idCampo).value += '-';
                }
                return true;
            }else
            if (!validKeyCode(code)){
                return false;
            }
	}
	/*
	 * Método máscara data dd/MM/aaaa
	 * Date: 29.10.2006
	 * Author: Ezequiel Tomazini
	 * Parâmetros:  idCampo and teclaPressionada
	 * Event: onkeypress
	*/ 
	function maskDate(idCampo, keyPress){
            var code = isIE ? keyPress.keyCode : keyPress.charCode
            var digitado = String.fromCharCode(code).toUpperCase();
                if ( !isNaN(digitado) && notSpace(code) ){	
                    if (document.getElementById(idCampo).value.length == 2){
                        document.getElementById(idCampo).value += '/';
                    }
                    if (document.getElementById(idCampo).value.length == 5){
                        document.getElementById(idCampo).value += '/';
                    }
                    return true;
                }else
                if (!validKeyCode(code)){
                    return false;
                }
	}
	/*
	 * Método máscara cpf
	 * Date: 29.10.2006
	 * Author: Ezequiel Tomazini
	 * Parâmetros:  idCampo and teclaPressionada
	 * Event: onkeypress
	*/ 
	function maskCpf(idCampo, keyPress){
            var code = isIE ? keyPress.keyCode : keyPress.charCode
            var digitado = String.fromCharCode(code).toUpperCase();
            if ( !isNaN(digitado) && notSpace(code) ){	
                if (document.getElementById(idCampo).value.length == 3){
                    document.getElementById(idCampo).value += '.';
                }
                if (document.getElementById(idCampo).value.length == 7){
                    document.getElementById(idCampo).value += '.';
                }
                if (document.getElementById(idCampo).value.length == 11){
                    document.getElementById(idCampo).value += '-';
                }
                return true;
            }else
            if (!validKeyCode(code)){
                return false;
            }
	}	
	/*
	 * Método máscara cnpj
	 * Date: 22.11.2006
	 * Author: Ezequiel Tomazini
	 * Parâmetros:  idCampo and teclaPressionada
         *
	 * Event: onkeypress
	*/ 
	function maskCnpj(idCampo, keyPress){
            var code = isIE ? keyPress.keyCode : keyPress.charCode
            var digitado = String.fromCharCode(code).toUpperCase();
            if ( !isNaN(digitado) && notSpace(code) ){	
                if (document.getElementById(idCampo).value.length == 2){
                    document.getElementById(idCampo).value += '.';
                }
                if (document.getElementById(idCampo).value.length == 6){
                    document.getElementById(idCampo).value += '.';
                }
                if (document.getElementById(idCampo).value.length == 10){
                    document.getElementById(idCampo).value += '/';
                }
                if (document.getElementById(idCampo).value.length == 15){
                    document.getElementById(idCampo).value += '-';
                }
                return true;
            }else
            if (!validKeyCode(code)){
                return false;
            }
	}
	/*
	 * Método para o campo aceitar somente números
	 * Date: 29.10.2006
	 * Author: Ezequiel Tomazini
	 * Parâmetros:  idCampo and teclaPressionada
	 * Event: onkeypress
	*/ 
	function maskNumber(idCampo, keyPress){
            var code = isIE ? keyPress.keyCode : keyPress.charCode
            var digitado = String.fromCharCode(code).toUpperCase();
            if ( !isNaN(digitado) && notSpace(code) ){	
                return true;
            }else
            if (!validKeyCode(code)){
                return false;
            }
	}
        /*
         * Método que retorna o valor no formato moeda (real);
         * Date: 22.03.2007
         * Author: Ezequiel Tomazini
         * Event: No events
         * OBS: Está com bug.
        */ 
        function floatToMoeda(num) {
            x = 0;

            if(num<0) {
                num = Math.abs(num);
                x = 1;
            }
            if(isNaN(num)) num = "0";
            cents = Math.floor((num*100+0.5)%100);

            num = Math.floor((num*100+0.5)/100).toString();

            if (cents < 10){ 
                cents = "0" + cents;
            }
            for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++){
                num = num.substring(0,num.length-(4*i+3))+'.'+num.substring(num.length-(4*i+3));
            }
            ret = num + ',' + cents;   
            if (x == 1){
                ret = ' - ' + ret;
            }
            return ret;
        }
        /*
         * Método que retorna o valor no formato moeda (real);
         * Date: 22.03.2007
         * Author: Ezequiel Tomazini
         * Event: No events
         * Parâmetro: valor
        */ 
        function toMoeda(N){
            texto = N.toString();
            texto2 = ""
            if (texto.indexOf(',') != -1){
                for (var i = 0; i < texto.length; i++){
                    if(texto.charAt(i) == ",")
                        texto2 += ".";
                    else
                        texto2 += texto.charAt(i);
                }
                texto = texto2;
            }   

            texto[texto.indexOf(',')] = ".";
            ponto = texto.indexOf('.');
            if (ponto == -1){
                texto += ".00";
                Term = texto
            }else{
                texto += "0";
                decimal = ponto + 3;
                Term = texto.substring(0,decimal);
            }
            if (Term == ".0")    { Term = "0.00";}
            if (Term == ".00")   { Term = "0.00";}
            return Term;
        }        

        /*
         * Método que retorna o valor no formato moeda (real);
         * Date: 22.03.2007
         * Author: Ezequiel Tomazini
         * Event: No events
         * Parâmetros: valor, separador de milhar, separador decimal e evento.
        */ 
        function maskReal(fld, milSep, decSep, e) { 

            var sep = 0; var key = ''; var i = j = 0; var len = len2 = 0; var strCheck = '0123456789'; 	var aux = aux2 = '';
            var whichCode = (window.Event) ? e.which : e.keyCode;
            if (whichCode == 13) return true;
            key = String.fromCharCode(whichCode);// Valor para o código da Chave
            if (strCheck.indexOf(key) == -1) return false; // Chave inválida
            len = fld.value.length;
            for(i = 0; i < len; i++){
                if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
                aux = '';
            }            
            for(; i < len; i++){
                if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
            }    
            aux += key;

            len = aux.length; 	
            if (len == 0) fld.value = ''; 			
            if (len == 1) fld.value = '0'+ decSep + '0' + aux;

            if (len == 2) fld.value = '0'+ decSep + aux;

            if (len > 2){
            aux2 = ''; 		
            for (j = 0, i = len - 3; i >= 0; i--){
                if (j == 3){
                    aux2 += milSep;
                    j = 0;
                }
                aux2 += aux.charAt(i);
                j++;
            }
            fld.value = ''; 		
            len2 = aux2.length; 		
            for (i = len2 - 1; i >= 0; i--) 			
                fld.value += aux2.charAt(i); 			
                fld.value += decSep + aux.substr(len - 2, len); 		
            } 		
            return false; 	
        } 
		/*
		* Método máscara time HH:MM
		* Date: 29.10.2006
		* Author: Ezequiel Tomazini
		* Parâmetros:  idCampo and teclaPressionada
		* Event: onkeypress
		*/ 
		function maskTime(idCampo, keyPress){
			var code = isIE ? keyPress.keyCode : keyPress.charCode
			var digitado = String.fromCharCode(code).toUpperCase();
			if ( !isNaN(digitado) && notSpace(code) ){	
				if (document.getElementById(idCampo).value.length == 2){
					document.getElementById(idCampo).value += ':';
				}
				return true;
			}else
			if (!validKeyCode(code)){
				return false;
			}
		}	

	
	function validKeyCode(code){
            switch(code){
                case 0  : { return true;  } break;
                case 32 : { return false; } break;
                default : { return false; } break;
            }
	}
        function validKeyCodeNumber(code){
            if (code >= 48 && code <= 57){
                return true;
            }else{
                return false;
            }
        }
	function notSpace(space){
            if (space == 32){
                return false;
            }
            return true;	
	}