/****************************************************
	FUNÇÃO ESCONDER
****************************************************/

function fechar(valor) {
//	closeAll('div'+valor);
    //alert(document.getElementById("div" + valor).style.display);
if ((document.getElementById("div" + valor).style.display == 'none')||(document.getElementById("div" + valor).style.display == ''))
	{
		document.getElementById("div" + valor).style.display = 'block';
		document.getElementById("acao" + valor).innerHTML = 'Ocultar este campo';
		document.getElementById("acao" + valor).previousSibling.className = 'icone-minimizar';
        document.getElementById("acao" + valor).previousSibling.parentNode.className = '';
	}
	else
	{
		document.getElementById("div"+ valor).style.display = 'none';
		document.getElementById("acao" + valor).innerHTML = 'Abrir campo';		
        document.getElementById("acao" + valor).previousSibling.className = 'icone-ampliar';
        document.getElementById("acao" + valor).previousSibling.parentNode.className = 'ampliar';
	}
}

function closeAll(divId) {
    
    var divs = document.getElementsByTagName("div");
	tam = divs.length;
    for (x=0; x<tam; x++) {
        try {
          if (divs[x].id!=divId && divs[x].className=='controle') {
			  if (divs[x].childNodes[1].innerHTML.length<=2000)  {
				  divs[x].childNodes[1].className = 'conteudo-sem-rolagem';
			  }
			  divs[x].style.display = 'none';
              valor = divs[x].id.replace("div","");
              document.getElementById("acao" + valor).innerHTML = 'Abrir campo';
              document.getElementById("acao" + valor).previousSibling.className = 'icone-ampliar';
              document.getElementById("acao" + valor).previousSibling.parentNode.className = 'ampliar';

     		 }   
 	    } catch (e) {}
    }

    var fls = document.getElementsByTagName("fieldset");
	tam = fls.length;
    for (x=0; x<tam; x++) {
        try {
          if (fls[x].id=='divcartografia' && fls[x].id!=divId)
			  fls[x].style.display = 'none';

		  if (fls[x].id=='divmidia' && fls[x].id!=divId)
              fls[x].style.display = 'none'; 

          if (fls[x].id=='divvideo' && fls[x].id!=divId) 
			  fls[x].style.display = 'none';
     		    
 	    } catch (e) {}
    }

    try {
         div_notas = document.getElementById('notas');
         num_notas = div_notas.getElementsByTagName('p').length;
		 h4 = div_notas.parentNode.getElementsByTagName('h4')[0];
         if (num_notas==0) {
              div_notas.style.display = 'none';
              h4.style.display = 'none';
              return;
         }  
         else if (num_notas <= 5)  
               div_notas.id = 'notas-sem-rolagem';

    } catch (e) {}

}

/****************************************************
	FUNÇÃO MOSTRAR
****************************************************/

function abrir(valor) {
	if (document.getElementById("div" + valor).style.display == 'block')
		document.getElementById("div" + valor).style.display = 'none';
	else
		document.getElementById("div" + valor).style.display = 'block';
}


function showHide(idObjeto) {
	document.getElementById(idObjeto).style.display = document.getElementById(idObjeto).style.display == 'block' ? 'none': 'block';
}

function showItem(idObjeto) {
	document.getElementById(idObjeto).style.display = 'block';
}

function hideItem(idObjeto) {
    document.getElementById(idObjeto).style.display = 'none';
    document.getElementById('overlay').style.display = 'none';
}

function windowLogin(arg1, arg2) {
	document.getElementById('login').style.display = arg1;
	document.getElementById('senha').style.display = arg2;
	document.getElementById('overlay').style.display = 'block';
}

function setUrlRedirect(strUrl) {
	document.getElementById('loginAdm').urlredirect.value = strUrl;
}

function pesquisar(pageNumber) {

         document.pbi.action='index.php';
		 document.pbi.p.value=pageNumber;
         document.pbi.submit();

}

 function checkEnter(e){
 	//e is event object passed from function invocation
 	var characterCode; //literal character code will be stored in this variable

 	if(e && e.which){ //if which property of event object is supported (NN4)
 	   e = e;
	   characterCode = e.which; //character code is contained in NN4's which property
	} else {
 	try {
	   e = event;
	 } catch(ex) {}
		 characterCode = e.keyCode; //character code is contained in IE's keyCode property
	 }

	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
	 return true;
	 } else {
	 return false;
	 }
 }