/* DCWebEdit version 2.0 */
/* Author: Damian Cox BSc */

var arrAllButtons = new Array("paragraph","font","fontsize","fontcolor","bold","italic","underline",
    "strikethrough","justifyleft","justifycenter","justifyright","justifyfull","rule","superscript","subscript","link","unlink",
    "image","clean","table","numberedlist","bullets","outdent","indent","redoundo","copypaste",
    "form","checkbox","radio","textarea","submitbutton","imagebutton","resetbutton","hiddenfield","textfield",
    "passwordfield","print","selectall","spellcheck","dbfield");
var arrButtons;
var preview_url = "";
var save_props;

function displayItem(itm)
{
    for(di_index=0; di_index<arrButtons.length; di_index++)
    {
        if(arrButtons[di_index].toLowerCase() == itm.toLowerCase() || arrButtons[di_index].toLowerCase() == itm.toLowerCase()+":true") 
        { 
            return true;
        }
    }
    return false;
}

function GetVPos(elmt) 
{ 
    var ost = elmt.offsetTop; 
    var osp = elmt.offsetParent; 
    while(osp) 
    { 
        ost += osp.offsetTop; 
        osp = osp.offsetParent; 
    }
    return ost;
}; 

function GetHPos(elmt) 
{ 
    var osl = elmt.offsetLeft; 
    var osp = elmt.offsetParent; 
    while(osp) 
    { 
        osl += osp.offsetLeft; 
        osp = osp.offsetParent;
    }
    return osl;
}; 

function HideSelects() 
{ 
    SelectsMouseOut(); 
    document.getElementById("formatblock3").style.display = "none"; 
    FontFaceListMouseOut(); 
    document.getElementById("fontface3").style.display = "none"; 
    FontSizeListMouseOut(); 
    document.getElementById("fontsize3").style.display = "none"; 
    FontColourListMouseOut(); 
    document.getElementById("fontcolor3").style.display = "none";
}; 


//font colour functions
function ColourChartMouseOver() //handles highlighting of colours in chart on roll over
{
    if(this.className == "edtdropdown14") this.className = "edtdropdown13";
    else this.className = "edtdropdown14";
}
function ColourChartMouseOut() //removes highlight when move mouse away from colour in chart
{
    if(this.className == "edtdropdown14") this.className = "edtdropdown13";
    else this.className = "edtdropdown14";
}
function ColourChartClick(fcolour) //sets the font colour when a colour is clicked
{
    HideSelects(); 
    document.getElementById(edtName).contentWindow.document.execCommand("forecolor", false, fcolour); 
    document.getElementById("fontcolor4").style.backgroundColor = fcolour;
}

//toolbar select lists (eg. paragraph, font face etc.)
function SelectsItemsMouseOver() //highlights individual drop-down list items when mouse hovered over them
{ 
    this.style.color = "#FFFFFF"; 
    this.style.backgroundColor = "#316AC5"; 
    document.getElementById(edtName).contentWindow.focus();
}; 
function SelectsItemsMouseOut() //removes highlight from drop-down list items when mouse moved away
{ 
    this.style.color = "#000000"; 
    this.style.backgroundColor = "#FFFFFF";
}; 
function SelectsItemsClick()    //implements the selected formatting when item selected from a list
{ 
    if (this.innerHTML == "Header 1") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("formatblock", false, "<h1>"); 
        document.getElementById("format1").innerHTML = "Header 1";
    } 
    else if (this.innerHTML == "Header 2") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("formatblock", false, "<h2>"); 
        document.getElementById("format1").innerHTML = "Header 2";
    } 
    else if (this.innerHTML == "Header 3") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("formatblock", false, "<h3>"); 
        document.getElementById("format1").innerHTML = "Header 3";
    } 
    else if (this.innerHTML == "Header 4") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("formatblock", false, "<h4>"); 
        document.getElementById("format1").innerHTML = "Header 4";
    } 
    else if (this.innerHTML == "Header 5") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("formatblock", false, "<h5>"); 
        document.getElementById("format1").innerHTML = "Header 5";
    } 
    else if (this.innerHTML == "Header 6") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("formatblock", false, "<h6>"); 
        document.getElementById("format1").innerHTML = "Header 6";
    } 
    else if (this.innerHTML == "Paragraph") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("formatblock", false, "<p>"); 
        document.getElementById("format1").innerHTML = "Paragraph";
    } 
    else if (this.innerHTML == "verdana") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontname", false, "verdana"); 
        document.getElementById("fontface1").innerHTML = "verdana";
    } 
    else if (this.innerHTML == "verdana Black") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontname", false, "verdana black"); 
        document.getElementById("fontface1").innerHTML = "verdana Black";
    } 
    else if (this.innerHTML == "verdana Narrow") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontname", false, "verdana narrow"); 
        document.getElementById("fontface1").innerHTML = "verdana Narrow";
    } 
    else if (this.innerHTML == "Courier New") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontname", false, "courier new"); 
        document.getElementById("fontface1").innerHTML = "Courier New";
    } 
    else if (this.innerHTML == "Century Gothic") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontname", false, "century gothic"); 
        document.getElementById("fontface1").innerHTML = "Century Gothic";
    } 
    else if (this.innerHTML == "Comic Sans MS") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontname", false, "comic sans ms"); 
        document.getElementById("fontface1").innerHTML = "Comic Sans MS";
    } 
    else if (this.innerHTML == "Impact") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontname", false, "impact"); 
        document.getElementById("fontface1").innerHTML = "Impact";
    } 
    else if (this.innerHTML == "Tahoma") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontname", false, "tahoma"); 
        document.getElementById("fontface1").innerHTML = "Tahoma";
    } 
    else if (this.innerHTML == "Times New Roman") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontname", false, "times new roman"); 
        document.getElementById("fontface1").innerHTML = "Times New Roman";
    } 
    else if (this.innerHTML == "Trebuchet MS") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontname", false, "trebuchet ms"); 
        document.getElementById("fontface1").innerHTML = "Trebuchet MS";
    } 
    else if (this.innerHTML == "Verdana") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontname", false, "verdana"); 
        document.getElementById("fontface1").innerHTML = "Verdana";
    } 
    else if (this.innerHTML == "1") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontsize", false, "1"); 
        document.getElementById("fontsize1").innerHTML = "1";
    } 
    else if (this.innerHTML == "2") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontsize", false, "2"); 
        document.getElementById("fontsize1").innerHTML = "2";
    } 
    else if (this.innerHTML == "3") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontsize", false, "3"); 
        document.getElementById("fontsize1").innerHTML = "3";
    } 
    else if (this.innerHTML == "4") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontsize", false, "4"); 
        document.getElementById("fontsize1").innerHTML = "4";
    } 
    else if (this.innerHTML == "5") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontsize", false, "5"); 
        document.getElementById("fontsize1").innerHTML = "5";
    } 
    else if (this.innerHTML == "6") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontsize", false, "6"); 
        document.getElementById("fontsize1").innerHTML = "6";
    } 
    else if (this.innerHTML == "7") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("fontsize", false, "7"); 
        document.getElementById("fontsize1").innerHTML = "7";
    }
    this.style.color = "#000000"; 
    this.style.backgroundColor = "#FFFFFF"; 
    HideSelects();
}; 
function SelectsMouseOver() //highlights a drop-down when the mouse is hovered over it
{ 
    document.getElementById("format1").className = "ToolbarListHover"; 
    document.getElementById("format2").className = "ToolbarListArrowHover";
}; 
function SelectsMouseOut() //removes highlighting from drop-down when mouse moved away
{ 
    document.getElementById("format1").className = "ToolbarList"; 
    document.getElementById("format2").className = "ToolbarListArrow";
}; 
function SelectsClick() //displays items when drop-down list clicked
{ 
    HideSelects(); 
    document.getElementById("format1").className = "ToolbarListHover"; 
    document.getElementById("format2").className = "ToolbarListArrowHover"; 
    document.getElementById("format1").style.left = GetHPos(document.getElementById("format1")); 
    document.getElementById("format1").style.top = GetVPos(document.getElementById("format1")) + document.getElementById("format1").offsetHeight; 
    document.getElementById("formatblock3").style.display = (document.getElementById("formatblock3").style.display == "none" ) ? "" : "none"; 
    var kids = document.getElementsByTagName('DIV'); 
    for (var i=0; i < kids.length; i++) 
    { 
        if (kids[i].id == "format1" || kids[i].id == "format2") 
        { 
            kids[i].onmouseout = SelectsClick;
        } 
        else if (kids[i].id == "fontface1" || kids[i].id == "fontface2") { kids[i].onmouseout = FontFaceListMouseOut;} 
        else if (kids[i].id == "fontsize1" || kids[i].id == "fontsize2") { kids[i].onmouseout = FontSizeListMouseOut;} 
        else if (kids[i].id == "fontcolor1" || kids[i].id == "fontcolor2") { kids[i].onmouseout = FontColourListMouseOut;}
    }
}; 
//font face drop-down list functions
function FontFaceListMouseOver() 
{ 
    document.getElementById("fontface1").className = "ToolbarListHover"; 
    document.getElementById("fontface2").className = "ToolbarListArrowHover";
}; 

function FontFaceListMouseOut() 
{ 
    document.getElementById("fontface1").className = "ToolbarList"; 
    document.getElementById("fontface2").className = "ToolbarListArrow";
}; 

function FontFaceListClick() 
{ 
    HideSelects(); 
    document.getElementById("fontface1").className = "ToolbarListHover"; 
    document.getElementById("fontface2").className = "ToolbarListArrowHover"; 
    document.getElementById("fontface1").style.left = GetHPos(document.getElementById("fontface1")); 
    document.getElementById("fontface1").style.top = GetVPos(document.getElementById("fontface1")) + document.getElementById("fontface1").offsetHeight; 
    document.getElementById("fontface3").style.display = (document.getElementById("fontface3").style.display == "none" ) ? "" : "none"; 
    var kids = document.getElementsByTagName('DIV'); 
    for (var i=0; i < kids.length; i++) 
    { 
        if (kids[i].id == "format1" || kids[i].id == "format2") { kids[i].onmouseout = SelectsMouseOut; } 
        else if (kids[i].id == "fontface1" || kids[i].id == "fontface2") { kids[i].onmouseout = FontFaceListClick; } 
        else if (kids[i].id == "fontsize1" || kids[i].id == "fontsize2") { kids[i].onmouseout = FontSizeListMouseOut; } 
        else if (kids[i].id == "fontcolor1" || kids[i].id == "fontcolor2") { kids[i].onmouseout = FontColourListMouseOut; }
    }
}; 

function FontSizeListMouseOver() 
{ 
    document.getElementById("fontsize1").className = "ToolbarListHover"; 
    document.getElementById("fontsize2").className = "ToolbarListArrowHover";
}; 

function FontSizeListMouseOut() 
{ 
    document.getElementById("fontsize1").className = "ToolbarList"; 
    document.getElementById("fontsize2").className = "ToolbarListArrow";
}; 

function FontSizeListClick() 
{ 
    HideSelects(); 
    document.getElementById("fontsize1").className = "ToolbarListHover"; 
    document.getElementById("fontsize2").className = "ToolbarListArrowHover"; 
    document.getElementById("fontsize1").style.left = GetHPos(document.getElementById("fontsize1")); 
    document.getElementById("fontsize1").style.top = GetVPos(document.getElementById("fontsize1")) + document.getElementById("fontsize1").offsetHeight; 
    document.getElementById("fontsize3").style.display = (document.getElementById("fontsize3").style.display == "none" ) ? "" : "none"; 
    var kids = document.getElementsByTagName('DIV'); 
    for (var i=0; i < kids.length; i++) 
    { 
        if (kids[i].id == "format1" || kids[i].id == "format2") { kids[i].onmouseout = SelectsMouseOut; } 
        else if (kids[i].id == "fontface1" || kids[i].id == "fontface2") { kids[i].onmouseout = FontFaceListMouseOut; } 
        else if (kids[i].id == "fontsize1" || kids[i].id == "fontsize2") { kids[i].onmouseout = FontSizeListClick; } 
        else if (kids[i].id == "fontcolor1" || kids[i].id == "fontcolor2") { kids[i].onmouseout = FontColourListMouseOut; }
    }
}; 

function FontColourListMouseOver() 
{ 
    document.getElementById("fontcolor1").className = "ToolbarListHover"; 
    document.getElementById("fontcolor2").className = "ToolbarListArrowHover";
}; 

function FontColourListMouseOut() 
{ 
    document.getElementById("fontcolor1").className = "ToolbarList"; 
    document.getElementById("fontcolor2").className = "ToolbarListArrow";
}; 

function FontColourListClick() 
{ 
    HideSelects(); 
    document.getElementById("fontcolor1").className = "ToolbarListHover"; 
    document.getElementById("fontcolor2").className = "ToolbarListArrowHover"; 
    document.getElementById("fontcolor1").style.left = GetHPos(document.getElementById("fontcolor1")); 
    document.getElementById("fontcolor1").style.top = GetVPos(document.getElementById("fontcolor1")) + document.getElementById("fontcolor1").offsetHeight; 
    document.getElementById("fontcolor3").style.display = (document.getElementById("fontcolor3").style.display == "none" ) ? "" : "none"; 
    var kids = document.getElementsByTagName('DIV'); 
    for (var i=0; i < kids.length; i++) 
    { 
        if (kids[i].id == "format1" || kids[i].id == "format2") { kids[i].onmouseout = SelectsMouseOut; } 
        else if (kids[i].id == "fontface1" || kids[i].id == "fontface2") { kids[i].onmouseout = FontFaceListMouseOut; }
        else if (kids[i].id == "fontsize1" || kids[i].id == "fontsize2") { kids[i].onmouseout = FontSizeListMouseOut; } 
        else if (kids[i].id == "fontcolor1" || kids[i].id == "fontcolor2") { kids[i].onmouseout = FontColourListClick; }
    }
}; 

//mode button functions
function ModeButtonsMouseUp() { this.className = "edtbtn9"; }; 
function ModeButtonsMouseOut() { this.className = "edtbtn6"; }; 
function ModeButtonsClick() { this.className = "edtbtn9"; }; 
function ModeButtonsMouseOver() { this.className = "edtbtn7";}; 
function ModeButtonsMouseDown() 
{ 
    var kids = document.getElementsByTagName("DIV"); 
    for (var i=0; i < kids.length; i++) 
    { 
        if(kids[i].className == "edtbtn6" || kids[i].className == "edtbtn7" || kids[i].className == "edtbtn8" || kids[i].className == "edtbtn9")
        { 
            kids[i].className = "edtbtn6"; 
            kids[i].onmouseover = ModeButtonsMouseOver; 
            kids[i].onmouseout = ModeButtonsMouseOut; 
            kids[i].onmousedown = ModeButtonsMouseDown; 
            kids[i].onmouseup = ModeButtonsMouseUp;
        }
    }
    this.className = "edtbtn9"; 
    this.onmouseover = ModeButtonsMouseOver; 
    this.onmouseout = ModeButtonsClick; 
    this.onmouseup = ModeButtonsMouseUp;
}; 
function CancelClick()
{
    window.location=window.location;
}
function SaveClick()
{
    FormHandler();
    
    if(save_props)
    {
        var pageprops = window.open(edtHTMLPathPageProperties,"pageprops","toolbar=no,width=320,height=220,scrollbars=yes,status=yes")
        if(pageprops == null)
        {
            alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
        }
        else
        {
            pageprops.focus()
        }
        pageprops.focus();
    }
    else
    {
        Save()
        //document.getElementById("save").value = "1";
        //document.getElementById("hidText").value = getXHTML(trim(document.getElementById(edtFormName).value));
        //document.forms[0].submit();
    }
}

function Save()
{
    FormHandler();
    document.forms[0].action = edtFormSubmitUrl;
    document.getElementById("ctl00$ContentPlaceHolder1$hidText").value = getXHTML(trim(document.getElementById(edtFormName).value));
    document.getElementById("ctl00$ContentPlaceHolder1$save").value = "1"
    document.forms[0].submit();
//    alert("Save complete");
}

function SwitchMode(mode) 
{ 
    if (mode == "edt_design_mode") 
    { 
        FormHandler2(); 
        document.getElementById(edtName).contentWindow.document.body.innerHTML = getXHTML(trim(document.getElementById(edtFormName).value)); 
        document.getElementById("tb1").style.display = ""; 
        document.getElementById(edtFormName).style.display = "none"; 
        document.getElementById(edtName).style.display = ""; 
        document.getElementById("preview_" + edtName).style.display = "none"; 
        document.getElementById(edtName).contentWindow.focus(); 
        document.getElementById("tblEditor").style.border=1;
        return false;
    } 
    else if (mode == "edt_code_mode") 
    { 
        FormHandler(); 
        document.getElementById(edtFormName).value = getXHTML(trim(document.getElementById(edtName).contentWindow.document.body.innerHTML)); 
        document.getElementById("tb1").style.display = "none"; 
        document.getElementById(edtFormName).style.display = ""; 
        document.getElementById(edtName).style.display = "none"; 
        document.getElementById("preview_" + edtName).style.display = "none";
        document.getElementById("tblEditor").style.border=1;
    } 
    else if (mode == "edt_preview_mode") 
    { 
        FormHandler(); 
        
        if(preview_url=="")
        {
            html = "<div style=\"padding:5px;\">" + getXHTML(trim(document.getElementById(edtFormName).value)) + "</div>"; 
            document.getElementById('preview_' + edtName).contentWindow.document.open(); 
            document.getElementById('preview_' + edtName).contentWindow.document.write("<html><head><style type=\"text/css\">@import url("+document.getElementById("preview_css").value+");</style></head><body>" + html + "</body></html>"); 
            document.getElementById('preview_' + edtName).contentWindow.document.close(); 
            document.getElementById("tb1").style.display = "none"; 
            document.getElementById(edtFormName).style.display = "none"; 
            document.getElementById(edtName).style.display = "none"; 
            document.getElementById("preview_" + edtName).style.display = "";
        }
        else
        {
            document.getElementById("hidText").value = getXHTML(trim(document.getElementById(edtName).contentWindow.document.body.innerHTML)); 
            preview = window.open(preview_url,"PreviewWin","height=500,width=650,scrollbars=yes,resizable=yes");
            if(preview == null)
            {
                alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
            }
            else
            {
                preview.focus()
            }
            SwitchMode("edt_design_mode");
            preview.focus();
        }
        document.getElementById("tblEditor").style.border=0;
    }
}; 

//toolbar button functions
function ToolbarButtonsClick(id) 
{    
    HideSelects(); 
    if (this.id != "editlink" && this.id != "insertflash" && this.id != "edittable" && this.id != "createlink" 
        && this.id != "insertimage" && this.id != "inserttable" && this.id != "insertrowbelow" && this.id != "insertrowabove" 
        && this.id != "insertcolumnleft" && this.id != "insertcolumnright" && this.id != "deletecolumn" && this.id != "deleterow" 
        && this.id != "insertform" && this.id != "form_checkbox" && this.id != "form_radio" && this.id != "form_dropdown" 
        && this.id != "form_textarea" && this.id != "form_submit" && this.id != "form_image_submit" && this.id != "form_reset" 
        && this.id != "form_hidden" && this.id != "form_password" && this.id != "form_textfield" && this.id != "spellcheck" 
        && this.id != "printedt" && this.id != "edtHelp" && this.id != "Database Field") 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand(this.id, false, null); 
        document.getElementById(this.id).className = "edtbtn4"; 
        document.getElementById(this.id).onmouseout = ToolbarButtonsMouseDown; 
        document.getElementById(edtName).contentWindow.focus();
    }
}; 

function ToolbarButtonsMouseDown() 
{ 
    var kids = document.getElementsByTagName('DIV'); 
    for (var i=0; i < kids.length; i++) 
    { 
        if (kids[i].className == "edtbtn2" || kids[i].className == "edtbtn3" || kids[i].className == "edtbtn4") 
        { 
            kids[i].className = "edtbtn1";
        }
    }
    doEvent(); 
    this.className = "edtbtn4";
}; 
function ToolbarButtonsMouseUp() { this.className = "edtbtn4"; }; 
function ToolbarButtonsMouseOut() { this.className = "edtbtn1"; }; 
function ToolbarButtonsMouseOver() { this.className = "edtbtn2"; }; 
function InsertImageClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertImage , "blank","toolbar=no,width=340,height=220,status=yes"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function EditLinkClick() 
{ 
    popupWin = window.open(edtHTMLPathEditLink , "blank","toolbar=no,width=350,height=300"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function EditTableClick() 
{ 
    popupWin = window.open(edtHTMLPathEditTable , "blank","toolbar=no,width=320,height=280"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function CreateLinkClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertLink , "blank","toolbar=no,width=350,height=300"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function InsertDbFieldClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertDbField, "blank","toolbar=no,width=350,height=120,status=yes"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
};
function PrintClick() 
{ 
    if (document.all)
    { 
        var oFrame = window.frames[edtName]; 
        oFrame.focus(); 
        oFrame.print();
    }
    else
    { 
        var oFrame = document.getElementById(edtName).contentWindow; 
        oFrame.focus(); 
        oFrame.window.print();
    }
}; 
//form buttons
function InsertFormClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertForm , "blank","toolbar=no,width=320,height=180"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function InsertCheckboxClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertCheckbox , "blank","toolbar=no,width=320,height=150"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function InsertRadioClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertRadiobutton , "blank","toolbar=no,width=320,height=150"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function InsertFlashClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertFlash , "blank","toolbar=no,width=350,height=130"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function InsertTextAreaClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertTextArea , "blank","toolbar=no,width=320,height=230"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function InsertSubmitBtnClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertSubmit , "blank","toolbar=no,width=320,height=130"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function InsertSubmitImgClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertImageSubmit , "blank","toolbar=no,width=320,height=130"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function InsertResetBtnClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertReset , "blank","toolbar=no,width=320,height=130"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function InsertHiddenFieldClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertHidden , "blank","toolbar=no,width=320,height=130"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function InsertPasswordFieldClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertPassword , "blank","toolbar=no,width=320,height=150"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function InsertTextboxClick() 
{ 
    popupWin = window.open(edtHTMLPathInsertText , "blank","toolbar=no,width=320,height=170"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
//end of form buttons

//table buttons
function InsertTableClick() 
{
    popupWin = window.open(edtHTMLPathInsertTable , "blank","toolbar=no,width=320,height=300"); 
    if(popupWin == null)
    {
        alert("Popup Blocked\n\nThis feature requires a page to be opened in a popup window, which appears to have been blocked.\nPlease add this website to your popup blockers \"Allowed Sites\" list to use this feature.");
    }
    else
    {
        popupWin.focus()
    }
}; 
function InsertTableRowBeforeClick() 
{ 
    if (window.getSelection) { var selected_obj = document.getElementById(edtName).contentWindow.window.getSelection().focusNode; }
    else if (document.getSelection) { var selected_obj = document.getElementById(edtName).contentWindow.document.getSelection().focusNode; }
    else if (document.selection) { var selected_obj = document.getElementById(edtName).contentWindow.document.selection.createRange().parentElement(); }
    current_tag = selected_obj; 
    while(current_tag.tagName != "TABLE")
    { 
        if (current_tag.tagName == "TR") 
        { 
            cellTotal = current_tag.cells.length; RowIndex = current_tag.rowIndex;
        }
        if (current_tag.parentNode.tagName == "TBODY") 
        { 
            var x=current_tag.parentNode.insertRow(RowIndex); 
            for (i=0; i < cellTotal; i++) { var j=x.insertCell(i); j.innerHTML="&nbsp;"; }
        }
        current_tag = current_tag.parentNode;
    }
}; 
function InsertTableRowAfterClick() 
{ 
    if (window.getSelection)
    { 
        var selected_obj = document.getElementById(edtName).contentWindow.window.getSelection().focusNode;
    }
    else if (document.getSelection)
    { 
        var selected_obj = document.getElementById(edtName).contentWindow.document.getSelection().focusNode;
    }
    else if (document.selection)
    { 
        var selected_obj = document.getElementById(edtName).contentWindow.document.selection.createRange().parentElement();
    }
    current_tag = selected_obj; 
    while(current_tag.tagName != "TABLE")
    { 
        if (current_tag.tagName == "TR") { cellTotal = current_tag.cells.length; RowIndex = current_tag.rowIndex; }
        if (current_tag.parentNode.tagName == "TBODY") 
        { 
            var x=current_tag.parentNode.insertRow(RowIndex+1); 
            for (i=0; i < cellTotal; i++) { var j=x.insertCell(i); j.innerHTML="&nbsp;"; }
        }
        current_tag = current_tag.parentNode;
    }
}; 
function InsertTableColumnBeforeClick() 
{ 
    if (window.getSelection) { var selected_obj = document.getElementById(edtName).contentWindow.window.getSelection().focusNode; }
    else if (document.getSelection) { var selected_obj = document.getElementById(edtName).contentWindow.document.getSelection().focusNode; }
    else if (document.selection) { var selected_obj = document.getElementById(edtName).contentWindow.document.selection.createRange().parentElement(); }
    current_tag = selected_obj; 
    while(current_tag.tagName != "TABLE")
    { 
        if (current_tag.tagName == "TD") { cellIndex = current_tag.cellIndex; }
        if (current_tag.tagName == "TBODY") 
        { 
            RowTotal = current_tag.parentNode.rows.length; 
            var x=current_tag.parentNode; 
            for (i=0; i < RowTotal; i++)
            { 
                var j=x.rows[i].insertCell(cellIndex); 
                j.innerHTML="&nbsp;";
            }
        }
        current_tag = current_tag.parentNode;
    }
}; 
function InsertTableColumnAfterClick() 
{ 
    if (window.getSelection)
    { 
        var selected_obj = document.getElementById(edtName).contentWindow.window.getSelection().focusNode;
    }
    else if (document.getSelection)
    { 
        var selected_obj = document.getElementById(edtName).contentWindow.document.getSelection().focusNode;
    }
    else if (document.selection)
    { 
        var selected_obj = document.getElementById(edtName).contentWindow.document.selection.createRange().parentElement();
    }
    current_tag = selected_obj; 
    while(current_tag.tagName != "TABLE") 
    { 
        if (current_tag.tagName == "TD") { cellIndex = current_tag.cellIndex; }
        if (current_tag.tagName == "TBODY") 
        { 
            RowTotal = current_tag.parentNode.rows.length; 
            var x=current_tag.parentNode; 
            for (i=0; i < RowTotal; i++)
            { 
                var j=x.rows[i].insertCell(cellIndex+1); 
                j.innerHTML="&nbsp;";
            }
        }
        current_tag = current_tag.parentNode;
    }
}; 
function DeleteTableColumnClick() 
{ 
    if (window.getSelection)
    { 
        var selected_obj = document.getElementById(edtName).contentWindow.window.getSelection().focusNode;
    }
    else if (document.getSelection)
    { 
        var selected_obj = document.getElementById(edtName).contentWindow.document.getSelection().focusNode;
    }
    else if (document.selection)
    { 
        var selected_obj = document.getElementById(edtName).contentWindow.document.selection.createRange().parentElement();
    }
    current_tag = selected_obj; 
    while(current_tag.tagName != "TABLE")
    { 
        if (current_tag.tagName == "TD") { cellIndex = current_tag.cellIndex; }
        if (current_tag.tagName == "TBODY") 
        { 
            RowTotal = current_tag.parentNode.rows.length; 
            var x=current_tag.parentNode; 
            for(i=0; i < RowTotal; i++ ) { j=x.rows[i].deleteCell(cellIndex); }
        }
        current_tag = current_tag.parentNode;
    }
}; 
function DeleteTableRowClick() 
{ 
    if (window.getSelection)
    { 
        var selected_obj = document.getElementById(edtName).contentWindow.window.getSelection().focusNode;
    }
    else if (document.getSelection)
    { 
        var selected_obj = document.getElementById(edtName).contentWindow.document.getSelection().focusNode;
    }
    else if (document.selection)
    { 
        var selected_obj = document.getElementById(edtName).contentWindow.document.selection.createRange().parentElement();
    }
    current_tag = selected_obj; 
    while(current_tag.tagName != "TABLE")
    { 
        if (current_tag.tagName == "TR") { RowIndex = current_tag.rowIndex; }
        if (current_tag.tagName == "TBODY") 
        { 
            RowTotal = current_tag.parentNode.rows.length; 
            var x=current_tag.parentNode; x.deleteRow(RowIndex);
        }
        current_tag = current_tag.parentNode;
    }
}; 
//end of table buttons

function InsertHTML(html) 
{ 
    document.getElementById(edtName).contentWindow.focus();
    if (document.all) 
    { 
        var oRng = document.getElementById(edtName).contentWindow.document.selection.createRange(); 
        oRng.pasteHTML(html); 
        oRng.collapse(false); 
        oRng.select();
    } 
    else 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand('insertHTML', false, html);
    }
};

function LaunchEditor(edtPreloadContent) 
{ 
    edtCSS = document.getElementById("preview_css").value; 
    var kids = document.getElementsByTagName("FORM"); 
    for (var i=0; i < kids.length; i++) { kids[i].onsubmit = FormHandler; }
    document.getElementById(edtName).contentWindow.document.designMode = "on"; 
    document.getElementById(edtFormName).value = edtPreloadContent; 
    document.getElementById(edtName).contentWindow.document.open(); 
    document.getElementById(edtName).contentWindow.document.write("<html><head><style type=\"text/css\">@import url("+edtCSS+");</style></head><body>" + edtPreloadContent + "</body></html>"); 
    document.getElementById(edtName).contentWindow.document.close(); 
    if (document.all && !window.opera) 
    { 
        document.getElementById(edtName).contentWindow.document.attachEvent("onkeypress", doEvent); 
        document.getElementById(edtName).contentWindow.document.attachEvent("onclick", doEvent); 
        document.getElementById(edtName).contentWindow.document.attachEvent("onmouseup", doEvent);
    } 
    else 
    { 
        document.getElementById(edtName).contentWindow.document.execCommand("useCSS", false, null); 
        document.getElementById(edtName).contentWindow.document.addEventListener("keypress", doEvent, true); 
        document.getElementById(edtName).contentWindow.document.addEventListener("click", doEvent, true); 
        document.getElementById(edtName).contentWindow.document.addEventListener("mouseup", doEvent, true);
    }
    doEvent(); 
    var kids = document.getElementsByTagName("DIV"); 
    for (var i=0; i < kids.length; i++) 
    { 
        if(kids[i].className == "edtbtn6")
        { 
            kids[i].onmouseover = ModeButtonsMouseOver; 
            kids[i].onmouseout = ModeButtonsMouseOut; 
            kids[i].onmousedown = ModeButtonsMouseDown; 
            kids[i].onmouseup = ModeButtonsMouseUp;
        }
    }
}; 

function FormHandler() 
{ 

    if (document.getElementById(edtFormName).style.display == "") { var newHTML = getXHTML(trim(document.getElementById(edtFormName).value)); }
    else { var newHTML = getXHTML(trim(document.getElementById(edtName).contentWindow.document.body.innerHTML)); }
    pattern = /<div[^>]*border: 1px dotted red[^>]*>.*<\/form><\/div>/gi; matchesArray = newHTML.match(pattern); 
    if (matchesArray != null)
    { 
        for (i=0; i<matchesArray.length; i++)
        { 
            pattern2 = /<div[^>]*border: 1px dotted red[^>]*>/gi; 
            pattern3 = /<\/div>/gi; replacement = matchesArray[i]; 
            replacement = replacement.replace(pattern2, ""); 
            replacement = replacement.replace(pattern3, ""); 
            if (document.getElementById(edtFormName).style.display == "") 
                { newHTML = document.getElementById(edtFormName).value.replace(matchesArray[i], replacement); }
            else 
                { newHTML = document.getElementById(edtName).contentWindow.document.body.innerHTML.replace(matchesArray[i], replacement); }
        }
    }
    pattern = /<table[^>]*class=\"edt_tbl\"[^>]*>/gi; 
    matchesArray = newHTML.match(pattern); 
    if (matchesArray != null)
    { 
        for (i=0; i<matchesArray.length; i++)
        { 
            pattern2 = /class=\"edt_tbl\"/gi; replacement = matchesArray[i]; 
            replacement = replacement.replace(pattern2, ""); 
            newHTML = newHTML.replace(matchesArray[i], replacement);
        }
    }

    document.getElementById(edtFormName).value = newHTML; 
    document.getElementById(edtName).contentWindow.document.body.innerHTML = newHTML;
//    alert(document.getElementById(edtName).contentWindow.document.body.innerHTML = newHTML)
}; 

function FormHandler2() 
{ 
    if (document.getElementById(edtFormName).style.display == "")
    { 
        var newHTML = document.getElementById(edtFormName).value;
    }
    else
    { 
        var newHTML = document.getElementById(edtName).contentWindow.document.body.innerHTML;
    }
    pattern = /<form[^>]*>[^<]*<\/form>/gi; matchesArray = newHTML.match(pattern); 
    if (matchesArray != null)
    { 
        for (i=0; i<matchesArray.length; i++)
        { 
            replacement = matchesArray[i]; 
            replacement = replacement.replace(matchesArray[i], "<div style=\"border: 1px dotted red;\">" + matchesArray[i] + "</div>"); 
            if (document.getElementById(edtFormName).style.display == "")
                { newHTML = document.getElementById(edtFormName).value.replace(matchesArray[i], replacement); }
            else
                { newHTML = document.getElementById(edtName).contentWindow.document.body.innerHTML.replace(matchesArray[i], replacement); }
        }
    }
    pattern = /<table[^>]*border=\"0\"[^>]*>/gi; 
    matchesArray = newHTML.match(pattern); 
    if (matchesArray != null)
    { 
        for (i=0; i<matchesArray.length; i++)
        { 
            pattern2 = /border=\"0\"/gi; 
            replacement = matchesArray[i]; 
            replacement = replacement.replace(pattern2, "border=\"0\" class=\"edt_tbl\""); 
            newHTML = newHTML.replace(matchesArray[i], replacement);
        }
    }
    if (document.getElementById(edtFormName).style.display == "")
        { document.getElementById(edtFormName).value = newHTML; }
    else
        { document.getElementById(edtName).contentWindow.document.body.innerHTML = newHTML; }
}; 

function doEvent() 
{ 
    if(document.getElementById(edtName).contentWindow.document.selection.type != "Control") 
    {
        HideSelects(); 
        if (document.getElementById("edt_code_mode").className == "edtbtn9")
        { 
            document.getElementById("tb1").style.display = "none"; 
        } 
        else 
        { 
            document.getElementById("format1").innerHTML = "Paragraph"; 
            document.getElementById("fontface1").innerHTML = "Verdana"; 
            document.getElementById("fontsize1").innerHTML = "2"; 
            var kids = document.getElementsByTagName('DIV'); 
            for (var i=0; i < kids.length; i++) 
            { 
                switch(kids[i].className)
                { 
                    case "edtbtn1":
                        if (kids[i].onmouseover != ToolbarButtonsMouseOver) { kids[i].onmouseover = ToolbarButtonsMouseOver; }
                        if (kids[i].onclick != ToolbarButtonsClick) { kids[i].onclick = ToolbarButtonsClick; }
                        if (kids[i].className == "edtbtn4") 
                        { 
                            if (kids[i].onmouseout != ToolbarButtonsMouseDown) { kids[i].onmouseout = ToolbarButtonsMouseDown; }
                        } 
                        else 
                        { 
                            if (kids[i].onmouseout != ToolbarButtonsMouseOut) { kids[i].onmouseout = ToolbarButtonsMouseOut; }
                        }
                        if (kids[i].onmousedown != ToolbarButtonsMouseDown) { kids[i].onmousedown = ToolbarButtonsMouseDown; }
                        if (kids[i].onmouseup != ToolbarButtonsMouseUp) { kids[i].onmouseup = ToolbarButtonsMouseUp; }
                        break; 
                    case "edtbtn2":
                        kids[i].className = "edtbtn1"; 
                        if (kids[i].onmouseover != ToolbarButtonsMouseOver) { kids[i].onmouseover = ToolbarButtonsMouseOver; }
                        if (kids[i].onclick != ToolbarButtonsClick) { kids[i].onclick = ToolbarButtonsClick; }
                        if (kids[i].className == "edtbtn4") 
                        { 
                            if (kids[i].onmouseout = ToolbarButtonsMouseDown) { kids[i].onmouseout = ToolbarButtonsMouseDown; }
                        } 
                        else 
                        { 
                            if (kids[i].onmouseout != ToolbarButtonsMouseOut) { kids[i].onmouseout = ToolbarButtonsMouseOut; }
                        }
                        if (kids[i].onmousedown != ToolbarButtonsMouseDown) { kids[i].onmousedown = ToolbarButtonsMouseDown; }
                        if (kids[i].onmouseup != ToolbarButtonsMouseUp) { kids[i].onmouseup = ToolbarButtonsMouseUp; }
                        break; 
                    case "edtbtn3":
                        kids[i].className = "edtbtn1"; 
                        if (kids[i].onmouseover != ToolbarButtonsMouseOver) {kids[i].onmouseover = ToolbarButtonsMouseOver; }
                        if (kids[i].onclick != ToolbarButtonsClick) { kids[i].onclick = ToolbarButtonsClick; }
                        if (kids[i].className == "edtbtn4") 
                        { 
                            if (kids[i].onmouseout != ToolbarButtonsMouseDown) { kids[i].onmouseout = ToolbarButtonsMouseDown; }
                        }
                        else 
                        { 
                            if (kids[i].onmouseout != ToolbarButtonsMouseOut) { kids[i].onmouseout = ToolbarButtonsMouseOut; }
                        }
                        if (kids[i].onmousedown != ToolbarButtonsMouseDown) { kids[i].onmousedown = ToolbarButtonsMouseDown; }
                        if (kids[i].onmouseup != ToolbarButtonsMouseUp) { kids[i].onmouseup = ToolbarButtonsMouseUp; }
                        break; 
                    case "edtbtn4":
                        kids[i].className = "edtbtn1"; 
                        if (kids[i].onmouseover != ToolbarButtonsMouseOver) { kids[i].onmouseover = ToolbarButtonsMouseOver; }
                        if (kids[i].onclick != ToolbarButtonsClick) { kids[i].onclick = ToolbarButtonsClick; }
                        if (kids[i].onmouseout != ToolbarButtonsMouseOut) { kids[i].onmouseout = ToolbarButtonsMouseOut; }
                        if (kids[i].onmousedown != ToolbarButtonsMouseDown) { kids[i].onmousedown = ToolbarButtonsMouseDown; }
                        if (kids[i].onmouseup != ToolbarButtonsMouseUp) { kids[i].onmouseup = ToolbarButtonsMouseUp; }
                        break;
                }
                switch(kids[i].id)
                { 
                    case "format1":
                        if (kids[i].onmouseover != SelectsMouseOver) { kids[i].onmouseover = SelectsMouseOver; }
                        if (kids[i].onmousedown != SelectsClick) { kids[i].onmousedown = SelectsClick; }
                        if (kids[i].onmouseout != SelectsMouseOut) { kids[i].onmouseout = SelectsMouseOut; }
                        if (kids[i].className == "edtdropdown6") 
                        { 
                            if (kids[i].onmouseout != SelectsClick) { kids[i].onmouseout = SelectsClick; }
                        } 
                        else 
                        { 
                            if (kids[i].onmouseout != SelectsMouseOut) { kids[i].onmouseout = SelectsMouseOut; }
                        }
                        break; 
                    case "format2":
                        if (kids[i].onmouseover != SelectsMouseOver) { kids[i].onmouseover = SelectsMouseOver; }
                        if (kids[i].onmousedown != SelectsClick) { kids[i].onmousedown = SelectsClick; }
                        if (kids[i].onmouseout != SelectsMouseOut) { kids[i].onmouseout = SelectsMouseOut; }
                        if (kids[i].className == "edtdropdown6") { kids[i].onmouseout = SelectsClick; } 
                        else { kids[i].onmouseout = SelectsMouseOut; }
                        break; 
                    case "fontface1":
                        if (kids[i].onmouseover != FontFaceListMouseOver) { kids[i].onmouseover = FontFaceListMouseOver; }
                        if (kids[i].onmousedown != FontFaceListClick) { kids[i].onmousedown = FontFaceListClick; }
                        if (kids[i].onmouseout != FontFaceListMouseOut) { kids[i].onmouseout = FontFaceListMouseOut; }
                        if (kids[i].className == "edtdropdown6") 
                        { 
                            if (kids[i].onmouseout != FontFaceListClick) { kids[i].onmouseout = FontFaceListClick; }
                        } 
                        else 
                        { 
                            if (kids[i].onmouseout != FontFaceListMouseOut) { kids[i].onmouseout = FontFaceListMouseOut; }
                        }
                        break; 
                    case "fontface2":
                        if (kids[i].onmouseover != FontFaceListMouseOver) { kids[i].onmouseover = FontFaceListMouseOver; }
                        if (kids[i].onmousedown != FontFaceListClick) { kids[i].onmousedown = FontFaceListClick; }
                        if (kids[i].onmouseout != FontFaceListMouseOut) { kids[i].onmouseout = FontFaceListMouseOut; }
                        if (kids[i].className == "edtdropdown6") 
                        { 
                            if (kids[i].onmouseout != FontFaceListClick) { kids[i].onmouseout = FontFaceListClick; }
                        } 
                        else 
                        { 
                            if (kids[i].onmouseout != FontFaceListMouseOut) { kids[i].onmouseout = FontFaceListMouseOut; }
                        }
                        break; 
                    case "fontsize1":
                        if (kids[i].onmouseover != FontSizeListMouseOver) { kids[i].onmouseover = FontSizeListMouseOver; }
                        if (kids[i].onmousedown != FontSizeListClick) { kids[i].onmousedown = FontSizeListClick; }
                        if (kids[i].onmouseout != FontSizeListMouseOut) { kids[i].onmouseout = FontSizeListMouseOut; }
                        if (kids[i].className == "edtdropdown6") 
                        { 
                            if (kids[i].onmouseout != FontSizeListClick) { kids[i].onmouseout = FontSizeListClick; }
                        } 
                        else 
                        { 
                            if (kids[i].onmouseout != FontSizeListMouseOut) { kids[i].onmouseout = FontSizeListMouseOut; }
                        }
                        break; 
                    case "fontsize2":
                        if (kids[i].onmouseover != FontSizeListMouseOver) { kids[i].onmouseover = FontSizeListMouseOver; }
                        if (kids[i].onmousedown != FontSizeListClick) { kids[i].onmousedown = FontSizeListClick; }
                        if (kids[i].onmouseout != FontSizeListMouseOut) { kids[i].onmouseout = FontSizeListMouseOut; }
                        if (kids[i].className == "edtdropdown6") 
                        { 
                            if (kids[i].onmouseout != FontSizeListClick) { kids[i].onmouseout = FontSizeListClick; }
                        } 
                        else 
                        { 
                            if (kids[i].onmouseout != FontSizeListMouseOut) { kids[i].onmouseout = FontSizeListMouseOut; }
                        }
                        break; 
                    case "fontcolor1":
                        if (kids[i].onmouseover != FontColourListMouseOver) { kids[i].onmouseover = FontColourListMouseOver; }
                        if (kids[i].onmousedown != FontColourListClick) { kids[i].onmousedown = FontColourListClick; }
                        if (kids[i].onmouseout != FontColourListMouseOut) { kids[i].onmouseout = FontColourListMouseOut; }
                        if (kids[i].className == "edtdropdown9") 
                        { 
                            if (kids[i].onmouseout != FontColourListClick) { kids[i].onmouseout = FontColourListClick; }
                        } 
                        else 
                        { 
                            if (kids[i].onmouseout != FontColourListMouseOut) { kids[i].onmouseout = FontColourListMouseOut; }
                        }
                        break; 
                    case "fontcolor2":
                        if (kids[i].onmouseover != FontColourListMouseOver) { kids[i].onmouseover = FontColourListMouseOver; }
                        if (kids[i].onmousedown != FontColourListClick) { kids[i].onmousedown = FontColourListClick; }
                        if (kids[i].onmouseout != FontColourListMouseOut) { kids[i].onmouseout = FontColourListMouseOut; }
                        if (kids[i].className == "edtdropdown9") 
                        { 
                            if (kids[i].onmouseout != FontColourListClick) { kids[i].onmouseout = FontColourListClick; }
                        } 
                        else 
                        { 
                            if (kids[i].onmouseout != FontColourListMouseOut) { kids[i].onmouseout = FontColourListMouseOut; }
                        }
                        break; 
                    case "formatblock":
                        if (kids[i].onmouseover != SelectsItemsMouseOver) { kids[i].onmouseover = SelectsItemsMouseOver; }
                        if (kids[i].onmouseout != SelectsItemsMouseOut) { kids[i].onmouseout = SelectsItemsMouseOut; }
                        if (kids[i].onmousedown != SelectsItemsClick) { kids[i].onmousedown = SelectsItemsClick; }
                        break; 
                    case "fontface":
                        if (kids[i].onmouseover != SelectsItemsMouseOver) { kids[i].onmouseover = SelectsItemsMouseOver; }
                        if (kids[i].onmouseout != SelectsItemsMouseOut) { kids[i].onmouseout = SelectsItemsMouseOut; }
                        if (kids[i].onmousedown != SelectsItemsClick) { kids[i].onmousedown = SelectsItemsClick; }
                        break; 
                    case "fontsize":
                        if (kids[i].onmouseover != SelectsItemsMouseOver) { kids[i].onmouseover = SelectsItemsMouseOver; }
                        if (kids[i].onmouseout != SelectsItemsMouseOut) { kids[i].onmouseout = SelectsItemsMouseOut; } 
                        if (kids[i].onmousedown != SelectsItemsClick) { kids[i].onmousedown = SelectsItemsClick; }
                        break; 
                    case "fontcolor":
                        if (kids[i].onmouseover != ColourChartMouseOver) { kids[i].onmouseover = ColourChartMouseOver; }
                        if (kids[i].onmouseout != ColourChartMouseOut) { kids[i].onmouseout = ColourChartMouseOut; }
                        break;
                }
           }

            var tbl = false; 
            var in_list = false; 

            if (window.getSelection) 
                { var selected_obj = document.getElementById(edtName).contentWindow.window.getSelection().focusNode; }
            else if (document.getSelection) 
                { var selected_obj = document.getElementById(edtName).contentWindow.document.getSelection().focusNode;}
            else if (document.selection) 
                { var selected_obj = document.getElementById(edtName).contentWindow.document.selection.createRange().parentElement(); }
            var is_link = false; 
            var is_table = false; 
            var current_tag = selected_obj; 
            var previous_tagName = selected_obj.tagName; 
            var textcolor = ""; 

            document.getElementById("fontcolor4").style.backgroundColor = "#000000"; 
            while(previous_tagName != "HTML")
            { 
                if(previous_tagName == "B" || previous_tagName == "STRONG")
                { 
                    document.getElementById("bold").className = "edtbtn4"; 
                    document.getElementById("bold").onmouseout = ToolbarButtonsMouseDown;
                }
                if (previous_tagName == "LI") { in_list = true;}
                if (previous_tagName == "TD" && !is_table) { is_table = true;}
                if(previous_tagName == "I" || previous_tagName == "EM")
                { 
                    document.getElementById("italic").className = "edtbtn4"; 
                    document.getElementById("italic").onmouseout = ToolbarButtonsMouseDown;
                }
                if(previous_tagName == "U")
                { 
                    document.getElementById("underline").className = "edtbtn4"; 
                    document.getElementById("underline").onmouseout = ToolbarButtonsMouseDown;
                }
                if(previous_tagName == "STRIKE")
                { 
                    document.getElementById("strikethrough").className = "edtbtn4"; 
                    document.getElementById("strikethrough").onmouseout = ToolbarButtonsMouseDown;
                }
                if(previous_tagName == "A") 
                { 
                    is_link = true; 
                    document.getElementById("editlink").className = "edtbtn4"; 
                    document.getElementById("editlink").onmouseout = ToolbarButtonsMouseDown;
                }
                if(previous_tagName == "UL")
                { 
                    document.getElementById("insertunorderedlist").className = "edtbtn4"; 
                    document.getElementById("insertunorderedlist").onmouseout = ToolbarButtonsMouseDown;
                }
                if(previous_tagName == "OL") 
                {
                    document.getElementById("insertorderedlist").className = "edtbtn4"; 
                    document.getElementById("insertorderedlist").onmouseout = ToolbarButtonsMouseDown;
                }
                if(previous_tagName == "SUB")
                { 
                    document.getElementById("subscript").className = "edtbtn4"; 
                    document.getElementById("subscript").onmouseout = ToolbarButtonsMouseDown;
                }
                if(previous_tagName == "SUP")
                { 
                    document.getElementById("superscript").className = "edtbtn4"; 
                    document.getElementById("superscript").onmouseout = ToolbarButtonsMouseDown;
                }
                if(previous_tagName == "H1") { document.getElementById("format1").innerHTML = "Header 1"; }
                if(previous_tagName == "H2") { document.getElementById("format1").innerHTML = "Header 2"; }
                if(previous_tagName == "H3") { document.getElementById("format1").innerHTML = "Header 3"; }
                if(previous_tagName == "H4") { document.getElementById("format1").innerHTML = "Header 4"; }
                if(previous_tagName == "H5") { document.getElementById("format1").innerHTML = "Header 5"; }
                if(previous_tagName == "H6") { document.getElementById("format1").innerHTML = "Header 6"; }
                if(previous_tagName == "BLOCKQUOTE")
                { 
                    document.getElementById("indent").className = "edtbtn4"; 
                    document.getElementById("indent").onmouseout = ToolbarButtonsMouseDown;
                }
                if (is_table) 
                { 
                    document.getElementById("table_options_on").style.display = ""; 
                    document.getElementById("table_options_off").style.display = "none";
                } 
                else if (!is_table)
                { 
                    document.getElementById("table_options_on").style.display = "none"; 
                    document.getElementById("table_options_off").style.display = "";
                }
                if (!displayItem("table:true"))
                {
                    document.getElementById("table_options_on").style.display = "none"; 
                    document.getElementById("table_options_off").style.display = "none";
                }

                if (current_tag.align == "left") 
                { 
                    document.getElementById("justifyleft").className = "edtbtn4"; 
                    document.getElementById("justifyleft").onmouseout = ToolbarButtonsMouseDown;
                } 
                else if (current_tag.align == "center") 
                { 
                    document.getElementById("justifycenter").className = "edtbtn4"; 
                    document.getElementById("justifycenter").onmouseout = ToolbarButtonsMouseDown;
                } 
                else if (current_tag.align == "right") 
                { 
                    document.getElementById("justifyright").className = "edtbtn4"; 
                    document.getElementById("justifyright").onmouseout = ToolbarButtonsMouseDown;
                } 
                else if (current_tag.align == "justify") 
                { 
                    document.getElementById("justifyfull").className = "edtbtn4"; 
                    document.getElementById("justifyfull").onmouseout = ToolbarButtonsMouseDown;
                } 
                else if (current_tag.align == "") { document.getElementById("justifyleft").className = "edtbtn1"; } 
                else { }
                if (current_tag.face == "verdana") { document.getElementById("fontface1").innerHTML = "verdana"; }
                else if (current_tag.face == "verdana black") { document.getElementById("fontface1").innerHTML = "verdana Black"; } 
                else if (current_tag.face == "verdana narrow") { document.getElementById("fontface1").innerHTML = "verdana Narrow"; } 
                else if (current_tag.face == "courier new") { document.getElementById("fontface1").innerHTML = "Courier New"; } 
                else if (current_tag.face == "century gothic") { document.getElementById("fontface1").innerHTML = "Century Gothic"; } 
                else if (current_tag.face == "comic sans ms") { document.getElementById("fontface1").innerHTML = "Comic Sans MS"; } 
                else if (current_tag.face == "impact") { document.getElementById("fontface1").innerHTML = "Impact"; } 
                else if (current_tag.face == "tahoma") { document.getElementById("fontface1").innerHTML = "Tahoma"; } 
                else if (current_tag.face == "times new roman") { document.getElementById("fontface1").innerHTML = "Times New Roman"; } 
                else if (current_tag.face == "trebuchet ms") { document.getElementById("fontface1").innerHTML = "Trebuchet MS"; } 
                else if (current_tag.face == "verdana") { document.getElementById("fontface1").innerHTML = "Verdana"; }
                if (current_tag.size == "1") { document.getElementById("fontsize1").innerHTML = "1"; } 
                else if (current_tag.size == "2") { document.getElementById("fontsize1").innerHTML = "2"; } 
                else if (current_tag.size == "3") { document.getElementById("fontsize1").innerHTML = "3"; } 
                else if (current_tag.size == "4") { document.getElementById("fontsize1").innerHTML = "4"; } 
                else if (current_tag.size == "5") { document.getElementById("fontsize1").innerHTML = "5"; } 
                else if (current_tag.size == "6") { document.getElementById("fontsize1").innerHTML = "6"; } 
                else if (current_tag.size == "7") { document.getElementById("fontsize1").innerHTML = "7"; } 
                else { }
                if (current_tag.color != null) { textcolor = current_tag.color; }
                current_tag = current_tag.parentNode; 
                previous_tagName = current_tag.tagName;
            }
            if (in_list) { }
        }
        if (textcolor == "") { textcolor = "#000000"; }

        document.getElementById("fontcolor4").style.backgroundColor = textcolor; 
        if (is_link && displayItem("link"))
        {   
            document.getElementById("createlink").style.display = "none"; 
            document.getElementById("editlink").style.display = ""; 
        }
        else if(!is_link && displayItem("link"))
        { 
            document.getElementById("createlink").style.display = ""; 
            document.getElementById("editlink").style.display = "none";
        }
        else if(!displayItem("link"))
        {
            document.getElementById("createlink").style.display = "none";
            document.getElementById("editlink").style.display = "none";
        }
    }
}; 

function HelpClick() 
{ 
    msg=window.open("","msg","height=50,width=320"); 
    msg.document.write("<style>"); 
    msg.document.write("body, td {"); 
    msg.document.write("background-color:#ECE9D8;"); 
    msg.document.write("font-family:verdana;"); 
    msg.document.write("font-size:11px;"); 
    msg.document.write("}"); 
    msg.document.write("input {"); 
    msg.document.write("font-family:verdana;"); 
    msg.document.write("font-size:11px;"); 
    msg.document.write("}"); 
    msg.document.write("select {"); 
    msg.document.write("font-family:verdana;"); 
    msg.document.write("font-size:11px;"); 
    msg.document.write("}"); 
    msg.document.write("</style>"); 
    msg.document.write("<fieldset>"); 
    msg.document.write("<legend><b>Help</b></legend>"); 
    msg.document.write("<table width=\"100%\" cellspacing=\"2\" cellpadding=\"0\" border=\"0\">"); 
    msg.document.write("<tr>"); 
    msg.document.write("<td colspan=\"2\" align=\"center\">Coming soon!</td>"); 
    msg.document.write("</tr>"); 
    msg.document.write("</table>"); 
    msg.document.write("</fieldset>"); 
    msg.document.close();
}; 

function AboutClick() 
{ 
alert("here")
    /*msg=window.open("","msg","height=50,width=320"); 
    msg.document.write("<style>"); 
    msg.document.write("body, td {"); 
    msg.document.write("background-color:#ECE9D8;"); 
    msg.document.write("font-family:verdana;"); 
    msg.document.write("font-size:11px;"); 
    msg.document.write("}"); 
    msg.document.write("input {"); 
    msg.document.write("font-family:verdana;"); 
    msg.document.write("font-size:11px;"); 
    msg.document.write("}"); 
    msg.document.write("select {"); 
    msg.document.write("font-family:verdana;"); 
    msg.document.write("font-size:11px;"); 
    msg.document.write("}"); 
    msg.document.write("</style>"); 
    msg.document.write("<fieldset>"); 
    msg.document.write("<legend><b>About the Web Editor</b></legend>"); 
    msg.document.write("<table width=\"100%\" cellspacing=\"2\" cellpadding=\"0\" border=\"0\">"); 
    msg.document.write("<tr>"); 
    msg.document.write("<td colspan=\"2\" align=\"center\">Developed by DC Web Design</td>"); 
    msg.document.write("</tr>"); 
    msg.document.write("<tr>"); 
    msg.document.write("<td colspan=\"2\" align=\"center\"><a href=\"mailto:support@dcwebdesign.co.uk\">support@dcwebdesign.co.uk</a></td>"); 
    msg.document.write("</tr>"); 
    msg.document.write("</table>"); 
    msg.document.write("</fieldset>"); 
    msg.document.close();*/
}; 


function doSpellCheck() { alert('Not yet supported.'); }; 

//function to create lists such as font face, font size and paragraph style
function drawSelect(slct_id)
{
    //get the items for the specified list into an array
    arrSelectItems = eval("edtArr"+slct_id+"Items");
    
    document.write('		        <div id="'+slct_id.toLowerCase()+'3" class="ToolbarListItems" style="position:absolute;display:none;">'); 
    for(ds_index=0; ds_index < arrSelectItems.length; ds_index=ds_index+2)
    {
        document.write('			        <div unselectable="on" id="'+slct_id.toLowerCase()+'" class="'+arrSelectItems[ds_index+1]+'" nowrap>'+arrSelectItems[ds_index]+'</div>'); 
    }
    document.write('                </div>');
}

//function to add items onto the toolbar
function addToolbarItem(itm)
{
    //split the value passed in and place two parts into array (1=item name, 2=show or not)
    var arrBut=itm.split(":");
    itm=arrBut[0];
    if(arrBut[1]=="true") show=true 
    else show=false;

    //new toolbar
    if(itm.toLowerCase()=="newline")
    {
        document.write('                        <td style="text-align:right;background-image:url('+edtImagePath+'bg.gif);" width="100%"><img src="' + edtImagePath + 'finish.gif" width="14" height="25"></td>'); 
        document.write('                    </tr>');
        document.write('                </table>');
        document.write('                <table cellpadding="0" cellspacing="0" onmousedown="return false;" border="0">');
        document.write('                    <tr>');
        document.write('                        <td width="7"><img src="' + edtImagePath + 'start.gif" width="7" height="25"></td>'); 
    }
    
    //spacer
    else if(itm.toLowerCase()==" ")
    {
        document.write('            <td class="toolbar_bg" id="edtsep1"><img src="' + edtImagePath + 'blank.gif"></td>'); 
    }
    
    //separator
    else if(itm.toLowerCase()=="|")
    {
        document.write('            <td class="toolbar_bg" id="edtsep2"><img src="' + edtImagePath + 'seperator.gif"></td>'); 
    }
    
    //various format buttons (bold, italic, etc)
    else if(itm.toLowerCase()=="bold" || itm.toLowerCase()=="italic" || itm.toLowerCase()=="underline" 
        || itm.toLowerCase()=="justifyleft" || itm.toLowerCase()=="justifycenter" || itm.toLowerCase()=="justifyright"
        || itm.toLowerCase()=="justifyfull" || itm.toLowerCase()=="strikethrough" || itm.toLowerCase()=="superscript"
        || itm.toLowerCase()=="subscript")
    {
        document.write('            <td class="toolbar_bg" title="'+arrButtons[i]+'"><div id="'+itm.toLowerCase()+'" class="edtbtn1"><img src="' + edtImagePath + itm.toLowerCase()+'.gif"></div></td>'); 
        if(!show)
        {
            document.getElementById(itm.toLowerCase()).style.display="none";
        }
    }
    
    //paragraph style 
    else if (itm.toLowerCase()=="paragraph")
    {
        document.write('            <td background="' + edtImagePath + 'bg.gif" id="edtformat">'); 
        document.write('		        <table width="100%;" cellpadding="0" cellspacing="0" id="format4" title="Style">'); 
        document.write('                    <tr>'); 
        document.write('                        <td nowrap><div unselectable="on" id="format1" class="ToolbarList" style="width:58px;font-family:verdana;font-size:11px;color:#000000;">Paragraph</div></td>'); 
        document.write('                        <td><div unselectable="on" id="format2" class="ToolbarListArrow"><img src="' + edtImagePath + 'arrow.gif" width="11" height="16"></div></td>'); 
        document.write('                    </tr>'); 
        document.write('                </table>'); 
        drawSelect("FormatBlock");
        document.write('            </td>'); 
        if(!show) 
        {
            document.getElementById("format1").style.display="none";
            document.getElementById("format2").style.display="none";
            document.getElementById("formatblock3").style.display="none";
        }
    }
    
    //font face
    else if(itm.toLowerCase()=="font")
    {
        document.write('            <td background="' + edtImagePath + 'bg.gif" id="edtfontface">'); 
        document.write('		        <table style="width:110px;background-color:transparent;" cellpadding="0" cellspacing="0" title="Font">'); 
        document.write('                    <tr>'); 
        document.write('                        <td nowrap><div unselectable="on" id="fontface1" class="edtdropdown1" style="width:98px;font-family:verdana;font-size:11px;color:#000000;">Verdana</div></td>'); 
        document.write('                        <td><div unselectable="on" id="fontface2" class="edtdropdown2"><img src="' + edtImagePath + 'arrow.gif" width="11" height="16"></div></td>'); 
        document.write('                    </tr>'); 
        document.write('                </table>'); 
        drawSelect("FontFace");
        document.write('            </td>'); 
        if(!show)
        {
            document.getElementById("edtfontface").style.display="none";
            document.getElementById("fontface1").style.display="none";
            document.getElementById("fontface2").style.display="none";
            document.getElementById("fontface3").style.display="none";
        }
    }
    
    //font colour
    else if(itm.toLowerCase()=="fontcolor")
    {
        document.write('            <td class="toolbar_bg" id="edtfontcolor" title="Font Colour">'); 
        document.write('        	    <table style="width:35px;" border="0" cellspacing="0" cellpadding="0">'); 
        document.write('        		    <tr>'); 
        if (!document.all || window.opera)
        { 
            document.write('        			    <td><div id="fontcolor1" align="center" class="ToolbarList" style="padding-bottom:1px;"><img src="' + edtImagePath + 'fontcolor.gif"><br><img id="fontcolor4" src="' + edtImagePath + 'fontcolor2.gif" style="background-color:#FF0000;"></div></td>'); 
            document.write('        			    <td><div align="center" id="fontcolor2" class="ToolbarListArrow"><img src="' + edtImagePath + 'arrow.gif"></div></td>');
        }
        else
        { 
            document.write('        			    <td><div id="fontcolor1" align="center" class="ToolbarList" style="padding-bottom:1px;"><img src="' + edtImagePath + 'fontcolor.gif"><br><img id="fontcolor4" src="' + edtImagePath + 'fontcolor2.gif" style="background-color:#FF0000;"></div></td>'); 
            document.write('        			    <td><div align="center" id="fontcolor2" class="ToolbarListArrow"><img src="' + edtImagePath + 'arrow.gif"></div></td>');
        }
        document.write('        		    </tr>'); 
        document.write('        	    </table>'); 
        document.write('		        <div id="fontcolor3" class="ColourDropDown" style="position:absolute;display:none;padding:4px;border:1px solid #002D96;">'); 
        document.write('			        <table border="0" cellspacing="1" cellpadding="0">'); 
        document.write('				        <tr>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#000000;" onClick="ColourChartClick(\'#000000\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#993300;" onClick="ColourChartClick(\'#993300\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#333300;" onClick="ColourChartClick(\'#333300\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#003300;" onClick="ColourChartClick(\'#003300\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#003366;" onClick="ColourChartClick(\'#003366\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#000080;" onClick="ColourChartClick(\'#000080\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#333399;" onClick="ColourChartClick(\'#333399\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#333333;" onClick="ColourChartClick(\'#333333\');"></div></td>'); 
        document.write('				        </tr>'); 
        document.write('				        <tr>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#800000;" onClick="ColourChartClick(\'#800000\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#FF6600;" onClick="ColourChartClick(\'#FF6600\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#808000;" onClick="ColourChartClick(\'#808000\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#008000;" onClick="ColourChartClick(\'#008000\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#008080;" onClick="ColourChartClick(\'#008080\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#0000FF;" onClick="ColourChartClick(\'#0000FF\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#666699;" onClick="ColourChartClick(\'#666699\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#808080;" onClick="ColourChartClick(\'#808080\');"></div></td>'); 
        document.write('				        </tr>'); 
        document.write('				        <tr>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#FF0000;" onClick="ColourChartClick(\'#FF0000\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#FF9900;" onClick="ColourChartClick(\'#FF9900\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#99CC00;" onClick="ColourChartClick(\'#99CC00\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#339966;" onClick="ColourChartClick(\'#339966\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#33CCCC;" onClick="ColourChartClick(\'#33CCCC\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#3366FF;" onClick="ColourChartClick(\'#3366FF\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#800080;" onClick="ColourChartClick(\'#800080\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#999999;" onClick="ColourChartClick(\'#999999\');"></div></td>'); 
        document.write('				        </tr>'); 
        document.write('				        <tr>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#FF00FF;" onClick="ColourChartClick(\'#FF00FF\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#FFCC00;" onClick="ColourChartClick(\'#FFCC00\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#FFFF00;" onClick="ColourChartClick(\'#FFFF00\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#00FF00;" onClick="ColourChartClick(\'#00FF00\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#00FFFF;" onClick="ColourChartClick(\'#00FFFF\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#00CCFF;" onClick="ColourChartClick(\'#00CCFF\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#993366;" onClick="ColourChartClick(\'#993366\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#C0C0C0;" onClick="ColourChartClick(\'#C0C0C0\');"></div></td>'); 
        document.write('				        </tr>'); 
        document.write('				        <tr>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#FF99CC;" onClick="ColourChartClick(\'#FF99CC\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#FFCC99;" onClick="ColourChartClick(\'#FFCC99\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#FFFF99;" onClick="ColourChartClick(\'#FFFF99\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#CCFFCC;" onClick="ColourChartClick(\'#CCFFCC\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#CCFFFF;" onClick="ColourChartClick(\'#CCFFFF\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#99CCFF;" onClick="ColourChartClick(\'#99CCFF\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#CC99FF;" onClick="ColourChartClick(\'#CC99FF\');"></div></td>'); 
        document.write('					        <td><div id="fontcolor" class="edtdropdown13"><img src="' + edtImagePath + 'fontcolor3.gif" style="background-color:#FFFFFF;" onClick="ColourChartClick(\'#FFFFFF\');"></div></td>'); 
        document.write('				        </tr>'); 
        document.write('			        </table>'); 
        document.write('		        </div>'); 
        document.write('             </td>'); 
        
        if(!show)
        {
            document.getElementById("edtfontcolor").style.display="none";
            document.getElementById("fontcolor1").style.display="none";
            document.getElementById("fontcolor2").style.display="none";
            document.getElementById("fontcolor3").style.display="none";
            document.getElementById("fontcolor").style.display="none";
        }
    }
    
    //font size
    else if(itm.toLowerCase()=="fontsize")
    {
        document.write('            <td background="' + edtImagePath + 'bg.gif" id="edtfontsize">'); 
        document.write('		        <table width="100%" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" title="Font Size">'); 
        document.write('                    <tr>'); 
        document.write('                        <td><div unselectable="on" id="fontsize1" class="edtdropdown1" style="font-family:verdana;font-size:11px;color:#000000;">2</div></td>'); 
        document.write('                        <td><div unselectable="on" id="fontsize2" class="edtdropdown2"><img src="' + edtImagePath + 'arrow.gif" width="11" height="16"></div></td>'); 
        document.write('                    </tr>'); 
        document.write('                </table>'); 
        drawSelect("FontSize");
        document.write('            </td>'); 
        
        if(!show)
        {
            document.getElementById("edtfontsize").style.display="none";
            document.getElementById("fontsize1").style.display="none";
            document.getElementById("fontsize2").style.display="none";
            document.getElementById("fontsize3").style.display="none";
            document.getElementById("fontsize").style.display="none";
        }
    }
    
    //horizontal rule
    else if(itm.toLowerCase()=="rule") 
    {
        document.write('            <td class="toolbar_bg" title="Horizontal Rule"><div id="inserthorizontalrule" class="edtbtn1"><img src="' + edtImagePath + 'hr.gif"></div></td>'); 
        if(!show) document.getElementById("inserthorizontalrule").style.display="none";
    }
    
    //insert link
    else if(itm.toLowerCase()=="link") 
    {
        document.write('            <td class="toolbar_bg"><div id="createlink" class="edtbtn1" title="Insert Hyperlink"><a href="javascript:CreateLinkClick();" style="cursor:default;"><img src="' + edtImagePath + 'insertlink.gif" border="0"></a></div><div style="display:none;" id="editlink" class="edtbtn1" title="Edit Hyperlink"><a href="javascript:EditLinkClick();" style="cursor:default;"><img src="' + edtImagePath + 'insertlink.gif"border="0"></a></div></td>'); 
        if(!show) document.getElementById("createlink").style.display="none";
    }
    
    //remove link
    else if(itm.toLowerCase()=="unlink") 
    {
        document.write('            <td class="toolbar_bg" title="Remove Hyperlink"><div id="unlink" class="edtbtn1"><img src="' + edtImagePath + 'unlink.gif"></div></td>'); 
        if(!show) document.getElementById("unlink").style.display="none";
    }
    
    //insert image
    else if(itm.toLowerCase()=="image") 
    {
        document.write('        <td class="toolbar_bg" title="Insert Image"><div id="insertimage" class="edtbtn1"><a href="javascript:InsertImageClick();" style="cursor:default;"><img src="' + edtImagePath + 'insertimage.gif" border="0"></a></div></td>'); 
        if(!show) document.getElementById("insertimage").style.display="none";
    }
    
    //remove formatting
    else if(itm.toLowerCase()=="clean") 
    {
        document.write('        <td class="toolbar_bg" title="Remove Formatting"><div id="removeformat" class="edtbtn1"><img src="' + edtImagePath + 'format.gif"></div></td>'); 
        if(!show) document.getElementById("removeformat").style.display="none";
    }
    
    //tables
    else if(itm.toLowerCase()=="table") 
    {
        document.write('        <td class="toolbar_bg"><table cellpadding="0" cellspacing="0" id="table_options_on" border="0" ><tr>');
        document.write('        <td class="toolbar_bg" ><div id="edittable" class="edtbtn1" title="Edit Table Properties"><a href="javascript:EditTableClick();" style="cursor:default;"><img src="' + edtImagePath + 'inserttable.gif" border="0"></a></div></td>'); 
        document.write('        <td class="toolbar_bg"><div id="insertcolumnleft" class="edtbtn1" title="Insert Column to the left"><img src="' + edtImagePath + 'insertcolumnleft.gif" onClick="InsertTableColumnBeforeClick();"></div></td>'); 
        document.write('        <td class="toolbar_bg"><div id="insertcolumnright" class="edtbtn1" title="Insert Column to the right"><img src="' + edtImagePath + 'insertcolumnright.gif" onClick="InsertTableColumnAfterClick();"></div></td>'); 
        document.write('        <td class="toolbar_bg"><div id="insertrowabove" class="edtbtn1" title="Insert Row above"><img src="' + edtImagePath + 'insertrowabove.gif" onClick="InsertTableRowBeforeClick();"></div></td>'); 
        document.write('        <td class="toolbar_bg"><div id="insertrowbelow" class="edtbtn1" title="Insert Row below"><img src="' + edtImagePath + 'insertrowbelow.gif" onClick="InsertTableRowAfterClick();"></div></td>'); 
        document.write('        <td class="toolbar_bg"><div id="deletecolumn" class="edtbtn1" title="Delete Current column"><img src="' + edtImagePath + 'deletecolumn.gif" onClick="DeleteTableColumnClick();"></div></td>'); 
        document.write('        <td class="toolbar_bg"><div id="deleterow" class="edtbtn1" title="Delete Current row"><img src="' + edtImagePath + 'deleterow.gif" onClick="DeleteTableRowClick();"></div></td>'); 
        document.write('        <td class="toolbar_bg"><div id="tableincell" class="edtbtn1" title="Insert Table in Cell"><a href="javascript:InsertTableClick();" id="inserttableincelllink" style="cursor:default;"><img src="' + edtImagePath + 'table_in_cell.gif" id="imgInsertTableInCell" border="0"></a></div></td>'); 
        document.write('        </tr></table></td>');

        document.write('        <td class="toolbar_bg"><table cellpadding="0" cellspacing="0" border="0" id="table_options_off"><tr>');
        document.write('        <td><div id="inserttable" class="edtbtn1" title="Insert Table"><a href="javascript:InsertTableClick();" id="inserttablelink" style="cursor:default;"><img src="' + edtImagePath + 'inserttable.gif" id="imgInsertTable" border="0"></a></div></td>'); 
        document.write('        <td><div id="insertcolumnleft" class="edtbtn5" title="Insert Column to the left"><img src="' + edtImagePath + 'insertcolumnleftgrey.gif"></div></td>'); 
        document.write('        <td><div id="insertcolumnright" class="edtbtn5" title="Insert Column to the right"><img src="' + edtImagePath + 'insertcolumnrightgrey.gif"></div></td>'); 
        document.write('        <td><div id="insertrowabove" class="edtbtn5" title="Insert Row above"><img src="' + edtImagePath + 'insertrowabovegrey.gif"></div></td>'); 
        document.write('        <td><div id="insertrowbelow" class="edtbtn5" title="Insert Row below"><img src="' + edtImagePath + 'insertrowbelowgrey.gif"></div></td>'); 
        document.write('        <td><div id="deletecolumn" class="edtbtn5" title="Delete Current column"><img src="' + edtImagePath + 'deletecolumngrey.gif"></div></td>'); 
        document.write('        <td><div id="deleterow" class="edtbtn5" title="Delete Current row"><img src="' + edtImagePath + 'deleterowgrey.gif"></div></td>'); 
        document.write('        </tr></table></td>');
        
        if(!show)
        {
            document.getElementById("table_options_on").style.display="none";
            document.getElementById("table_options_off").style.display="none";
        }        
    }
    
    //numbered list
    else if(itm.toLowerCase()=="numberedlist") 
    {
        document.write('        <td class="toolbar_bg" title="Numbering"><div id="insertorderedlist" class="edtbtn1"><img src="' + edtImagePath + 'orderedlist.gif"></div></td>');                     
        if(!show) document.getElementById("insertorderedlist").style.display="none";
    }
    
    //bullet list
    else if(itm.toLowerCase()=="bullets") 
    {   
        document.write('        <td class="toolbar_bg" title="Bullets"><div id="insertunorderedlist" class="edtbtn1"><img src="' + edtImagePath + 'unorderedlist.gif"></div></td>'); 
        if(!show) document.getElementById("insertunorderedlist").style.display="none";
    }
    
    //decrease indent (outdent)
    else if(itm.toLowerCase()=="outdent") 
    {
        document.write('        <td class="toolbar_bg" title="Decrease Indent"><div id="outdent" class="edtbtn1"><img src="' + edtImagePath + 'decreaseindent.gif"></div></td>'); 
        if(!show) document.getElementById("outdent").style.display="none";
    }
    
    //increase indent
    else if(itm.toLowerCase()=="indent") 
    {
        document.write('        <td class="toolbar_bg" title="Increase Indent"><div id="indent" class="edtbtn1"><img src="' + edtImagePath + 'increaseindent.gif"></div></td>'); 
        if(!show) document.getElementById("indent").style.display="none";
    }
    
    //undo and redo
    else if(itm.toLowerCase()=="undoredo")
    {
        document.write('        <td class="toolbar_bg" title="Undo"><div id="undo" class="edtbtn1"><img src="' + edtImagePath + 'undo.gif"></div></td>');         
        document.write('        <td class="toolbar_bg" title="Redo"><div id="redo" class="edtbtn1"><img src="' + edtImagePath + 'redo.gif"></div></td>'); 
        if(!show)
        {
            document.getElementById("undo").style.display="none";
            document.getElementById("redo").style.display="none";
        }
    }
    
    //copy, cut and paste
    else if(itm.toLowerCase()=="copypaste")
    {
        if (!document.all || window.opera) 
        { 
            document.write('        <td id="cut" class="toolbar_bg" title="Cut"><div class="edtbtn5"><img src="' + edtImagePath + 'cutgrey.gif"></div></td>'); 
            document.write('        <td id="copy" class="toolbar_bg" title="Copy"><div class="edtbtn5"><img src="' + edtImagePath + 'copygrey.gif"></div></td>'); 
            document.write('        <td id="paste" class="toolbar_bg" title="Paste"><div class="edtbtn5"><img src="' + edtImagePath + 'pastegrey.gif"></div></td>');
        }
        else
        { 
            document.write('        <td id="cut" class="toolbar_bg" title="Cut"><div id="cut" class="edtbtn1"><img src="' + edtImagePath + 'cut.gif"></div></td>'); 
            document.write('        <td id="copy" class="toolbar_bg" title="Copy"><div id="copy" class="edtbtn1"><img src="' + edtImagePath + 'copy.gif"></div></td>'); 
            document.write('        <td id="paste" class="toolbar_bg" title="Paste"><div id="paste" class="edtbtn1"><img src="' + edtImagePath + 'paste.gif"></div></td>');
        }
        if(!show)
        {
            document.getElementById("cut").style.display="none";
            document.getElementById("copy").style.display="none";
            document.getElementById("paste").style.display="none";
        }
    }
    
    //forms
    else if(itm.toLowerCase()=="form")
    {
        document.write('        <td class="toolbar_bg"><table cellpadding="0" cellspacing="0" border="0" id="edtForm"><tr>');
        document.write('        <td class="toolbar_bg" title="Form"><a href="javascript:InsertFormClick();" style="cursor:default;"><div id="insertform" class="edtbtn1"><img src="' + edtImagePath + 'form.gif" border="0"></div></a></td>'); 
        document.write('        <td class="toolbar_bg" title="Check Box"><a href="javascript:InsertCheckboxClick();" style="cursor:default;"><div id="form_checkbox" class="edtbtn1"><img src="' + edtImagePath + 'checkbox.gif" border="0"></div></a></td>'); 
        document.write('        <td class="toolbar_bg" title="Radio Button"><a href="javascript:InsertRadioClick();" style="cursor:default;"><div id="form_radio" class="edtbtn1"><img src="' + edtImagePath + 'radio.gif" border="0"></div></a></td>'); 
        document.write('        <td class="toolbar_bg" title="Text Area"><a href="javascript:InsertTextAreaClick();" style="cursor:default;"><div id="form_textarea" class="edtbtn1"><img src="' + edtImagePath + 'textarea.gif" border="0"></div></a></td>'); 
        document.write('        <td class="toolbar_bg" title="Submit Button"><a href="javascript:InsertSubmitBtnClick();" style="cursor:default;"><div id="form_submit" class="edtbtn1"><img src="' + edtImagePath + 'submit.gif" border="0"></div></a></td>'); 
        document.write('        <td class="toolbar_bg" title="Image Button"><a href="javascript:InsertSubmitImgClick();" style="cursor:default;"><div id="form_image_submit" class="edtbtn1"><img src="' + edtImagePath + 'imagesubmit.gif" border="0"></div></a></td>'); 
        document.write('        <td class="toolbar_bg" title="Reset Button"><a href="javascript:InsertResetBtnClick();" style="cursor:default;"><div id="form_reset" class="edtbtn1"><img src="' + edtImagePath + 'reset.gif" border="0"></div></a></td>'); 
        document.write('        <td class="toolbar_bg" title="Hidden Field"><a href="javascript:InsertHiddenFieldClick();" style="cursor:default;"><div id="form_hidden" class="edtbtn1"><img src="' + edtImagePath + 'hidden.gif" border="0"></div></a></td>'); 
        document.write('        <td class="toolbar_bg" title="Password Field"><a href="javascript:InsertPasswordFieldClick();" style="cursor:default;"><div id="form_password" class="edtbtn1"><img src="' + edtImagePath + 'password.gif" border="0"></div></a></td>'); 
        document.write('        <td class="toolbar_bg" title="Text Field"><a href="javascript:InsertTextboxClick();" style="cursor:default;"><div id="form_textfield" class="edtbtn1"><img src="' + edtImagePath + 'textfield.gif" border="0"></div></a></td>'); 
        document.write('        </tr></table></td>');
        
        if(!show)
        {
            document.getElementById("edtForm").style.display="none";
        }
    }
    
    //print
    else if(itm.toLowerCase()=="print") 
    {
        document.write('        <td class="toolbar_bg" title="Print"><div id="printedt" class="edtbtn1"><img src="' + edtImagePath + 'print.gif" onClick="PrintClick();"></div></td>'); 
        if(!show) document.getElementById("printedt").style.display="none";
    }
    
    //select all
    else if(itm.toLowerCase()=="selectall") 
    {
        document.write('        <td class="toolbar_bg" title="Select All"><div id="selectall" class="edtbtn1"><img src="' + edtImagePath + 'selectall.gif"></div></td>'); 
        if(!show) document.getElementById("selectall").style.display="none";
    }
    
    //spell check
    else if(itm.toLowerCase()=="spellcheck") 
    {
        if (!document.all || window.opera) 
        { 
            document.write('        <td id="spellchecker" class="toolbar_bg" title="Spell Check"><div id="spellcheck" class="edtbtn5"><img src="' + edtImagePath + 'spellcheckgrey.gif"></div></td>');
        } 
        else 
        { 
            document.write('        <td id="spellchecker" class="toolbar_bg" title="Spell Check"><div id="spellcheck" class="edtbtn5"><img src="' + edtImagePath + 'spellcheckgrey.gif"></div></td>');
        }
        if(!show) document.getElementById("spellchecker").style.display="none";
    }
    
    //database field
    else if(itm.toLowerCase()=="dbfield") 
    {
        if((edtASPNet == true || edtASP == true) && displayItem("DbField")) 
        {
            document.write('        <td class="toolbar_bg" title="Database Field"><div id="Database Field" class="edtbtn1"><img src="' + edtImagePath + 'dbfield.gif" onClick="InsertDbFieldClick();"></div></td>');
            if(!show) document.getElementById("Database Field").style.display="none";            
        }
    }
    
    //help
    else if(itm.toLowerCase()=="help") 
    {
        document.write('        <td class="toolbar_bg" id="help" title="Get Help"><a href="javascript:HelpClick();" style="cursor:default;"><div id="edtHelp" class="edtbtn1"><img src="' + edtImagePath + 'help.gif" border="0"></div></a></td>'); 
        document.getElementById("help").style.display="none";
    }
    
    //about
    else if(itm.toLowerCase()=="about") 
    {
        document.write('        <td class="toolbar_bg" title="About"><a href="javascript:alert(\'hello\');" style="cursor:default;"><div id="edtAbout" class="edtbtn1"><img src="' + edtImagePath + 'about.gif" border="0"></div></a></td>'); 
        if(!show) document.getElementById("about").style.display="none";
    }
}

//edtPreloadContent = content to load into editor
//edtCSS = stylesheet to use
//edtPreviewUrl = url of preview page. if to preview in editor window, leave blank.
//edtButtons = the buttons to show on toolbar, separated by comma's.
function Editor(edtPreloadContent, edtCSS, edtButtons) 
{ 
    if (!document.designMode) 
    { 
        document.write('<textarea id="' + edtFormName + '" name="' + edtFormName + '" style="width:' + edtWidth + ';height:' + edtHeight + ';"></textarea>');
    } 
    else 
    { 
        //put requested buttons into array, and add ":true" to end of each
        arrButtons = edtButtons.split(",");
        for(i=0;i<arrButtons.length;i++)
        {
            arrButtons[i]=arrButtons[i]+":true";
        }

        //add unused buttons to the array
        var arrButtons2 = arrButtons
        
        for (i=0; i<arrAllButtons.length;i++)
        {
            if(!displayItem(arrAllButtons[i] + ":true")) 
            {
                arrButtons2[arrButtons2.length] = arrAllButtons[i] + ":false";
            }
        }
        arrButtons = arrButtons2;
        
        //hidden fields for css style sheet and editor name         
        document.write('<input type="hidden" id="preview_css" value="' + edtCSS + '">'); 
        document.write('<input type="hidden" id="iframe_name" value="' + edtName + '">'); 

        document.write('<table style="width:' + edtWidth + ';border:0px solid #3B619C;" cellpadding="0" cellspacing="0" id="tblEditor">'); 
        document.write('  <tr>'); 
        document.write('    <td bgcolor="#C3DAF9">'); 
        document.write('	    <table cellpadding="0" cellspacing="0" id="tb1" onmousedown="return false;">'); 
        document.write('            <tr>');
  

        /***********
        * Toolbars *
        ***********/
        for(i=0;i<arrButtons.length;i++)
        {
            if(i==0)
            {
                document.write('            <td>');
                document.write('                <table cellpadding="0" cellspacing="0" onmousedown="return false;" border="0">');
                document.write('                    <tr>');
                document.write('                        <td width="7"><img src="' + edtImagePath + 'start.gif" width="7" height="25"></td>'); 
                document.write('                        <td class="toolbar_bg" id="edtsep1"><img src="' + edtImagePath + 'blank.gif"></td>'); 
            }
            else
            {
                addToolbarItem(arrButtons[i]);
            }
        }
        document.write('    <td style="text-align:right;background-image:url('+edtImagePath+'bg.gif);" width="100%"><img src="' + edtImagePath + 'finish.gif" width="14" height="25"></td>'); 
        document.write("</tr></table></td></tr></table>");
        
        /*********
        * Editor *
        *********/
        document.write('  <tr>'); 
        document.write('    <td style="border:1px solid #C3DAF9;">'); 
        document.write('		<iframe name="' + edtName + '" id="' + edtName + '" style="width:' + edtWidth + '; height:' + edtHeight + '; background-color:#FFFFFF;" frameborder="0"></iframe>'); 
        document.write('		<textarea name="' + edtFormName + '" id="' + edtFormName + '" style="display:none;width:' + edtWidth + '; height:' + edtHeight + '; background-color:#FFFFFF; font-family:courier new; font-size:12px; color:#000000; border:1px;"></textarea>'); 
        document.write('		<iframe id="preview_' + edtName + '" style="width:' + edtWidth + '; height:' + edtHeight + '; background-color:#FFFFFF; display:none;" frameborder="0"></iframe>'); 
        document.write('	</td>'); 
        document.write('  </tr>'); 
        
        /*****************************************
        * Bottom toolbar (mode buttons and save) *
        *****************************************/
        document.write('  <tr>'); 
        document.write('    <td bgcolor="#C3DAF9" height="25" class="toolbar_bg">'); 
        document.write('		<table width="100%" cellspacing="0" cellpadding="0" border="0" onmousedown="return false;">'); 
        document.write('			<tr>'); 
        document.write('				<td>')
        document.write('					<table width="0" cellspacing="3" cellpadding="0" border="0" class="toolbar_bg">'); 
        document.write('						<tr>'); 
        if (edtDesignMode) 
        { 
            document.write('							<td style="color:#000000; font-family:verdana; font-size:11px;"><div class="edtbtn9" id="edt_design_mode" onclick="SwitchMode(\'edt_design_mode\');"><img src="' + edtImagePath + 'design.gif">&nbsp;Design</div></td>');
        }
        else
        { 
            document.write('							<td style="display:none;color:#000000; font-family:verdana; font-size:11px;"><div class="edtbtn9" id="edt_design_mode"><img src="' + edtImagePath + 'design.gif">&nbsp;Design</div></td>');
        }
        if (edtCodeMode) 
        { 
            document.write('							<td style="color:#000000; font-family:verdana; font-size:11px;"><div class="edtbtn6" id="edt_code_mode" onclick="SwitchMode(\'edt_code_mode\');"><img src="' + edtImagePath + 'code.gif">&nbsp;Code</div></td>');
        }
        else
        { 
            document.write('							<td style="display:none;color:#000000; font-family:verdana; font-size:11px;"><div class="edtbtn6" id="edt_code_mode"><img src="' + edtImagePath + 'code.gif">&nbsp;Code</div></td>');
        }
        if (edtPreviewMode) 
        { 
            document.write('							<td style="color:#000000; font-family:verdana; font-size:11px;"><div class="edtbtn6" id="edt_preview_mode" onclick="SwitchMode(\'edt_preview_mode\');"><img src="' + edtImagePath + 'preview.gif">&nbsp;Preview</div></td>');
        }
        else
        { 
            document.write('							<td style="display:none;color:#000000; font-family:verdana; font-size:11px;"><div class="edtbtn6" id="edt_preview_mode"><img src="' + edtImagePath + 'preview.gif">&nbsp;Preview</div></td>');
        }
        document.write('							<td style="color:#000000; font-family:verdana; font-size:11px; width:25%;"><div class="edtbtn6" id="edt_save" onclick="SaveClick();"><img src="' + edtImagePath + 'save.gif">&nbsp;Save</div></td>');
        document.write('							<td style="color:#000000; font-family:verdana; font-size:11px; width:25%;"><div class="edtbtn6" id="edt_cancel" onclick="CancelClick();"><img src="' + edtImagePath + 'cancel.gif">&nbsp;Cancel</div></td>');
        document.write('                            <td style="color:#000000; font-family:verdana; font-size:9px; text-align:right; width:50%;">WCMv1.0/PMA</td>');
        document.write('						</tr>'); 
        document.write('					</table>'); 
        document.write('				</td>'); 
        document.write('			</tr>'); 
        document.write('		</table>'); 
        document.write('	</td>'); 
        document.write('  </tr>'); 
        document.write('</table>'); 
        
        LaunchEditor(edtPreloadContent); 
    }
};