	var aberto = false;
	var strAltura  = (screen.height);
	var strLargura = (screen.width);
	
	function caminhoAplicacao(){
		var i;
		var strUrl = "http://" + window.location.host + "/";
		
		for (i=1; i<window.location.pathname.length; i++) {
			if (window.location.pathname.substr(i,1)=="/") {
				break;
			}
			strUrl = strUrl + window.location.pathname.substr(i,1);
		}
		return strUrl;
	}
	function fechaSige() {
		window.close();
		return true;
	}
		
	function fechaHelp() {
		//função que verifica se a tela de help ainda já foi fechada
		//redimensiona a página principal
		if (help.closed) {
			parent.window.resizeTo(strLargura,strAltura-25);
			aberto = false;
		}
		else {
			setTimeout("fechaHelp()",100);
			aberto = true;
		}
	}

	function abreHelp(pagina) {
		var strCaminho;
		strCaminho = caminhoAplicacao();
		
		//Abre a tela de help e redimensiona a página
		if (pagina=="")
			pagina = "help/inicio_hlp.asp";
		
		if (!aberto) {
			strCaminho = strCaminho + "/help/hlp.asp?pagina=" + strCaminho + "/" + pagina;				
			parent.window.resizeTo((strLargura-300),(strAltura-25));
			help = window.open(strCaminho,"help","height=" + (strAltura-25) + ",width=300,menubar=no,toolbar=no,scrollbars=yes,status=yes,top=0,left=600");
			fechaHelp();
			
		} else {
			help.close();
		}
	}
	
	function paginaHelp(pagina){
		//Página de help a ser chamada a ser chamada. Caso não tenha passar "" (vazio)		
		if (parent.topo.frm.txtPaginaHelp){
			if (pagina=="")
				parent.topo.frm.txtPaginaHelp.value  = "";
			else
				parent.topo.frm.txtPaginaHelp.value  = pagina;
		}
			return true;
	}
	
	function tituloPagina(descricao){
		//preenche no topo.asp o título 
		if (parent.topo.titulo)
			parent.topo.titulo.innerText = descricao;
		return true;
	}	
	
	function reload(){
		frm.submit();
		return true;	
	}
	function currencyFormat(fld, e) { 
		var sep = 0; 
		var milSep='.';
		var decSep=',';
		var key = ''; 
		var i = j = 0; 
		var len = len2 = 0; 
		var strCheck = '0123456789'; 
		var aux = aux2 = ''; 
		var whichCode = (window.Event) ? e.which : e.keyCode; 
		
		if (whichCode == 13) return true;  // Enter 
		
		key = String.fromCharCode(whichCode);  // Get key value from key code 
		
		if (strCheck.indexOf(key) == -1) return false;  // Not a valid key 
		
		len = fld.value.length; 
		
		for(i = 0; i < len; i++) 
			if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break; 
			
		aux = ''; 
		
		for(; i < len; i++) 
			if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i); 
			
		aux += key; 
		len = aux.length; 
		if (len == 0) fld.value = ''; 
		if (len == 1) fld.value = '0'+ decSep + '0' + aux; 
		if (len == 2) fld.value = '0'+ decSep + aux; 
		if (len > 2) { 
			aux2 = ''; 
			for (j = 0, i = len - 3; i >= 0; i--) { 
				if (j == 3) { 
					aux2 += milSep; 
					j = 0; 
				} 
				aux2 += aux.charAt(i); 
				j++; 
			} 
			fld.value = ''; 
			len2 = aux2.length; 
			for (i = len2 - 1; i >= 0; i--) 
				fld.value += aux2.charAt(i); 
				
			fld.value += decSep + aux.substr(len - 2, len); 
		} 
			return false; 
	} 
	function currencyFormat3(fld, e) { 
		var sep = 0; 
		var milSep='.';
		var decSep=',';
		var key = ''; 
		var i = j = 0; 
		var len = len2 = 0; 
		var strCheck = '0123456789'; 
		var aux = aux2 = ''; 
		var whichCode = (window.Event) ? e.which : e.keyCode; 
		
		if (whichCode == 13) return true;  // Enter 
		
		key = String.fromCharCode(whichCode);  // Get key value from key code 
		
		if (strCheck.indexOf(key) == -1) return false;  // Not a valid key 
		
		len = fld.value.length; 
		
		for(i = 0; i < len; i++) 
			if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break; 
			
		aux = ''; 
		
		for(; i < len; i++) 
			if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i); 
			
		aux += key; 
		len = aux.length; 
		if (len == 0) fld.value = ''; 
		if (len == 1) fld.value = '0'+ decSep + '00' + aux; 
		if (len == 2) fld.value = '0'+ decSep + '0' + aux; 
		if (len == 3) fld.value = '0'+ decSep + aux; 
		if (len > 3) { 
			aux2 = ''; 
			for (j = 0, i = len - 4; i >= 0; i--) { 
				if (j == 4) { 
					aux2 += milSep; 
					j = 0; 
				} 
				aux2 += aux.charAt(i); 
				j++; 
			} 
			fld.value = ''; 
			len2 = aux2.length; 
			for (i = len2 - 1; i >= 0; i--) 
				fld.value += aux2.charAt(i); 
				
			fld.value += decSep + aux.substr(len - 3, len); 
		} 
			return false; 
	} 	
	
function CasasDecimais(value, precision)
	{
		/*
		@desc	Função que delimita a quantidade de casas decimais
		@autor	Roberto Júnior - roberto.junior@see.go.gov.br
		@versão	1.0
		@param	valor: Valor a ser alterado
		@param	numCasas: Define a quantidade de casas decimais para o valor fornecido
		@rel	
		@pre	Informar o valir e a qtd de casas decimais
		@pos	formata o valor de acordo com a qtde de casas decimais informadas
		@ret	retorna o valor formatado
		@hist
		*/
			
			if (value == "") { 
				value =="0.00";
			}
			
			value = "" + value //convert value to string
			
			precision = parseInt(precision);
			var whole = "" + Math.round(value * Math.pow(10, precision));

//alert("whole:"+whole);
//alert(Math.round(value * Math.pow(10, precision)));


			if 	(whole == "0") 
				whole = "000";
			
			var decPoint = whole.length - precision;
			var decPointControle
			//alert("whole.length:"+whole.length);
			//alert("precision:"+precision);
			//alert("decPoint:"+decPoint)
			decPointControle = decPoint
			if (decPoint<0) decPointControle = 0
			//alert("decPoint pos:"+decPoint)			
			//result = "0"
			if(decPointControle != 0)
			{       
				result = whole.substring(0, decPoint);
				result += ".";
				result += whole.substring(decPoint, whole.length);        
			}
			else
			{
//				result = decPoint;
//				result += ".";
				if (decPoint==-1) {
					//alert("passou")
					result = "0.0";
				} else {
					result = "0.";
				}
				result += whole;
				//alert(result)
			}
			return result.replace(".",",");
	}		
	function limpar(){
		//limpa os campos do formulário
		var form = window.document.forms[0]
		var urlForm
		urlForm = location.href; //retorna a url da página
		
		//limpa os parametros da url
		urlForm = urlForm.substring(0, urlForm.indexOf("?"));
		
		for (var i = 0; i < form.elements.length; i++) {
			//verifica todos os checkbox
			
			if (form.elements[i].type == "checkbox"){
				form.elements[i].checked = false;			
			}	
			
			if (form.elements[i].type == "radio"){ //option button
				form.elements[i].value= "";			
			}	
			
			if (form.elements[i].type == "select-one") //combo
				form.elements[i].value=0;
			
			if (form.elements[i].type == "text") //text box
				form.elements[i].value="";
				
			if (form.elements[i].type == "hidden") //text box escondido
				form.elements[i].value="";
				
			if (form.elements[i].type == "password") //campo de senha
				form.elements[i].value="";					
			
			if (form.elements[i].type == "textarea")
				form.elements[i].value="";
		}
		form.action = urlForm;
		form.submit();
		return true;	
	}	
	
	function principal(){
		var pagina;
		
		if (window.location.host.toUpperCase()=="LOCALHOST")
			pagina = "http://" + window.location.host + "/sige/conteudo.asp";
			
		else
			pagina = "http://" + window.location.host + "/sige2005/conteudo.asp";
			
		window.navigate(pagina);
	}		
	
	function trim(str) 
	{
		// Remove leading spaces and carriage returns	
		while ((str.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
		{
			str = str.substring(1,str.length);
		}
		// Remove trailing spaces and carriage returns
		while ((str.substring(str.length-1,str.length) == ' ') || (str.substring(str.length-1,str.length) == '\n') || (str.substring(str.length-1,str.length) == '\r'))
		{
			str = str.substring(0,str.length-1);
		}
		return str;
	}
		
	function abreConsulta(caminho){
		window.open(caminho,"consulta","top=0,left=0,height=500,width=810,menubar=no,toolbar=no,scrollbars=yes,status=yes");
	}	

	function linhaMouseOver(linha){
		linha.style.backgroundColor="#E8EFF0";
		return true;
	}
	
	function linhaMouseOut(linha){
		linha.style.backgroundColor="";
		return true;
	}	
	
	function FormataCNPJ(Campo, teclapres){
		   var tecla = teclapres.keyCode;
		
		   var vr = new String(Campo.value);
		   vr = vr.replace(".", "");
		   vr = vr.replace(".", "");
		   vr = vr.replace("/", "");
		   vr = vr.replace("-", "");
		
		   tam = vr.length + 1 ;
			   
		   if (tecla != 9 && tecla != 8){
			  if (tam > 2 && tam < 6)
				 Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
			  if (tam >= 6 && tam < 9)
				 Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
			  if (tam >= 9 && tam < 13)
				 Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
			  if (tam >= 13 && tam < 15)
				 Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
			}
	}	
	function formataCampo(objCampo,intTipo,intTamanho){
		//objCampo   = campo a ser formatado
		//intTipo    = 1 -> texto; intTipo = 2 -> número; intTipo = 3 -> data; intTipo=4 ->texto e numero; intTipo=5 ->CPF; 
		//intTipo    = 6 -> numero e virgula
		//intTipo    = 7 -> Data Referencia
		//intTipo    = 12-> texto minusculo
		//intTipo    = 13-> texto kilometragem
		//intTamanho = Quantidade de caracteres que o campo poderá aceitar
		
		var strValidado = false

		//verifica tecla pressionada
		var str=objCampo.value
		
		//Tamanho máximo permitido
		if (str.length>intTamanho-1){
			return false
		}
		
		//Verifica o intTipo para barrar caracteres inválidos
		switch (intTipo)
		{
			case 1: //texto~
				if (window.event.keyCode==32) {
					return true
				}
				if (window.event.keyCode>=97 && window.event.keyCode<=122) {
					window.event.keyCode = window.event.keyCode - 32
					return true	
				}
				if (window.event.keyCode>=65 && window.event.keyCode<=90) {
					return true
				}
				if (window.event.keyCode>=123 && window.event.keyCode<=255) {
					window.event.keyCode = window.event.keyCode - 32
					return true
				}
				
				break
			case 2: //números
				if (window.event.keyCode>=48 && window.event.keyCode<=57){
					return true
				}
			case 3: //Data
				if (window.event.keyCode<48 || window.event.keyCode>57){
					return false
				}
				if (str.length==2){
					objCampo.value = objCampo.value + '/'
					return true
				}
				if (str.length==5){
					objCampo.value = objCampo.value + '/'
					return true
				}
				return true
			
			case 7: //Data Referencia 
				if (window.event.keyCode<48 || window.event.keyCode>57){
					return false
				}
				if (str.length==2){
					objCampo.value = objCampo.value + '/'
					return true
				}
				return true
				
			case 4: //Texto e numero
				if (window.event.keyCode==32) {
					return true
				}
				if (window.event.keyCode>=97 && window.event.keyCode<=122) {
					window.event.keyCode = window.event.keyCode - 32
					return true	
				}
				if (window.event.keyCode>=65 && window.event.keyCode<=90) {
					return true
				}
				
				if (window.event.keyCode>=48 && window.event.keyCode<=57){
					return true
				}
			
			case 5: //cpf
				
				if (window.event.keyCode<48 || window.event.keyCode>57){
					return false
				}
				
				switch (str.length)
				{	
					case 3:
						if (str.length==3){
							objCampo.value = objCampo.value + '.'
							return true
						}						
						
					case 7:
					if (str.length==7){
						objCampo.value = objCampo.value + '.'
						return true
					}					
					case 11:				
						if (str.length==11){
							objCampo.value = objCampo.value + '-'
							return true
						}
				  default:
						return true	
				}
			case 6: //numero e virgula
				if (window.event.keyCode==32) {
					return true
				}
				if (window.event.keyCode==44) {
					return true	
				}
				//if (window.event.keyCode>=65 && window.event.keyCode<=90) {
				//	return true
				//}
				
				if (window.event.keyCode>=48 && window.event.keyCode<=57){
					return true
				}
			case 8: //números com -
				if (window.event.keyCode>=45 && window.event.keyCode<=57) {
					return true
				}
			case 9: //somente x e X
				if (window.event.keyCode==120 || window.event.keyCode==88) {
					return true
				}
			case 10: //hora
				if (window.event.keyCode<48 || window.event.keyCode>57){
					return false
				}
				if (str.length==2){
					objCampo.value = objCampo.value + ':'
					return true
				}
				if (str.length==5){
					objCampo.value = objCampo.value + ':'
					return true
				}
			case 11: //texto~minusculo-- não esta utilizando
				return true
			case 12: //texto~minusculo
				if (window.event.keyCode==32) {
					//Nao permitir a digitacao de 2 espacos em branco
					if (str.substring(str.length-1,str.length)== ' ') return false
					else return true
				}
				if (window.event.keyCode>=97 && window.event.keyCode<=122) {
					return true	
				}
				if (window.event.keyCode>=65 && window.event.keyCode<=90) {
					window.event.keyCode = window.event.keyCode + 32
					return true
				}
				if (window.event.keyCode>=193 && window.event.keyCode<=199) {
					window.event.keyCode = window.event.keyCode + 32
					strValidado = true
					return true
				}
				if (window.event.keyCode>=123 && window.event.keyCode<=255 && strValidado==false) {
					return false
				}					
				return true	
			case 13: //km
				
				if (window.event.keyCode<48 || window.event.keyCode>57){
					return false
				}
				
				switch (str.length)
				{	
					case 1:
						if (str.length==1){
							objCampo.value = objCampo.value + '.'
							return true
						}						
						
					case 4:
					if (str.length==4){
						objCampo.value = objCampo.value + '.'
						return true
					}					
					case 11:				
						if (str.length==11){
							objCampo.value = objCampo.value + '-'
							return true
						}
				  default:
						return true	
				}				
			return false
		}
	
		return false
	}
	
	function validaData(objCampo){
		//verifica se uma deterimnada data é válida ou não
		var strData = objCampo.value
		if (strData==""){
			return false;
		}
		var intDia = parseInt(strData.substring(0,2),10);
		var intMes = parseInt(strData.substring(3,5),10);
		var intAno = parseInt(strData.substring(6,10),10);
		
		if (intDia <= 31 && intMes <=12 && intAno >= 1000){
		  if (strData.substring(0,1)=='0' && strData.substring(1,2) != '0' || strData.substring(0,1)!='0'){
		    if (strData.substring(2,3)=="/"){
		      if (strData.substring(3,4)=='0' && strData.substring(4,5)!='0' || strData.substring(3,4)!='0'){
		        if (strData.substring(5,6)=="/"){
		          if (strData.substring(6,7)== '0' || strData.substring(6,7)=='' && strData.substring(7,8)!='0'){
		            window.alert('Ano inexistente!');
		            objCampo.focus();
								objCampo.select();
		            return false;
		          } 
		          else {
		            if (intMes == 2){
		              if ((intDia > 0 ) && (intDia <= 29)){
		                 if (intDia == 29){
		                    if ((intAno % 4) == 0){
		                      return true;
		                    }
		                    else {
		                      window.alert('Este dia não existe, digite novamente!');
		                      objCampo.focus();
													objCampo.select();
		                      return false;
		                    }
		                 }
		              } 
		              else {
		                window.alert('Este dia não existe, digite novamente!');
		                objCampo.focus();
										objCampo.select();
		                return false;
		              }
		            }
		            if ((intMes == 4)||(intMes == 6)||(intMes == 9)||(intMes ==11)){
		              if ((intDia > 0 ) && (intDia <= 30)){
		                return true;
		              }
		              else{
		                window.alert('Este dia não existe, digite novamente!');
		                objCampo.focus();
										objCampo.select();
		                return false;
		              }
		            }
		            if ((intMes == 1)||(intMes == 3)||(intMes == 5)||(intMes ==7)||(intMes ==8)||(intMes == 10)||(intMes == 12)) {
		              if ((intDia > 0) && (intDia <= 31)) {
		                return true;
		              }
		              else{
		                window.alert('Este dia não existe, digite novamente!');
		                objCampo.focus();
										objCampo.select();
		                return false;
		              }
		            }
		          }
		        }
		        else{
		          window.alert('A data digitada não está no formato padrão(dd/mm/aaaa)!');
		          objCampo.focus();
							objCampo.select();
		          return false;
		        }
		      }
		      else{
		        window.alert('Mês inexistente!');
		        objCampo.focus();
						objCampo.select();
		        return false;
		      }
		    }
		    else{
		      window.alert('A data digitada não está no formato padrão(dd/mm/aaaa)!');
		      objCampo.focus();
					objCampo.select();
		      return false;
		    }
		  }
		  else{
		    window.alert('Dia inexistente!');
		    objCampo.focus();
				objCampo.select();
		    return false;
		  }
		}
		else {
		  window.alert('O dia e/ou o mês digitado não está no formato padrão (dd/mm/aaaa)!');
		  objCampo.focus();
			objCampo.select();
		  return false;
		}
	return true;
	}
	
	function validaCPF(campo) {
		var pcpf=campo.value;
		
		pcpf = pcpf.replace(".","");
		pcpf = pcpf.replace(".","");
		pcpf = pcpf.replace("-","");
		
		if (pcpf != "") {
		
			if (pcpf.length != 11){
				sim=false;
			}
			else{
				sim=true;
			}
			
			if ( (pcpf==11111111111) || (pcpf==22222222222) ||
				(pcpf==33333333333) || (pcpf==44444444444) || (pcpf==55555555555) ||
				(pcpf==66666666666) || (pcpf==77777777777) || (pcpf==88888888888) ||
				(pcpf==99999999999) || (pcpf==00000000000) ){
					sim=false;
			}
			
			if(sim){
				for (i=0; i<=(pcpf.length-1) && sim; i++){
					val = pcpf.charAt(i);
					if((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4")&&( val!="5")&&(val!="6")&&(val!="7")&&(val!="8")){
						sim=false;
					}
				}
			
				if(sim){
					soma=0;
					for (i=0;i<=8;i++){
						val = eval(pcpf.charAt(i));
						soma = soma + (val*(i+1));
					}
				
					resto = soma % 11;
					
					if (resto>9)
						dig = resto -10;
					else
						dig = resto;
					
				
					if (dig != eval(pcpf.charAt(9))){
						sim=false
					}else{
						soma = 0
						for (i=0;i<=7;i++){
							val = eval(pcpf.charAt(i+1))
							soma = soma +	(val*(i+1))
						}
						soma = soma + (dig * 9)
						resto = soma % 11
						if (resto>9){
							dig = resto -10
						}else{
							dig = resto
						}
				
						if (dig != eval(pcpf.charAt(10))){
							sim = false
						}else{
							sim = true
						}
					}
				}
			}
			
			if (!sim){
				alert("CPF inválido!");
				campo.focus();
				campo.select();
			}
					
		}
	}
	
function calculaNota(valor){ //->função que ignora deixa somente 1 número após a víergula. Ex.: 6.86 para 6.8

	var qtde;
	var i;
	var VNota = "";
	var ponto = false;
	valor = "" + valor; //->converte para string
	qtde = valor.length;

	for(i=0;i<qtde;i++){
		VNota = VNota + valor.substring(i,i+1);
		if (valor.substring(i,i+1) =="."){
			ponto = true;
			break;
		}
	}
	
	if (ponto){
		VNota = VNota + valor.substring(i+1,i+2)
	}	
	
	return VNota;
}	

/*
Funções que carregam as combos de série, semestre, unidade de ensino sem que ocorra submit na página. 
Utiliza-se o arquivo proxylet.asp (neste faz-se o select, conexão com o bd, e coloca o resultado em uma string)
proxylet.js (irá fazer o acesso a proxylet.asp utilizando métodos da classe proxylet.class - classe em java e montando a combo)
*/
function carregaSerie(comp, filtro, conjunto){
  var intCodComp = comp;
	var strUrl="proxyLet.asp?tipoAcao=carregaSerieNormal";		
	if (intCodComp!=""){
		strUrl = strUrl + "&intCodComp=" + intCodComp;
		strUrl = strUrl + "&filtroSerie=" + filtro;
		strUrl = strUrl + "&conjuntoSerie=" + conjunto;
		preencheCombo2(strUrl,frm.cmbSerie);
	}
	carregaSemestre(comp)
	carregaTurma(0, 0, 0, '')	
}

function carregaSemestre(composicao){
	var strUrl="proxyLet.asp?tipoAcao=carregaSemestreNormal";
	strUrl = strUrl + "&intCodComp=" + composicao;
	var habilita = "sim";
	preencheSemestre2(strUrl,frm.cmbSemestre);

}

function carregaTurma(composicao, serie, turno, dependencia){
	var strUrl="proxyLet.asp?tipoAcao=carregaTurma";
	strUrl = strUrl + "&intCodComp=" + composicao;
	strUrl = strUrl + "&intCodSerie=" + serie;
	strUrl = strUrl + "&intCodTurno=" + turno;
	strUrl = strUrl + "&strDep=" + dependencia;
	//alert(strUrl)
	
	preencheCombo2(strUrl,frm.cmbTurma);

}
function MarcaTodos(valor){
	var form = window.document.forms[0];
	var i;
	
	
	for (var i = 0; i < form.elements.length; i++) {
		//verifica todos os checkbox
		if (form.elements[i].type == "checkbox"){
			//verifica se o checkbox está marcado
			if (form.chkAluno) {
				if (form.elements[i].name == "chkAluno"){
					//verifica se o checkbox está marcado
					if (form.elements[i].disabled==false) {
						form.elements[i].checked=valor;
					}
				}
			}
			else {
				form.elements[i].checked=valor;
			}
		}
	}
}	


function roundOff(value, precision) 
	//->Função utilizada pelo colégio militar
	// arredonda a nota ex.: 6.85 para 6.9 e 6.44 para 6.4
	{
		//if value>0 then
		//{
			value = "" + value //convert value to string
			precision = parseInt(precision);
			var whole = "" + Math.round(value * Math.pow(10, precision));
			alert
			var decPoint = whole.length - precision;
			if(decPoint != 0)
			//if(decPoint > 1)
			{       
				result = whole.substring(0, decPoint);
				result += ".";
				result += whole.substring(decPoint, whole.length);        
			}
			else
			{
				result = decPoint;
				result += ".";
				result += whole;
			}
			return result;
		//else 
	}

	function funcCheckContaCorrente(campo){

		//formata aao digitar a conta corretne
		//verifica tecla pressionada
		var str=campo.value.replace("-","");
		var strConta
		var strContaDigito
		var tam = 1

		if (str.length == 1){
			tam = 0
		}
		strConta = str.substring(0,str.length-tam);
		strContaDigito = str.substring((str.length-tam),(str.length));
		if (str.length == 1) strContaDigito = "";
		if (str.length == 0){
			campo.value = "";
		}
		else{
			if (str.length == 1){
				campo.value = strConta;
			}else{
				campo.value = strConta + '-' + strContaDigito;
			}
		}
		return true
	}	
	
	
//-------------------------AJAX------------------------------
    var http_request = false;
	function carregaDados(url) {
        http_request = false;
        if (window.XMLHttpRequest) { 
		
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
			
        } else if (window.ActiveXObject) {
		
            try {
			 
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
				
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
					
                } catch (e) {
				alert('Erro.');
				 
				}
            }
        }

        if (!http_request) {
            alert('Erro.');
            return false;
        }
       
        http_request.open('GET', url, false);
		//conectando a url...
				
        http_request.send(null);
		
		// testando estado de pronto...
		//se for diferente de 4 a consulta não foi feita
		if (http_request.readyState == 4) {
		
			if (http_request.status == 200) {					  
					 return http_request.responseText;

			}else{ 
			  return "|";
			}
			
		}else{ 
			return "|";
		}
    }

	
	function preencheCombo (url, combo, textoCombo) {
		var texto = carregaDados(url);
		var vetTexto = texto.split("|");
		//variavel que ira selecionar o texto no combo(guarda o indice)
		varIndex=1;
		//LIMPA A COMBO
		combo.length = 1;
		combo.options[0].text = ("Carregando...");
		
		for(cont = 0; cont < vetTexto.length; cont++)
		{
			
			var arrLine = vetTexto[cont].split(";");
			if (arrLine[0] != '') {
				var i = combo.length;
				combo.length = i + 1;
				combo.options[i].value = arrLine[0];
				combo.options[i].text = arrLine[1];
				
				
				if(arrLine[2]=="S")
				{
					combo.selectedIndex=varIndex;
				}
				else
				{
					varIndex=varIndex+1;
				}
			}
			
		}

		combo.options[0].text = (textoCombo);
	} 

	function preencheDoisCampos (url, campo1, campo2) {
	
		var texto = carregaDados(url);
		var arrLine = texto.split(";");
		
		if (arrLine[0] != '') 
		{
			campo1.value = arrLine[0];
			campo2.value = arrLine[1];
		}
		else
		{
			campo1.value='';
			campo2.value='';			
		}
	//	alert(campo1.value);
	//	alert(campo2.value);
		
	}
	function preencheUmCampo (url, campo1) {
	
		var texto = carregaDados(url);
		var arrLine = texto.split(";");
		
		if (arrLine[0] != '') 
		{
			campo1.value = arrLine[0];
		}
		else
		{
			campo1.value='';
		}
	}	

// fim -------------------------AJAX------------------------------

	function LimitaTexto(obj, limit)
	{
		var size = obj.value.length;
		div_atual.innerHTML = "Caracteres digitados: <font color='red'><b>" + parseInt(size) + "</font></b>";
		div_rest.innerHTML =  "Caracteres restantes: <font color='red'><b>" + parseInt(limit - size) + "</font></b>";
	
		if (size > limit)
		{
			temp = obj.value;
	
			obj.value = temp.substring(0, limit);
			div_atual.innerHTML = "Caracteres digitados: <font color='red'><b>" + parseInt(limit) + "</font></b>";
			div_rest.innerHTML =  "Caracteres restantes: <font color='red'><b>" + 0 + "</font></b>";
	
			alert("Máximo de " + limit + " caracteres para a este campo.");
	
			return false;
		}
	}	
	
	function CheckEnter(Key)
	{
		var charCode = (Key.which) ? Key.which : event.keyCode;
	
		if (charCode > 9 && charCode < 14)
			return false;
	
		return true;
	}

	function funcCheckCPF_CNPJ(campo,tipo,tamanho){
		//tipo = 1 -> CPF
		//verifica tecla pressionada
		var str=campo.value
		
		//Tamanho máximo permitido
		if (str.length>tamanho-1){
			return false
		}
		
		//Verifica o tipo para barrar caracteres inválidos
		switch (tipo)
		{
			case 1: //texto
				if (window.event.keyCode==32) {
					return true
				}
				if (window.event.keyCode>=97 && window.event.keyCode<=122) {
					window.event.keyCode = window.event.keyCode - 32
					return true	
				}
				if (window.event.keyCode>=65 && window.event.keyCode<=90) {
					return true
				}
				break
			case 2: //números
				if (window.event.keyCode>=48 && window.event.keyCode<=57){
					return true
				}
			case 3: //cpf cnpj
				var x
				
				//alert(window.event.keyCode)
				
				if (window.event.keyCode<48 || window.event.keyCode>57){
						return false
				}		
				
				x = str.replace(".","")
				y = x.replace("-","")
				str = y.replace("/","")
				str = str.replace(".","")

				//alert(str)				
				if (str.length<11)
				{
					if (str.length==2){
						campo.value = campo.value + '.'
						return true
					}
					if (str.length==5){
						campo.value = campo.value + '.'
						return true
					}
				}
				else 
				{
					
					if (str.length==11){
						campo.value = str.substring(0,2) + '.' + str.substring(2,5) + '.' + str.substring(5,8) + '/' +  str.substring(8,str.length)
						return true
					}
					if (str.length==12){
						campo.value = campo.value + '-'
						return true
					}
				}
			case 4: //Texto e numero
				if (window.event.keyCode==32) {
					return true
				}
				if (window.event.keyCode>=97 && window.event.keyCode<=122) {
					window.event.keyCode = window.event.keyCode - 32
					return true	
				}
				if (window.event.keyCode>=65 && window.event.keyCode<=90) {
					return true
				}
				
				if (window.event.keyCode>=48 && window.event.keyCode<=57){
					return true
				}				
			default:
				return false
		}
		return false
	}	
	
	function mascara(o,f){
		v_obj=o
		v_fun=f
		setTimeout("execmascara()",1)
	}
	
	function execmascara(){
		v_obj.value=v_fun(v_obj.value)
	}
	
	function telefone(v){
		v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
		v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
		v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
		return v
	}
	function cep(v){
		v=v.replace(/D/g,"")                //Remove tudo o que não é dígito
		v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
		return v
	}	
	function site(v){
		//Esse sem comentarios para que você entenda sozinho ;-)
		v=v.replace(/^http:\/\/?/,"")
		dominio=v
		caminho=""
		if(v.indexOf("/")>-1)
			dominio=v.split("/")[0]
			caminho=v.replace(/[^\/]*/,"")
		dominio=dominio.replace(/[^\w\.\+-:@]/g,"")
		caminho=caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g,"")
		caminho=caminho.replace(/([\?&])=/,"$1")
		if(caminho!="")dominio=dominio.replace(/\.+$/,"")
		v="http://"+dominio+caminho
		return v
	}		
