var xmlHttp;
function selEstado1(uf,campo,valor){

var url = 'gera_xml.asp?uf='+uf;
Vcampo = campo;
Vvalor = valor

	if (window.ActiveXObject){
		xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
	}
  	else if (window.XMLHttpRequest)
  	{
		xmlHttp = new XMLHttpRequest();
  	}
  
  	xmlHttp.open('GET', url, true);
  	xmlHttp.onreadystatechange = callback1;
  	xmlHttp.send(null);
}

function callback1(){
	if (xmlHttp.readyState == 4){
    	if (xmlHttp.status == 200){
			var cidades = xmlHttp.responseXML.getElementsByTagName("cidade")
	 		var obj = document.getElementById(Vcampo);
			obj.options.length = 0;
			
			var o = document.createElement("option");
	    		o.text = '-- Selecione --';
	    		o.value = '';
	    		obj.add(o);
			
	  		for(i=0; i<cidades.length; i++){
				var o = document.createElement("option");
	    		o.text = cidades[i].text;
	    		o.value = cidades[i].text;
	    		obj.add(o);
				
				if ( cidades[i].text == Vvalor ){
					document.getElementById(Vcampo).value = Vvalor;
				}
      		}
    	}
  	}
}

var xmlHttp1;
function selEstado2(uf,campo,valor){

var url = 'gera_xml.asp?uf='+uf;
V_campo = campo;
V_valor = valor

	if (window.ActiveXObject){
		xmlHttp1 = new ActiveXObject('Microsoft.XMLHTTP');
	}
  	else if (window.XMLHttpRequest)
  	{
		xmlHttp1 = new XMLHttpRequest();
  	}
  
  	xmlHttp1.open('GET', url, true);
  	xmlHttp1.onreadystatechange = callback2;
  	xmlHttp1.send(null);
}

function callback2(){
	if (xmlHttp1.readyState == 4){
    	if (xmlHttp1.status == 200){
			var cidades = xmlHttp1.responseXML.getElementsByTagName("cidade")
	 		var obj = document.getElementById(V_campo);
			obj.options.length = 0;

			var o = document.createElement("option");
	    		o.text = '-- Selecione --';
	    		o.value = '';
	    		obj.add(o);
				
	  		for(i=0; i<cidades.length; i++){
				var o = document.createElement("option");
	    		o.text = cidades[i].text;
	    		o.value = cidades[i].text;
	    		obj.add(o);
				
				if ( cidades[i].text == V_valor ){
					document.getElementById(V_campo).value = V_valor;
				}
      		}
    	}
  	}
}

function converteMai(val){
  valor = val.value.toUpperCase();
  val.value = valor;
}

function converteMin(val){
  valor = val.value.toLowerCase();
  val.value = valor;
}

function mascaraData()
{

	var arrData = new Array("","","/","","","/","","","",""," ","","",":","","");
	var strSaida = "";
	var strValor = event.srcElement.value + String.fromCharCode(event.keyCode);
	
	if(isNaN(String.fromCharCode(event.keyCode))) return false;
	if(event.srcElement.value.length >= Number(event.srcElement.maxLength)) return true;
	
	while(strValor.indexOf("/") != -1) strValor = strValor.replace("/","");
	while(strValor.indexOf(" ") != -1) strValor = strValor.replace(" ","");
	while(strValor.indexOf(":") != -1) strValor = strValor.replace(":","");
	
	for(var intContador = 0; intContador < strValor.length; intContador++)
		if(arrData[strSaida.length] == "")
			strSaida += strValor.substr(intContador,1)
		else
		{
			strSaida += arrData[strSaida.length];
			intContador--;
		}

	event.srcElement.value = strSaida;
	return false;
}