//Valida numérico
function numerico()
{
	if( !(event.keyCode >= 48 && event.keyCode <= 57) )
	{
	 //alert(event.keyCode);
	 return false;
	}
}

// VOLTA PARA A HOME DO SISTEMA
function Mascara (formato, keypress, objeto)
{
 campo = eval (objeto);
 // CEP
 if (formato=='CEP')
  {
   separador = '-'; 
   conjunto1 = 5;
   if (campo.value.length == conjunto1)
	 {
     campo.value = campo.value + separador;
    }
  }

 // DATA
 if (formato=='DATA')
  {
   separador = '/'; 
   conjunto1 = 2;
   conjunto2 = 5;
   if (campo.value.length == conjunto1)
    {
     campo.value = campo.value + separador;
    }
   if (campo.value.length == conjunto2)
    {
     campo.value = campo.value + separador;
    }
  }

 // TELEFONE
 if (formato=='TELEFONE')
  {
   separador = '-'; 
   conjunto1 = 2;
   conjunto2 = 8;
   if (campo.value.length == conjunto1)
	 {
     campo.value = '(' + campo.value + ')'
    }
   if (campo.value.length == conjunto2)
	 {
     campo.value = campo.value + separador
    }
  } 

}

function ir_home(){
	window.location = '../home/home.asp';
}
//

function comboNulo(ObjSel,Campo) {//Verifica se o SelectBox está com valor 0 
 if (ObjSel.value == 0) {
   alert("Selecione "+ Campo +".");
   ObjSel.focus();
   return false}
}

function campoVazio(ObjSel,Campo) {//Verifica se o Campo está vazio.
 if (ObjSel.value == '') {
   alert("Não é permitido deixar o campo '"+ Campo +"' em branco.");
   ObjSel.focus();
   return false}
}


function encerrar(){//FUNCAO QUE ENCERRA A UTILIZACAO DA ADMINISTRACAO
	if (confirm("Realmente deseja sair da Administração?") == true){
		window.opener=null;
		top.close();
		self.close();
		window.close();}
}

//Valida Campo somente de Numeros
function soNumeros(objSel,campo){
	var valor;
	valor = objSel.replace(',','')
	valor = valor.replace('.','')	
	if ( isNaN(valor)){
		alert("Só é permitido valores numéricos no campo '"+ campo +"'.");
		return false;}
}
 
//MENU COMISSOES
var ns6=document.getElementById&&!document.all?1:0
 
var head="display:''"
var folder=''
 
function expandit(curobj)
{
		folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style

		if (folder.display=="none")
			folder.display=""
		else
			folder.display="none"

}

var m = 'n';
var s = 'n';

function abreFecha(menu, sub_menu)
{
	if (menu != 'fixo')
	{
		if (m != 'n' && m == menu && sub_menu == 'n')
		{
			var aux = document.getElementById(m);
			if (aux.style.display == '')
			{
				aux.style.display = 'none';
				m = 'n';
			}
			
			if (s != 'n')
			{
				var aux = document.getElementById(s);
				if (aux.style.display == '')
				{
					aux.style.display = 'none';
					s = 'n';
				}
			}
		}
		else
		{ 
			if (m != 'n' && m == menu && sub_menu == s)
			{
				var aux = document.getElementById(s);
				if (aux.style.display == '')
				{
					aux.style.display = 'none';
					s = 'n';
				}
			}
			else
			{
				if (m == 'n' && s == 'n')
				{
					var aux = document.getElementById(menu);
					if (aux.style.display == 'none')
					{
						aux.style.display = '';
						m = menu;
					}
				}
				
				if (m != 'n' && s == 'n' && sub_menu != 'n')
				{
					var aux = document.getElementById(sub_menu);
					if (aux.style.display == 'none')
					{
						aux.style.display = '';
						s = sub_menu;
					}
				}
				
				if (m != 'n' && s == 'n' && sub_menu == 'n')
				{
					var aux = document.getElementById(m);
					if (aux.style.display == '')
					{
						aux.style.display = 'none';
					}
					
					var aux1 = document.getElementById(menu);
					if (aux1.style.display == 'none')
					{
						aux1.style.display = '';
						m = menu;
						s = 'n';
					}
				}
				
				if (m != 'n' && s != 'n' && s != sub_menu)
				{
					if (m == menu && s == sub_menu)
					{
						var aux = document.getElementById(sub_menu);
						if (aux.style.display == '')
						{
							aux.style.display = 'none';
							s = 'n';
						}
					}
					if (m == menu && s != sub_menu)
					{
						var aux = document.getElementById(s);
						if (aux.style.display == '')
						{
							aux.style.display = 'none';
							s = 'n';
						}
							
						var aux1 = document.getElementById(sub_menu);
						if (aux1.style.display == 'none')
						{
							aux1.style.display = '';
							s = sub_menu;
						}
					}
					else
					{
						var aux = document.getElementById(m);
						if (aux.style.display == '')
						{
							aux.style.display = 'none';
							m = 'n';
							
							if (s != '')
							{
								var aux1 = document.getElementById(s);
								if (aux1.style.display == '')
								{
									aux1.style.display = 'none';
									s = 'n';
								}
							}
						}
						
						var aux1 = document.getElementById(menu);
						if (aux1.style.display == 'none')
						{
							aux1.style.display = '';
							m = menu;
						}
					}
				}
			}
	  	}
	}
	else
	{
		if (m != 'n')
		{
			var aux = document.getElementById(m);
			if (aux.style.display == '')
			{
				aux.style.display = 'none';
				m = 'n';
			}
		}
		if (s != 'n')
		{
			var aux = document.getElementById(s);
			if (aux.style.display == '')
			{
				aux.style.display = 'none';
				s = 'n';
			}
		}
	}
}


//Valida Tipo de Arquivo que será feito Upload
function validaImg(objSel,Campo){
	if (objSel.value != ''){
		qtde = parseInt(objSel.value.length - 3);
		txt = objSel.value;
		txt = txt.slice(qtde,objSel.value.length)
		if (txt != 'jpg' && txt != 'JPG' && txt != 'gif' && txt != 'GIF'){
			alert("No campo '"+ Campo +"' só é permitido enviar arquivos do tipo 'JPG' ou 'GIF' .");
			objSel.focus();
			return false;}
	}
}
//***********************