//função para pegar o tamanho da área útil do IE
/*
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;
}
*/

function mostrarImagem(param,altura,largura)
{	
   var url = "modulos/produtos/popup_lay.php?parametro="+param;
   window.open(url,"foto","width="+largura+", height="+altura+" scrollbars=no");
}

function mostrarImagem2(param,altura,largura)
{	
   var url = "modulos/produtos/popup_prd.php?parametro="+param;
   window.open(url,"foto","width="+largura+", height="+altura+" scrollbars=no");
}

/*function mostrarImagem(param,altura,largura)
{	
	var pageSize = getPageSize();
	document.getElementById('mascara').style.height = (pageSize.pageHeight + 'px');
	
	document.getElementById('caixa').innerHTML 		= '<img src="imagens/layouts/'+param+'" height="'+altura+'" width="'+largura+'" alt="Clique na imagem para fechar"><div id="caixa_legenda">Clique na imagem para fechar</div>';
	document.getElementById('caixa').style.width 	= largura+'px';
	n_altura = parseInt(altura) + 20;
	document.getElementById('caixa').style.height 	= n_altura +'px';
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		var alturaScroll = document.documentElement.scrollTop;
		diferencaIE = alturaScroll - altura/2;
		document.getElementById('caixa').style.marginLeft = -largura/2 + "px";
		document.getElementById('caixa').style.marginTop = diferencaIE + "px";
	}
	else
	{
		document.getElementById('caixa').style.margin = "-"+ altura/2 + "px 0 0 -" + largura/2 + "px";	
	}
	document.getElementById('mascara').style.display 	= '';
	document.getElementById('caixa').style.display 	= '';
}
*/
/*function mostrarImagemAdm(param,altura,largura)
{	
	var pageSize = getPageSize();
	document.getElementById('mascara').style.height = (pageSize.pageHeight + 'px');
	
	document.getElementById('caixa').innerHTML 		= '<img src="../../imagens/layouts/'+param+'" height="'+altura+'" width="'+largura+'" alt="Clique na imagem para fechar"><div id="caixa_legenda">Clique na imagem para fechar</div>';
	document.getElementById('caixa').style.width 	= largura+'px';
	n_altura = parseInt(altura) + 20;
	document.getElementById('caixa').style.height 	= n_altura +'px';
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		var alturaScroll = document.documentElement.scrollTop;
		diferencaIE = alturaScroll - altura/2;
		document.getElementById('caixa').style.marginLeft = -largura/2 + "px";
		document.getElementById('caixa').style.marginTop = diferencaIE + "px";
	}
	else
	{
		document.getElementById('caixa').style.margin = "-"+ altura/2 + "px 0 0 -" + largura/2 + "px";	
	}
	document.getElementById('mascara').style.display 	= '';
	document.getElementById('caixa').style.display 	= '';
}

function fecharImagem()
{
	document.getElementById('caixa').innerHTML 		= '';
	document.getElementById('mascara').style.display 	= 'none';
	document.getElementById('caixa').style.display 	= 'none';
}
*/


function validarCnt(){
	var str = document.getElementById('email').value;
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if(filter.test(str))
	  valido = true;
	else{
	  alert("E-mail invalido!");
	  document.getElementById('email').value = "";
	  document.getElementById('email').focus();
	  valido = false;
	}
	return valido;
}



function validaCnt() {
   var nome    = document.getElementById('nome');	
   var email   = document.getElementById('email');	
   var ddd    = document.getElementById('ddd');	
   var fone    = document.getElementById('fone');	
   var cidade    = document.getElementById('cidade');	
   var estado    = document.getElementById('estado');	
   var msg     = document.getElementById('mensagem');	
   
   if(!nome.value) {
	  alert("Por favor preencha o campo Nome");
	  return nome.focus();
   }
   if(!email.value) {
	  alert("Por favor preencha o campo E-mail");
	  return email.focus();
   }
   if(!ddd.value) {
	  alert("Por favor preencha o campo DDD");
	  return ddd.focus();
   }
   if(!fone.value) {
	  alert("Por favor preencha o campo Telefone");
	  return fone.focus();
   }
   if(!cidade.value) {
	  alert("Por favor preencha o campo Cidade");
	  return cidade.focus();
   }
   if(!estado.value) {
	  alert("Por favor preencha o campo Estado");
	  return estado.focus();
   }
   if(!msg.value) {
	  alert("Por favor preencha o campo Mensagem");
	  return msg.focus();
   }
   xhSend('modulos/fale/envia_contato.php','form_cnt',enviaFormCntRe);	
}

function enviaFormCntRe() {

    if (xhReq.readyState == 4)
	{
		resposta = xhReq.responseXML;
		if (resposta)
		{
			obj = resposta.getElementsByTagName('retorno');
			// variaveis do XML
			Xmsg 	= obj[0].getElementsByTagName('mensagem')[0].firstChild;
			if (Xmsg.nodeValue == '1')
			{
				alert("E-mail enviado com sucesso");
				document.form_cnt.reset();
			}
			else { 
			    alert("Falha ao enviar E-mail"); 
			}
		}
		else { 
		   alert("Falha de xml"); 
		   document.form_cnt.reset();
		}
	}
}



/**/

function validaOrc() {
   var nome    = document.getElementById('nome');	
   var email   = document.getElementById('email');	
   var ddd    = document.getElementById('ddd');	
   var fone    = document.getElementById('fone');	
   var cidade    = document.getElementById('cidade');	
   var estado    = document.getElementById('estado');
   var produto    = document.getElementById('produto');	
   var msg     = document.getElementById('mensagem');	
   
   if(!nome.value) {
	  alert("Por favor preencha o campo Nome");
	  return nome.focus();
   }
   if(!email.value) {
	  alert("Por favor preencha o campo E-mail");
	  return email.focus();
   }
   if(!ddd.value) {
	  alert("Por favor preencha o campo DDD");
	  return ddd.focus();
   }
   if(!fone.value) {
	  alert("Por favor preencha o campo Telefone");
	  return fone.focus();
   }
   if(!cidade.value) {
	  alert("Por favor preencha o campo Cidade");
	  return cidade.focus();
   }
   if(!estado.value) {
	  alert("Por favor preencha o campo Estado");
	  return estado.focus();
   }
   if(!produto.value) {
	  alert("Por favor preencha o campo Produto");
	  return produto.focus();
   }
   if(!msg.value) {
	  alert("Por favor preencha o campo Considerações");
	  return msg.focus();
   }
   xhSend('modulos/orcamento/envia_orcamento.php','form_orc',enviaFormCntOrc);	
   
}

function enviaFormCntOrc() {

    if (xhReq.readyState == 4)
	{
		resposta = xhReq.responseXML;
		if (resposta)
		{
			obj = resposta.getElementsByTagName('retorno');
			// variaveis do XML
			Xmsg 	= obj[0].getElementsByTagName('mensagem')[0].firstChild;
			if (Xmsg.nodeValue == '1')
			{
				alert("Orcamento enviado com sucesso!");
				document.form_orc.reset();
			}
			else { 
			    alert("Falha ao enviar E-mail"); 
			}
		}
		else { 
		   alert("Falha de xml");
		   document.form_orc.reset();
		}
	}
}



/**/

