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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//scroll abrir janela
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',noresizable'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}

// Foto Grande
function GM_MostraFotoGrande(vArquivo,vLegenda)
		{
		  document.foto_grande.src= "" + vArquivo;
		 // document.foto_grande.alt= vLegenda;
		//  document.formulario_foto.legenda.value = vLegenda;
		}

function GM_MostraFotoGrande2(vArquivo2,vLegenda2)
		{
		  document.foto_grande2.src= "" + vArquivo2;
		 // document.foto_grande.alt= vLegenda;
		//  document.formulario_foto.legenda.value = vLegenda;
		}

function GM_MostraFotoGrande3(vArquivo3,vLegenda3)
		{
		  document.foto_grande3.src= "" + vArquivo3;
		 // document.foto_grande.alt= vLegenda;
		//  document.formulario_foto.legenda.value = vLegenda;
		}
		
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features,"left='200',top='200',width='80',height='50',toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no");
}

// Checar se o formulário está completo RESERVAS
function checa_formulario_total(){
if (form1.nome.value == ""){
alert("É necessário informar seu NOME");
form1.nome.focus();
return (false);
}
if (form1.telefone.value == ""){
alert("É necessário informar seu TELEFONE para contato");
form1.telefone.focus();
return (false);
}
if (form1.email.value == ""){
alert("É necessário informar seu E-MAIL para contato");
form1.email.focus();
return (false);
}
return (true);
}

// Checar se o formulário está completo CONTATO
function checa_formulario_contato(){
if (form2.cnome.value == ""){
alert("É necessário informar seu NOME");
form2.cnome.focus();
return (false);
}
if (form2.ctelefone.value == ""){
alert("É necessário informar seu TELEFONE para contato");
form2.ctelefone.focus();
return (false);
}
if (form2.cemail.value == ""){
alert("É necessário informar seu E-MAIL para contato");
form2.cemail.focus();
return (false);
}
if (form2.cmensagem.value == ""){
alert("É necessário adicionar sua MENSAGEM");
form2.cmensagem.focus();
return (false);
}
return (true);
}

// Checar se o formulário está completo boletim
function checa_formulario_boletim(){
if (boletim.nome_boletim.value == ""){
alert("É necessário informar seu E-mail");
boletim.nome_boletim.focus();
return (false);
}
return (true);
}

// Checar se o formulário está completo pesquisa
function checa_formulario_pes(){
if (form3.pnome.value == ""){
alert("É necessário informar seu Nome");
form3.pnome.focus();
return (false);
}
return (true);
}

// Telefone formato
function TelefoneFormat(Campo, e) {
	var key = '';
	var len = 0;
	var strCheck = '0123456789';
	var aux = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	
	if (whichCode == 13 || whichCode == 8 || whichCode == 0)
	{
		return true;  // Enter backspace ou FN qualquer um que não seja alfa numerico
	}
	key = String.fromCharCode(whichCode);
	if (strCheck.indexOf(key) == -1){
		return false;  //NÃO E VALIDO
	}
	
	aux =  Telefone_Remove_Format(Campo.value);
	
	len = aux.length;
	if(len>=10)
	{
		return false;	//impede de digitar um telefone maior que 10
	}
	aux += key;
	
	Campo.value = Telefone_Mont_Format(aux);
	return false;
}

function  Telefone_Mont_Format(Telefone)
{
	var aux = len = '';
	
	len = Telefone.length;
	if(len<=9)
	{
		tmp = 5;
	}
	else
	{
		tmp = 6;
	}
	
	aux = '';
	for(i = 0; i < len; i++)
	{
		if(i==0)
		{
			aux = '(';
		}
		aux += Telefone.charAt(i);
		if(i+1==2)
		{
			aux += ')';
		}
		
		if(i+1==tmp)
		{
			aux += '-';
		}
	}
	return aux ;
}

function  Telefone_Remove_Format(Telefone)
{
	var strCheck = '0123456789';
	var len = i = aux = '';
	len = Telefone.length;
	for(i = 0; i < len; i++)
	{
		if (strCheck.indexOf(Telefone.charAt(i))!=-1)
		{
			aux += Telefone.charAt(i);
		}
	}
	return aux;
}

// Abrir mapas
function abrejanela(url,l,a)
{
var x = parseInt((screen.width-l)/2);
var y = parseInt((screen.height-a)/2);
var win = window.open(url,'','width='+l+',height='+a);
win.moveTo(x,y);
}

// JavaScript Document
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function showOrHide(elemento,f){
	if(f){
		visi="visible";
	} else { 
		visi="hidden";
	}
		
	if(document.layers){
		document.elemento.visibility = visi;
	}
	
	if(document.all){
		document.getElementById(elemento).style.visibility = visi;
	}
	
	if(document.getElementById){
		document.getElementById(elemento).style.visibility = visi;
	}
}
