tms=new Array()
tms=new Array()

//Mostra o submenu no mouseover
function over(n)
{
 if(typeof(tms[n])!="undefined")clearTimeout(tms[n])
 document.getElementById("s"+n).style.visibility="visible"
}

//Esconde o submenu no mouseout
function out(n)
{
 tms[n]=setTimeout('document.getElementById("s'+n+'").style.visibility="hidden"',0)
}

//Funcao Javascript para fechar a janela do browser
function CloseWindow()
{
 return window.close();
}

//Janela para Imprimir e Indicar 
function NewWindow(url, w, h)
{
 window.open(url,'send','toolbar=no, width='+w+', height='+h+', statusbar=no'); 
}

//função usada na barra do governo do estado
function gotoPage(varItem)
{
 if (varItem != "null") 
 {
  window.open(document.destaques.menu.value)
 }
 else
 {
  alert("Selecione uma opção válida")
 }
}



function ValidFormEnvia(formName)
{
 //minimiza parâmetros dos comandos javascript
 formulario=eval("document."+formName);
 //vetor com o nome dos campos do formulário
 fields= new Array("fromname","fromemail","toname","toemail");
 labels= new Array();
 labels[0]="- Digite seu nome.\n";
 labels[1]="- Digite seu e-mail.\n";
 labels[2]="- Digite o nome do seu amigo.\n";
 labels[3]="- Digite o e-mail do seu amigo.\n";
 //início da mensagem
 msg ="Atenção: Não foi possível enviar a notícia pois você deve preencher \n";
 msg+="a(s) seguinte(s) informação(ões):\n";
 flag=false;
 for(i=0;i<labels.length;i++)
 {
  if(formulario.elements[fields[i]].value=='')
  {
   msg+=labels[i];
   flag=true;
  }
 }
 //envia o e-mail ou mostra a mensagem de erro
 if(flag)
 {
  alert(msg);
 }
 else
 {
  formulario.submit();
 }
}


function DisplayHelp(div_name)
{
var new_display=(document.getElementById(div_name).style.display=="") ? "none" : "";
var new_img=(new_display=="none") ? "icohelp.gif" : "bt_fechar.gif";
document.getElementById(div_name).style.display = new_display;
}



/*
Função JS para validação de campos que só aceitam caracteres numéricos
*/
function Valid( formName, field, valor )
{
  form = eval( 'document.'+formName );
  er = /[a-zA-Z\'\"@!\#$%&*\)\,\.\:\\>\<\?\:\|\/\\§ªº°(=\-_\]\[\{\}\^`~+]+/i;
  if ( er.test( valor ) )
  {
    form.elements[field].value = '';
    msg="Atenção: Este campo apenas aceita caracter(es) numérico(s).\n";
    msg+="O valor '"+ valor +"',  possui caracter(es) não numérico(s).";
    alert( msg );
    form.elements[field].focus();
  }
}


//------------ COLOCAR AS FUNÇÕES ABAIXO NA MÁQUINA SOL: BEGIN
function AbreBusca(idBoxBusca)
{
  if(document.getElementById(idBoxBusca).style.display=='none')
  {
   document.getElementById(idBoxBusca).style.display='';
   document.getElementById('icoBuscaDisable').className='icoBuscaEnable';
  }
  else
  {
   document.getElementById(idBoxBusca).style.display='none';
   document.getElementById('icoBuscaDisable').className='icoBuscaDisable';
  }
}


function AlterStyleCellCfo(idCell)
{
 if(document.getElementById(idCell).style.display=='')
 {	
  document.getElementById('cellNome_'+idCell).className='borderTableCellBlack';
  document.getElementById('cellCrea_'+idCell).className='borderTableCellBlack';
 }
 else
 {
  document.getElementById('cellNome_'+idCell).className=null;
  document.getElementById('cellCrea_'+idCell).className=null;
 }
}


//REDIRECIONA PARA A PÁGINA DE BUSCA NA ESTRUTURA ANTIGA MUDAR NA HORA DE COLOCAR NA SOL O
//ENDEREÇO DE REDIRECIONAMENTO
function DisparaBuscaCFOAntigaPragaCultura(municipio, cultura)
{
 if(municipio && cultura)	
 {
  //desenv	
  //window.location.href="http://10.5.16.10/defesa/www/credenciados/?action=LocalizaCfoBaseAntigaCulturaMunicipio&mun="+municipio+"&cult="+cultura;
  window.location.href="http://www.cda.sp.gov.br/www/credenciados/?action=LocalizaCfoBaseAntigaCulturaMunicipio&mun="+municipio+"&cult="+cultura;
 }
}