// JavaScript Document


// [INICIO] popup simples
function func_abrePopUp(){
	window.open("/website/v6/pages/regulamento-gloss.htm", "janela", "toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=800, height=600, top=50, left=50");
}
// [FIM] popup simples


function func_mudaImg(nomeImg, caminhoImg){
	
	document.getElementById(nomeImg).src = caminhoImg
	 
}

// [INICIO] funções para controlar a abertura de divs display none

function func_showDiv (id) {
	var total = document.getElementById("totalRegistro").value;
	var nomeDiv = document.getElementById("nomeDivRegistro").value;
	var guardaValor = id;
	
	for (numero=1; numero <= total; numero++){
		if (id == numero) {
			if (document.getElementById(nomeDiv+id).style.display == 'table'){
				document.getElementById(nomeDiv+numero).style.display = 'none';
			}
			else {
				document.getElementById(nomeDiv+numero).style.display = 'table';
			}
		}
		else {
			document.getElementById(nomeDiv+numero).style.display = 'none';
		}
	}
}

// [FIM] funções para controlar a abertura de divs display none


// JavaScript Document

//Controla o rollover de imagens
function swapImg (imgID, imgPath) {
	document.getElementById(imgID).src = imgPath;
}

//Script Função ajax que detecta o navegador
function getBrowser() {
if (window.XMLHttpRequest) { 
	a=new XMLHttpRequest(); } //Objeto nativo (FF/Safari/Opera7.6+)
else {
  try { 
	 a=new ActiveXObject("Msxml2.XMLHTTP");  //activeX (IE5.5+/MSXML2+)
  }   
  catch(e) {
	try { 
 a=new ActiveXObject("Microsoft.XMLHTTP"); //activeX (IE5+/MSXML1)
	}   
	catch(e) { /* O navegador nÃ£o tem suporte */ 
 a=false; 
	}
  }
} 
return a;
}
//Fim do Scrip Função ajax que detecta o navegador

function func_ajax(url, divID){
	

	ajax = getBrowser();
	if(ajax){
		ajax.open("GET",url, true);
		ajax.onreadystatechange = function(){
			if(ajax.readyState != 4){

				document.getElementById(divID).innerHTML = "Carregando...";

			}
			if(ajax.readyState == 4){
				if(ajax.status == 200) {

					 document.getElementById(divID).innerHTML =  ajax.responseText;

       			} else {

					document.getElementById(divID).innerHTML = ajax.responseText;

      			}
			}
		}
		ajax.send(null);
	}
}


function validaMailing () {
	df = document.form1;
	if (df.cmpNome.value == "") {
		alert ("Preencha o campo Nome");
		df.cmpNome.focus();
		return false;
	}
	if (df.cmpEmail.value == "") {
		alert ("Preencha o campo Email");
		df.cmpEmail.focus();
		return false;
	}
	if (isNaN(df.cmpNascDia.value) || isNaN(df.cmpNascMes.value) || isNaN(df.cmpNascAno.value)) {
		alert ("Preencha o campo Data de Nascimento");
		return false;
	}
	if (df.cmpNascDia.value <= 0 || df.cmpNascDia.value > 31) {
		alert ("Dia da Data de Nascimento preenchido incorretamente");
		df.cmpNascDia.focus();
		return false;
	}
	if (df.cmpNascMes.value <= 0 || df.cmpNascMes.value > 12) {
		alert ("Mês da Data de Nascimento preenchido incorretamente");
		df.cmpNascMes.focus();
		return false;
	}
	dt = new Date();
	if (df.cmpNascAno.value <= (dt.getFullYear()-100) || df.cmpNascAno.value > dt.getFullYear()) {
		alert ("Ano da Data de Nascimento preenchido incorretamente");
		df.cmpNascAno.focus();
		return false;
	}
	df.submit();
}


function enviar(url){
	document.forms[0].action=url;
	document.forms[0].submit();
}

/* função para controlar a aparição de layers */
var lastLayerOpen = ""

function showLayer(layerID) {
	d = document;
	if (lastLayerOpen != "") {
		d.getElementById(lastLayerOpen).style.display = 'none';
	}
	if (layerID == lastLayerOpen) {
		lastLayerOpen = "";
		d.getElementById(layerID).style.display = 'none';
	} else {
		lastLayerOpen = layerID;
		d.getElementById(layerID).style.display = 'block';
	}
}


