																																										//----------------------------------------------------------------------------
//Nome     : Validação de formulários
//Criacao  : 20041101 17:00PM
//Autor    : Gilberto Russo Jenuino <jenuino@gmail.com>
//Versao   : 1.0.0.0
//Local    : Jundiaí - SP, São Paulo
//Copyright: 2004 by Russo Jenuino, Gilberto
//----------------------------------------------------------------------------
///========================================================================
//função ajax

try {
	ajax = new XMLHttpRequest();
	} catch(ee) {
				try {
					ajax = new ActiveXObject("Msxml2.XMLHTTP");
					} catch(e) {
								try {
									ajax = new ActiveXObject("Microsoft.XMLHTTP");
									} catch(E) {
												ajax = false;
												}
									}
}

//função ajax
function _fcAjax(a,b){
	var exibeResultado = document.getElementById(a);
				ajax.open("get",b, true);

					ajax.onreadystatechange = function(){
					exibeResultado.innerHTML = "<h5 style='background:#f3f3f3; size:12px; border:1px; font:Verdana, Arial, Helvetica, sans-serif; width:100%; border-color:#fcfcfc; border-width:1px'>Carregando...</h5>";
							if (ajax.readyState == 4){
								if(ajax.status == 200){
									var resultado = ajax.responseText;
									resultado = resultado.replace(/\+/g," ");
									resultado = unescape(resultado);
									exibeResultado.innerHTML = resultado;
								}else{
									exibeResultado.innerHTML = "Erro: "+ajax.status;
									}
													}
													}
					ajax.send(null);
					//ajax.send('txtNome=' + document.getElementById('txtNome').value + '&txtEmail=' + document.getElementById('txtEmail').value + '&txtAssunto=' + document.getElementById('txtAssunto').value + '&txtMensagem=' + document.getElementById('txtMensagem').value);
}


//exibe resultado do ajax
function _exibeMsg(msg,id){
	var exibeMsg = document.getElementById(id);
					exibeMsg.innerHTML = msg;

}


//função para o cep
 function MM_formtCep(e,src,mask) {
if(window.event) { _TXT = e.keyCode; } 
else if(e.which) { _TXT = e.which; }
if(_TXT > 47 && _TXT < 58) { 
 var i = src.value.length; var saida = mask.substring(0,1); var texto = mask.substring(i)
 if (texto.substring(0,1) != saida) { src.value += texto.substring(0,1); } 
    return true; } else { if (_TXT != 8) { return false; } 
 else { return true; }
}
}

//////////////////////mascara telefone
 function MM_formtTel(e,src,mask) {
if(window.event) { _TXT = e.keyCode; } 
else if(e.which) { _TXT = e.which; }
if(_TXT > 47 && _TXT < 58) { 
 var i = src.value.length; var saida = mask.substring(0,1); var texto = mask.substring(i)
 if (texto.substring(0,1) != saida) { src.value += texto.substring(0,1); } 
    return true; } else { if (_TXT != 9) { return false; } 
 else { return true; }
}
}



//FUNÇÃO LETRA MAIÚSCULA

function Converte(CAMPO) {
        CAMPO.value = CAMPO.value.toUpperCase();}

						

//------------------------
function _fcPop(url, nome, largura, altura) {
//------------------------
  posleft = (((screen.width - largura)/2)-10);
  postop  = (screen.height - altura)/2;
  parametros = 'toolbar=no, location=no, directories=no, status=no, ';
  parametros += 'scrollbars=no, resizable=no, menubar=no, ';
  parametros += 'width='+largura+', height='+altura+', left='+posleft+', top='+postop;
  void(window.open(url, nome, parametros));
}

//=======================================================
//função muda de campo
	function autoTab(input,len, e) {
		var keyCode = (isNN) ? e.which : e.keyCode;
			var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
			if(input.value.length >= len && !containsElement(filter,keyCode)) {
				input.value = input.value.slice(0, len);
				input.form[(getIndex(input)+1) % input.form.length].focus();
			}
	function containsElement(arr, ele) {
		var found = false, index = 0;
			while(!found && index < arr.length)
				if(arr[index] == ele)
					found = true;
				else
					index++;
					return found;
				}
	function getIndex(input) {
		var index = -1, i = 0, found = false;
			while (i < input.form.length && index == -1)
				if (input.form[i] == input)index = i;
				else i++;
				return index;
				}
return true;
}	