

function openUrl(url, postData) {
  var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"]
    .getService(Components.interfaces.nsIWindowMediator);
  var browserWindow = windowManager.getMostRecentWindow("navigator:browser");
  var browser = browserWindow.getBrowser();
	
  if(browser.mCurrentBrowser.currentURI.spec == "about:blank")
    browserWindow.loadURI(url, null, postData, false);
  else
    browser.loadOneTab(url, null, null, postData, false, false);
}

CmdUtils.CreateCommand({
  name: "movieshare",
  icon: "http://moviedemocracy.com/favicon.ico",
  homepage: "http://myouvies.com/",
  author: { name: "Ken Knutson", email: "ken@myouvies.com"},
  contributors: ["Ken Knutson"],
  license: "MPL",
  description: "Allows easy submissions to moviedemocracy.com",
  help: "Highlight an area of text, issue the movieshare command and the current page will be sent to moviedemocracy.com for submission.",
  
  preview: "Share this article at moviedemocracy.com, the web's movie-specific social news website",
  execute: function() {
    try {
      var document = context.focusedWindow.document;
      description = escape(CmdUtils.getSelection());
      headline = document.title;
      url = document.location;
      sendto = 'http://moviedemocracy.com/contribute.php?step=2&url='+url+'&headline='+headline+'&des='+description;
      openUrl(sendto);

    } catch(e) {
      displayMessage('oops');
    }
  }
})