<!--
// funções de Javascript



//função para pré-carregar imagens no documento. Basta digitar a URL das imagens, separadas por vírgula
//Não importa o número de argumentos. Cada argumento é uma imagem.

function carregar()
{
var imagens=new array();

for (i=0; i<arguments.length; i++)
     {
     imagens[i]=new Image();
     imagens[i].src=arguments[i];
     }
}




function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function





function checar(formulario)
{
var f=document.forms[formulario];
var i;

for(i=0;i<f.elements.length;i++)
     {
	 var campo=document.forms[formulario].elements[i];
	 
	 if(campo.obrigatorio==1)
	      {
	 	  if(trim(campo.value)=="")
	           {
		  	   window.alert("O campo " + campo.nomecampo + " não pode ficar vazio");
		  	   campo.focus();
		  	   return false;
		  	   break;
		  	   }
	      }
	 }
}


function validarmaximo(valor, maximo)
     {
	 if(valor>maximo)
	      {
		  window.alert("O valor máximo para este campo é " + maximo);
		  return true;
		  }
	 else
	      {
		  return false;
		  }
	 }



function validarminimo(valor, minimo)
     {
	 if(valor<minimo)
	      {
		  window.alert("O valor mínimo para este campo é " + minimo);
		  return true;
		  }
	 else
	      {
		  return false;
		  }
	 }


function validarnumero()
{
var tecla=window.event.keyCode;
var valor=String.fromCharCode(tecla);

if (parseInt(valor)!=valor)
	{
	event.returnValue=false;
	}
}


function validardecimal()
{
var tecla=window.event.keyCode;
var valor=String.fromCharCode(tecla);

if (parseInt(valor)!=valor && valor!="-" && valor!="." && event.keyCode!="13")
	{
	event.returnValue=false;
	}
}



function validardecimalbr()
{
var tecla=window.event.keyCode;
var valor=String.fromCharCode(tecla);

if (parseInt(valor)!=valor && valor!="-" && valor!="," && event.keyCode!="13")
	{
	event.returnValue=false;
	}
}


function pular()
{

if(window.event.srcElement.type=='text')
	{
	var ele=window.event.srcElement;
	var index=ele.sourceIndex;
	if(ele.value.length==ele.getAttribute('maxlength'))
		{
		document.all.item(index+1).focus();
		}
	
	}
}


function nao_navega()
	{
	if(window.event.srcElement.tagName=="A" || window.event.srcElement.tagName=="IMG")
		{
		alert('Ops! \n\nEsta página é só para impressão. Não é possível navegar a partir dela.')
		}
	}



function escolher_dia() 
{ 

var destino = '../ferramentas/folhinha_escolher_dia.php';

var altura=240;
var largura=200;
var esquerda=(screen.availWidth-largura)/2;
var topo=(screen.availHeight-altura)/2;;

window.open(destino, '','toolbar=no, scrollbars=no, left=' + esquerda + ', top=' + topo + ', width=' + largura + ', height= ' + altura + ''); 
} 



function exibe_foto(foto_url, largura, altura) 
{ 

var destino = '../ferramentas/mostrafoto.php?foto_url=' + foto_url + '&largura=' + largura + '&altura=' + altura;

var esquerda=(screen.availWidth-largura)/2;
var topo=(screen.availHeight-altura)/2;;

window.open(destino, '','toolbar=no, scrollbars=no, left=' + esquerda + ', top=' + topo + ', width=' + largura + ', height= ' + altura + ''); 
} 



function amplia_galeria(galeria_id, foto_id_escolhida) 
{ 

var destino = '../galeria_janela.php?galeria_id=' + galeria_id + '&foto_id_escolhida=' + foto_id_escolhida;

var altura=100;
var largura=100;
var esquerda=(screen.availWidth-largura)/2;
var topo=(screen.availHeight-altura)/2;;

window.open(destino, '','toolbar=no, scrollbars=yes, left=' + esquerda + ', top=' + topo + ', width=' + largura + ', height= ' + altura + ''); 
} 


function janela_impressao(arquivo) 
{ 

var destino = '../ferramentas/imprime_frames.php?arquivo=' + arquivo;

var largura=580;
var altura=400;

var esquerda=(screen.availWidth-largura)/2;
var topo=(screen.availHeight-altura)/2;;

window.open(destino, '','toolbar=no, scrollbars=yes, left=' + esquerda + ', top=' + topo + ', width=' + largura + ', height= ' + altura + ''); 
} 


function janela_envio(arquivo, usuario_id_selecionado, treino_id_selecionado) 
{ 

var destino = '../ferramentas/envia_frames.php?arquivo=' + arquivo + '&usuario_id_selecionado=' + usuario_id_selecionado + '&treino_id_selecionado=' + treino_id_selecionado;

var largura=580;
var altura=400;

var esquerda=(screen.availWidth-largura)/2;
var topo=(screen.availHeight-altura)/2;;

window.open(destino, '','toolbar=no, scrollbars=yes, left=' + esquerda + ', top=' + topo + ', width=' + largura + ', height= ' + altura + ''); 
} 


function imagem(url) 
{ 

var destino = '../ferramentas/imagem.php?url=' + url;

var largura=100;
var altura=100;
var esquerda=(screen.availWidth-largura)/2;
var topo=(screen.availHeight-altura)/2;

window.open(destino, '','toolbar=no, scrollbars=no, left=' + esquerda + ', top=' + topo + ', width=' + largura + ', height= ' + altura + ''); 
} 



function janela_entrada() 
{ 
var destino="entrada.php";

var largura=200;

var altura=200;

var esquerda=((screen.availWidth-largura)/2);

var topo=(screen.availHeight-altura)/2;

window.open(destino, '','toolbar=no, scrollbars=no, left=' + esquerda + ', top=' + topo + ', width=' + largura + ', height= ' + altura + ''); 
} 


function confirma(destino, mensagem)
{

var quero;

quero=window.confirm(mensagem);

if(quero)
     {
	 window.location.href=destino;
	 }
}


function janela_organizacao(organizacao_id) 
{ 
var destino="../detalhes_organizacao.php?organizacao_id=" + organizacao_id;

var largura=350;

var altura=250;

var esquerda=((screen.availWidth-largura)/2);

var topo=(screen.availHeight-altura)/2;

window.open(destino, '','toolbar=no, scrollbars=no, left=' + esquerda + ', top=' + topo + ', width=' + largura + ', height= ' + altura + ''); 
} 


-->