function defineWord(word, callback) {
  var url = "http://tfd.com";
  var params = Utils.paramsToString({
    word: word
  });

  Utils.ajaxGet(url + params, function(xml) {
    CmdUtils.loadJQuery( function(jQuery) {
      var text = jQuery(xml).find("#MainTxt table :first").html();
      callback(text);
    });
  });
}

CmdUtils.CreateCommand({
  names: ["tfd"],
  description: "Gives the meaning of a word.",
  help: "Try issuing &quot;tfd aglet&quot;",
  homepage: "http://onurgu.blogspot.com/",
  author: { name: "Onur Gungor"},
  license: "GPL - borrowed from \"define\" command.",
  icon: "http://www.tfd.com/favicon.ico",
  arguments: [{role: "object", nountype: noun_arb_text, label: "word"}],
  execute: function( args ) {
    var word = args.object.text;
    Utils.openUrlInBrowser( "http://tfd.com/" + escape(word) );
  },
  preview: function( pblock, args ) {
    var word = args.object.text;
    if (word.length < 2)
      pblock.innerHTML = "Gives the definition of a word.";
    else {
      pblock.innerHTML = "Gives the definition of the word " + word + ".";
      defineWord( word, function(text){
        pblock.innerHTML = text;
      });
    }
  }
});
