/*# CONTA CARACTER */
function contaCaracter(obj_campo,vc_contador,it_limite) {
	it_caracter		= eval('document.frm.' + vc_contador);
	
	if (obj_campo.value.length > it_limite) {
		obj_campo.value		= obj_campo.value.substring(0,it_limite);
	} else {
		it_caracter.value	= it_limite - obj_campo.value.length;
	}
}

/*# redimensionamento do iframe do topo*/
function resizer(vc_objeto, it_altura){
	// aumenta altura do iFrame
			parent.document.getElementById(vc_objeto).style.height = it_altura +'px';
	}

/*# aceita só números digitados num campo */
function soNumero(evtKeyPress) {
	var nTecla;
	nTecla = (evtKeyPress.which) ? evtKeyPress.which : evtKeyPress.keyCode;
	
	if((nTecla > 47 && nTecla < 58) || nTecla == 8 || nTecla == 9 || nTecla == 37 || nTecla == 39 || nTecla == 46)
		return true;
	else
		return false;
}

/*# MASCARA */
function mascarar(vc_campo,vc_mascara) {
	var i		= vc_campo.value.length;
	var x		= vc_mascara.substring(0,1);
	var y		= vc_mascara.substring(i);
	
	if (y.substring(0,1) != x) {
		vc_campo.value += y.substring(0,1);
	}
}

/*# VALIDA ESTADO*/
function validaEstado(vc_campo) {
	if (vc_campo.value.length > 0) {
		// monta array com todoas as UF válidas
		var ar_uf		= new Array("AC", "AL", "AM", "AP", "BA", "CE", "DF", "ES", "GO", "MA", "MG", "MS", "MT", "PA", "PB", "PE", "PI", "PR", "RJ", "RN", "RO", "RR", "RS", "SC", "SE", "SP", "TO");
		var it_err		= 1;
		var vc_estado	= vc_campo.value.toUpperCase();
		
		// loop p/ verificar se foi digitado uma UF válida
		for (var i=0; i<ar_uf.length; i++) {
			if (vc_estado.toString() == ar_uf[i].toString()) {
				// caso esteja correto, zera o it_err e sai do loop
				it_err	= 0;
				break;
			} else {
				// incrementa a variável de erro
				it_err++;
			}
		}
		
		// verifica se foram encontrado erros
		if (it_err > 0) {
			alert("Por favor, preencha um estado válido!"); 
			vc_campo.focus(); 
			vc_campo.value	= "";
		}
	}
}

/*# VERIFICA DATA #*/
function verificaData(vc_campo) { 
	if (vc_campo.value.length > 0) {  
		it_dia		= eval(vc_campo.value.substring(0,2)); 
		it_mes		= eval(vc_campo.value.substring(3,5)); 
		it_ano		= eval(vc_campo.value.substring(6,10)); 
		it_erro		= 0; 
		
		if (it_dia < 1 || it_dia > 31 || it_dia > 30 && (it_mes == 4 || it_mes == 6 || it_mes == 9 || it_mes == 11 )) { 
			it_erro	= 1; 
		} 

		if (it_mes < 1 || it_mes > 12 ) { 
			it_erro	= 1; 
		} 

		if (it_mes == 2 && (it_dia < 1 || it_dia > 29 || (it_dia > 28 && (parseInt(it_ano / 4) != it_ano / 4)))) { 
			it_erro	= 1; 
		} 

		if ((it_ano < 1900) || (it_ano>2078)){
			it_erro	= 1;
		}
		
		if (it_erro == 1) { 
			alert("Por favor, preencha uma data válida!"); 
			vc_campo.focus(); 
			vc_campo.value	= '';
		}
	} 
}

/*# Reseta forumlário ao recarregar a página */
function resetForms() {
   for (var i = 0; i < document.forms.length; i++) {
     document.forms[i].reset();
   }
}

/*# Abre popup centralizada na tela. Passar largura e altura */
function wopen(page,wdt,hgt)
{
	var _x				= wdt / 2;
	var _y				= hgt / 2;
	var pos_tela_width		= (screen.width / 2) - _x;
	var pos_tela_height		= (screen.height / 2) - _y;

	window.open(page,"pre","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,noresize,copyhistory=no,width="+wdt+",height="+hgt+",top="+pos_tela_height+",left="+pos_tela_width);
}

function abreResults(page){
	parent.codigos.location.href = "../codigos/"+page;
}

/*# Exclui uma imagem */
function excluir_img(vc_pagina, id) {
	if (confirm('Deseja apagar a imagem?')) top.codigo.location.href = "../codigos/"+vc_pagina+"?act=4&id="+id;
}

/*# Exclui um registro */
function excluir(vc_pagina, id) {
	if (confirm('Deseja apagar o registro?')) top.codigo.location.href = '../codigos/'+vc_pagina+'?act=3&id='+id;
}

/*# EXIBIR / APAGAR LAYER*/
function sL(layerName, timeOut){
	document.getElementById(layerName).style.display = "block";
}
        
function hL(layerName){
	document.getElementById(layerName).style.display = "none";
}

/*# TROCA DE IMAGENS DETALHES SEMINOVOS */
function trocaImg(layerName, imagem){
	document.getElementById(layerName).src = imagem;
}
        
function resizerNovos () {
		parent.document.getElementById('framenovos').style.height=document.getElementById('tudo_novos').offsetHeight+40+'px';
}


function abreRentaCar(){
	window.open("http://www.agencialinking.com.br/Vigo_RentaCar/home.htm","_blank");
}

/*# TROCA LAYERS #*/
function tL(id_exibe, id_esconde){
	document.getElementById(id_exibe).style.display = 'block';
	document.getElementById(id_esconde).style.display = 'none';
	resizerNovos();
}

/*# PULA CAMPO EX.: DDD PARA TELEFONE #*/
function proxCampo (numCa,campo,proxCampo) {
	if (campo.value.length >= numCa) {
		proxCampo.focus(true);
	}
}
/*# ALERTA PARA O CAMPO DE ACOMPANHAMENTO*/
function alertVazio(){
	alert("Preencha o campo com a placa que deseja consultar");
}

/* jquery */
document.write('<script src="/jss/jquery.js"></script>')
document.write('<script src="/jss/jquery_global.js"></script>')
