// JavaScript Document
var xmlhttp_state_content3;

function busca_mv(estado)
{
	//alert("edo: "+estado);
	xmlhttp_state_content3 = GetXmlHttpObject();
	if(xmlhttp_state_content3==null)
	{
		alert("Browser does not support HTTP Request");
		return;
	}
	var url_content = "../scripts/obtenerMun.php";
	url_content = url_content + "?estado=" + estado;
	url_content = url_content + "&sid=" + Math.random(); 
	xmlhttp_state_content3.onreadystatechange = stateChanged_data_content3;
	xmlhttp_state_content3.open("GET", url_content, true);
	xmlhttp_state_content3.send(null);
}

function stateChanged_data_content3()
{
	if(xmlhttp_state_content3.readyState==4)
	{
		sel = document.createElement('SELECT');
		sel.name = "municipio_vict";
		sel.id = "municipio_vict";
		sel.style.width = "200px";
	
		document.getElementById('MN2').appendChild(sel);
		
		var datos = (xmlhttp_state_content3.responseText).split(",");
		//alert(datos.length);
		
		opcioncur = document.createElement('OPTION');
     	opcioncur.innerHTML = "Elige";
    	opcioncur.value = "";
		opcioncur.selected = "selected"
     	document.getElementById('municipio_vict').appendChild(opcioncur);
			
		for(j=0; j<datos.length-1; j=j+2)
		{
			opcioncur = document.createElement('OPTION');
			opcioncur.value = datos[j];
     		opcioncur.innerHTML = datos[j+1];
     		document.getElementById('municipio_vict').appendChild(opcioncur);
		}
	}
}

function GetXmlHttpObject()
{
	var req = null;
	// branch for native XMLHttpRequest object
	if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		try {
			req = new XMLHttpRequest();
		} catch(e) {
			req = null;
	}
	// branch for IE/Windows ActiveX version
	} else if(window.ActiveXObject) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				req = null;
			}
		}
	}
	return req;
}
