/*
*  Desenvolvedor  		: Elias de Almeida Rodrigues
*  Empresa            	: OpenCorporate [ www.opencorporate.com ]
*  Cliente              : Mitra
*  Descrição          	: Arquivo que contém os scripts JS utilizados no WebSite
*  Package             	: WebSite
*/
function openAjax() {

	var ajax;

	try{
		ajax = new XMLHttpRequest(); //XMLHttpRequest para browsers decentes, como: Firefox, Safari, dentre outros.
	}catch(ee){
		try{
			ajax = new ActiveXObject("Msxml2.XMLHTTP"); // Para o IE da MS
		}catch(e){
			try{
				ajax = new ActiveXObject("Microsoft.XMLHTTP"); // Para o IE da MS
			}catch(E){
				ajax = false;
			}
		}
	}
	return ajax;
}


function newsletter() {

	var nome = document.getElementById('txtNomeNewsletter');
	var email = document.getElementById('txtEmailNewsletter');

	if(nome.value=="" || email.value=="" || nome.value=="Nome" || email.value=="Email"){
		var msg ="Os campos abaixo são obrigatórios:";
		if(nome.value=="Nome" || nome.value=="")
			msg+="\n- Nome.";
		if(email.value=="E-mail" || email.value=="")
			msg+="\n- E-mail.";

		alert(msg);
		return false;
	}
	return true;
}

function mostraPopUpPromo(id){
	www = "catalogo_popup_promo.php?id="+id;
	h='300';
	w='785';

	var height = window.screen.height - 160;
	var width = window.screen.width;
	var top = (height- h)/2;
	var left = (width - w)/2;
	window.open(www,"Produto","top=" + top + ",left="+ left +",width="+w+",height="+h+",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,scrolling=yes,resizable=yes")
}

function mostraPopUp(id){
	www = "catalogo_popup.php?id="+id;
	h='300';
	w='785';

	var height = window.screen.height - 160;
	var width = window.screen.width;
	var top = (height- h)/2;
	var left = (width - w)/2;
	window.open(www,"Produto","top=" + top + ",left="+ left +",width="+w+",height="+h+",toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,scrolling=yes,resizable=yes")
}

function bloqueiaPromoSession(valor){

	var ajax = openAjax(); // Inicia o Ajax.
	url = "controle.php?session="+valor;
	//alert(url);
	ajax.open("GET", url, true);
	ajax.send(null); // submete

}

function apresentaPromocoes(){

	var divPromo = document.getElementById('vitrine').checked;
	bloqueiaPromoSession('0');
	//alert("Bloquear/Esconder: " + divPromo);
	document.getElementById('boxPromocao_interno').style.display = 'none';
	//divPromo = false;
	document.getElementById('alt').style.display = 'block';
	document.getElementById('vitrine').checked = false;
}

function ativaPromocoes(){

	bloqueiaPromoSession('1');
	//alert("Desbloquear/Mostrar: " + divPromo);
	document.getElementById('boxPromocao_interno').style.display = 'block';
	//divPromo = false;
	document.getElementById('vitrine').checked = false;
	document.getElementById('alt').style.display = 'none';
}


