function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}


  function MM_openBrWindow(theURL,winName,features,left_f,top_f){ 
    var left = (screen.width - left_f) / 2,top = (screen.height - top_f - 35) / 2;
    features = ""+ features +",left="+ left +",top="+ top +"";
    window.open(theURL,winName,features);
  }

function MM_openBrWindow2(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}


function MM_setTextOfLayer(objName,x,newText) { //v3.0
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (navigator.appName=='Netscape') {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}

    function zeraCombo(__Ref){
      for (_Y=__Ref.options.length-1;_Y>0;_Y--)
        __Ref.options[_Y] = null
    }   


  function docjslib_getRealLeft(imgElem) {
  	xPos = eval(imgElem).offsetLeft;
  	tempEl = eval(imgElem).offsetParent;
    	while (tempEl != null) {
    		xPos += tempEl.offsetLeft;
    		tempEl = tempEl.offsetParent;
    	}
  	return xPos;
  }
  function docjslib_getRealTop(imgElem) {
  	yPos = eval(imgElem).offsetTop;
  	tempEl = eval(imgElem).offsetParent;
  	while (tempEl != null) {
    		yPos += tempEl.offsetTop;
    		tempEl = tempEl.offsetParent;
    	}
  	return yPos;
  }

  function MarcarComboPorValor(_RefObject, _ValueObject){
    for (i=0;i<_RefObject.length;i++){
      if (_RefObject.options[i].value.toLowerCase() == _ValueObject.toLowerCase()){
       _RefObject.options[i].selected = true;  
  }}}

	function MarcarRadioPorValor(refRadio, ValorRadio)
	{
		for (i=0;i<refRadio.length;i++)
		{
			if (refRadio[i].value.toLowerCase() == ValorRadio.toLowerCase())
				refRadio[i].checked = true;			
		}
	}


  function limpa_string(S){
    var Digitos = "0123456789";
    var temp = "", digito = "";
      for (var i=0; i<S.length; i++){
        digito = S.charAt(i);
        if (Digitos.indexOf(digito)>=0){temp=temp+digito}
      } return temp
  }

  function IsNumeric(sText)
  { 
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
   

	function EnviarConteudoEmail(Titulo)
	{	
		var urlEnviarConteudoPorEmail = 'sis_aux_enviarporemail.asp'
			+ '?urlc=' + escape(self.location.href)
			+ '&titc=' + escape(Titulo)
			+ '&tipc=';
			
		var left = (screen.width - 530) / 2,top = (screen.height - 415) / 2;
		var features = "width=530, height=415,status=yes,scrollbars=yes,resizable=no,left="+ left +",top="+ top +"";
			
			objAbreEnviarPorEmail = window.open(urlEnviarConteudoPorEmail, "winEnviarPorEmail", features);
			if (objAbreEnviarPorEmail == null) objAbreEnviarPorEmail.opener = self;
	}
	

	////////////////////////////////////////////////////////////////////////////////////////
	// {INÍCIO} FUNÇÕES DIVERSAS UTILIZADAS PARA TRATAMENTO DE FORMULARIOS
	////////////////////////////////////////////////////////////////////////////////////////
	
	function verificaValidadeEmail(EmailInformado)
	{
		if (/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(EmailInformado))
			return true;
		else
			return false;
	}
	
	function VerificaSomenteNumeros(ValorInformado)
	{
		if (/^[+]?\d*$/.test(ValorInformado))
			return true;
		else
			return false;
	}
	
	function VerificaSomenteData(ValorInformado)
	{
		if (/^([0-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/[1-2](0|8|9)[0-9][0-9]$/.test(ValorInformado))
			return true;
		else
			return false;
	}
	
	function DesabilitaBotoesComando(botaoSubmit, botaoResetCancelar)
	{
		if (botaoResetCancelar != null)
			botaoResetCancelar.style.display = 'none';
		
		botaoSubmit.value = ' ... Aguarde, enviando informações ... ';
		botaoSubmit.disabled = true;
	}
	
	function VerificaPesquisaSite()
	{
		if (document.formPesquisa.pesquisar.value.length < 3)
		{
			alert('Digite um valor para sua pesquisa');
			document.formPesquisa.pesquisar.focus();
			return false;
		}
	}
	
	function VerificaFocoCaixaPesquisa()
	{
		var ValorAtualPesquisa = document.formPesquisa.pesquisar.value.toLowerCase();
		
		if (ValorAtualPesquisa == "buscar" || ValorAtualPesquisa == "search" || ValorAtualPesquisa == "búsqueda")
			document.formPesquisa.pesquisar.value = "";
		else
			document.formPesquisa.pesquisar.select();
	}
	
	////////////////////////////////////////////////////////////////////////////////////////
	// {FINAL} FUNÇÕES DIVERSAS UTILIZADAS PARA TRATAMENTO DE FORMULARIOS
	////////////////////////////////////////////////////////////////////////////////////////
	
	




	function verificaTeclaEsc()
	{
		if (document.all && document.getElementById)
			if (event.keyCode == 27)
				self.close();
	}





	////////////////////////////////////////////////////////////////////////////////////////
	// FUNÇÕES RELACIONADAS AO SISTEMA DE AUTO-TABULAÇÃO PARA O SITE TODO
	////////////////////////////////////////////////////////////////////////////////////////
	
	var verificaAutoTabulacao = false;
	
	function executaAutoTabulacao(Controle, MaximoCaracteres)
	{
		if (Controle.value.length == MaximoCaracteres && verificaAutoTabulacao)
		{
			var indiceFormulario = 0;
			var indiceControle = null;
			
			for (i=0;i<document.forms.length;i++)
			{
				for (j=0;j<document.forms[i].elements.length;j++)
					if (document.forms[i].elements[j].name == Controle.name)	
						indiceFormularioControle = i;
			}
			
			if (indiceFormularioControle == null)
				return false;
			
			for (i=0;i<document.forms[indiceFormulario].elements.length;i++)
			{
				if (document.forms[indiceFormulario].elements[i].name == Controle.name)
					indiceControle = (i+1);
			}
			
			while (document.forms[indiceFormulario].elements[indiceControle].disabled)
				indiceControle++;
				
			document.forms[indiceFormulario].elements[indiceControle].focus();			
			verificaAutoTabulacao = false;			
				
		}
	}
	
	function statusAutoTabulacao(NovoStatus)
	{
		verificaAutoTabulacao = NovoStatus;
	}
	
	////////////////////////////////////////////////////////////////////////////////////////
	// FINALD DAS FUNÇÕES RELACIONADAS AO SISTEMA DE AUTO-TABULAÇÃO PARA O SITE TODO
	////////////////////////////////////////////////////////////////////////////////////////

