var colour; var htmlOn; //Function to format text in the text box function FormatText(command, option) { var editor = document.getElementById('message'); //Show iframes if ((command == 'forecolor') || (command == 'backcolor') || (command == 'hilitecolor') || (command == 'fontname') || (command == 'formatblock') || (command == 'fontsize')) { parent.command = command; buttonElement = document.getElementById(command); switch (command){ case 'fontname': iframeWin = 'fontSelect'; break; case 'formatblock': iframeWin = 'formatFont'; break; case 'fontsize': iframeWin = 'textSize'; break; default: iframeWin = 'colourPalette'; } editor.contentWindow.focus() document.getElementById(iframeWin).style.left = getOffsetLeft(buttonElement) + 'px'; document.getElementById(iframeWin).style.top = (getOffsetTop(buttonElement) + buttonElement.offsetHeight) + 'px'; if (document.getElementById(iframeWin).style.visibility=='visible'){ hideIframes(); }else{ hideIframes(); document.getElementById(iframeWin).style.visibility='visible'; } var selectedRange = editor.contentWindow.document.selection; if (selectedRange != null) { range = selectedRange.createRange(); } } else{ editor.contentWindow.focus(); editor.contentWindow.document.execCommand(command, false, option); } editor.contentWindow.focus(); } //Function to initialise function initialiseCommand(selection){ var editor = document.getElementById('message') editor.contentWindow.document.execCommand(parent.command, false, selection); editor.contentWindow.focus(); hideIframes(); } //Function to switch to HTML view function HTMLview() { var editor = document.getElementById('message'); //WYSIWYG view if (htmlOn == true){ var html = editor.contentWindow.document.body.ownerDocument.createRange(); html.selectNodeContents(editor.contentWindow.document.body); editor.contentWindow.document.body.innerHTML = html.toString(); document.getElementById('ToolBar1').style.visibility='visible'; document.getElementById('ToolBar2').style.visibility='visible'; htmlOn = false; //HTML view }else{ var html = document.createTextNode(editor.contentWindow.document.body.innerHTML); editor.contentWindow.document.body.innerHTML = ''; editor.contentWindow.document.body.appendChild(html); document.getElementById('ToolBar1').style.visibility='hidden'; document.getElementById('ToolBar2').style.visibility='hidden'; htmlOn = true; } editor.contentWindow.focus(); } //Function to print editor content function printEditor() { document.getElementById('message').contentWindow.document.execCommand('Print'); } //Iframe top offset function getOffsetTop(elm) { var mOffsetTop = elm.offsetTop; var mOffsetParent = elm.offsetParent; while(mOffsetParent){ mOffsetTop += mOffsetParent.offsetTop; mOffsetParent = mOffsetParent.offsetParent; } return mOffsetTop; } //Iframe left offset function getOffsetLeft(elm){ var mOffsetLeft = elm.offsetLeft; var mOffsetParent = elm.offsetParent; while(mOffsetParent){ mOffsetLeft += mOffsetParent.offsetLeft; mOffsetParent = mOffsetParent.offsetParent; } return mOffsetLeft; } //Function to hide iframes function hideIframes() { document.getElementById('colourPalette').style.visibility='hidden'; document.getElementById('formatFont').style.visibility='hidden'; document.getElementById('fontSelect').style.visibility='hidden'; document.getElementById('textSize').style.visibility='hidden'; } //Function to perform spell check function checkspell(){ }