function mudacidade(cod){
	incluiPagina("previsaoCidade.php?idCidade="+cod,"divTempo","<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>Carregando...<br>&nbsp;<br>&nbsp;");
}

function exibeDIV(nomeDIV){
	var div = document.getElementById(nomeDIV);
	
	/*if(nomeDIV == "assistirVideo"){
		document.getElementById('listaCatalogo2').style.display = 'none';
		document.getElementById('listaCatalogo').style.display = 'none';
	}
	else{
		document.getElementById('assistirVideo').style.display = 'none';
	}*/
		
	if(div.style.display == 'block'){
		document.getElementById(nomeDIV).style.display = 'none';
	}
	else{
		document.getElementById(nomeDIV).style.display = 'block';
	}
}

// INÍCIO DAS FUNÇÕES QUE FAZEM O FADE DA DIV PRODUTOS
var tempo = 20;
var fim = 9;
var inicio = 0;

function zerar(){
	inicio = 0;
	fim = 9;
}

function aparece(diretorio){
	document.getElementById('mostraProdutos').innerHTML = '';
	document.getElementById('mostraProdutos').style.display= 'block';
	
	inicio = (inicio == "0")?1:inicio+1;
	
	var atr1 = inicio / 10;//"0."+inicio;
	var atr2 = "alpha(opacity: "+inicio+"0)";
	
	if(inicio <= fim){
		document.getElementById('mostraProdutos').style.opacity = atr1;
		document.getElementById('mostraProdutos').style.mozOpacity = atr1;
		document.getElementById('mostraProdutos').style.filter = atr2;
		window.setTimeout("aparece('"+diretorio+"')", tempo);
	}
	
	if(inicio > fim){
		// FUNÇÃO QUE INCLUI PÁGINA VIA AJAX
		var urlLocal = diretorio;// alert(urlLocal);
		
		document.getElementById('mostraProdutos').style.display= 'block';
		document.getElementById('mostraProdutos2').style.display= 'block';
		
		document.getElementById('mostraProdutos2').style.opacity = 1;
		document.getElementById('mostraProdutos2').style.mozOpacity = 1;
		document.getElementById('mostraProdutos2').style.filter = 100;
		
		incluiPagina(urlLocal,'mostraProdutos2','<table align="center" width="150" border="0" cellspacing="0" cellpadding="0"><tr><td height="220">&nbsp;</td></tr><tr><td style="padding:5px; border:1px solid #000000; color:#FFFFFF; background-color:#CC0000; font-weight:bold; font-size:13px;" align="center">Aguarde...</td></tr></table>');
	}
}

function desaparece(){
	fim = (fim == 9)?8:fim-1;
	
	var atr1 = "0."+fim;
	var atr2 = "alpha(opacity: "+fim+"0)";
	
	if(fim <= inicio && fim != 0){
		document.getElementById('mostraProdutos').style.opacity = atr1;
		document.getElementById('mostraProdutos').style.mozOpacity = atr1;
		document.getElementById('mostraProdutos').style.filter = atr2;
		
		document.getElementById('mostraProdutos2').style.opacity = atr1;
		document.getElementById('mostraProdutos2').style.mozOpacity = atr1;
		document.getElementById('mostraProdutos2').style.filter = atr2;
		
		window.setTimeout("desaparece()", tempo);
	}
	
	else{
		document.getElementById('mostraProdutos').style.display= 'none';
		document.getElementById('mostraProdutos2').style.display= 'none';
		zerar();
	}
}
// FINAL DAS FUNÇÕES QUE FAZEM O FADE DA DIV PRODUTOS

function abrePopUP(url,width,height){
	window.open(url,"Galeria","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width="+width+",height="+height);
}

function abrePopUP2(url,width,height){
	window.open(url,"Galeria","toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+width+",height="+height);
}

function mudaGaleria(vlrID){
	if(vlrID=="")
		alert('- Escolha uma galeria válida.');
	else
		location="galeriaEventos.php?id="+vlrID;
}

function verificaContato(){
	var msg = '';
	var ponto  = false;
	var arroba = false;
	var caracter = false;
	var empresa = document.formContato.cmpEmpresa.value;
	var contato = document.formContato.cmpContato.value;
	var ddd = document.formContato.cmpDDD.value;
	var fone = document.formContato.cmpFone.value;
	var email = document.formContato.cmpMail.value;
	var assunto = document.formContato.cmpAssunto.value;
	var mensagem = document.formContato.cmpMensagem.value;
	
	if(empresa == "")
		msg += "- Digite a empresa.\n";
	
	if(contato == "")
		msg += "- Digite o nome do contato.\n";
	
	if(ddd == "")
		msg += "- Digite o DDD.\n";
	
	if(fone == "")
		msg += "- Digite o telefone.\n";
	
	for(var i=0; i < email.length; i++){
		if(email.charAt(i) == "@")
			arroba = true;
		if(email.charAt(i) == ".")
			ponto = true;
		if(email.charAt(i) != " ")
			caracter = true;
	}
   	if (ponto == false || arroba == false || caracter == false){
		msg += ("- Digite o e-mail corretamente.\n");
	}
	
	if(assunto == "")
		msg += "- Digite o assunto.\n";
	
	if(mensagem == "")
		msg += "- Digite o texto da sua mensagem.";
		
	if(msg == ""){
		document.formContato.action = "enviaContato.php";
		document.formContato.submit();
	}
	else{
		alert(msg);
		return
	}
}

function verificaInserirEvento(){
	var titulo = document.formNovoEvento.tituloNovoEvento.value;
	var data   = document.formNovoEvento.inicioNovoEvento.value;
	var cidade = document.formNovoEvento.cidadeNovoEvento.value;
	var estado = document.formNovoEvento.estadoNovoEvento.value;
	var msg = "";
	
	if(titulo == "" || titulo == " ")
		msg = "- Digite o título do evento.\n";
	
	if(data == "" || data == " ")
		msg += "- Digite a data inicial do evento.\n";
	
	if(cidade == "" || cidade == " ")
		msg += "- Digite a cidade do evento.\n";
	
	if(estado == "" || estado == " ")
		msg += "- Escolha o Estado do evento.";
	
	if(msg=="")
		document.formNovoEvento.submit();
	else
		alert(msg);
}

function verificaOrcamento(qntProdutos){
	var msg = '';
	var ponto  = false;
	var arroba = false;
	var caracter = false;
	var empresa = document.formOrcamento.cmpEmpresa.value;
	var contato = document.formOrcamento.cmpContato.value;
	var ddd = document.formOrcamento.cmpDDD.value;
	var fone = document.formOrcamento.cmpFone.value;
	var email = document.formOrcamento.cmpMail.value;
	var mensagem = document.formOrcamento.cmpMensagem.value;
	var msg = "";
	
	if(empresa == "")
		msg += "- Digite a empresa.\n";
	
	if(contato == "")
		msg += "- Digite o nome do contato.\n";
	
	if(ddd == "")
		msg += "- Digite o DDD.\n";
	
	if(fone == "")
		msg += "- Digite o telefone.\n";
	
	for(var i=0; i < email.length; i++){
		if(email.charAt(i) == "@")
			arroba = true;
		if(email.charAt(i) == ".")
			ponto = true;
		if(email.charAt(i) != " ")
			caracter = true;
	}
   	if (ponto == false || arroba == false || caracter == false){
		msg += ("- Digite o e-mail corretamente.\n");
	}
	
	var check = false;
	var campo = "";
	for(var i=0;i<=parseInt(qntProdutos);i++){
		if(document.getElementById('cmpQntProduto'+i).value>0){
			check = true;
			i=parseInt(qntProdutos);
		}
	}
	if(check == false)
		msg += "- Digite a quantidade para no mínimo um item.\n";
	
	if(mensagem == "")
		msg += "- Digite os dados adicionais.";
		
	if(msg == ""){
		document.formOrcamento.action = "enviaOrcamento.php?ttl="+qntProdutos;
		document.formOrcamento.submit();
	}
	else{
		alert(msg);
		return
	}
}

function verificaInserirGaleria(){
	var titulo  = document.formNovaGaleria.tituloNovaGaleria.value;
	var data    = document.formNovaGaleria.inicioNovaGaleria.value;
	var cidade  = document.formNovaGaleria.cidadeNovaGaleria.value;
	var estado  = document.formNovaGaleria.estadoNovaGaleria.value;
	var fotos   = document.formNovaGaleria.qntFotosNovaGaleria.value;
	var pasta   = document.formNovaGaleria.diretorioNovaGaleria.value;
	var ilustra = document.formNovaGaleria.ilustraNovaGaleria.value;
	var msg = "";
	var vlrFotos = 0;
	
	if(titulo == "" || titulo == " ")
		msg = "- Digite o título da galeria.\n";
	
	if(data == "" || data == " ")
		msg += "- Digite a data inicial da galeria.\n";
	
	if(cidade == "" || cidade == " ")
		msg += "- Digite a cidade da galeria.\n";
	
	if(estado == "" || estado == " ")
		msg += "- Escolha o Estado da galeria.\n";
	
	if(fotos == "" || fotos == " ")
		msg += "- Digite a quantidade de fotos da galeria.\n";
	else
		vlrFotos++;
	
	if(pasta == "" || pasta == " ")
		msg += "- Digite o diretorio da galeria.\n";
	
	if(ilustra == "" || ilustra == " ")
		msg += "- Digite o número da foto ilustrativa da galeria.";
	else
		vlrFotos++;
	
	if(parseInt(ilustra) > parseInt(fotos) && vlrFotos == 2)
		msg += "- O número da foto ilustrativa deve estar entre o número de fotos da galeria.";
	
	if(msg=="")
		document.formNovaGaleria.submit();
	else
		alert(msg);
}

// MÁSCARAS DOS CAMPOS TXT
function txtBoxFormat(strField, sMask, evtKeyPress) {
	//COMO USAR: return txtBoxFormat('NOME_DO_CAMPO', 'FORMATO_DESEJA(EX:99/99/9999 PARA_DATAS)', event);
	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
	
	var browser = navigator.appName;
	browser = browser.split(" ");
	
	if(browser[0]=="Microsoft"){
		nTecla = evtKeyPress.keyCode;
	}
	else if(browser[0]!="Microsoft"){
		nTecla = evtKeyPress.which;
	}
	
	if(nTecla == 8){
		return true;
	}
	
	else if(nTecla != 8){
		sValue = document.getElementById([strField]).value;
		sValue = sValue.toString().replace( "-", "" );      
		sValue = sValue.toString().replace( "-", "" );      
		sValue = sValue.toString().replace( ".", "" );      
		sValue = sValue.toString().replace( ".", "" );      
		sValue = sValue.toString().replace( "/", "" );      
		sValue = sValue.toString().replace( "/", "" );      
		sValue = sValue.toString().replace( "(", "" );      
		sValue = sValue.toString().replace( "(", "" );      
		sValue = sValue.toString().replace( ")", "" );      
		sValue = sValue.toString().replace( ")", "" );      
		sValue = sValue.toString().replace( " ", "" );      
		sValue = sValue.toString().replace( " ", "" );  
		sValue = sValue.toString().replace( ":", "" );  
		
		fldLen = sValue.length;      
		mskLen = sMask.length;
		i = 0;
		nCount = 0;
		sCod = "";
		mskLen = fldLen;
		
		while (i <= mskLen) {        
			bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
			bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
			bolMask = bolMask || (sMask.charAt(i) == ":")
			
			if (bolMask) {
				sCod += sMask.charAt(i);
				mskLen++;
			}
			else {
				sCod += sValue.charAt(nCount);          
				nCount++;        
			}        
			i++;
		}
		
		document.getElementById([strField]).value = sCod;  
		
		if(sMask.charAt(i-1) == "9"){
			return ((nTecla > 47) && (nTecla < 58));
		}
		else{
			return true;
		}
	}
}

function soNumeros(campo, evt){
	var browser = navigator.appName;
	browser = browser.split(" ");
	
	if(browser[0]=="Microsoft"){
		var tecla = evt.keyCode;
	}
	else if(browser[0]!="Microsoft"){
		var tecla = evt.which;
	}
	
	//alert("Tecla: "+tecla);
	var caractere = String.fromCharCode(tecla);
	
	// Libera Apenas Teclas Númericas / BackSpace / Delete / Direita / Esquerda / Enter  (Ponto =>  && tecla != 46)
	if((tecla < 48 || tecla > 57) && tecla != 0 && tecla != 8 && tecla != 9 && tecla != 37 && tecla != 13 && tecla != 188 && tecla != 190){
	//if((tecla < 48 || tecla > 57) && tecla != 8 && tecla != 9 && tecla != 37 && tecla != 39 && tecla != 13 && tecla != 188 && tecla != 190){
		window.status = 'Tecla Inválida! (' + caractere + ')';
		cancela(evt);
	}
}

//Cancela Evento
function cancela(evt){
	if (window.event) {
		evt.cancelBubble = true;
   		evt.returnValue = false;
   	}
   	if (evt && evt.preventDefault && evt.stopPropagation){
   		evt.preventDefault();
   		evt.stopPropagation();
   	}
}

// INÍCIO DO BASE.JS
/**
 * Arquivo com funções básicas de javascript
 * 
 * @version 1.0
 * @author Lázaro Danillo Menezes
 */

/*
 * INCLUSÃO DE ARQUIVOS
 */

/**
  * Inclui um arquivo js para ser utilizado.
  *
  *  Obs.: baseada na função criada por MicoX
  * 
  * function incluiJs(arquivo);
  *
  * @param {String} arquivo O arquivo js a ser incluí­do
  */
function incluiJs(arquivo){	
	// Cria um elemento script
	var script = document.createElement("script");
	// Atribui o elemento "type" p/ o elemento criado
	script.setAttribute('type','text/javascript');
	// Atribui o arquivo passado por parâmetro ao atributo "src"
	script.setAttribute('src',arquivo);
	// Adiciona o elemento criado à tag head
	porTag("head")[0].appendChild(script);
}

/*
 * FIM DA INCLUSÃO DE ARQUIVOS
 */

/*
 * CAPTURA DE ELEMENTOS
 */

/**
  * Obtem um objeto por id
  *
  * @param {String} id O id do objeto
  * 
  * @return O objeto identificado pelo id passado
  */  
function porId(id){
	return document.getElementById(id);
}

/**
  * Obtem um objeto pelo nome da tag
  *
  * @param {String} tag O nome da tag
  * 
  * @return Array, baseado em zero, com todos os elementos correspondentes
  */ 
function porTag(tag){
	return document.getElementsByTagName(tag);
}

/**
  * Obtem um objeto pelo nome da tag
  *
  * @param {String} nome O nome do elemento
  * 
  * @return Array, baseado em zero, com todos os elementos correspondentes
  */ 
function porNome(nome){
	return document.getElementsByTagName(nome);
}

/*
 * FIM DA CAPTURA DE ELEMENTOS
 */

/**
 * Cria um elemento no documento. 
 * 
 * @param {String} tag A tag HTML a ser criada (SEM < e >)
 * 
 * @return {Object} O objeto HTML a ser criado 
 */
function cria(elemento){
	return document.createElement(elemento);
}

/**
 * Retorna o nome do navegador
 * 
 * @return {String} Nome do navegador
 */
function navegador(){
	return navigator.appName;
}

/**
 * Mostra informações sobre um objeto
 * 
 * @param {Object} obj Um objeto qualquer
 * @param {boolean} alt Se true, o resultado é mostrado em um alert
 */
function inspector(obj, alt){
	var alerta = "";
	if (alt){
		for (i in obj){
	 		alerta += i + "=" + obj[i] + "\n";
	}
    alert(alerta);
	}else{
		for (i in obj){
			document.writeln(i + "=" + obj[i] + "<br>");
		}
	}
	
}
// FINAL DO BASE.JS




/**
 *  MENU DESLIZANTE
 *  
 *  @author Lázaro
 *  @version 1.0.2
 */


/**
 * Indica o objeto do menu
 */
var objMenu = null;

/**
 * Indica se o objeto irá rolar ou não 
 */
var rola = false;

/**
 * Processo de intervalo
 */
var intervalo = null;

/**
 * Indica a posição inicial do objeto. (Sua extremidade esquerda)
 */
var posIni = null;

/**
 * Posição final do objeto. (Até onde poderá rolar para a esquerda);
 */
var posFim = null; // (larg_img + (padDir + padEsq)) * img_excedente) = (48 + 8) * 3 = 168

/**
 * Move o menu indicado por "setup" para a esquerda
 */
function esq(){
	left = objMenu.offsetLeft + 1; // posição real do elemento
	if(rola == true && (left - 5) > posFim){
		objMenu.style.left = (left - 5) + 'px';
	}else{
		objMenu.style.left = posFim + 'px';
	}
}

/**
 * Move o menu indicado por "setup" para a direita
 */
function dir(){
	left = objMenu.offsetLeft + 1; // posição real do elemento
	if(rola == true && (left + 5) < posIni){		
		objMenu.style.left = parseInt(left + 5) + 'px';
	}else{
		objMenu.style.left = posIni + 'px';
	}
}

/**
 * Inicia o processo de rolagem
 * 
 * @param {String} dir A direção. [D] Direita ou [E] Esquerda 
 */
function inicia(dir){
	rola = true;
	if(dir == 'E'){
		intervalo = setInterval("esq()",1);
	}else{
		intervalo = setInterval("dir()",1);
	}
}

/**
 * Força o menu a parar a rolagem
 */
function para(){
	rola = false;
	clearInterval(intervalo);
}

/**
 * 
 * Configura o menu deslizante
 * 
 * @param {String} idObj O id do objeto que será o menu
 * @param {String} idBtDir O id do objeto que será o botão para a direita
 * @param {String} idBtEsq O id do objeto que será o botão para a esquerda
 * @param {int} pIni A posição inicial do menu
 * @param {int} pFim A posição final do menu
 */
function setup(idObj, idBtDir, idBtEsq, pIni, pFim){
		posIni = pIni;
		posFim = pFim;
	
		configuraMenu(idObj);	
		
		confBtnDir(idBtDir);
		
		confBtnEsq(idBtEsq);
}

/**
 * Configura o objeto do menu
 * 
 * @param {String} idObj O id do objeto que será o menu
 */
function configuraMenu(idObj){
	objMenu = porId(idObj);
	objMenu.style.position = "absolute";
	objMenu.style.left = posIni + "px";	
}

/**
 * Configura o botão para a direita
 * 
 * @param {String} idBtDir O id do objeto que será o botão para a direita
 */
function confBtnDir(idBtDir){
	dirBt = porId(idBtDir);
	dirBt.onmouseover = function(){ inicia("D");};
	dirBt.onmouseout = para;
}

/**
 * Configura o botão para a esquerda
 * 
 * @param {String} idBtEsq O id do objeto que será o botão para a esquerda
 */
function confBtnEsq(idBtEsq){
	esqBt = porId(idBtEsq);
	esqBt.onmouseover = function(){ inicia("E");};
	esqBt.onmouseout = para;
}

/**
 * Obtém a posição à esquerda do objeto "obj". 
 * 
 * @param {Object} obj o objeto do qual se deseja a posição da esquerda
 */
function getLeftPosition(e){
 	var left = 0;
 	var top = 0;
 	
 	left = parseInt(e.style.left.replace("px",""));
 			 	
 	return left;
}
/** FIM DO MENU ROLANTE **/

/** PEGAR POSIÇÃO DO MOUSE ** /
function moveMouse(e){
	ns = document.layers;
	ie = document.all;
	ns6 = (document.getElementById && !document.all);
 	if(ie){
		posx = event.clientX;
		posy = event.clientY;
	}
	else if (ns){
		posx = e.x;
		posy = e.y;
	}
	else if (ns6){
		posx = e.clientX;
		posy = e.clientY;
	}
	document.getElementById('mouseW').value = posx;
	document.getElementById('mouseH').value = posy;
}
document.onmousemove = moveMouse;/**/