$( function(){
    $.fn.jqCidade = function( options )  {
        var opts = $.extend({
            id: "cidade",
            inicial: ''
        }, options);

        return this.each(function(){
            $("#" + opts.id).attr("disabled","disabled");
            if ( $(this).val() != null ) {
                $.ajax({
                    type: "GET",
                    url: "/xmldata/" + ($(this).val()).toLowerCase() + ".xml",
                    dataType: "xml",
                    success: function(xml) {
                        // limpa o combo de cidade
                        $("#"+opts.id+" option:not(:first)").remove();
                        $(xml).find("cid").each(function(){
                            select = ( $(this).attr('cod') == opts.inicial ) ? " selected=\"selected\"": "";
                            $("#"+opts.id).append("<option value=\"" + $(this).attr('cod') + "\"" + select + ">" + $(this).text() + "</option>");
                        }); //close each(
                        $("#"+opts.id).removeAttr("disabled");
                    }
                });
            }
      });
   }
});