<!--
// funções de Javascript




//AJAX_________________________________________

function cria_ajax()
	{
	var xmlhttp;
	try
		{
		xmlhttp = new XMLHttpRequest();
		}
	catch(ee)
		{
		try
			{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
		catch(e)
			{
			try
				{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
			catch(E)
				{
				xmlhttp = false;
				}
			}
		}
	return xmlhttp;
	}






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)
{
for(var i=0;i<formulario.elements.length;i++)
     {
	 
	 var campo=formulario.elements[i];
	 
	 if(campo.type=="text" || campo.type=="hidden" || campo.type=="select" || campo.type=="select-one" || campo.type=="password" || campo.type=="file" || campo.type=="textarea" || campo.type=="radio")
	      {
	 	  var obriga=campo.getAttribute('obrigatorio');
	 	  var nomecampoatual=campo.getAttribute('nomecampo');
		  
		  if(campo.type=="radio" && obriga==1)
		       {
			   var meuradio=document.getElementsByName(campo.getAttribute('name'));
			   var preencheu = false;
			   for (var k=0; k<meuradio.length; k++) 
			             {
						 //alert(k + "- teste: " + meuradio[k].value + " está " + meuradio[k].checked);
						 
						 if (meuradio[k].checked)
						           {
								   preencheu = true;
								   }
  						 }
			  if (preencheu==false)
			            {
						alert("Ao menos uma das opções do campo '" + nomecampoatual + "' deve ser selecionada.");
			   			return false;
						break;
						}
			   }
		  else if(obriga==1 && trim(campo.value)=="")
		       {
			   alert("O campo '" + nomecampoatual + "' não pode ficar vazio.");
			   campo.focus();
			   return false;
			   break;
			   }
		  }
	 }
return true;
}





//______________________________________________



function init()
	{
		
	//___inicia o menu superior_________________________
	DynarchMenu.setup('menusup', {electric: true});
	//__________________________________________________
	
	
	
	//___cria o listener para o acordion do menu esquerdo_____
	vetor_caixas=$$('h3.boxmenu');
	for(i=0; i<vetor_caixas.length; i++)
		{
		Event.observe(vetor_caixas[i], 'click', toggle_box);
		}
	//_________________________________________________
	}




function CheckForm()
		{
	
			if ( document.frmLogin.txtUserID.value == "" )
			{
				alert("Por favor informe seu usuário.");
				document.frmLogin.txtUserID.focus();
				return false;
			}
	
			if ( document.frmLogin.txtPWD.value == "" )
			{
				alert("Por favor informe sua senha.");
				document.frmLogin.txtPWD.focus();
				return false;
			}
	
			document.frmLogin.submit();
			return true;
	
		}

-->