<HTML>
<HEAD>
<TITLE>Make Uppercase</TITLE>
<SCRIPT language="javascript">
function canAcceptCommand(){
//Get the DOM of the current document
var theDOM = dw.getDocumentDOM();
//Get the offsets of the selection
var theSel = theDOM.getSelection();
//Get the selected node
var theSelNode = theDOM.getSelectedNode();
//Get the children of the selected node
var theChildren = theSelNode.childNodes;
//If the selection is not an insertion point,and either the selection
//or its first child is a text node,return true.
return (theSel[0] != theSel[1] && (theSelNode.nodeType == Node.TEXT_NODE || theChildren[0].nodeType == Node.TEXT_NODE));
}

function changeToUpperCase(){
//Get the DOM again
var theDOM = dw.getDocumentDOM();
//Get the offsets of the selection
var theSel = theDOM.getSelection();
//Get the outerHTML of the HTML tag (the entire contents of the document)
var theDocEl = theDOM.documentElement;
var theWholeDoc = theDocEl.outerHTML;
//Extract the selection
var selText = theWholeDoc.substring(theSel[0],theSel[1]);
//Re-insert the modified selection into the document
theDocEl.outerHTML = theWholeDoc.substring(0,theSel[0]) + selText.toUpperCase() + theWholeDoc.substring(theSel[1]);
//Set the selection back to where it was when you started
theDOM.setSelection(theSel[0],theSel[1]);
}
</SCRIPT>
</HEAD>
<BODY onLoad="changeToUpperCase()">

</BODY>
</HTML>
