function frame(pagina){
 var width=817;
 var height=647;
 x = window.screen.width;
 y = window.screen.height;  
 var left = (x/2)-(width/2);
 var top = (y/2)-(height/2);
 janela=window.open(pagina,'Pagina', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
 janela.focus();
}

function foco(){ 
 if(document.form){
  document.form.elements[0].focus();
 }
}

function checa_formulario(){
 var frm=document.form;

 for (var i = 0; i < frm.elements.length; i++){
  if ( (frm.elements[i].title.substr(0,1))=="*"){
	if (TrimString(frm.elements[i].value)==""){
	 alert("O campo é de preenchimento obrigatório!");
	 frm.elements[i].style.backgroundColor="#FFFFCC";
	 frm.elements[i].style.borderColor="#FF1717";
	 frm.elements[i].focus();
	 return false;
	 break;
	}else{
	 frm.elements[i].style.backgroundColor="#FFFFFF";
	 frm.elements[i].style.borderColor="#CCCCCC";
	}
   }
 }
 
 var departamento=document.getElementById("departamento");
 if(departamento.value=="0"){
  alert("O campo é de preenchimento obrigatório!");
  departamento.style.backgroundColor="#FFFFCC";
  departamento.style.borderColor="#FF1717";
  departamento.focus();
  return false;
 }else{
  departamento.style.backgroundColor="#FFFFFF";
  departamento.style.borderColor="#CCCCCC";
 }

 var botao=document.getElementById("botao");
 botao.value="Aguarde...";
 botao.disabled=1;
 setTimeout("document.form.submit()", 100);
  
}//fim checa_formulario

function submitAll(){
 if(document.form){
  setTimeout("document.form.submit()", 100);
 }
 if(document.form1){
  setTimeout("document.form1.submit()", 100);
 }
}

function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function mudaDiv(id,texto){
  html_div = document.getElementById(id);
  html_div.innerHTML = texto;
}
function removeDiv(id){
 var html_div = document.getElementById(id) || false;
 if(html_div!=false) {
  html_div.style.display='none';
 }
}

function goPage(url){
	window.location.href=url;
}

function excluir(arq,id){
 if(confirm("Deseja realmente excluir o arquivo '"+arq+"' ?")){
  goPage("index.php?page=arquivos&acao=excluir&id="+id);
 }
}
