// JavaScript Document

function vldCadVoador()
{
	var obj = document.form1, dados = null, url = null;

	if(obj.nome.value == ''){
		alert('Informe seu nome.');
		obj.nome.focus();
		return false;
	}else if(obj.email.value == ''){
		alert('Informe seu e-mail.');
		obj.email.focus();
		return false;
	}else if(obj.emailc.value == ''){
		alert('Confirme seu e-mail.');
		obj.emailc.focus();
		return false;
	}else if(obj.email.value != obj.emailc.value){
		alert('Os e-mails informados não coincidem.');
		obj.email.focus();
		return false;
/*	}else if(obj.cidade.value == ''){
		alert('Informe sua cidade.');
		obj.cidade.focus();
		return false;
	}else if(obj.estado.value == ''){
		alert('Informe seu estado.');
		obj.estado.focus();
		return false;
	}else if(obj.pais.value == ''){
		alert('Informe seu país.');
		obj.pais.focus();
		return false;*/
	}else{
		dados = '&nome='+obj.nome.value+'&email='+obj.email.value+'&emailc='+obj.emailc.value+'&cidade='+obj.cidade.value+'&estado='+obj.estado.value+'&pais='+obj.pais.value;
		url   = 'classes/ajax_global.php?acao=grava_email';
		execAjaxGet(url, dados, 'formulario_voador');
		alert('Obrigado por se cadastrar no portal Guia de Compras do Brasil.');
		fechaJanela();

		return false;
	}
}

function execAjaxGet(pUrl, pDados, pDestino)
{
	var ajaxObj1 = seta_ajax();

	ajaxObj1.onreadystatechange = function()
	{
		if(ajaxObj1.readyState == 4){
			if(ajaxObj1.status == 200){
			}
		}else{
			elemento(pDestino).innerHTML = '<img src="imagens/carregando2.gif" style="width:20px;" alt="Carregando">&nbsp;Gravando dados...';
		}
	}

	ajaxObj1.open("GET",pUrl+pDados);
	ajaxObj1.send(null);
}

function abreJanela(pLarg,pAlt)
{
	var obj = null, largura = null, altura = null, topo = null;
	var de = document.documentElement;

	obj = elemento('formulario_voador');
	
	sombra();

	largura = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	altura  = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	topo    = window.pageYOffset ? window.pageYOffset : document[(document.compatMode == 'CSS1Compat') ? 'documentElement' : 'body'].scrollTop;

	obj.style.left       = ((largura/2) - (pLarg/2) - 20).toString()+'px';
	obj.style.top        = ((altura/2) - (pAlt/2) + (topo - 10)).toString()+'px';
	obj.style.background = '#ffffff';
	obj.style.opacity    = '0.9';
	obj.style.filter     = 'alpha(opacity=90)';
	obj.style.overflow   = 'hidden';
	obj.style.border     = 'solid 5px #cccccc';
	obj.style.padding    = '10px';
	obj.style.width      = pLarg.toString()+'px';
	obj.style.height     = pAlt.toString()+'px';
	obj.style.display    = 'block';
}

function sombra()
{
	var objsombra = document.getElementById('sombra'), largura, altura;
	var de = document.documentElement, nav = navegador();

	largura = document.body.clientWidth || (de&&de.clientWidth) || self.innerWidth || window.innerWidth;
	altura  = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	topo    = window.pageYOffset ? window.pageYOffset : document[(document.compatMode == 'CSS1Compat') ? 'documentElement' : 'body'].scrollTop;
	
	objsombra.style.top        = topo.toString()+'px';
	objsombra.style.left       = '0px';
	objsombra.style.width      = largura.toString()+'px';
	objsombra.style.height     = altura.toString()+'px';
	objsombra.style.background = '#000000';
	objsombra.style.opacity    = '0.5';
	objsombra.style.filter     = 'alpha(opacity=50)';
	objsombra.style.display    = 'block';
}

function fechaJanela()
{
	var obj = document.getElementById('formulario_voador'), objsombra = document.getElementById('sombra');

	obj.innerHTML           = '';
	obj.style.display       = 'none';
	objsombra.style.display = 'none';
}

