// mostraLayer jquery
function showLayer(idLayer,totalLayers){

	for(i=1; i<=totalLayers; i++){
		$tempLayer = $("#layer" + i);
		if(i == idLayer){
			$tempLayer.css({display:"block"});
		}else{
			$tempLayer.css({display:"none"});
		}
	}
}	
	
function showRelatorios(idLayer,totalLayers){
	for(i=1; i<=totalLayers; i++){
		$tempLayer = $("#abre_rel" + i);
		if(i == idLayer){
			$tempLayer.css({display:"block"});
		}else{
			$tempLayer.css({display:"none"});
		}
	}
}	



/*# 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;
	}
}

/*# fecha div da promoção #*/

function fechaPromo(){
	document.getElementById('promocao_bola').style.display = "none";
}

/*# exibe/esconde 1 layer de roubo de taça por vez #*/

function trocaRoubo(exibe){
	
	document.getElementById('roubo1').style.display = "none";
	document.getElementById('roubo2').style.display = "none";
	
	if(exibe != 'nenhum'){
		document.getElementById(exibe).style.display = "block";
	}
}

/*# Reseta forumlário ao recarregar a página */
function resetForms() {
   for (var i = 0; i < document.forms.length; i++) {
     document.forms[i].reset();
   }
}

/*# 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;
}

/*# 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;
}

/*# Link do frame de menu */
function mnRedirectPage(vc_nome) {
	top.formulario.location.href	= '../formularios/' + vc_nome + '.asp?act=1';
	top.pesquisa.location.href		= '../pesquisas/' + vc_nome + '.asp';
	top.orientacoes.location.href	= '../orientacoes/' + vc_nome + '.asp';
}

/*# iFrame virtual #*/
function iframe_virtual(vc_url) {
	var tempIFrame	= (document.getElementById('iframe_virtual')) ? document.getElementById('iframe_virtual') : document.createElement('iframe');
	
	tempIFrame.style.border		='0px';
	tempIFrame.style.width		='0px';
	tempIFrame.style.height		='0px';
	
	tempIFrame.setAttribute('id','iframe_virtual');
	tempIFrame.setAttribute('name','iframe_virtual');
	tempIFrame.setAttribute('src',vc_url);
	
	IFrameObj					= document.body.appendChild(tempIFrame);
}

/*# 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;
}

/*# popup para selecionar uma opção */
function pop_select(vc_campo,vc_termo, evt) {
	var vc_campo	= vc_campo.replace('vc','select');
	var nTecla;
	nTecla = (evt.which) ? evt.which : evt.keyCode;
	
	if(nTecla == 13) {
		var W		= 330; 	
		var H		= 430;
		var X		= 50;
		var Y		= Math.ceil( (window.screen.width - W) / 2 );
		
		obj_win		= window.open('../relatorios/'+vc_campo+'.asp?vc_termo='+vc_termo,'ap_select','width='+W+',height='+H+',top='+X+',left='+Y+',location=no,status=yes,menubar=no,scrollbars=yes,resizable=no,directories=no,toolbar=no');
		obj_win.focus();
		return false;
	}
}

/*# limpa pop_select ao receber foco */
function pop_select_limpar(vc_campo,vc_termo) {
	var vc_campo		= eval('document.frm.'+vc_campo)

	if(vc_termo == 'clique e tecle ENTER'){
		vc_campo.value	= '';
	}	
}

/*# seta valores padrão p/ o pop_select */
function pop_select_restaura(vc_campo) {
	if (vc_campo.value.length == 0) {
		vc_campo.value	= 'clique e tecle ENTER';
		var id_campo	= vc_campo.name.replace('vc_','id_');
		id_campo		= eval('document.frm.'+id_campo);
		id_campo.value	= '';
	}
}

/*# enche os campos com o registro escolhido */
function pop_select_preenche(id_campo,vc_campo,tx_campo) {
	var id_item 										= String('id_'+tx_campo);
	var vc_item 										= String('vc_'+tx_campo);
	
	window.opener.eval('document.frm.'+id_item).value	= id_campo;
	window.opener.eval('document.frm.'+vc_item).value	= vc_campo;
	window.close();	
}

/*# muda status através do resultado da pesquisa */
function changeStatus(obj_dd, vc_script) {
	iframe_virtual('../codigos/'+ vc_script + '?act=4' + '&it_status=' + obj_dd.value + '&id=' + obj_dd.id);
}

/*# 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 wopenImg(page) {
	var _x					= 200;
	var _y					= 200;
	var pos_tela_width		= (screen.width / 2) - _x;
	var pos_tela_height		= (screen.height / 2) - _y;

	newWindow = window.open(page,"pre","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=1,copyhistory=no,width="+400+",height="+400+",top="+pos_tela_height+",left="+pos_tela_width);
}

/*# Abre popup centralizada na tela. Passar largura e altura */
//function wopenImg(page,wdt,hgt,target)
//{
//	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,target,"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);
//}

/*# Abre popup centralizada na tela. Passar largura e altura */
function wopenScroll(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,"cadastro","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,noresize,copyhistory=no,width="+wdt+",height="+hgt+",top="+pos_tela_height+",left="+pos_tela_width);
}

/*# Abre popup centralizada na tela. Passar largura e altura PARA COMENTÁRIOS */
function wopenComent(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,"comentarios","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);
}

/*# função para exibir/ocultar layers */
function sL(layerName){
	document.getElementById(layerName).style.visibility = "visible";
}
        
/*# 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);
	}
}

/*# VERIFICA DATA #*/
function verificaData(vc_campo) { 
	if (vc_campo.value.length > 0) {  
		it_dia		= (vc_campo.value.substring(0,2)); 
		it_mes		= (vc_campo.value.substring(3,5)); 
		it_ano		= (vc_campo.value.substring(6,10)); 
		it_erro		= 0; 
		
		if ((it_dia < 1) || (it_dia < 1 || it_dia > 30) && (it_mes == 4 || it_mes == 6 || it_mes == 9 || it_mes == 11 ) || it_dia > 31) { 
			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.value	= '';
			vc_campo.focus(); 
		}
	} 
}

// -->
