function wordCount() {	

alert("dw="+dw);
alert("dr="+dreamweaver);
	var doc = dw.getActiveWindow();	
	var offsets = doc.getSelection();
	var docHTML = doc.documentElement.outerHTML;
	var text = docHTML.substring(offsets[0], offsets[1]);
	if (text.length == 0) {
		text = docHTML;
	}
	
	text = text.replace(/<[^>]+>/g, "");	// eliminate all tags	
	text = text.replace(/&nbsp;/g, " ");	// replace all &nbsp; by a single whitespace char
	text = text.replace(/&[^;]+;/g, "a");	// replace all entities by a single character
	
	var words = text.match(/\w\b/g).length;
	text = text.replace(/\s/g, "");	// kill all whitespaces
	var chars = text.length;
	
	document.getElementsByTagName("span").item(0).innerHTML = words;
	document.getElementsByTagName("span").item(1).innerHTML = chars;
}

/*
 * this function is called to determine the buttons to display.
 * returns an array of button type and action pairs.
 */
function commandButtons() {
  var retArr = new Array(BTN_OK, "window.close()"); 
  return retArr;
}
