// JScript source code
function oldcleancode(controlname) {
	if (confirm('Clean up HTML?')){
		var DHTMLSafe=aeObjects[controlname];
		var code = DHTMLSafe.DOM.body.innerHTML
		// removes all Class attributes on a tag eg. '<p class=asdasd>xxx</p>' returns '<p>xxx</p>'
		code = code.replace(/<([\w]+) class=Mso([^ |>]*)([^>]*)/gi, "<$1$3");
		// removes all style attributes eg. '<tag style="asd asdfa aasdfasdf" something else>' returns '<tag something else>'
		code = code.replace(/<([\w]+) style="([^"]*)"([^>]*)/gi, "<$1$3");
		// gets rid of all xml stuff... <xml>,<\xml>,<?xml> or <\?xml>
		code = code.replace(/<\\?\??xml[^>]>/gi, "");
			// get rid of ugly colon tags <a:b> or </a:b>
		code = code.replace(/<\/?\w+:[^>]*>/gi, "");
		// removes all empty <p> tags
		code = code.replace(/<p([^>])*>(&nbsp;)*\s*<\/p>/gi,"");
		// removes all empty span tags
		code = code.replace(/<span([^>])*>(&nbsp;)*\s*<\/span>/gi,"");
		DHTMLSafe.DOM.body.innerHTML = code;
		return true;
	}
}


function cleancode(controlname){
	if (confirm('Clean up HTML?')){
		var DHTMLSafe=aeObjects[controlname];
		
		var html = DHTMLSafe.DOM.body.innerHTML;
		html = html.replace(/class=bodytext/g, "xclass=bodytext");
		html = html.replace(/class=bullettext/g, "xclass=bullettext");		
		DHTMLSafe.DOM.body.innerHTML = html;
				
//		var code = DHTMLSafe.DOM.body.innerHTML
		var editBody = DHTMLSafe.DOM.body;		
		/* clean up word content */
		// loop through all tags and remove all class and style attributes
//		var editBody = document.all.tbContentElement.DOM.body;
		for (var intLoop = 0; intLoop < editBody.all.length; intLoop++) {
			el = editBody.all[intLoop];
//			alert('loop' + intLoop + ' : ' + el.attributes.length);
//			for (i=0; i < el.attributes.length; i++){
//				alert(el.attributes.item(i).nodeName);
//					if ((el.attributes.item(i).value != 'bullettext') && (el.attributes.item(i).value != 'bodytext')) {
//						alert(el.attributes.item(i).nodeName);
//						el.removeAttribute("className","",0);
//						if (el.attributes.item(i).nodeName == 'className') {
//							el.attributes.item(i).removeAttribute;
//						}
//					}
//			}			
			el.removeAttribute("className","",0);
			el.removeAttribute("style","",0);
			el.removeAttribute("font","",0);			
		}

		var html = DHTMLSafe.DOM.body.innerHTML;
		html = html.replace(/<o:p>&nbsp;<\/o:p>/g, ""); // Remove all instances  of <o:p>&nbsp;</o:p>
		html = html.replace(/<o:p>&nbsp;<\/o:p>/g, ""); // Remove all instances  of <o:p>&nbsp;</o:p>		
		html = html.replace(/o:/g, ""); // remove all o: prefixes
		html = html.replace(/<st1:.*?>/g, ""); // remove all SmartTags (from Word XP!)
		html = html.replace(/<p([^>])*>(&nbsp;)*\s*<\/p>/gi,"");
		html = html.replace(/<span([^>])*>(&nbsp;)*\s*<\/span>/gi,"");
		html = html.replace(/<(font)[^>]*>/gi,"");
		html = html.replace(/<(\/font)>/gi, "");
		html = html.replace(/<(span)[^>]*>/gi,"");
		html = html.replace(/<(\/span)>/gi, "");		

		// pop my new html content back into the editor
		//document.all.tbContentElement.DOM.body.innerHTML = html;
		html = html.replace(/xclass="bodytext"/g, 'class=bodytext');
		html = html.replace(/xclass="bullettext"/g, 'class=bullettext');		
		html = html.replace(/xclass=bodytext/g, 'class=bodytext');
		html = html.replace(/xclass=bullettext/g, 'class=bullettext');		
		DHTMLSafe.DOM.body.innerHTML = html;
	}
} 

function converttotext(controlname) {
	if (confirm('Convert to text?')){
		var DHTMLSafe=aeObjects[controlname];
		DHTMLSafe.DOM.body.innerHTML=DHTMLSafe.DOM.body.innerText;
	}
}