FreemakeConverter.onFirefoxLoad = function(event) {
  document.getElementById("contentAreaContextMenu")
          .addEventListener("popupshowing", function (e){ FreemakeConverter.showFirefoxContextMenu(e); }, false);
};

FreemakeConverter.showFirefoxContextMenu = function(event) {
  // show or hide the menuitem based on what the context menu is on
  document.getElementById("context-FreemakeConverter").hidden = gContextMenu.onImage;
};

FreemakeConverter.onToolbarButtonCommand = function(event) {
	var process = Components.classes["@mozilla.org/process/util;1"]
                    .createInstance(Components.interfaces.nsIProcess);
					
	var file =
      Components.classes["@mozilla.org/file/local;1"].
      createInstance(Components.interfaces.nsILocalFile);
	
	file.initWithPath("c:\\Program Files\\Freemake\\Freemake Video Converter\\BrowserPlugin\\MiddleChainClient.exe");		
	
	var args = new Array();
	args[0] = content.document.location.href;
	args[1] = "cookie";
	args[2] = "FVC";		
			
	try
	{
	process.init(file);
	}
	catch(e)
	{
		file.initWithPath("c:\\Program Files (x86)\\Freemake\\Freemake Video Converter\\BrowserPlugin\\MiddleChainClient.exe");
		process.init(file);
	}
	process.runAsync(args, args.length);
}

window.addEventListener("load", FreemakeDownloader.onFirefoxLoad, false);