
//função para diminuir o tamanho do flsh em caso de foto unica
function getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY){
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	if(yScroll < windowHeight) pageHeight = windowHeight;
	else pageHeight = yScroll;
	if(xScroll < windowWidth) pageWidth = windowWidth;
	else pageWidth = xScroll;
	arrayPageSize = {pageWidth:pageWidth,pageHeight:pageHeight,windowWidth:windowWidth,windowHeight:windowHeight}
	return arrayPageSize;
}

//----------------

var xhReq;

function validarForm() {
   var nome     = document.getElementById('nome').value;	
   var cidade   = document.getElementById('cidade').value;	
   var email    = document.getElementById('email').value;	
   var fone     = document.getElementById('telefone').value;	
   var mensagem = document.getElementById('mensagem').value;	
   if(!nome || nome == "Nome:") {
	  alert("Por favor preencha o campo Nome");
	  return document.getElementById('nome').focus();
   }
   if(!email || email == "E-mail:") {
	  alert("Por favor preencha o campo E-mail");
	  return document.getElementById('email').focus();
   }
   if(!cidade || cidade == "Cidade:") {
	  alert("Por favor preencha o campo Cidade");
	  return document.getElementById('cidade').focus();
   }
   if(!fone || fone == "Telefone:") {
	  alert("Por favor preencha o campo Telefone");
	  return document.getElementById('fone').focus();
   }
   if(!mensagem || mensagem == "Mensagem>") {
	  alert("Por favor preencha o campo Mensagem");
	  return document.getElementById('mensagem').focus();
   }
   else {
	  enviaCont();   
   }
}

function enviaCont() {
   xhSend('modulos/contato/envia_contato.php','frmEmail',enviaContRe);
}

function enviaContRe() {
	if (xhReq.readyState == 4)
	{
		retorno = xhReq.responseXML;
        if (retorno != null)
		{
			obj = retorno.getElementsByTagName('retorno');
			if (obj[0].getElementsByTagName("mensagem")[0].firstChild.nodeValue == 1) {
			   alert("Dados enviados com sucesso!");
			}
			if (obj[0].getElementsByTagName("mensagem")[0].firstChild.nodeValue == 2) {
			   alert("Falha ao enviar Dados"); 
			}
		}
		else { 
		   alert("Falha de Xml"); 
		}
		document.getElementById('frmEmail').reset();
	}
	
}

