// menu botão direito mouse
var mozilla=document.getElementById && !document.all
var ie=document.all
var contextisvisible=0

function iebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function displaymenu(e){
el=document.getElementById("context_menu")
contextisvisible=1
if (mozilla){
el.style.left=pageXOffset+e.clientX+"px"
el.style.top=pageYOffset+e.clientY+"px"
el.style.visibility="visible"
e.preventDefault()
return false
}
else if (ie){
el.style.left=iebody().scrollLeft+event.clientX
el.style.top=iebody().scrollTop+event.clientY
el.style.visibility="visible"
return false
}
}

function hidemenu(){
if (typeof el!="undefined" && contextisvisible){
el.style.visibility="hidden"
contextisvisible=0
}
}

if (mozilla){
document.addEventListener("contextmenu", displaymenu, true)
document.addEventListener("click", hidemenu, true)
}
else if (ie){
document.attachEvent("oncontextmenu", displaymenu)
document.attachEvent("onclick", hidemenu)
}
// menu botão direito mouse


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function contato(){
	if (document.form_contato.nome.value == "" || document.form_contato.email.value == "" || document.form_contato.mensagem.value == "" || document.form_contato.mensagem.value == "Mensagem..."){
		window.alert("Todos os campos são obrigatórios!");
		}else{
			if (!/^([a-zA-Z0-9]+([_\-\.]{0,1}[a-zA-Z0-9]{1,})*)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(document.form_contato.email.value)){
				window.alert("Digite um endereço de e-mail válido");
				}else{
					document.form_contato.submit();
					}
			}
}


function numeros(pStr){
		if (reDigits.test(pStr)) {
			alert(pStr + " contém apenas dígitos.");
		} else if (pStr != null && pStr != "") {
			alert(pStr + " NÃO contém apenas dígitos.");
		}
}


function cotar(id_secao,id_linha,pagina){
	if (document.form_cot.quantidade.value == "" || document.form_cot.nome.value == "" || document.form_cot.email.value == "" || document.form_cot.dataevento.value == ""){
		window.alert("Apenas os campos telefone, CEP e observações não são obrigatórios!");
		}else{
			if (!/^([a-zA-Z0-9]+([_\-\.]{0,1}[a-zA-Z0-9]{1,})*)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(document.form_cot.email.value)){
				window.alert("Digite um endereço de e-mail válido!");
				}else{	
					if (Number(document.form_cot.quantidade.value)){
						var reDate = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/; //formato dd/mm/aaaa
						var pStr = document.form_cot.dataevento.value;
						if (reDate.test(pStr)) {							
						document.form_cot.submit();						
						}else if (pStr != null && pStr != ""){
						window.alert(pStr + " não é uma data válida.");
						document.form_cot.dataevento.value = "dd/mm/aaaa";
						}
						}else{
							window.alert("Digite apenas números no campo quantidade!");
							}

					}
			}
}


activateMenu = function(nav) {

	if (document.all && document.getElementById(nav).currentStyle) {  
       var navroot = document.getElementById(nav);
        
		var lis=navroot.getElementsByTagName("LI");  
        for (i=0; i<lis.length; i++) {       
            if(lis[i].lastChild.tagName=="UL"){
					
             	lis[i].onmouseover=function() {	
                   this.lastChild.style.display="block";
                }				
                lis[i].onmouseout=function() {                       
                   this.lastChild.style.display="none";
                }
            }
        }
  }
	
	
}
window.onload= function(){
   activateMenu('nav'); 
}

function buscar(){
	if (document.form.busca.value == "" || document.form.busca.value == " buscar..."){
		window.alert("Digite a sua busca!");
		document.form.busca.value = " buscar...";
		}else{
			if (document.form.busca.value.length < 3){
				window.alert("Digite no mínimo, três caracteres!");
				document.form.busca.value = " buscar...";
				}else{
					document.form.submit();
					}
			}
}

function abre_priv(){
	window.open("privacidade.html","janela_priv","width=440,height=484,scrollbars=0,statusbar=0");	
}

function fecha_teaser(){
	document.getElementById('teaser').style.visibility="hidden";
}

function indicar() {
	if (document.formindic.seunome.value == "" || document.formindic.seuemail.value == "" || document.formindic.destinatario.value == "" || document.formindic.emaildestinatario.value == ""){
		document.formindic.avisoindic.value = "Apenas o campo mensagem não é obrigatório!";
		}else{
		if (!/^([a-zA-Z0-9]+([_\-\.]{0,1}[a-zA-Z0-9]{1,})*)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(document.formindic.seuemail.value)){
		document.formindic.avisoindic.value = "O seu e-mail não é válido!";	
		}else{
		if (!/^([a-zA-Z0-9]+([_\-\.]{0,1}[a-zA-Z0-9]{1,})*)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(document.formindic.emaildestinatario.value)){
		document.formindic.avisoindic.value = "O e-mail do destinatário não é válido!";	
		}else{
			document.formindic.submit();
			}
		}
 }
}

function apagaindicformindic(){
		document.formindic.seunome.value = "";
		document.formindic.seuemail.value = "";
		document.formindic.destinatario.value = "";
		document.formindic.emaildestinatario.value = "";
		document.formindic.mensagem.value = "";
		document.formindic.avisoindic.value = "";
}

function verCep(){
	if (document.getElementById('cep').value.length == 9){
		document.getElementById('cep').value = document.getElementById('cep').value.substring(0,9);
	}else{
		if (Number(document.getElementById('cep').value) || document.getElementById('cep').value == 0){
			if (document.getElementById('cep').value.length == 8){
			document.getElementById('cep').value = document.getElementById('cep').value.substring(0,5) + "-" + document.getElementById('cep').value.substring(5,8);
			}
		}else{
		document.getElementById('cep').value = "";
		}	
	}
}