function NuevoAjax(){
        var xmlhttp=false;
        try{
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
                try{
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }catch(E){
                        xmlhttp = false;
                }
        }

        if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
                xmlhttp = new XMLHttpRequest();
        }
        return xmlhttp;
}

function ciudades(){
        var content;
        var dpto;
        content = document.getElementById('ciudad');
		dpto	= document.getElementById('dpto');
		idDpto = dpto.value;
		url="ciudades.php?id="+idDpto;
        //creamos el objeto XMLHttpRequest
        ajax=NuevoAjax(); 
        //peticionamos los datos, le damos la url enviada desde el link
        ajax.open("GET", url,true); 
        ajax.onreadystatechange=function(){
                if(ajax.readyState==1){
                        content.innerHTML = "<div style=\"color:#FF0000;\">Cargando...</div>"; 
                }else if(ajax.readyState==4){
                        if(ajax.status==200){
                                //mostramos los datos dentro de la celda
                                content.innerHTML = ajax.responseText; 
                                //preloader.style.background = "url('loaded.gif') no-repeat";
                        } else if(ajax.status==404){
                                content.innerHTML = "No existe municipio";
                        }else{
                                //mostramos el posible error
                                //preloader.innerHTML = "Error:".ajax.status; 
                        }
                }
        }
        ajax.send(null);
}	