<!--

	String.prototype.toFormatDouble = 
	function() 
	{
  	s = this;
  	while (s.indexOf(".") != -1)
  		s = s.replace(".", "");
  	s = s.replace(",", ".");
  	return s;
	}



	String.prototype.trim = function() 
	{
  	return this.replace(/^\s*(\b.*\b|)\s*$/, "$1");
	}


	var ie = document.all ? 1 : 0
	var ns = document.layers ? 1 : 0

	function autoTab(input, e) 
	{
		var keyCode = (ns) ? e.which : e.keyCode; 
		var filter = (ns) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];


		if(e.keyCode==38)
		{
			if (input.form[(getIndex(input)-1) % input.form.length])
				input.form[(getIndex(input)-1) % input.form.length].focus();
		}
		
		if(e.keyCode==40)
		{
			if (input.form[(getIndex(input)+1) % input.form.length])
				input.form[(getIndex(input)+1) % input.form.length].focus();
		}

		if(input.value.length >= input.maxLength && !containsElement(filter,keyCode)) 
		{
			input.value = input.value.slice(0, input.maxLength);
			input.form[(getIndex(input)+1) % input.form.length].focus();
		}

		function containsElement(arr, ele) {
			var found = false, index = 0;
			
			while(!found && index < arr.length)
				if(arr[index] == ele)
					found = true;
				else
					index++;
			return found;
		}

		function getIndex(input) 
		{
			var index = -1, i = 0, found = false;
			while (i < input.form.length && index == -1)
				if (input.form[i] == input)index = i;
				else i++;
			return index;
		}

		return true;
	}





	function ClearForm()
	{
		var obj;
		//alert(document.forms[0]);

		for (var i = 0; i < document.forms[0].length; i++)
		{
			obj = document.forms[0].elements[i];

			if (obj.type == 'text' || obj.type == 'textarea')
				obj.value = '';
			if (obj.type == 'select-one')
			{
				obj.selectedIndex=0;
			}
			if (obj.type == 'radio' || obj.type == 'checkbox')
			{
				obj.checked=false;
			}
				
		}
		
		SetFocus();
		
	}



	function Clear(StartIndex, StopIndex)
	{
		for (var i=StartIndex ;i< StopIndex;i++)
			document.forms[0].elements[i].value='';
	}

	
		
	function Validate(field, Index) 
	{
	 	if (document.forms[0].elements[Index].checked) 
	 	{
	 		field.blur();
	 	}
	}


	function PassaCampo( campo , Index, tecla )
	{
		var charCode = (navigator.appName == "Netscape") ? evento.which : evento.keyCode;
		if (charCode != 0 && charCode != 9 && charCode != 16 && charCode != 39 && charCode != 37 )
	 		 if ( campo.value.length == campo.maxLength ) 
				document.forms[0].elements[Index].focus();
	}


	function AutoSubmit (evento)
	{
		var AuxChar;
		var i;
		
		var charCode = (navigator.appName == "Netscape") ? evento.which : evento.keyCode;
		if (charCode == 13)
		{
			Submit();
		}
	}	


	function ValidaChar (evento, CharValidos, campo)
	{
		var AuxChar;
		var i;
		
		var charCode = (navigator.appName == "Netscape") ? evento.which : evento.keyCode;
		if (charCode == 13 || charCode == 8 || charCode == 0){return true;}
		
		var var_caracter = String.fromCharCode(charCode);		
		
		if (CharValidos != null)
		{
			switch (CharValidos) 
			{ 
				case 'A-Z': 
					AuxChar ='ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'ÁÉÍÓÚÇÃÕÂÊÔÀÜ' + '0123456789' + ',./()-_ ';
					AuxChar+=AuxChar.toLowerCase();
					break;
				case 'Email': 
					AuxChar ='ABCDEFGHIJKLMNOPQRSTUVWXYZ' + '0123456789' + '.@-_';
					AuxChar+=AuxChar.toLowerCase();
					break;
				case 'Valor':
					if (campo.value.indexOf(",") != -1) 
						if (var_caracter == ",")
						   return false;
						//else
						//   {
						//   var frac = campo.value.substring(campo.value.indexOf(","));
						//   if (frac.length == 3)
						//		return false;
						//   }
					AuxChar ='0123456789' + ',';
					break;
				default:
					AuxChar = CharValidos;
					break;
			}		
		}
		else
		{
			AuxChar = '0123456789';				//Default
		}
	
		if (AuxChar.indexOf(var_caracter) == -1)
			return false;
		return true;
	}


	function SetFocus()
	{
		
		
		for (var i = 0; i < document.forms[0].length; i++)
		{
			obj = document.forms[0].elements[i];

			if (obj.type == 'text' || obj.type == 'textarea' || obj.type == 'password')
			{
				obj.focus();
				return true;
			}	
			if (obj.type == 'select-one')
			{
				obj.focus();
				return true;
			}
				
		}
	}


	function getCounter(field) {
			
		countChars(field, 255 , 10);
			
		return;
	}

	function countChars(theElement, maxCount, offChar) {
		var realCount, visibleCount, i;
			
		visibleCount = 0;
		realCount = 0;
		if (offChar != 0) {
			for (i=0; i < theElement.value.length; i++) {
				if (visibleCount < maxCount) {
					realCount++;
				}
				if (theElement.value.charCodeAt(i) != offChar) {
					visibleCount++;
				}
			}
		}
			
		if ((maxCount - visibleCount) < 0) {
			alert('Outros Cursos de Informática precisa ter menos de ' + maxCount + ' caracteres!');	
			theElement.value = theElement.value.substring(0, realCount);
		}
	}


	
	function checkCPF(v){
		var s=null
		var r=null
		
		v = CleanField(v);
		
		if(v.length!=11||
			v=='00000000000'||v=='11111111111'||v=='22222222222'||v=='33333333333'||v=='44444444444'||
			v=='55555555555'||v=='66666666666'||v=='77777777777'||v=='88888888888'||v=='99999999999')return false
		s=0
		for(var i=0;i<9;i++)s+=parseInt(v.charAt(i))*(10-i)
		r=11-(s%11)
		if(r==10||r==11)r=0
		if(r!=parseInt(v.charAt(9)))return false
		s=0
		for(var i=0;i<10;i++)s+=parseInt(v.charAt(i))*(11-i)
		r=11-(s%11)
		if(r==10||r==11)r=0
		if(r!=parseInt(v.charAt(10)))return false
		return true
	}	


	function ClearRadio(field)
	{
		if (field.checked)
		{
			field.checked=false;
		}
	}



	function checkCNPJ(CNUMB)
	{
	
		CTYPE='CNPJ'
	
	  if(Verify(CNUMB, CTYPE))
	  {
	    return true;
	  }
	  else
	  {
	    return false;
	  }

			function ClearStr(str, char)
			{
			  while((cx=str.indexOf(char))!=-1)
			  {		
			    str = str.substring(0,cx)+str.substring(cx+1);
			  }
			  return(str);
			}

			function ParseNumb(c)
			{
			  c=ClearStr(c,'-');
			  c=ClearStr(c,'/');
			  c=ClearStr(c,',');
			  c=ClearStr(c,'.');
			  c=ClearStr(c,'(');
			  c=ClearStr(c,')');
			  c=ClearStr(c,' ');
			  if((parseFloat(c) / c != 1))
			  {
			    if(parseFloat(c) * c == 0)
			    {
			      return(c);
			    }
			    else
			    {
			      return(0);
			    }
			  }
			  else
			  {
			    return(c);
			  }
			}

			function Verify(CNUMB,CTYPE)
			{
			  CNUMB=ParseNumb(CNUMB)
			  if(CNUMB == 0)
			  {
			    return(false);
			  }
			  else
			  {
			    g=CNUMB.length-2;
			    if(TestDigit(CNUMB,CTYPE,g))
			    {
			      g=CNUMB.length-1;
			      if(TestDigit(CNUMB,CTYPE,g))
			      {	
			        return(true);
			      }
			      else
			      {
			        return(false);
			      }
			    }
			    else
			    {
			      return(false);
			    }
			  }
			}

			function TestDigit(CNUMB,CTYPE,g)
			{
			  var dig=0;
			  var ind=2;
			  for(f=g;f>0;f--)
			  {
			    dig+=parseInt(CNUMB.charAt(f-1))*ind;
			    if (CTYPE=='CNPJ')
			    { if(ind>8) {ind=2} else {ind++} }
			    else
			    { ind++ }
			  }
			  dig%=11;
			  if(dig<2)
			  {
			    dig=0;
			  }
			  else
			  {
			    dig=11-dig;
			  }
			  if(dig!=parseInt(CNUMB.charAt(g)))
			  {
			    return(false);
			  }
			  else
			  {
			    return(true);
			  }
			}
	}


	function checkEmail(v){
		var a=0
		var p=0
		for(var i=1;i<v.length;i++){
			if(!v.charAt(i))return false
			else if(v.charAt(i)=='@'){a++;if(v.charAt(i+1)=='')return false}
			else if(v.charAt(i)=='.'){p++;if(v.charAt(i+1)==''||v.charAt(i+1)=='@'||v.charAt(i-1)=='@')return false}
		}
		if(a==1&&p)return true
	}
	

	function checkPorcentagem(porc)
	{
		if ((porc.length<=3) && (!isNaN(porc)))
		{
			if (porc<=100)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}


	function checkTel(tel)
	{
		tel = CleanField(tel);
	
		if ((tel.length>=9) && (!isNaN(tel)))
		{
			return true;
		}
		else
		{
			return false;
		}
	}



	/* Esta função abre uma url em uma nova janela com dados nome e dimensão */
	function abrejanela(url,parameter,name,x,y){
	  var showpop;
	  
	  var LeftPosition;
	  var TopPosition;
	  
	  LeftPosition = (screen.width) ? (screen.width-x)/2 : 0;
	  TopPosition = (screen.height) ? (screen.height-y)/2 : 0;
	  
	  newwindow = window.open(url + '?' + parameter,name,'top='+ TopPosition +',left='+ LeftPosition +'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width='+ x +',height='+ y );
	  
	  if (window.focus) {newwindow.focus()}

	}
	

	function Submit(FormIndex)
	{

		if (FormIndex==null || FormIndex.length==0)
			FormIndex=0;	
	
		if (checkForm(FormIndex))
		{
			document.forms[FormIndex].submit();		
		}
	}
	
	
	function Submit2()
	{
		document.forms[0].submit();		
	}	


	
	function checkForm(FormIndex)
	{

		var obj;
		var DefaultColor="#FFFFFF";
		var ErrorColor="#E6E1B9";
		var msg;
		var flag;
		var fArray;
		
		flag = true;
	
	
		if (FormIndex==null || FormIndex.length==0)
			FormIndex=0;


		//Procura por campos obrigatorios
		for (var i = 0; i < document.forms[FormIndex].length; i++)
		{
			//Objeto do formulario
			obj = document.forms[FormIndex].elements[i];
			
			//Se for diferente de objetos escondidos, formata background do objeto
			if (obj.type!="hidden" && obj.type!="image" && obj.type!="button" && obj.type!="submit" && obj.type!="reset")
			{
				formataObjeto(obj,DefaultColor);
			}
			
			//Objeto de Preenchimento obrigatórios
			if (obj.required=='S')
			{
			
				//Objetos relacionados que precisam ter um deles preenchido
				if ((obj.MaxIndex!=0) && (!isNaN(obj.MaxIndex)))
				{
					//indica se existe preenchimento
					fArray=false;
					
					//procura por objetos preenchidos
					for(var j=0;j<obj.MaxIndex;j++)
					{	
						//inicializa a cor dos objetos
						formataObjeto(document.forms[FormIndex].elements[i+j],DefaultColor);
						
						//verifica se objeto esta preenchido
						if (checkObj(document.forms[FormIndex].elements[i+j]))
						{
							//Se existe preenchimento muda flag para true
							fArray=true;
						}
					}
					
					//Nao foi encontrado nenhum objeto preenchido
					if (!fArray)
					{
						//Muda cor dos Objetos
						for(var j=0;j<obj.MaxIndex;j++)
						{	
							formataObjeto(document.forms[FormIndex].elements[i+j],ErrorColor);
						}
						//Retorna False
						alert('Campo Obrigatório!');
						obj.focus();
						return false;
					}
					
					//Posiciona proximo objeto do formulario

					i+=obj.MaxIndex-1;
					
				}

				else
				{		
					if (!checkObj(obj))
					{
						flag=false;
						msg='Campo obrigatório!'
					} 

					if (!flag)
					{
						alert(msg);
						formataObjeto(obj,ErrorColor);
						obj.focus();
						return flag;
					}

				}
			}
		}
		

		flag=true;
		//Procura por campos que precisam ser validados
		for (var i = 0; i < document.forms[FormIndex].length; i++)
		{

			obj = document.forms[FormIndex].elements[i];
			if (obj.type!="hidden" && obj.type!="image" && obj.type!="button" && obj.type!="submit" && obj.type!="reset")
			{
				formataObjeto(obj,DefaultColor);
			}
			
			if (obj.value.length!=0)
			{
				switch (obj.validar) 
				{ 
				
					case 'tel': 
						if (!checkTel(obj.value))
						{
							msg = 'Telefone Inválido!';
							flag = false;	
						}
						break;
						
					case '%': 
						if (!checkPorcentagem(obj.value))
						{
							msg = 'Porcentagem Inválida!';
							flag = false;	
						}
						break;

					case 'cpf': 
						if (!checkCPF(obj.value))
						{
							msg = 'CPF Inválido!';
							flag = false;	
						}
						break;

					case 'cnpj': 
						if (!checkCNPJ(obj.value))
						{
							msg = 'CNPJ Inválido!';
							flag = false;	
						}
						break;

					case 'email': 
						if (!checkEmail(obj.value))
						{
							msg = 'Email Inválido!';
							flag = false;	
						}
						break;

					default:
						break;
				}				
			}

			if (!flag)
			{
				alert(msg);
				formataObjeto(obj,ErrorColor);
				obj.focus();
				obj.select();
				return flag
			}

		}
		
		return true;
		
		function formataObjeto(pobj, Color)
		{
			pobj.style.backgroundColor=Color;
		}
	}	



	function checkObj(obj)
	{
		//Check StandAlone Objects
		if (obj.type == 'text' || obj.type == 'textarea' || obj.type == 'password')
		{
			if (obj.value.length==0)
			{
				return false;
			}
		}
					
		if (obj.type == 'select-one')
		{
			if(obj.selectedIndex==0)
			{
				return false;
			}
		}

		if (obj.type == 'radio' || obj.type == 'checkbox')
		{
			if (!obj.checked)
			{
				return false;
			}
		}
		return true;
	}	
	
	
	
	function ReplaceContent(layerName, ContentInfo)
	{
		if(ie){document.all[layerName].innerHTML = ContentInfo}

		if(ns)
		{
			with(document.layers[layerName].document) 
			{ 
			   open(); 
			   write(ContentInfo); 
			   close(); 
			}
		}
	}
	

	function Tip(evento, texto, show)
	{
		var doc

		if(ns){doc = "document."; sty = ""}
		if(ie){doc = "document.all."; sty = ".style"}

		var initialize = show
		var Ex, Ey

		if(ie)
		{
			Ex = "event.x"
			Ey = "event.y"
		}

		if(ns)
		{
			Ex = "e.pageX"
			Ey = "e.pageY"
			window.captureEvents(Event.MOUSEMOVE)
			window.onmousemove=overhere
		}

		overhere(evento);
		EnterContent('ToolTip',texto);
		

		function MoveToolTip(layerName, FromTop, FromLeft, e)
		{
			if(ie)
			{
				eval(doc + layerName + sty + ".top = "  + (eval(FromTop) + document.body.scrollTop))
			}
			
			if(ns)
			{
				eval(doc + layerName + sty + ".top = "  +  eval(FromTop))
			}
			eval(doc + layerName + sty + ".left = " + (eval(FromLeft) + 15))
		}


		function overhere(e)
		{
			if(initialize)
			{
				MoveToolTip("ToolTip", Ey, Ex, e)
				eval(doc + "ToolTip" + sty + ".visibility = 'visible'")
			}
			else
			{
				MoveToolTip("ToolTip", 0, 0)
				eval(doc + "ToolTip" + sty + ".visibility = 'hidden'")
			}
		}



		function EnterContent(layerName, TContent)
		{
			var width = (TContent.length * 7) > 400 ? 400 : (TContent.length * 7)
			var ContentInfo='<table border="0" width="'+width+'" cellspacing="0" cellpadding="0" class="tooltip">'+
											'<tr><td width="100%" class="afonte">&nbsp;'+TContent+'&nbsp;</td></tr></table>'
			ReplaceContent(layerName, ContentInfo)
		}

	}	


	function Tip2(evento, texto, show)
	{
		var doc

		if(ns){doc = "document."; sty = ""}
		if(ie){doc = "document.all."; sty = ".style"}

		var initialize = show
		var Ex, Ey

		if(ie)
		{
			Ex = "event.x"
			Ey = "event.y"
		}

		if(ns)
		{
			Ex = "e.pageX"
			Ey = "e.pageY"
			window.captureEvents(Event.MOUSEMOVE)
			window.onmousemove=overhere
		}

		overhere(evento);
		EnterContent('ToolTip',texto);
		

		function MoveToolTip(layerName, FromTop, FromLeft, e)
		{
			if(ie)
			{
				eval(doc + layerName + sty + ".top = "  + (eval(FromTop) + document.body.scrollTop))
			}
			
			if(ns)
			{
				eval(doc + layerName + sty + ".top = "  +  eval(FromTop))
			}
			eval(doc + layerName + sty + ".left = " + (eval(FromLeft)-60))
		}


		function overhere(e)
		{
			if(initialize)
			{
				MoveToolTip("ToolTip", Ey, Ex, e)
				eval(doc + "ToolTip" + sty + ".visibility = 'visible'")
			}
			else
			{
				MoveToolTip("ToolTip", 0, 0)
				eval(doc + "ToolTip" + sty + ".visibility = 'hidden'")
			}
		}



		function EnterContent(layerName, TContent)
		{
			var ContentInfo='<table border="1" width="50" cellspacing="0" cellpadding="0" class="tooltip">'+
											'<tr><td width="100%" class="afonte">&nbsp;'+TContent+'&nbsp;</td></tr></table>'
			ReplaceContent(layerName, ContentInfo)
		}

	}		
	
	function seleciona(campo)
	{
	if (campo.name == 'TodosEstados')
		{
		for (var i=0; i<=document.forms[0].elements.length - 1; i++)
			{				
			var s = document.forms[0].elements[i].name;
			if (s == 'Estado')
				{
				document.forms[0].elements[i].checked = campo.checked;
				}
			}
		}

	if (campo.name == 'TodosMunicipios')
		{
		for (var i=0; i<=document.forms[0].elements.length - 1; i++)
			{				
			var s = document.forms[0].elements[i].name;
			if (s == 'Municipio')
				{
				document.forms[0].elements[i].checked = campo.checked;
				}
			}
		}

	if (campo.name == 'TodosPam')
		{
		for (var i=0; i<=document.forms[1].elements.length - 1; i++)
			{		
			var s = document.forms[1].elements[i].name;
			if (s == 'Pam')
				{
				document.forms[1].elements[i].checked = campo.checked;
				}
			}
		}


	}



	function ClearCheckRange(Field,Start,Stop)
	{
		if (Field.checked) 
		{
			for(var i=Start;i<=Stop;i++)
			{
				document.forms(0).elements(i+1).checked=false;		
			}
		}
	}
	
	
	function ClearCheck(Index, FormIndex)
	{
	
		if (FormIndex==null || FormIndex.length==0)
			FormIndex=0;
	
		if (document.forms(FormIndex).elements(Index).checked) 
		{
			for(var i=Index;i<(Index+4);i++)
			{
				document.forms(FormIndex).elements(i+1).checked=false;		
			}
		}
	}

	function ClickCheck(Index, FormIndex)
	{
		if (FormIndex==null || FormIndex.length==0)
			FormIndex=0;

		if (document.forms(FormIndex).elements(Index).checked) 
			return false;
		else
			return true;
	}


	function formatMoney(campo, texto)
		{		
		if (texto == null)
			var straux = campo.value;			
		else
			var straux = texto;
	
		while (straux.indexOf(".") != -1)
				{
				straux = straux.replace(".","");
				}
		
		if (straux == '')
		{
			straux = '0,00';
		}
		else
		{
			var pos = straux.indexOf(',');
			if (pos == -1)
			{
				straux = straux + ',00';	
			}
			else
			{
				var dec = straux.substring(pos).length;	
				switch (dec) 
				{ 
					case 1: 
						straux = straux + '00';
						break;
					case 2: 
						straux = straux + '0';
						break;
					case 3:
						break;
					default:
						straux = straux.substring(0,pos) + straux.substring(pos, pos + 3);
						break;
				}
			}			
		}

		if (texto == null)
			{
			var pos=-3;
			var s ='';
			for (var i=straux.length-1; i>=0; i--)
				{
				if ((pos % 3 == 0) && (pos > 0))
					s = straux.charAt(i) + '.' + s;
				else
					s = straux.charAt(i) + s;
				pos += 1;
				}	
			
			campo.value = s;
			return '';
			}
		else
			{
			var pos=-3;
			var s ='';
			for (var i=straux.length-1; i>=0; i--)
				{
				if ((pos % 3 == 0) && (pos > 0))
					s = straux.charAt(i) + '.' + s;
				else
					s = straux.charAt(i) + s;
				pos += 1;
				}
			return s;
			}
			
		}

		function CleanField(sValue)
		{
      sValue = sValue.toString().replace( "-", "" );
      sValue = sValue.toString().replace( "-", "" );
      sValue = sValue.toString().replace( ".", "" );
      sValue = sValue.toString().replace( ".", "" );
      sValue = sValue.toString().replace( "/", "" );
      sValue = sValue.toString().replace( "/", "" );
      sValue = sValue.toString().replace( "(", "" );
      sValue = sValue.toString().replace( "(", "" );
      sValue = sValue.toString().replace( ")", "" );
      sValue = sValue.toString().replace( ")", "" );
      sValue = sValue.toString().replace( ",", "" );
      sValue = sValue.toString().replace( " ", "" );
      
      return sValue;
		}
		
		
   /***
    * Descrição.: formata um campo do formulário de
    * acordo com a máscara informada...
    * Parâmetros: - objForm (o Objeto Form)
    * - strField (string contendo o nome
    * do textbox)
    * - sMask (mascara que define o
    * formato que o dado será apresentado,
    * usando o algarismo "9" para
    * definir números e o símbolo "!" para
    * qualquer caracter...
    * - evtKeyPress (evento)
    *
    * Uso.......: <input type="textbox"
    * name="xxx".....
    * onkeypress="return txtBoxFormat(document.rcfDownload, 'str_cep', '99999-999', event);">
    * Observação: As máscaras podem ser representadas
    * como os exemplos abaixo:
    * CEP -> 99999-999
    * CPF -> 999.999.999-99
    * CNPJ -> 99.999.999/9999-99
    * C/C -> 999999-!
    * Tel -> (99) 9999-9999
    ***/
    function txtBoxFormat(strField, sMask, evtKeyPress) {
      var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

      if(ie) { // Internet Explorer
        nTecla = evtKeyPress.keyCode; }
      else if(ns) { // Nestcape
        nTecla = evtKeyPress.which;
      }

			sValue = strField.value;

			//Caracteres que nao sao validados
      if (nTecla == 13 || nTecla == 8 || nTecla == 0){return true;}

			if (!((nTecla > 47) && (nTecla < 58))) {return false;}

			if (sValue.length == sMask.length) {return true};			

			// Limpa todos os caracteres de formatação que
			// já estiverem no campo.
			sValue = CleanField(sValue);
			fldLen = sValue.length;
			mskLen = sMask.length;

			i = 0;
			nCount = 0;
			sCod = "";
			mskLen = fldLen;

			while (i <= mskLen) {
			  bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
			  bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == ",") || (sMask.charAt(i) == " "))

			  if (bolMask) {
			    sCod += sMask.charAt(i);
			    mskLen++; }
			  else {
			    sCod += sValue.charAt(nCount);
			    nCount++;
			  }

			  i++;
			}
      
			strField.value = sCod;
      
    }


   /***
    * Descrição.: formata um campo do formulário de
    * acordo com a máscara informada...
    * Parâmetros: - objForm (o Objeto Form)
    * - strField (string contendo o nome
    * do textbox)
    * - sMask (mascara que define o
    * formato que o dado será apresentado,
    * usando o algarismo "9" para
    * definir números e o símbolo "!" para
    * qualquer caracter...
    * - evtKeyPress (evento)
    *
    * Uso.......: <input type="textbox"
    * name="xxx".....
    * onkeypress="return txtBoxFormat(document.rcfDownload, 'str_cep', '99999-999', event);">
    * Observação: As máscaras podem ser representadas
    * como os exemplos abaixo:
    * CEP -> 99999-999
    * CPF -> 999.999.999-99
    * CNPJ -> 99.999.999/9999-99
    * C/C -> 999999-!
    * Tel -> (99) 9999-9999
    ***/
    function txtBoxFormat2(strField, sMask) {
      var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

	  sValue = strField.value;

  		if (sValue.length == sMask.length) {return true};			

			// Limpa todos os caracteres de formatação que
			// já estiverem no campo.
			sValue = CleanField(sValue);
			fldLen = sValue.length;
			mskLen = sMask.length;

			i = 0;
			nCount = 0;
			sCod = "";
			mskLen = fldLen;

			while (i <= mskLen) {
			  bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
			  bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ") || (sMask.charAt(i) == ","))

			  if (bolMask) {
			    sCod += sMask.charAt(i);
			    mskLen++; }
			  else {
			    sCod += sValue.charAt(nCount);
			    nCount++;
			  }

			  i++;
			}
      
			strField.value = sCod;
      
    }


    function seleciona(campo)
	{
	if (campo.name == 'TodosEstados')
		{
		for (var i=0; i<=document.forms[0].elements.length - 1; i++)
			{				
			var s = document.forms[0].elements[i].name;
			if (s == 'Estado')
				{
				document.forms[0].elements[i].checked = campo.checked;
				}
			}	
		}
	if (campo.name == 'TodosMunicipios')
		{
		for (var i=0; i<=document.forms[0].elements.length - 1; i++)
		{				
			var s = document.forms[0].elements[i].name;
			if (s == 'Municipio')
				{
				document.forms[0].elements[i].checked = campo.checked;
				}
			}
		}
	if (campo.name == 'TodosPam')
		{
		for (var i=0; i<=document.forms[1].elements.length - 1; i++)
			{		
			var s = document.forms[1].elements[i].name;
			if (s == 'Pam')
				{
				document.forms[1].elements[i].checked = campo.checked;
				}
			}
		}
	}


	function EscreveDiv(p_DivID, texto, normal)
   	{
   		if (document.getElementById)
		{
			if (normal!= null)
				document.getElementById(p_DivID).innerHTML= texto;
			else
				{
				var s = texto.toString();
				document.getElementById(p_DivID).innerHTML=  formatMoney('',s.replace(".",","));
				}	
		} 
   		else 
		{
			with (document.layers[p_DivID].document) 
	   		{
	   			open();
	   			write(p_htmlstr);
	   			close();
     	   		}
 		}
	}


	function ValData (data) 
	{
    		if ( (data == null) || (data.length < 10) ) 
			{
     		 	return false;
    			}
    		var jsDataValida = true;
    		var jsDia = data.substring(0,2)-0;
    		var jsMes = data.substring(3,5)-1;
    		var jsAno = data.substring(6,10)-0;
    		var oData = new Date(jsAno, jsMes, jsDia);    
    		if (jsDia != oData.getDate()) { jsDataValida = false; }
    		if (jsMes != oData.getMonth()) { jsDataValida = false; }
    		if (jsAno != oData.getFullYear()) { jsDataValida = false; }
		return(jsDataValida);
	}

	/*------------------------------------------------------
	'Método: Trim
	'Finalidade: Retirar espaços da string
	'Parametros: texto string
	'Retorno: texto string sem espaços
	'Exemplo: Trim(texto)
	------------------------------------------------------*/
	function Trim(str) {
		while(str.charAt(0) == " ")
			str = str.substr(1,str.length -1);
		
		while(str.charAt(str.length-1) == " ")
			str = str.substr(0,str.length-1);

		return str;
	} 



//-->





