	var msgError = '';
	var existError = 0;
	var labelError = 'error';
	var br = '<br />';
	function setExistError(error){
            this.existError = error;
	}
	function getExistError(){
            return this.existError;
	}
	function nextPage(){
            if (getExistError() == 0){
                return true;
            }
            return false;
	}
	function setMsgError(valor){
            if (getMsgError() == ''){
                this.msg = valor;
            }else{
                this.msgError = getMsgError() + ' ' + valor;
            }
	}
	function getMsgError(){
            return this.msgError;
	}

	function fieldFocus(idCampo){
            document.getElementById(idCampo).focus();
            document.getElementById(idCampo).style.backgroundImage  = 'url(../images/fieldBackground.gif)';
            document.getElementById(idCampo).style.backgroundRepeat = 'no-repeat';
	}
	function fieldNoFocus(idCampo){
            document.getElementById(idCampo).style.backgroundColor = '#FFF';
            document.getElementById(idCampo).style.backgroundImage  = 'none';
            document.getElementById(labelError+idCampo).style.display  = 'none';
	}
	/*
	 * Método que valida um campo do tipo String
	*/
	function validationString(idCampo, labelCampo, minLength, maxLength){
            var erroString = 0;
            var msgString  = '';
            valorString    =  document.getElementById(idCampo).value;
            var linkFocus  =  "<b class='fieldFocus' onclick=fieldFocus('"+idCampo+"')>"+labelCampo+"</b> ";
            if (valorString == ''){
                msgString += 'O campo ' + linkFocus + ' é de preenchimento obrigatório.';
            }else{
                if ( (minLength != '' && minLength > 0) && (maxLength != '' && maxLength > 0) ){
                    if (valorString.length < minLength || valorString > maxLength){
                        msgString = 'O campo ' + linkFocus + 'deve ter no mínimo ' + minLength + ' e no máximo ' + maxLength + ' caracteres.'+ br;
                    }
                }else
                if ( (minLength == '' && maxLength  > 0) && valorString.length < maxLength){
                    msgString = 'O campo ' + linkFocus + 'deve ter ' + maxLength + ' caracteres.'+ br;
                }
            }
            if (msgString != ''){
                existsError(idCampo, msgString);
            }else{
                document.getElementById(labelError + idCampo).innerHTML = '';
                fieldNoFocus(idCampo);
            }
	}
	
	function validationSelect(idCampo, labelCampo){
            valorSelectedIndex    =  document.getElementById(idCampo).selectedIndex;
            var msgSelect  = '';
            var linkFocus  =  "<b class='fieldFocus' onclick=fieldFocus('"+idCampo+"')>"+labelCampo+"</b> ";
            if (valorSelectedIndex == 0){
                msgSelect = 'O campo ' + linkFocus + ' não está selecionado corretamente.';
                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 linkFocus  =  "<b class='fieldFocus' onclick=fieldFocus('"+idCampo+"')>"+labelCampo+"</b> ";
            var dia = document.getElementById(idCampo).value.substring(0,2);
            var mes = document.getElementById(idCampo).value.substring(3,5);
            var 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 ' + linkFocus + 'está incorreta.'+ br;
                existsError(idCampo, msgString);
            }
            if (msgString != ''){
            }else{
                document.getElementById(labelError + idCampo).innerHTML = '';
                fieldNoFocus(idCampo);
            }
        }
	/* Description: Método para validar a hora
	 * Author: Ezequiel Tomaizni
	 * Date:   06.02.2007 22:06 hs
	*/
	function validationTime(idCampo, labelCampo){
            var linkFocus  =  "<b class='fieldFocus' onclick=fieldFocus('"+idCampo+"')>"+labelCampo+"</b> ";
            var hora   = document.getElementById(idCampo).value.substring(0,2);
            var minuto = document.getElementById(idCampo).value.substring(3,5);
            if ( (hora >= 0 && hora <= 24) && (minuto >= 0 && minuto <= 59) ){
                msgString = '';
            }else{
                msgString = 'A hora inserida no campo ' + linkFocus + 'está incorreta.'+ br;
                existsError(idCampo, msgString);
            }
            if (msgString != ''){
            }else{
                document.getElementById(labelError + idCampo).innerHTML = '';
                fieldNoFocus(idCampo);
            }
        }
	
        function existsError(idCampo, msg){
            setExistError(1);
            document.getElementById(labelError + idCampo).innerHTML = msg;
            document.getElementById(labelError + idCampo).className = 'msgErrorAtiva';
        }
	/* 
	 * 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 time HH:MM
	 * Date: 06.02.2007
	 * 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 += ':';
                }else
                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;
            }
	}	
	
	function validKeyCode(code){
            switch(code){
                case 0  : { return true;  } break;
                case 32 : { return false; } break;
                default : { return false; } break;
            }
	}
	function notSpace(space){
            if (space == 32){
                return false;
            }
            return true;	
	}
	
	
	/* CAPTURA A HORA DO MICRO */
	var timerID = null;
	var timerRunning = false;
	function stopclock (){
			if(timerRunning)
					clearTimeout(timerID);
			timerRunning = false;
	}

	function startclock () {
			// Certifica que o relógio está parado
			stopclock();
			showtime();
	}

	function showtime () {
			var now = new Date();
			var hours = now.getHours();
			var minutes = now.getMinutes();
			var seconds = now.getSeconds()
			var timeValue = "" + ((hours >12) ? hours -12 :hours)
			timeValue += ((minutes < 10) ? ":0" : ":") + minutes
			timeValue += ((seconds < 10) ? ":0" : ":") + seconds
			timeValue += (hours >= 12) ? " P.M." : " A.M."
			document.clock.face.value = timeValue;
			// você poderá substituir a linha acima pelo código
			// abaixo e terá o relógio na linha de status:
			// window.status = timeValue;
			timerID = setTimeout("showtime()",1000);
			timerRunning = true;
	}

    function deleta(){
        if (confirm('Deseja excluir?')){
            return true;
        }
        return false;
    }

