function limparCampo(oCampo){
  if((oCampo.name != 'ok')&&
	 (oCampo.value == 'login')||
	 (oCampo.value == 'senha')||
	 (oCampo.value == 'pesquisa escolar'))
  {
     oCampo.value = '';
	 oCampo.focus();
  }
}
	  
function restaurarCampo(oCampo){
  if(oCampo.value == ''){
    if(oCampo.name == 'strLogin'){
      oCampo.value = 'login';
	}else if(oCampo.name == 'strpc'){
	  oCampo.value = 'pesquisa escolar';
    }else if(oCampo.name == 'strSenha'){
	  oCampo.style.display = 'none';
	  document.getElementById('strSenhaFD').style.display = '';
    }
  }
}

function ocultarSenha(oCampo){
  oCampo.style.display = 'none';
  document.getElementById('strSenha').style.display = '';
  document.getElementById('strSenha').focus();
}

function abrirPopup(theURL,winName,features) { //v2.0
  window.open(theURL,'','scrollbars=yes,tollbar=no,width=380,resizable=off,height=400');
}

/* PORTO SOLIDÁRIO */
function validaForm(oForm)
{
	var strMensagem = '';
	
	if (oForm.txtEstado.value == '')
		{
			strMensagem = 'Por favor, preencha o campo "Estado".';
			oForm.txtEstado.focus();	
		}

	if (oForm.txtCidade.value == '')
		{
			strMensagem = 'Por favor, preencha o campo "Cidade".';
			oForm.txtCidade.focus();	
		}

	if (oForm.txtFone.value == '')
		{
			strMensagem = 'Por favor, preencha o campo "Telefone".';
			oForm.txtFone.focus();	
		}

	if (oForm.txtFoneDDD.value == '')
		{
			strMensagem = 'Por favor, preencha o campo "DDD - Fone".';
			oForm.txtFoneDDD.focus();	
		}

	if (oForm.txtEmail.value != '')
	{
		//Pega o conteúdo do campo Email
		var strValue = oForm.txtEmail.value;	
		
		//Verifica se existe ocorrência de @ e ponto, ou seja, se 
		//o valor está no formato correto de email
		if (!((strValue.indexOf("@") > -1) 
			&& (strValue.substring(strValue.indexOf("@")+1).indexOf(".") > -1)))
		{
			strMensagem = 'O formato de email não é válido.';
			oForm.txtEmail.select();	
		}
	}
	
	else
		{ 	
			strMensagem = 'Por favor, preencha o campo "Email".';
			oForm.txtEmail.focus();	
		}

	if (oForm.txtProfissao.value == '')
		{
			strMensagem = 'Por favor, preencha o campo "Profissão".';
			oForm.txtProfissao.focus();	
		}
	
	if (oForm.selUnidade.selectedIndex == 0)
		{
			strMensagem = 'Por favor, Indique a sua "Unidade".';
			oForm.selUnidade.focus();	
		}
	
	if (oForm.txtNome.value == '')
		{
			strMensagem = 'Por favor, preencha o campo "Nome".';
			oForm.txtNome.focus();	
		}

	if (strMensagem != '')
		{
		alert(strMensagem);
		return false;
		}
	else return true;
}
/* PORTO SOLIDÁRIO */

/* LOGIN  VALIDAÇÃO */
function ValidaLogin(form) {
   if ((form.strLogin.value == '')||(form.strLogin.value == 'login')) {
	window.alert('Favor entrar com um valor no campo "Login".');
	form.strLogin.value = '';
	form.strLogin.focus();
	return (false);
   }
   
   if (form.strSenhaFD.style.display == '') {
	 window.alert('Favor entrar com um valor no campo "Senha".');
	 form.strSenhaFD.style.display = 'none';
	 form.strSenha.style.display = '';
	 form.strSenha.focus();
	 return (false);
   }else{ 
	 if (form.strSenha.value == '') {
	   window.alert('Favor entrar com um valor no campo "Senha".');
	   form.strSenha.value = '';
	   form.strSenha.focus();
	   return (false);
	 }
   }
	 return (true);
}
/* LOGIN  VALIDAÇÃO */

/* SLIDE HOME */
var slideMenu=function(){
	var sp,st,t,m,sa,l,w,sw,ot;
	return{
		build:function(sm,sw,mt,s,sl,h){
			sp=s; st=sw; t=mt;
			m=document.getElementById(sm);
			sa=m.getElementsByTagName('li');
			l=sa.length; w=m.offsetWidth; sw=w/l;
			ot=Math.floor((w-st)/(l-1)); var i=0;
			for(i;i<l;i++){s=sa[i]; s.style.width=sw+'px'; this.timer(s)}
			if(sl!=null){m.timer=setInterval(function(){slideMenu.slide(sa[sl-1])},t)}
		},
		timer:function(s){s.onmouseover=function(){clearInterval(m.timer);m.timer=setInterval(function(){slideMenu.slide(s)},t)}},
		slide:function(s){
			var cw=parseInt(s.style.width,'10');
			if(cw<st){
				var owt=0; var i=0;
				for(i;i<l;i++){
					if(sa[i]!=s){
						var o,ow; var oi=0; o=sa[i]; ow=parseInt(o.style.width,'10');
						if(ow>ot){oi=Math.floor((ow-ot)/sp); oi=(oi>0)?oi:1; o.style.width=(ow-oi)+'px'}
						owt=owt+(ow-oi)}}
				s.style.width=(w-owt)+'px';
			}else{clearInterval(m.timer)}
		}
	};
}();
/* SLIDE HOME */

/* LOGIN */
function valida(form) {
  if (form.strLogin.value == "") {
    alert('Favor entrar com um valor no campo "Login".');
    form.strLogin.focus();
    return (false);
  } else
    if (form.strSenha.value == "") {
    alert('Favor entrar com um valor no campo "Senha".');
    form.strSenha.focus();
    return (false);
  } else
  return (true);
}  

function validaemail(form) {
 var emailOK = isEmailValid(form,'emailvalidar');
 
 if(!emailOK) {
  window.alert('Por favor, entre com um endereço válido no campo "e-mail".'); 
  return(false); 
 }
 return (true);
}
/* LOGIN */

/* MENU INTERNAS */
function fu_mostra_esconde(div,array,flag) {
	if ( array != null ) {
		for ( i = 0; array[i]; i++ ) {
			if ( document.getElementById(array[i]) )
				document.getElementById(array[i]).style.display='none';
		}
		if ( document.getElementById(div) )
			document.getElementById(div).style.display = "block";
			
		if ( flag == 1 ) {
			//onmouseout
			for ( i = 0; array[i]; i++ )
			{
				if ( document.getElementById(array[i]) )
					document.getElementById(array[i]).style.display='none';
			}
		}
	} else {
		if ( document.getElementById(div) ) {
			if ( document.getElementById(div).style.display == "block" )
				document.getElementById(div).style.display = "none";
			else
				document.getElementById(div).style.display = "block"
			if ( flag == 1 ) {
				//onmouseout
				document.getElementById(div).style.display = "none";
			}
		}
	}
}
/* MENU INTERNAS */
