// Copyright 1999 Macromedia, Inc. All rights reserved.

   function receiveArguments()
   {
      if (dw.constructor.gPrimaryEditorURL != "")
	  {
		 var selection = dw.getSelection();
    	 var node      = dw.offsetsToNode( selection[0], selection[1] );
    	 var imageSrc  = node.getAttribute( "src" );
		 var fullPath = getFullPath(imageSrc);
		 dw.openWithImageEditor(fullPath, dw.constructor.gPrimaryEditorURL);
	  }
	  return true;
   }

   function canAcceptCommand()
   {
	  var selection = dw.getSelection();
      var node      = dw.offsetsToNode( selection[0], selection[1] );
      var imageSrc  = node.getAttribute( "src" );

	  if (selection && node && imageSrc)
	  {
	  	var primaryEditorArray = dw.getPrimaryExtensionEditor(imageSrc);
		if (primaryEditorArray.length > 1)
		  return true;
		else
		  return false;
	  }
	  else
		return false;
   }

   function setMenuText()
   {
	  var selection = dw.getSelection();
      var node      = dw.offsetsToNode( selection[0], selection[1] );
      var imageSrc  = node.getAttribute( "src" );
	  var fullPath = getFullPath(imageSrc);

	// get the primary external editor for the selected item
	  var primaryEditorArray = dw.getPrimaryExtensionEditor(fullPath);
	  if (primaryEditorArray.length == 1)
	  	 return MENU_EditImage;
	  else
	  {
	  	dw.constructor.gPrimaryEditorName = primaryEditorArray[0];
	  	dw.constructor.gPrimaryEditorURL = primaryEditorArray[1];
		return MENU_EditWith + " " + primaryEditorArray[0];
	  }
   }
