/*function addSector(id){
  return $.ajax({
    type: 'GET',
    url: '/organizacion/sector?id='+id,
    async: false
  }).responseText;
}*/

function addCiudad(id){
  return $.ajax({
    type: 'GET',
    url: '/organizacion/ciudad?id='+id,
    async: false
  }).responseText;
}

/*function SectorOrganizacion(val){
  $('#organizacion_id_sector').replaceWith(addSector(val));
}*/

function CiudadOrganizacion(val){
  $('#organizacion_id_ciudad').replaceWith(addCiudad(val));
  //$('#organizacion_id_sector').replaceWith('<select name="organizacion[id_sector]" id="organizacion_id_sector"><option value="" selected="selected">-- Sector --</option></select>');
}

function addEstado(id){
  return $.ajax({
    type: 'GET',
    url: '/organizacion/estado?id='+id,
    async: false
  }).responseText;
}

$(document).ready(function(){
  $('#organizacion_id_pais').change(function(e){
    e.preventDefault();
    $('#organizacion_id_estado').replaceWith(addEstado($(this).val()));
	$('#organizacion_id_ciudad').replaceWith('<select name="organizacion[id_ciudad]" id="organizacion_id_ciudad"><option value="" selected="selected">-- Ciudad --</option></select>');
	//$('#organizacion_id_sector').replaceWith('<select name="organizacion[id_sector]" id="organizacion_id_sector"><option value="" selected="selected">-- Sector --</option></select>');
  });
  
  $('#usuario_id_pais').change(function(e){
    e.preventDefault();
    $('#usuario_id_estado').replaceWith(addEstadoRegistro($(this).val()));
  });
});

function addEstadoRegistro(id){
  return $.ajax({
    type: 'GET',
    url: '/usuario/estado?id='+id,
    async: false
  }).responseText;
}


