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

   function receiveArguments()
   {
      var selItems = site.getSelection();
	  if (selItems.length > 1)
	  {
	  	site.open();
		return true;
	  }
      else if (dw.constructor.gPrimaryEditorURL != "")
	  {
		 dw.openWithApp(site.getSelection(), dw.constructor.gPrimaryEditorURL);
		 return true;
	  }
	  else
	  {
	     site.open();
		 return true;
	  }
   }

   function canAcceptCommand()
   {
      var selItems = site.getSelection();
	  if (selItems.length == 0)
	  	return false;
	  else if (selItems.length > 1)
	  	return site.canOpen();
	  else if (DWfile.exists(selItems[0]))
	    return (DWfile.getAttributes(selItems[0]) != "D");
	  else
		return false;
   }

   function setMenuText()
   {
	  var selItems = site.getSelection();
	  if (selItems.length > 1 || selItems.length == 0)
	     return "";

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