// Copyright 2007 Adobe Systems Incorporated.  All rights reserved.

<html>
<head>

<script language="javascript">

	function receiveArguments()
	{
		// By convention (for selected image nodes): 
		// Passing attribute WIDTH with empty value evokes Reset Size (to dimensions of web image)
		// (passing attribute HEIGHT with empty value evokes Reset Size To Dimensions Of Original Asset)
		dw.getDocumentDOM().setAttributeWithErrorChecking('WIDTH', '')
		
		return true;
	}

	function canAcceptCommand()
	{
		var returnValue = false;
		var selection   = dw.getSelection();
		if (!selection)
			return false;
			
		var node = dw.offsetsToNode(selection[0], selection[1]);
		if (!node)
			return false;
			
		var imageAttrWidth = node.getAttribute("width");
		var imageAttrHeight = node.getAttribute("height");
		var imageSrc = node.getAttribute("src");
		if ((!imageSrc) || (!imageAttrWidth) || (!imageAttrHeight))
			return false;
			
		var fullPath  = getFullPath(imageSrc);

		var imageWidth = dw.getImageWidth(fullPath);
		var imageHeight = dw.getImageHeight(fullPath);

		if ((imageWidth > 0) && (imageHeight > 0))
		{
			if ((imageAttrWidth != imageWidth) || (imageAttrHeight != imageHeight))
				returnValue = true;		
		}

		return returnValue;

	}

</script>
</head>
<body>
</body>
</html>
