/*####################################################################*/
/*# EDITOR OBJECT #*/ 

/*####################################################################*/
function editorObject()
{
	this.oEditorDiv = null;
	this.paletteIsFor = null;
	this.toggleMode = 0;
}
/*####################################################################*/
/*# EDITOR FUNCTIONS #*/
/*####################################################################*/

function makeActive()
{
	lastActiveWindow.lastEditor = this;
}
function getValue()
{
	if(this.toggleMode == 1) this.toggleIt();
	if(this.oEditorDiv.textBBArea.contentWindow.document.body.innerHTML == '')
	{
		return this.oEditorDiv.htmlViewer.firstChild.innerText;
	}
	else
	{
		return this.oEditorDiv.textBBArea.contentWindow.document.body.innerHTML;
	}
}
function insertValue(theValue)
{
	this.oEditorDiv.textBBArea.contentWindow.document.body.innerHTML = theValue;
}

function createEditor(xmlSheetPath,editorWidth,editorHeight,uploadLoc)
{
	this.uploadLoc = uploadLoc;
	lastActiveWindow.lastEditor = this;

	// generate editor HTML	
	var editorHTML = '\
		<table class="oEditorHeader" style="width: '+editorWidth+'; height: '+editorHeight+';" cellspacing="0" cellpadding="0" border="0" onmouseover="if(!document.all) lastActiveWindow.lastEditor = this.parentNode.oRef;">\
		<tbody>\
			<tr style="height:65px; border-bottom: solid 1px #cccccc;">\
				<td valign="top">\
					<div id="oEditorToolBar" style="padding: 3px 3px 0px 3px; ">\
						<!-- Icons will go here after transform -->\
					<\/div>\
					<div style="display: none; position: absolute; width:150px; height:inherit;z-index: 999" onmouseover="this.style.display = \'inline\';" onmouseout="this.style.display = \'none\';">\
						<!-- Pallette will go here after transform -->\
						<div id="fontArea"></div>\
					<\/div>\
					<div style="display: none; position: absolute; width:auto; height:auto; z-index: 999; background-color:#f0f0f0; border:1px solid #cccccc" onmouseover="this.style.display = \'inline\';" >\
						<table>\
						<tbody>\
						<tr>\
							<td><label class="link_label">Link<\/label></td><td><input class="link_input_box" type=text name="link_input" id="link_input"></td>\
						</tr>\
						<tr>\
							<td>\
								<label class="link_label">New window</label>\
							</td>\
							<td>\
								<input type="checkbox" name="new_window" id="new_window">\
								<button type="button" id="button_add_link" onclick="lastActiveWindow.lastEditor.addLinkToText();">\
									<span>Add Link<\/span>\
								<\/button>\
								<button type="button" id="button_add_link" onclick="this.parentNode.parentNode.parentNode.parentNode.parentNode.style.display = \'none\'">\
									<span>Cancel<\/span>\
								<\/button>\
							<\/td>\
						</tr>\
						</tbody>\
						</table>\
					<\/div>\
					<div id="oEditorToolBar2" style="position:relative; margin: 3px; z-index:1">\
					<\/div>\
				<\/td>\
			<\/tr>\
			<tr style="height:99%;">\
				<td valign="top" style="height:99%;">\
					<iframe style="background: #ffffff; height:100%; width:100%; vertical-align:top;" onfocus="lastActiveWindow.lastEditor = this.parentNode.parentNode.parentNode.parentNode.parentNode.oRef;" onblur="/*selection2 = this.contentWindow.document.selection.createRange(); selection2.select();*/" frameborder="0"></iframe>\
				<\/td>\
			<\/tr>\
		<\/tbody>\
		<\/table>\
		<div style="display: none; margin-left: -1px;" id="htmlviewerCI"><textarea style="width: '+editorWidth+'; height: '+editorHeight+';"></textarea></div>\
		<div style="display: none; position: absolute; width: 100%; height: 800px; margin-top: -200px; z-index: 3;"><img src="../images/spacer.gif" style="width: 100%; height: 100%;" /></div>\
		<iframe style="display: none;" name="editorupdater"></iframe>\
		<div class="oEditorFooter" style="padding: 2px;" >\
			<div id="toggleButton" style="cursor: default; text-align: center; width: 100px; padding: 2px; border: solid 1px #cccccc;" onclick="lastActiveWindow.lastEditor.toggleIt(this);">View HTML Source</div>\
		<\/div>\
		';
	
	this.oEditorDiv = document.createElement('div');
	this.oEditorDiv.className = 'oEditorBorder';
	//this.oEditorDiv.style.border = 'solid 1px #cccccc';
	
	this.oEditorDiv.innerHTML = editorHTML;
	
	this.oEditorDiv.enableIcons = this.oEditorDiv.getElementsByTagName("DIV")[0];
	this.oEditorDiv.textBBArea = this.oEditorDiv.getElementsByTagName("IFRAME")[0];
	
	this.oEditorDiv.pallette = this.oEditorDiv.getElementsByTagName("DIV")[1];
	this.oEditorDiv.cover = this.oEditorDiv.getElementsByTagName("DIV")[2];
	this.oEditorDiv.hyperlink = this.oEditorDiv.getElementsByTagName("DIV")[3];
	this.oEditorDiv.enableFont = this.oEditorDiv.getElementsByTagName("DIV")[4];
	this.oEditorDiv.wyswigViewer = this.oEditorDiv.getElementsByTagName("TABLE")[0];
	this.oEditorDiv.htmlViewer = getChildElementById(this.oEditorDiv,'DIV','htmlviewerCI');
	
	
	// transform icon xml sheet with xsl sheet
	// Begin transform
	
	// Icon elements
	this.xmlPreloadDataEditorIcons = loadXMLDoc(xmlSheetPath, false);
	this.xslPreloadDataEditorIcons = loadXMLDoc(window.location.protocol+"//"+window.location.hostname+top.app_path+'/pcrunch-api/oEditor/editor.xsl', false);


	// Font elements
	this.xmlPreloadFontItems = loadXMLDoc(window.location.protocol+"//"+window.location.hostname+top.app_path+'/pcrunch-api/oEditor/fonts.xml', false);
	this.xslPreloadFontItems = loadXMLDoc(window.location.protocol+"//"+window.location.hostname+top.app_path+'/pcrunch-api/oEditor/fonts.xsl', false);
	
	var newHTML = "";
	var fontsHTML = "";


	switch(top.getBrowser())
	{
		case "msie":
			// Icon elements
			newHTML = this.xmlPreloadDataEditorIcons.transformNode(this.xslPreloadDataEditorIcons);
			this.oEditorDiv.enableIcons.innerHTML = newHTML;

			// Font names
			fontsHTML = this.xmlPreloadFontItems.transformNode(this.xslPreloadFontItems);
			this.oEditorDiv.enableFont.innerHTML = fontsHTML;		
		break;
		
		case "mozilla":
			// Icon elements
			var processor = new XSLTProcessor();
			processor.importStylesheet(this.xslPreloadDataEditorIcons);
			newHTML = processor.transformToFragment(this.xmlPreloadDataEditorIcons, document);
			this.oEditorDiv.enableIcons.appendChild(newHTML);

			// Font names
			var processorFonts = new XSLTProcessor();
			processorFonts.importStylesheet(this.xslPreloadFontItems);
			fontsHTML = processorFonts.transformToFragment(this.xmlPreloadFontItems, document);
			this.oEditorDiv.enableFont.appendChild(fontsHTML);				


		case "safari":
			// Icon elements
			var processor = new XSLTProcessor();
			processor.importStylesheet(this.xslPreloadDataEditorIcons);
			newHTML = processor.transformToFragment(this.xmlPreloadDataEditorIcons, document);
			this.oEditorDiv.enableIcons.innerHTML = newHTML.xml;

			// Font names
			var processorFonts = new XSLTProcessor();
			processorFonts.importStylesheet(this.xslPreloadFontItems);
			fontsHTML = processorFonts.transformToFragment(this.xmlPreloadFontItems, document);
			this.oEditorDiv.enableFont.innerHTML = fontsHTML.xml;
		
		break;
	
	
	}// end Transform
	
	
	/* special case icons that cannot be generated */
	var imageIconHTML = '\
		<form action="'+lastActiveWindow.lastEditor.uploadLoc+'" enctype="multipart/form-data" method="post" class="fileUpload" target="editorupdater"><div class="fileinputs" style="overflow: hidden;"><input name="userfile" type="file" class="file hidden" noscript="true" onchange="len(this.parentNode.parentNode); this.parentNode.parentNode.submit();" />\
			<div class="fakefile">\
				<input />\
				<img src="../pcrunch-api/oEditor/images/default/dx_image.gif" alt="Browse" style="position: absolute; left: 0px; z-index:5;" />\
			<\/div>\
		<\/div>\
		<\/form>\
	';
	var imageIcon = document.createElement('span');
	imageIcon.style.position = 'absolute';
	imageIcon.innerHTML = imageIconHTML;
	imageIcon.style.border = 'solid 1px #cccccc';
	imageIcon.style.paddingLeft = '1px';
	imageIcon.style.paddingRight = '4px';
	imageIcon.style.overflow = 'hidden';
	if(document.all) imageIcon.style.height = '24px';
	else imageIcon.style.height = '22px';
	imageIcon.onmouseover = function() { if(lastActiveWindow && lastActiveWindow.lastEditor) lastActiveWindow.lastEditor.overIt(imageIcon) }
	imageIcon.onmouseout = function() { if(lastActiveWindow && lastActiveWindow.lastEditor) lastActiveWindow.lastEditor.offIt(imageIcon) }
	imageIcon.onmousedown = function() { if(lastActiveWindow && lastActiveWindow.lastEditor) lastActiveWindow.lastEditor.offIt(imageIcon) }
	imageIcon.onmouseup = function() { if(lastActiveWindow && lastActiveWindow.lastEditor) lastActiveWindow.lastEditor.releasedIt(imageIcon) }
	this.oEditorDiv.enableIcons.appendChild(imageIcon);

	// transform pallette xml sheet with xsl sheet

	this.xmlPreloadDataEditorPallette = loadXMLDoc('../pcrunch-api/oEditor/editor_pallette.xml', false);
	this.xslPreloadDataEditorPallette = loadXMLDoc('../pcrunch-api/oEditor/editor_pallette.xsl', false);

	if (window.ActiveXObject)
	{
		var newHTML = this.xmlPreloadDataEditorPallette.transformNode(this.xslPreloadDataEditorPallette);
		this.oEditorDiv.pallette.innerHTML = newHTML;
	}
	else if(document.implementation && document.implementation.createDocument)
	{
		var processor = new XSLTProcessor();
		processor.importStylesheet(this.xslPreloadDataEditorPallette);
		newHTML = processor.transformToFragment(this.xmlPreloadDataEditorPallette, document);

		if (top.getBrowser() == 'safari')
			this.oEditorDiv.pallette.innerHTML = newHTML.xml;
		else
			this.oEditorDiv.pallette.appendChild(newHTML);
	}
	// end Transform
	this.oEditorDiv.oRef = this;	
}

function overrideFonts(xmlSheetPath)
{
	// transform font xml sheet with xsl sheet
	this.xmlPreloadDataEditorFont = loadXMLDoc("../pcrunch-api/dx_list/sortdata.xsl", false);
	this.xslPreloadDataEditorFont = loadXMLDoc('../pcrunch-api/oEditor/fonts.xsl', false);

	if (window.ActiveXObject)
	{
		var newHTML = this.xmlPreloadDataEditorFont.transformNode(this.xslPreloadDataEditorFont);
		this.oEditorDiv.enableFont.innerHTML = newHTML;
	}
	else if(document.implementation && document.implementation.createDocument)
	{
		var processor = new XSLTProcessor();
		processor.importStylesheet(this.xslPreloadDataEditorFont);
		newHTML = processor.transformToFragment(this.xmlPreloadDataEditorFont, document);
		
		if (top.getBrowser() == 'safari')
			this.oEditorDiv.enableFont.innerHTML = newHTML.xml;
		else
			this.oEditorDiv.enableFont.appendChild(newHTML);
	}
	// end Transform
}

function editMode() 
{
	this.oEditorDiv.textBBArea.contentWindow.document.designMode = "on";
	this.oEditorDiv.textBBArea.contentWindow.document.onkeydown = imageDialog;
	this.oEditorDiv.textBBArea.contentWindow.document.onmouseup = imageDialog;
}

// button behaviours
function overIt(obj)
{
	obj.style.borderColor = '#000000';
	obj.style.backgroundColor = '#ffdda6';
	obj.style.cursor = 'default';	
}
function offIt(obj)
{
	obj.style.borderColor = '#D6D3CE';  
	obj.style.backgroundColor = '#f0f0f0';
}
function clickedIt(obj)
{
	obj.style.backgroundColor = '#FFFFFF';
}
function releasedIt(obj)
{
    	obj.style.backgroundColor = '';
}

// Button action methods
function boldIt() 
{
	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('bold', false, null);
}
function italicIt() 
{ 
	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('italic', false, null); 
}
function underlineIt() 
{ 
	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('underline', false, null); 
}
function leftIt()
{ 
	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('justifyleft', false, null); 
}
function centreIt()
{ 
	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('justifycenter', false, null); 
}
function rightIt()
{ 
	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('justifyright', false, null); 
}
function numList()
{ 
	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('insertorderedlist', false, null); 
}
function bulletList()
{ 
	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('insertunorderedlist', false, null); 
}
function fgColour()
{
    	var fCol = prompt('Enter colour coz have to do colour thing', '');
    
    	if(fCol != null)
      	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('forecolor', false, fCol);
}



function getRangeObject(selectionObject) 
{
	if (selectionObject.getRangeAt)
		return selectionObject.getRangeAt(0);
	else { // Safari!
		var range = document.createRange();
		range.setStart(selectionObject.anchorNode,selectionObject.anchorOffset);
		range.setEnd(selectionObject.focusNode,selectionObject.focusOffset);
		return range;
	}
	
	// Should never get to here but if it does return null (FF moan)
	return null;
}

function linkIt()
{

	// Hide pallette divs...
	Editor.oEditorDiv.pallette.style.display = 'none';
	
	// Show our hyperlink div
	Editor.oEditorDiv.hyperlink.style.marginTop = '0px';
	Editor.oEditorDiv.hyperlink.style.marginLeft = '227px';
	Editor.oEditorDiv.hyperlink.style.display = 'inline';
	
	// Capture selection
	var userSelection;

	switch(top.getBrowser())
	{
		
		case "mozilla":
		case "safari":
			userSelection = lastActiveWindow.lastEditor.oEditorDiv.textBBArea.contentWindow.getSelection();
			top.rangeObject = getRangeObject(userSelection);
			top.currentSelection = top.rangeObject.commonAncestorContainer.parentNode;

			//check if it is an external link

			//if it is an external link - extract the url then set the tick box as ticked

			//if it is not an external link set tick box to blank
			document.getElementById('new_window').checked = false;
			if(top.currentSelection.tagName == "A") { document.getElementById('link_input').value = top.currentSelection.href; }
			else { document.getElementById('link_input').value = ""; }
		break;
		
		case "msie":
		case "opera":
			userSelection = lastActiveWindow.lastEditor.oEditorDiv.textBBArea.contentWindow.document.selection.createRange();

			//check if it is an external link

			//if it is an external link - extract the url then set the tick box as ticked

			//if it is not an external link set tick box to blank
			document.getElementById('new_window').checked = false;
			var tempHref = "";
			top.currentSelection = userSelection;
			var tempHtmlString = userSelection.htmlText.toString();
			var tempStartString = tempHtmlString.indexOf('http://');
			var tempEndString = tempHtmlString.indexOf('">');
			if(tempStartString != -1 && tempEndString != -1){
				tempHref = tempHtmlString.substring(tempStartString,tempEndString);

			}
			else
			{
				// there wasnt a previous link
				tempHref = "";
			}
			document.getElementById('link_input').value = tempHref;
		break;
	}

}


function addLinkToText()
{
	rawLink = document.getElementById('link_input').value;

	if(rawLink.length > 0)
	{		
		var currentText = "";
		// Check whether user has added http:// or ../ to the url
		if((rawLink.indexOf("://") == "-1") && (rawLink.indexOf("../") == "-1")){
			currentText = "http://" + rawLink;
		}
		else{
			currentText = rawLink;
		}
		// Check whether checkbox is ticked
		newWindow = document.getElementById('new_window').checked;
		if(newWindow) currentText = "javascript: var url = window.open('"+currentText+"');";

		if(document.all)
		{
			 top.currentSelection.execCommand("CreateLink", false, currentText);
		}
		else
		{
			lastActiveWindow.lastEditor.oEditorDiv.textBBArea.contentWindow.document.execCommand("CreateLink", false, currentText);
		}	
		
		Editor.oEditorDiv.hyperlink.style.display = 'none';
	}	
}
function imageIt()
{
    	var imgSrc = prompt('Enter image location', '');
    
    	if(imgSrc != null)    
     	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('insertimage', false, imgSrc);
}
function ruleIt()
{
    	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('inserthorizontalrule', false, null);
}

function unDoIt()
{
    	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('undo', false, null);
}

function reDoIt()
{
    	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('redo', false, null);
}

function maximiseEditor()
{
	grabText = this.oEditorDiv.textBBArea.contentWindow.document.body.innerHTML;
	document.getElementById('maximiseWindow').innerHTML = document.getElementById('maxWrapper').innerHTML;
	document.getElementById('fontDialog').style.display = 'none';
	document.getElementById('maxWrapper').innerHTML = '';
	document.getElementById('wrapper').style.height = document.body.clientHeight;
	document.getElementById('textBBArea').style.width = '100%';
	document.getElementById('textBBArea').style.height = document.body.clientHeight - 40;

	setTimeout("document.getElementById('textBBArea').contentWindow.document.body.innerHTML = grabText",0);
	editMode();
	document.getElementById('maximiseWindow').style.display = 'inline';
	overIt(document.getElementById('maxIcon'));
}

function restoreOriginalEditor(originalSize)
{
	grabText = document.getElementById('textBBArea').contentWindow.document.body.innerHTML;
	
	document.getElementById('maximiseWindow').style.display = 'none';
	document.getElementById('fontDialog').style.display = 'none';
	document.getElementById('maxWrapper').innerHTML = document.getElementById('maximiseWindow').innerHTML;
	document.getElementById('maximiseWindow').innerHTML = '';
	document.getElementById('wrapper').style.height = originalSize;
	document.getElementById('textBBArea').style.height = originalSize;

	setTimeout("document.getElementById('textBBArea').contentWindow.document.body.innerHTML = grabText",0);
	editMode();
	offIt(document.getElementById('maxIcon'));
}

// Pallette Functions
function openPalette(command)
{
	// Hide hyperlink
	this.oEditorDiv.hyperlink.style.display = 'none';
	this.oEditorDiv.pallette.style.display = 'inline';
	this.paletteIsFor = command;
	lastActiveWindow.lastEditor = this.oEditorDiv.oRef;
}

function bgColour(colour)
{
        var bCol = colour;

        if(bCol != null)
	if(this.paletteIsFor == 'backcolor')
	{ 
		if(document.all)
		{
			this.oEditorDiv.textBBArea.contentWindow.document.execCommand('backcolor', false, bCol);
		}
		else 
		{
			this.oEditorDiv.textBBArea.contentWindow.document.execCommand('hilitecolor', false, bCol);
		}
	}
	else 
	{
		this.oEditorDiv.textBBArea.contentWindow.document.execCommand('forecolor', false, bCol);
	}
	this.oEditorDiv.pallette.style.display = 'none';
}

// Font Dialog stuff
function changeFont(fonte)
{
	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('FontName', false, fonte);
}

// new versions for new drop box
function changeFontThis(doc, currentFont)
{
	lastActiveWindow.lastEditor.oEditorDiv.textBBArea.contentWindow.document.execCommand('fontname', false, currentFont);
}
function changeFontSizeThis(doc, currentSize)
{
	lastActiveWindow.lastEditor.oEditorDiv.textBBArea.contentWindow.document.execCommand('fontsize', false, currentSize-0);
}
// end of new versions for new drop box

function changeFontSize(sizee)
{
	this.oEditorDiv.textBBArea.contentWindow.document.execCommand('FontSize', false, sizee);
}

function fontDialog()
{
        selection1 = this.oEditorDiv.textBBArea.contentWindow.document.selection.createRange();
}

function showFontDialog()
{
	document.getElementById('fontDialog').style.display = 'inline';
	overIt(document.getElementById('fontIcon'));
        offIt(document.getElementById('imageIcon'));
}

function hideFontDialog(originalHeight)
{
	document.getElementById('fontDialog').style.display = 'none';
	document.getElementById('wrapper').style.height = originalHeight;
	document.getElementById('textBBArea').style.height = originalHeight;

	offIt(document.getElementById('fontIcon'));
}

function imageDialog()
{
	try
	{
		selection1 = lastActiveWindow.lastEditor.oEditorDiv.textBBArea.contentWindow.document.selection.createRange();
	}
	catch(e)
	{
		//alert(e.message);	
	}
}

function disableIcons()
{
	document.getElementById('enableIcons').style.display = 'none';
	document.getElementById('disableIcons').style.display = 'inline';
}

function enableIcons()
{
	document.getElementById('enableIcons').style.display = 'inline';
	document.getElementById('disableIcons').style.display = 'none';
}

function plainText(theHTML)
{
	var returnedHTML = theHTML.replace(/(<([^>]+)>)/ig,'\n');
	return returnedHTML;
}

function convert2HTML(theHTML)
{
	theHTML = theHTML.replace(/\n/ig,'<br>');
	return theHTML;
}

function encodeHref(theHref)
{
	theHref = theHref.replace(/href=\"/ig,'href="http:\/\/@@ci');
	return theHref;
}

function toggleIt(obj)
{
	//debugger;


	if(this.toggleMode == 1)
	{
		// IE
		if(document.all)
		{
			this.oEditorDiv.wyswigViewer.style.display = 'inline';
			this.oEditorDiv.htmlViewer.style.display = 'none';
			this.oEditorDiv.textBBArea.contentWindow.document.body.innerHTML = this.oEditorDiv.htmlViewer.firstChild.innerText;
			//this.oEditorDiv.textBBArea.contentWindow.document.body.innerHTML = this.oEditorDiv.htmlViewer.firstChild.value;
			//this.oEditorDiv.textBBArea.contentWindow.document.write(this.oEditorDiv.htmlViewer.firstChild.value);
			selection1 = this.oEditorDiv.textBBArea.contentWindow.document.selection.createRange();
			document.getElementById('toggleButton').innerHTML = 'View HTML Source';
		}
		else // FF
		{
			this.oEditorDiv.textBBArea.contentWindow.document.body.innerHTML = this.oEditorDiv.textBBArea.contentWindow.document.body.textContent;
			document.getElementById('toggleButton').innerHTML = 'View HTML Source';
		}
		this.toggleMode = 0;
		if(obj)
		{
			this.offIt(obj);
			document.getElementById('oEditorToolBar').style.visibility = 'visible';
			document.getElementById('oEditorToolBar2').style.visibility = 'visible';
		}
	}
	else
	{
		// IE
		if(document.all)
		{
			this.oEditorDiv.wyswigViewer.style.display = 'none';
			this.oEditorDiv.htmlViewer.style.display = 'inline';
			if(this.oEditorDiv.textBBArea.contentWindow.document.body.innerHTML != '')
			this.oEditorDiv.htmlViewer.firstChild.value = this.oEditorDiv.textBBArea.contentWindow.document.body.innerHTML;
			document.getElementById('toggleButton').innerHTML = 'View HTML';


		} 
		else // FF
		{
			// Images do not appear unless a full path is specified so we specify it here for the sake of them appearing
			this.oEditorDiv.textBBArea.contentWindow.document.body.textContent = this.oEditorDiv.textBBArea.contentWindow.document.body.innerHTML;
			document.getElementById('toggleButton').innerHTML = 'View HTML';
		}

		this.toggleMode = 1;
		if(obj)
		{
			this.overIt(obj);
			document.getElementById('oEditorToolBar').style.visibility = 'hidden';
			document.getElementById('oEditorToolBar2').style.visibility = 'hidden';
		}
	}
}
function hideDivs()
{
	lastActiveWindow.lastEditor.oEditorDiv.hyperlink.style.display = 'none';
	lastActiveWindow.lastEditor.oEditorDiv.pallette.style.display = 'none';
}

function cleanWordContent(wordContent)
{

	wordDiv = document.createElement("DIV");
	wordDiv.innerHTML = wordContent;

	for (var i=0;i<wordDiv.all.length;i++)
	{
		wordDiv.all[i].removeAttribute("className","",0);
		wordDiv.all[i].removeAttribute("style","",0);
	}
	wordContent = wordDiv.innerHTML;
	wordContent = String(wordContent).replace(/<\\?\?xml[^>]*>/g,"");
	wordContent = String(wordContent).replace(/<\/?o:p[^>]*>/g,"");
	wordContent = String(wordContent).replace(/<\/?v:[^>]*>/g,"");
	wordContent = String(wordContent).replace(/<\/?o:[^>]*>/g,"");
	wordContent = String(wordContent).replace(/&nbsp;/g,"");//<p>&nbsp;</p>
	wordContent = String(wordContent).replace(/<\/?SPAN[^>]*>/g,"");
	wordContent = String(wordContent).replace(/<\/?FONT[^>]*>/g,"");
	wordContent = String(wordContent).replace(/<\/?STRONG[^>]*>/g,"");
	wordContent = String(wordContent).replace(/<\/?P[^>]*><\/P>/g,"");
	wordContent = String(wordContent).replace(/<\/?H1[^>]*>/g,"");
	wordContent = String(wordContent).replace(/<\/?H2[^>]*>/g,"");
	wordContent = String(wordContent).replace(/<\/?H3[^>]*>/g,"");
	wordContent = String(wordContent).replace(/<\/?H4[^>]*>/g,"");
	wordContent = String(wordContent).replace(/<\/?H5[^>]*>/g,"");
	wordContent = String(wordContent).replace(/<\/?H6[^>]*>/g,"");
	
	return(wordContent);
}

/*####################################################################*/
/*# PROTOTYPES #*/
/*####################################################################*/
editorObject.prototype.makeActive = makeActive;
editorObject.prototype.getValue = getValue;
editorObject.prototype.insertValue = insertValue;
editorObject.prototype.createEditor = createEditor;
editorObject.prototype.overrideFonts = overrideFonts;
editorObject.prototype.editMode = editMode;
editorObject.prototype.changeFont = changeFont;
editorObject.prototype.changeFontSize = changeFontSize;
editorObject.prototype.overIt = overIt;
editorObject.prototype.offIt = offIt;
editorObject.prototype.clickedIt = clickedIt;
editorObject.prototype.releasedIt = releasedIt;
editorObject.prototype.boldIt = boldIt;
editorObject.prototype.italicIt = italicIt;
editorObject.prototype.underlineIt = underlineIt;
editorObject.prototype.leftIt = leftIt;
editorObject.prototype.centreIt = centreIt;
editorObject.prototype.rightIt = rightIt;
editorObject.prototype.numList = numList;
editorObject.prototype.bulletList = bulletList;
editorObject.prototype.linkIt = linkIt;
editorObject.prototype.ruleIt = ruleIt;
editorObject.prototype.unDoIt = unDoIt;
editorObject.prototype.reDoIt = reDoIt;
editorObject.prototype.fontDialog = fontDialog;
editorObject.prototype.bgColour = bgColour;
editorObject.prototype.showFontDialog = showFontDialog;
editorObject.prototype.hideFontDialog = hideFontDialog;
editorObject.prototype.imageDialog = imageDialog;
editorObject.prototype.enableIcons = enableIcons;
editorObject.prototype.openPalette = openPalette;
editorObject.prototype.plainText = plainText;
editorObject.prototype.convert2HTML = convert2HTML;
editorObject.prototype.toggleIt = toggleIt;
editorObject.prototype.changeFontSizeThis = changeFontSizeThis;
editorObject.prototype.changeFontThis = changeFontThis;
editorObject.prototype.addLinkToText = addLinkToText;
editorObject.prototype.hideDivs = hideDivs;
editorObject.prototype.cleanWordContent = cleanWordContent;

