﻿// toolbars
var __count = 100;
var __aAllComponents = new Array();
var __aAllTagComponents = new Array();
// all popup iframes
var __aAllPopups = new Array();
var __hasEvalation = false;
var __hasCancel = false;
var __isEvaluation = false;
var __isMode = "";

function Toolbars(containerid) {
    this.aToolbars = new Array();
    this.container = containerid;
    this.backcolor = "ButtonFace";

    this.add = __toolbars_add;
    this.create = __toolbars_create;
    this.getComponents = __toolbars_getcomponents;
    this.getTagComponents = __toolbars_gettagcomponents;
    this.reset = __toolbars_reset;
    this.hide = __toolbars_hide;
    this.show = __toolbars_show;
}

function __toolbars_getcomponents() {
    return __aAllComponents;
}

function __toolbars_gettagcomponents() {
    return __aAllTagComponents;
}

function __toolbars_add(toolbar) {
    var id = this.aToolbars.length;
    this.aToolbars[id] = toolbar;
    toolbar.id = __count;
    __count++;
}

function __toolbars_create() {
    
    var temp = "";
    var temp1 = "<div unselectable='on' id='" + this.container + "_div" + "' style='width: 100%;height:";
    var temp2 = "px;background-color: " + this.backcolor + "'>";
    var height = 0;
    
    // get code for all toolbars
    for (var i = 0; i < this.aToolbars.length; i++) {
        var toolbar = this.aToolbars[i];
        // calculate the height
        height = height + toolbar.height;
        temp += "<table unselectable='on' class='pinToolbarOut" + toolbar.design + "' width='100%' cellpadding=0 cellspacing=0 border=0><tr unselectable='on'><td unselectable='on'>";
        if (toolbar.fullsize)
            temp += "<table unselectable='on' style='width:100%;"
        else
            temp += "<table unselectable='on' style='width:1%;"
        if (!toolbar.border) {
            temp += "border: 0";
        }
        temp += "' class='pinToolbarIn" + toolbar.design + "'  cellpadding=0 cellspacing=0 border=0><tr unselectable='on'>";
        for (var j = 0; j < toolbar.aComponents.length; j++) {
            var component = toolbar.aComponents[j];
            var html = component.create();
            temp += html;
        }
        var eva = "";

        if (!__hasCancel) {
            if ((i == 0 && __isMode == "I")) {
                eva = "<a href='javascript: editCancel()'><img src='design/image/close.gif' border=0></a>";
                __hasCancel = true;
            }
        }

        if (!__hasEvalation) {
            if (i == this.aToolbars.length - 1 && __isEvaluation) {
                eva = "<font color='#ff0000'>pinEdit Evaluation " + __editVersion + "</font>";
                __hasEvalation = true;
            }
        }
        temp += "</tr></table>";
        if (toolbar.fullsize)
            temp += "</td><td></td></tr></table>";
        else
            temp += "</td><td unselectable='on' style='border:0' align='right' width=100%>" + eva + "</td></tr></table>";
    }
    temp += "</div>";
    // write html code in div
    var objContainer = document.getElementById(this.container);
    objContainer.innerHTML = temp1 + height + temp2 + temp;

       //alert(objContainer.innerHTML)
}

function __toolbars_reset() {
    try {
        for (var i = 0; i < __aAllPopups.length; i++) {
            var popup = __aAllPopups[i];
            popup.init();
        }
    } catch (Error) { }
}

function __toolbars_hide() {
    try {
        if (browser.ns6)
            document.getElementById(this.container + "_div").style.visibility = 'hidden';
        else
            document.getElementById(this.container + "_div").style.display = 'none';
    } catch (Error) { }
}

function __toolbars_show() {
    if (browser.ns6)
        document.getElementById(this.container + "_div").style.visibility = 'visible';
    else
        document.getElementById(this.container + "_div").style.display = 'inline';
}

// Toolbar
function Toolbar() {
    this.id = "";
    this.height = 27;
    this.border = true;
    this.action = "";
    this.design = "";
    this.fullsize = false;

    this.aComponents = new Array();
    this.add = __toolbar_add;
}

function __toolbar_add(component) {
    var id = this.aComponents.length;
    this.aComponents[id] = component;
    component.id = __count;
    component.toolbar = this;
    component.design = this.design;
    __count++;

    // we ned this for access within events
    var id = __aAllComponents.length;
    __aAllComponents[id] = component;

    // optimization so that only the buttons with tag are set
    var id = __aAllTagComponents.length;
    if (component.tag) {
        __aAllTagComponents[id] = component;
    }
}

function Button(text, id, image, action, tooltip, design, tag, width) {
    this.id = "";
    if (width > 0)
        this.width = width;
    this.toolbar = null;
    this.tag = tag;
    this.text = text;
    this.action = action;
    this.image = image;
    // try to cache the image
    this.imageObj = new Image();
    this.imageObj.src = image;

    this.tooltip = tooltip;
    this.design = design;
    this.pressed = false;
    this.enabled = true;
    this.visible = true;

    this.setVisible = __button_visible;
    this.setEnabled = __button_enable;
    this.setStatus = __button_status;
    this.setImage = __button_setimage;

    this.onmouseup = __button_mouseup;
    this.onmousedown = __button_mousedown;
    this.onmouseover = __button_mouseover;
    this.onmouseout = __button_mouseout;

    // MDEARMAN - 04-06-2004 - Added for keyboard accessibility
    this.onfocus = __button_focus;
    this.onblur = __button_blur;
    this.onclick = __button_click;

    this.create = __button_create;
}

function __button_direct(id, action) {
    for (var j = 0; j < __aAllComponents.length; j++) {
        if (__aAllComponents[j].id == id) {
            var component = __aAllComponents[j];
            if (action == "OVER")
                component.onmouseover();
            if (action == "OUT")
                component.onmouseout();
            if (action == "DOWN")
                component.onmousedown();
            if (action == "UP") {
                component.onmouseup();
                if (component.toolbar.action != "") {
                    if (component.tag != "" && component.tag != null)
                        eval(component.toolbar.action + "('" + component.tag + "')");
                }
            }
            // MDEARMAN 04-06-2004 - Added for keyboard accessibility
            else if (action == "FOCUS")
                component.onfocus();
            else if (action == "BLUR")
                component.onblur();
            else if (action == "CLICK")
                component.onclick();
            return;
        }
    }
}

function __button_create() {
    var temp = "<td  unselectable='on' ";
    if (this.width != "")
        temp += " width='" + this.width + "'";
    temp += "><table  unselectable='on' width='100%' cellspacing=1 cellpadding=0 border=0><tr unselectable='on'>";
    temp += "<td  unselectable='on' align='center'";
    if (this.width != "")
        temp += " width='" + this.width + "'";
    temp += " nowrap id='" + this.id + "' ";
    temp += "class='pinButtonStandard" + this.design + "' ";
    temp += "onmouseover='__button_direct(" + this.id + ",\"OVER\")'";
    temp += "onmouseout='__button_direct(" + this.id + ",\"OUT\")'";
    temp += "onmousedown='__button_direct(" + this.id + ",\"DOWN\")'";
    temp += "onmouseup='__button_direct(" + this.id + ",\"UP\")'";

    // MDEARMAN 04-06-2004 - Added for keyboard accessibility
    temp += "onfocus='__button_direct(" + this.id + ",\"FOCUS\")' ";
    temp += "onblur='__button_direct(" + this.id + ",\"BLUR\")' ";
    temp += "onkeypress='if (window.event.keyCode == 32 || window.event.keyCode == 13) __button_direct(" + this.id + ",\"CLICK\")' ";
    temp += "tabindex='1' ";
    temp += "title='" + this.tooltip + "' ";

    temp += ">";
    if (this.image) {
        this.imageid = this.id + "_image";
        temp += "<img  unselectable='on' id='" + this.imageid + "' title='" + this.tooltip + "' align='absmiddle' border='0' src='" + this.image + "'>";
    }
    if (this.text)
        temp += "<span unselectable='on'> " + this.text + "</span>";
    temp += "</td></tr></table></td>";
    return temp;
}

function __button_visible(value) {
    this.visible = value;
}

function __button_enable(value) {
    this.enabled = value;
    var button = document.getElementById(this.id);
    if (value) {
        button.className = 'pinButtonDisabled';
        button.innerHTML = "<span class='pinButtonDisabledContainer'><span class='pinButtonDisabledContainer'>" + button.innerHTML + "</span></span>";
    } else {
        button.className = 'pinButtonStandardOffice';
        button.innerHTML = button.firstChild.firstChild.innerHTML;
    }
}

function __button_status(value) {
    if (this.pressed == value)
        return;

    this.pressed = value;
    if (value) {
        document.getElementById(this.id).className = 'pinButtonActive' + this.design;
    } else {
        document.getElementById(this.id).className = 'pinButtonStandard' + this.design;
    }
}

function __button_setimage(image) {
    this.image = image;
    document.getElementById(this.imageid).src = image;
}


function __button_mouseup() {
    if (!this.enabled)
        return;
    document.getElementById(this.id).className = 'pinButtonHover' + this.design;
    if (this.action != "") {
        eval(this.action);
    }
}

function __button_mousedown() {
    __toolbars_reset();
    if (!this.enabled)
        return;
    document.getElementById(this.id).className = 'pinButtonActive' + this.design;
}

function __button_mouseover() {
    if (!this.enabled)
        return;
    document.getElementById(this.id).className = 'pinButtonHover' + this.design;
}

function __button_mouseout() {
    if (!this.enabled)
        return;
    if (this.pressed == false)
        document.getElementById(this.id).className = 'pinButtonStandard' + this.design;
    else
        document.getElementById(this.id).className = 'pinButtonActive' + this.design;
}

// MDEARMAN 04-06-2004 - Added for keyboard accessibility
function __button_focus() {
    this.onmouseover();
}

function __button_blur() {
    this.onmouseout();
}

function __button_click() {
    this.onmousedown();
    this.onmouseup();

    if (this.toolbar.action != "") {
        if (this.tag != "" && this.tag != null)
            eval(this.toolbar.action + "('" + this.tag + "')");
    }
}
// MDEARMAN 04-06-2004 - End of keyboard accessibility functions



//---------------------------------------------------------------------------------------------
// Combo Object
//---------------------------------------------------------------------------------------------
function Combo(action) {
    this.id = "";
    this.action = action;

    this.setSelected = __combo_setselected;
    this.getSelected = __combo_getselected;

    this.clear = __combo_clear;
    this.setSelectedText = __combo_settext;
    this.create = __combo_create;
    this.add = __combo_add;
}

function __combo_create() {
    var temp = "<td  unselectable='on' style='padding-left: 2px'><select id='" + this.id + "' class='pinCombo' onchange=\"javascript: __combo_direct(" + this.id + ")\"></select></td>";
    return temp;
}

function __combo_clear() {
    var combo = document.getElementById(this.id);
    while (combo.length) {
        combo.remove(0);
    }
}

function __combo_settext(value) {
    var combo = document.getElementById(this.id);
    len = combo.length;
    for (var i = 0; i < len; i++) {
        if (combo.options[i].value == value) {
            combo.selectedIndex = i;
            break;
        }
    }
}

function __combo_add(value, key) {
    var combo = document.getElementById(this.id);
    var item = document.createElement("option");
    item.text = value;
    item.value = key;
    if (browser.ie) {
        combo.add(item);
    } else {
        combo.add(item, null);
    }
}
function __combo_getselected() {
    var temp = "";
    try {
        var combo = document.getElementById(this.id);
        temp = combo.options[combo.selectedIndex].value;
    } catch (Error) { }
    return temp;
}
function __combo_setselected(value) {
    var temp = "";
    try {
        var combo = document.getElementById(this.id);
        len = combo.length;
        for (var i = 0; i < len; i++) {
            if (combo.options[i].value == value) {
                combo.selectedIndex = i;
                break;
            }
        }
    } catch (Error) { }
}
function __combo_direct(id) {
    for (var j = 0; j < __aAllComponents.length; j++) {
        if (__aAllComponents[j].id == id) {
            var component = __aAllComponents[j];
            if (component.action != "") {
                eval(component.action);
            }
            return;
        }
    }
}

//---------------------------------------------------------------------------------------------
// Separator Object
//---------------------------------------------------------------------------------------------
function Separator(image) {
    this.image = image;
    this.create = __separator_create;
    this.design = "";
}
function __separator_create() {
    //var temp = "<td  unselectable='on' class='pinButtonStandard'><img border='0' src='" +  this.image + "'></td>";
    var temp = "<td unselectable='on'><img border='0' src='" + this.image + "'></td>";
    return temp;
}

//---------------------------------------------------------------------------------------------
// Distance Object
//---------------------------------------------------------------------------------------------
function Distance(width, value) {
    this.width = width;
    this.create = __distance_create;
    this.design = "";
    this.background = value;
}
function __distance_create() {
    var temp = "";
    if (this.background)
        temp = "<td unselectable='on' class='pinToolbarDistance" + this.design + "'><div style='width:" + this.width + "px'></div></td>";
    else
        temp = "<td unselectable='on'><div style='width:" + this.width + "px'></div></td>";
    return temp;
}

//-----------------------------------------------------------------------------------------------------
// TABLE BUTTON
//-----------------------------------------------------------------------------------------------------
var __pbutton_clicked;

function TableButton(image, action, tooltip, design, tag) {
    this.id = "";
    this.toolbar = null;
    this.action = action;
    this.tag = tag;
    this.image = image;
    this.tooltip = tooltip;
    this.design = design;
    this.pressed = false;
    this.enabled = true;
    this.visible = true;

    this.setVisible = __pbutton_visible;
    this.setEnabled = __pbutton_enable;
    this.setStatus = __pbutton_status;

    this.onmouseup = __pbutton_mouseup;
    this.onmousedown = __pbutton_mousedown;
    this.onmouseover = __pbutton_mouseover;
    this.onmouseout = __pbutton_mouseout;

    // MDEARMAN - 04-06-2004 - Added for keyboard accessibility
    this.onfocus = __pbutton_focus;
    this.onblur = __pbutton_blur;
    this.onclick = __pbutton_click;

    this.create = __pbutton_create;
    this.init = __pbutton_init;
}

function __pbutton_init() {
    try {
        if (document.getElementById("__tablepopup").style.visibility != "hidden") {
            document.getElementById("__tablepopup").style.visibility = "hidden";
            this.pressed = false;
            this.onmouseup();
        }
    } catch (Error) { }
}

function __pbutton_direct(id, action) {
    for (var j = 0; j < __aAllComponents.length; j++) {
        if (__aAllComponents[j].id == id) {
            var component = __aAllComponents[j];
            if (action == "OVER")
                component.onmouseover();
            if (action == "OUT")
                component.onmouseout();
            if (action == "DOWN") {
                component.onmousedown();
                // get the position
                var tablepopup = document.getElementById("__tablepopup");
                var obj = document.getElementById(id);
                var x = globalGetPositonX(obj) - 2;
                var y = globalGetPositonY(obj);
                tablepopup.style.left = x;
                tablepopup.style.top = y + obj.offsetHeight - 1;
                tablepopup.style.visibility = "visible";
                // save the current button
                __pbutton_clicked = component;
            }
            if (action == "UP") {
                component.onmouseup();
            }
            // MDEARMAN 04-06-2004 - Added for keyboard accessibility
            else if (action == "FOCUS")
                component.onfocus();
            else if (action == "BLUR")
                component.onblur();
            else if (action == "CLICK") {
                component.onclick();
                // get the position
                var tablepopup = document.getElementById("__tablepopup");
                var obj = document.getElementById(id);
                var x = globalGetPositonX(obj);
                var y = globalGetPositonY(obj);
                tablepopup.style.left = x;
                tablepopup.style.top = y + obj.offsetHeight - 1;
                //tablepopup.style.top = obj.offsetHeight;
                tablepopup.style.visibility = "visible";
                // save the current button
                __pbutton_clicked = component;
            }
            return;
        }
    }
}

function __pbutton_popup_click(row, col) {
    //__pbutton_popup_cancel();
    __pbutton_clicked.init();
    if (__pbutton_clicked.action != "") {
        eval(__pbutton_clicked.action + "(" + row + "," + col + ")");
    }
}

// needed because directly called from tabel popup
function __pbutton_popup_cancel() {
    try {
        document.getElementById("__tablepopup").style.visibility = "hidden";
        __pbutton_clicked.pressed = false;
        __pbutton_clicked.onmouseup();
    } catch (Error) { }
}

function __pbutton_create() {
    var temp = "<td unselectable='on'><table unselectable='on' cellspacing=1 cellpadding=0 border=0><tr><td nowrap id='" + this.id + "' ";
    temp += "class='pinButtonStandard" + this.design + "' ";
    temp += "onmouseover='__pbutton_direct(" + this.id + ",\"OVER\")'";
    temp += "onmouseout='__pbutton_direct(" + this.id + ",\"OUT\")'";
    temp += "onmousedown='__pbutton_direct(" + this.id + ",\"DOWN\")'";
    temp += "onmouseup='__pbutton_direct(" + this.id + ",\"UP\")'";

    // MDEARMAN 04-06-2004 - Added for keyboard accessibility
    temp += "onfocus='__pbutton_direct(" + this.id + ",\"FOCUS\")' ";
    temp += "onblur='__pbutton_direct(" + this.id + ",\"BLUR\")' ";
    temp += "onkeypress='if (window.event.keyCode == 32 || window.event.keyCode == 13) __pbutton_direct(" + this.id + ",\"CLICK\")' ";
    temp += "tabindex='1' ";
    temp += "title='" + this.tooltip + "' ";

    temp += ">";
    if (this.image)
        temp += "<img  unselectable='on' id='__image' title='" + this.tooltip + "' align='absmiddle' border='0' src='" + this.image + "'>";
    if (this.text)
        temp += " " + this.text;
    temp += "<iframe unselectable='on' id='__tablepopup' src='popup/table.html?language=" + language + "&style=" + design + "' style='overflow:hidden;visibility:hidden;position:absolute;left:10px;width:120px;height:132px' frameborder='0' scrolling='no'></iframe>";
    temp += "</td></tr></table></td>";

    // add the id to the popup collection
    var count = __aAllPopups.length;
    __aAllPopups[count] = this;  //"__pbutton_popup_cancel()";

    return temp;
}

function __pbutton_visible(value) {
    this.visible = value;
}

function __pbutton_enable(value) {
    this.enabled = value;
    var button = document.getElementById(this.id);
    if (value) {
        button.className = 'pinButtonDisabled';
        button.innerHTML = "<span class='pinButtonDisabledContainer'><span class='pinButtonDisabledContainer'>" + button.innerHTML + "</span></span>";
    } else {
        button.className = 'pinButtonStandardOffice';
        button.innerHTML = button.firstChild.firstChild.innerHTML;
    }
}

function __pbutton_status(value) {
    this.pressed = value;
    if (value) {
        document.getElementById(this.id).className = 'pinButtonPopup' + this.design;
    } else {
        document.getElementById(this.id).className = 'pinButtonStandard' + this.design;
    }
}

function __pbutton_mouseup() {
    if (!this.enabled)
        return;
    if (!this.pressed) {
        document.getElementById(this.id).className = 'pinButtonStandard' + this.design;
        document.getElementById("__tablepopup").style.visibility = "hidden";
    }
}

function __pbutton_mousedown() {
    //__toolbars_reset();
    if (!this.enabled)
        return;
    this.pressed = !this.pressed;
    if (this.pressed)
        document.getElementById(this.id).className = 'pinButtonPopup' + this.design;
}

function __pbutton_mouseover() {
    if (!this.enabled)
        return;
    if (this.pressed)
        document.getElementById(this.id).className = 'pinButtonPopup' + this.design;
    else
        document.getElementById(this.id).className = 'pinButtonHover' + this.design;
}

function __pbutton_mouseout() {
    if (!this.enabled)
        return;
    if (this.pressed == false)
        document.getElementById(this.id).className = 'pinButtonStandard' + this.design;
    else
        document.getElementById(this.id).className = 'pinButtonPopup' + this.design;
}

// MDEARMAN 04-06-2004 - Added for keyboard accessibility
function __pbutton_focus() {
    this.onmouseover();
}

function __pbutton_blur() {
    this.onmouseout();
}

function __pbutton_click() {
    this.onmousedown();
}
// MDEARMAN 04-06-2004 - End of keyboard accessibility functions

var __csbutton_clicked;

//--------------------------------------------------------------------------------------------------
// COLOR SELECTOR
//--------------------------------------------------------------------------------------------------
function ColorSelector(image, image2, action, tooltip, tooltip2, design, tag) {
    this.id = "";
    this.toolbar = null;
    this.action = action;
    this.tag = tag;
    this.image = image;
    this.image2 = image2;
    this.tooltip = tooltip;
    this.tooltip2 = tooltip2;
    this.design = design;
    this.pressed = false;
    this.enabled = true;
    this.visible = true;

    this.setVisible = __csbutton_visible;
    this.setEnabled = __csbutton_enable;

    this.onmouseup = __csbutton_mouseup;
    this.onmousedown = __csbutton_mousedown;
    this.onmouseover = __csbutton_mouseover;
    this.onmouseout = __csbutton_mouseout;

    // MDEARMAN - 04-06-2004 - Added for keyboard accessibility
    this.onfocus = __csbutton_focus;
    this.onblur = __csbutton_blur;
    this.onclick = __csbutton_click;

    this.create = __csbutton_create;
    this.init = __csbutton_init;
}

function __csbutton_init() {
    try {
        if (document.getElementById("__cspopup" + this.id).style.visibility != "hidden") {
            document.getElementById("__cspopup" + this.id).style.visibility = "hidden";
            document.getElementById(this.id + "_1").className = 'pinButtonStandard' + __csbutton_clicked.design;
            this.pressed = false;
            //__csbutton_clicked.onmouseup();
        }
    } catch (Error) { }
}

function __csbutton_direct(id, action, part) {
    for (var j = 0; j < __aAllComponents.length; j++) {
        if (__aAllComponents[j].id == id) {
            var component = __aAllComponents[j];
            if (action == "OVER")
                component.onmouseover(part);
            else if (action == "OUT")
                component.onmouseout(part);
            else if (action == "DOWN") {
                if (part == 1) {
                    // get the position
                    var popup = document.getElementById("__cspopup" + id);
                    var obj = document.getElementById(id);
                    var x = globalGetPositonX(obj) - 2;
                    var y = globalGetPositonY(obj);
                    popup.style.left = x;
                    popup.style.top = y + obj.offsetHeight;
                    // save the current button
                    __csbutton_clicked = component;
                }
                component.onmousedown(part);
            }
            else if (action == "UP") {
                component.onmouseup(part);
            }
            // MDEARMAN 04-06-2004 - Added for keyboard accessibility
            else if (action == "FOCUS")
                component.onfocus(part);
            else if (action == "BLUR")
                component.onblur(part);
            else if (action == "CLICK") {
                if (part == 1) {
                    // get the position
                    var popup = document.getElementById("__cspopup" + id);
                    var obj = document.getElementById(id);
                    var x = globalGetPositonX(obj);
                    var y = globalGetPositonY(obj);
                    popup.style.left = x;
                    popup.style.top = y + obj.offsetHeight;
                    // save the current button
                    __csbutton_clicked = component;
                }
            }
            return;
        }
    }
}

function __csbutton_popup_click(color) {
    //__csbutton_popup_cancel();
    __csbutton_clicked.init();
    if (color != "") {
        if (__csbutton_clicked.action != "") {
            eval(__csbutton_clicked.action + "('" + color + "')");
        }
        if (color == "NOCOLOR")
            document.getElementById("__color" + __csbutton_clicked.id).style.backgroundColor = "black";
        else
            document.getElementById("__color" + __csbutton_clicked.id).style.backgroundColor = color;
    }
}

/*
function __csbutton_popup_cancel()
{
try {
document.getElementById("__cspopup" + __csbutton_clicked.id).style.visibility = "hidden";
document.getElementById(__csbutton_clicked.id + "_1").className='pinButtonStandard' + __csbutton_clicked.design;
__csbutton_clicked.pressed = false;
//__csbutton_clicked.onmouseup();
} catch(Error) {}
}
*/

function __csbutton_create() {
    var temp = "<td unselectable='on'><table unselectable='on' cellspacing=1 cellpadding=0 border=0><tr><td nowrap id='" + this.id + "' ";
    temp += "class='pinButtonStandard" + this.design + "' ";
    temp += "onmouseover='__csbutton_direct(" + this.id + ",\"OVER\",0)'";
    temp += "onmouseout='__csbutton_direct(" + this.id + ",\"OUT\",0)'";
    temp += "onmousedown='__csbutton_direct(" + this.id + ",\"DOWN\",0)'";
    temp += "onmouseup='__csbutton_direct(" + this.id + ",\"UP\",0)'";

    // MDEARMAN 04-06-2004 - Added for keyboard accessibility
    temp += "onfocus='__csbutton_direct(" + this.id + ",\"FOCUS\", 0)' ";
    temp += "onblur='__csbutton_direct(" + this.id + ",\"BLUR\", 0)' ";
    temp += "onkeypress='if (window.event.keyCode == 32 || window.event.keyCode == 13) __csbutton_direct(" + this.id + ",\"CLICK\", 0)' ";
    temp += "tabindex='1' ";
    temp += "title='" + this.tooltip + "' ";

    temp += ">";
    if (this.image)
        temp += "<img id='__image" + this.id + "' title='" + this.tooltip + "' align='absmiddle' border='0' src='" + this.image + "'>";
    if (this.text)
        temp += " " + this.text;
    temp += "<br><div id='__color" + this.id + "' style='font-family: Arial;font-size:3px;width:16px;height:4px;background-color:red;'></div>";
    temp += "</td>";

    temp += "<td nowrap id='" + this.id + "_1" + "' ";
    temp += "class='pinButtonStandard" + this.design + "' ";
    temp += "onmouseover='__csbutton_direct(" + this.id + ",\"OVER\",1)'";
    temp += "onmouseout='__csbutton_direct(" + this.id + ",\"OUT\",1)'";
    temp += "onmousedown='__csbutton_direct(" + this.id + ",\"DOWN\",1)'";
    temp += "onmouseup='__csbutton_direct(" + this.id + ",\"UP\",1)'";

    // MDEARMAN 04-06-2004 - Added for keyboard accessibility
    temp += "onfocus='__csbutton_direct(" + this.id + ",\"FOCUS\", 1)' ";
    temp += "onblur='__csbutton_direct(" + this.id + ",\"BLUR\", 1)' ";
    temp += "onkeypress='if (window.event.keyCode == 32 || window.event.keyCode == 13) __csbutton_direct(" + this.id + ",\"CLICK\", 1)' ";
    temp += "tabindex='1' ";
    temp += "title='" + this.tooltip + "' ";

    temp += ">";
    if (this.image2)
        temp += "<img id='__image2" + this.id + "' title='" + this.tooltip2 + "' align='absmiddle' border='0' src='" + this.image2 + "'>";
    temp += "</td></tr></table></td>";
    temp += "<iframe unselectable='on' id='__cspopup" + this.id + "' src='popup/color.html?language=" + language + "&style=" + design + "&bgcolor=" + globalToolbarColor + "' style='overflow:hidden;visibility:hidden;position:absolute;width:140px;height:128px' frameborder='0' scrolling='no'></iframe>";
    // add the id to the popup collection
    var count = __aAllPopups.length;
    __aAllPopups[count] = this;  //"__csbutton_popup_cancel()";

    return temp;
}

function __csbutton_visible(value) {
    this.visible = value;
}

function __csbutton_enable(value) {
    this.enabled = value;
    var button = document.getElementById(this.id);
    if (value) {
        button.className = 'pinButtonDisabled';
        button.innerHTML = "<span class='pinButtonDisabledContainer'><span class='pinButtonDisabledContainer'>" + button.innerHTML + "</span></span>";
    } else {
        button.className = 'pinButtonStandardOffice';
        button.innerHTML = button.firstChild.firstChild.innerHTML;
    }
}

function __csbutton_mouseup(part) {
    if (part == 0) {
        document.getElementById(this.id).className = 'pinButtonHover' + this.design;
        if (this.action != "") {
            var color = document.getElementById("__color" + this.id).style.backgroundColor;
            eval(this.action + "('" + color + "')");
        }
    }
}

function __csbutton_mousedown(part) {
    if (!this.enabled)
        return;

    if (part == 0) {
        document.getElementById(this.id).className = 'pinButtonActive' + this.design;
    } else {
        if (!this.pressed) {
            document.getElementById(this.id + "_1").className = 'pinButtonPopup' + this.design;
            document.getElementById("__cspopup" + this.id).style.visibility = "visible";
            this.pressed = true;
        } else {
            __toolbars_reset();
        }
    }
}

function __csbutton_mouseover(part) {
    if (!this.enabled)
        return;
    document.getElementById(this.id).className = 'pinButtonHover' + this.design;
    if (this.pressed)
        document.getElementById(this.id + "_1").className = 'pinButtonPopup' + this.design;
    else
        document.getElementById(this.id + "_1").className = 'pinButtonHover' + this.design;
}

function __csbutton_mouseout(part) {
    if (!this.enabled)
        return;

    document.getElementById(this.id).className = 'pinButtonStandard' + this.design;
    if (this.pressed == false)
        document.getElementById(this.id + "_1").className = 'pinButtonStandard' + this.design;
    else
        document.getElementById(this.id + "_1").className = 'pinButtonPopup' + this.design;
}

// MDEARMAN 04-07-2004 - Added for keyboard accessibility
function __csbutton_focus(part) {
    this.onmouseover(part);
}

function __csbutton_blur(part) {
    this.onmouseout(part);
}

function __csbutton_click(part) {
    this.onmousedown(part);
}
// MDEARMAN 04-07-2004 - End of keyboard accessibility functions


//-------------------------------------------------------------------------------------------------
// COLOR BUTTON
//-------------------------------------------------------------------------------------------------
function ColorButton(color, tooltip, design, tag) {
    this.id = "";
    this.color = color;
    this.toolbar = null;
    this.tag = tag;
    this.tooltip = tooltip;
    this.design = design;
    this.pressed = false;
    this.enabled = true;
    this.visible = true;

    this.onmouseup = __cbutton_mouseup;
    this.onmousedown = __cbutton_mousedown;
    this.onmouseover = __cbutton_mouseover;
    this.onmouseout = __cbutton_mouseout;

    // MDEARMAN - 04-06-2004 - Added for keyboard accessibility
    this.onfocus = __cbutton_focus;
    this.onblur = __cbutton_blur;
    this.onclick = __cbutton_click;

    this.create = __cbutton_create;
    this.init = __cbutton_init;
}

function __cbutton_init() {
    if (document.getElementById("__tablepopup").style.visibility != "hidden") {
        document.getElementById("__tablepopup").style.visibility = "hidden";
        this.pressed = false;
        this.onmouseup();
    }
}

function __cbutton_direct(id, action) {
    for (var j = 0; j < __aAllComponents.length; j++) {
        if (__aAllComponents[j].id == id) {
            var component = __aAllComponents[j];
            if (action == "OVER")
                component.onmouseover();
            else if (action == "OUT")
                component.onmouseout();
            else if (action == "DOWN")
                component.onmousedown();
            else if (action == "UP") {
                component.onmouseup();
                if (component.toolbar.action != "") {
                    if (component.tag != "" && component.tag != null)
                        eval(component.toolbar.action + "('" + component.tag + "')");
                }
            }

            // MDEARMAN 04-06-2004 - Added for keyboard accessibility
            else if (action == "FOCUS")
                component.onfocus();
            else if (action == "BLUR")
                component.onblur();
            else if (action == "CLICK") {
                component.onclick();
                if (component.toolbar.action != "") {
                    if (component.tag != "" && component.tag != null)
                        eval(component.toolbar.action + "('" + component.tag + "')");
                }
            }
            return;
        }
    }
}

function __cbutton_popup_click(row, col) {
    //__pbutton_popup_cancel();
    __pbutton_clicked.init();
    if (__pbutton_clicked.action != "") {
        eval(__pbutton_clicked.action + "(" + row + "," + col + ")");
    }
}

/*
function __cbutton_popup_cancel()
{
document.getElementById("__tablepopup").style.visibility = "hidden";
__pbutton_clicked.pressed = false;
__pbutton_clicked.onmouseup();
}
*/

function __cbutton_create() {
    var temp = "<td unselectable='on' nowrap id='" + this.id + "' ";
    temp += "class='pinButtonStandard" + this.design + "' ";
    temp += "onmouseover='__cbutton_direct(" + this.id + ",\"OVER\")'";
    temp += "onmouseout='__cbutton_direct(" + this.id + ",\"OUT\")'";
    temp += "onmousedown='__cbutton_direct(" + this.id + ",\"DOWN\")'";
    temp += "onmouseup='__cbutton_direct(" + this.id + ",\"UP\")'";

    // MDEARMAN 04-06-2004 - Added for keyboard accessibility
    temp += "onfocus='__cbutton_direct(" + this.id + ",\"FOCUS\")' ";
    temp += "onblur='__cbutton_direct(" + this.id + ",\"BLUR\")' ";
    temp += "onkeypress='if (window.event.keyCode == 32 || window.event.keyCode == 13) __cbutton_direct(" + this.id + ",\"CLICK\")' ";
    temp += "tabindex='1' ";
    temp += "title='" + this.tooltip + "' ";

    temp += ">";

    temp += "<div unselectable='on' style='height:11px;width:11px;font-family: Arial;font-size:3px;background-color:" + this.color + ";'></div>";
    temp += "</td>";
    return temp;
}

function __cbutton_mouseup() {
    if (!this.enabled)
        return;
    document.getElementById(this.id).className = 'pinButtonHover' + this.design;
    if (this.action != "") {
        eval(this.action);
    }
}

function __cbutton_mousedown() {
    __toolbars_reset();
    if (!this.enabled)
        return;
    document.getElementById(this.id).className = 'pinButtonActive' + this.design;
}

function __cbutton_mouseover() {
    if (!this.enabled)
        return;
    document.getElementById(this.id).className = 'pinButtonHover' + this.design;
}

function __cbutton_mouseout() {
    if (!this.enabled)
        return;
    if (this.pressed == false)
        document.getElementById(this.id).className = 'pinButtonStandard' + this.design;
    else
        document.getElementById(this.id).className = 'pinButtonActive' + this.design;
}

// MDEARMAN 04-07-2004 - Added for keyboard accessibility
function __cbutton_focus() {
    this.onmouseover();
}

function __cbutton_blur() {
    this.onmouseout();
}

function __cbutton_click() {
    this.onmousedown();
}
// MDEARMAN 04-07-2004 - End of keyboard accessibility functions



//-----------------------------------------------------------------------------------------------------
// MENU BUTTON
//-----------------------------------------------------------------------------------------------------
var __mbutton_clicked;

function MenuButton(menu, image, action, tooltip, design, tag) {
    this.id = "";
    this.width = "150px";
    this.height = "90px";
    this.toolbar = null;
    this.action = action;
    this.menu = menu;
    this.tag = tag;
    this.image = image;
    this.tooltip = tooltip;
    this.design = design;
    this.pressed = false;
    this.enabled = true;
    this.visible = true;

    this.setVisible = __mbutton_visible;
    this.setEnabled = __mbutton_enable;
    this.setStatus = __mbutton_status;

    this.onmouseup = __mbutton_mouseup;
    this.onmousedown = __mbutton_mousedown;
    this.onmouseover = __mbutton_mouseover;
    this.onmouseout = __mbutton_mouseout;

    // MDEARMAN - 04-06-2004 - Added for keyboard accessibility
    this.onfocus = __mbutton_focus;
    this.onblur = __mbutton_blur;
    this.onclick = __mbutton_click;

    this.create = __mbutton_create;
    this.init = __mbutton_init;
}

function __mbutton_init() {
    try {
        if (document.getElementById("__menupopup" + this.id).style.visibility != "hidden") {
            document.getElementById("__menupopup" + this.id).style.visibility = "hidden";
            document.getElementById(this.id).className = 'pinButtonStandard' + this.design;
            this.pressed = false;
        }
    } catch (Error) { }
}

function __mbutton_direct(id, action) {
    for (var j = 0; j < __aAllComponents.length; j++) {
        if (__aAllComponents[j].id == id) {
            var component = __aAllComponents[j];
            if (action == "OVER")
                component.onmouseover();
            if (action == "OUT")
                component.onmouseout();
            if (action == "DOWN") {
                // get the position
                var tablepopup = document.getElementById("__menupopup" + component.id);
                var obj = document.getElementById(id);
                var x = globalGetPositonX(obj) - 2;
                var y = globalGetPositonY(obj);
                tablepopup.style.left = x;
                tablepopup.style.top = y + obj.offsetHeight - 1;
                //tablepopup.style.visibility = "visible";
                // save the current button
                __mbutton_clicked = component;
                component.onmousedown();
            }
            if (action == "UP") {
                component.onmouseup();
            }

            // MDEARMAN 04-06-2004 - Added for keyboard accessibility
            else if (action == "FOCUS")
                component.onfocus();
            else if (action == "BLUR")
                component.onblur();
            else if (action == "CLICK") {
                if (!this.pressed) {
                    // get the position
                    var menupopup = document.getElementById("__menupopup" + component.id);
                    var obj = document.getElementById(id);
                    var x = globalGetPositonX(obj);
                    var y = globalGetPositonY(obj);
                    menupopup.style.left = x;
                    menupopup.style.top = y + obj.offsetHeight - 1;
                    //					menupopup.contentWindow.objMenu.focus();
                    //tablepopup.style.visibility = "visible";
                    // save the current button
                    __mbutton_clicked = component;
                    component.onclick();
                    this.pressed = true;
                } else {
                    __toolbars_reset();
                }
            }
            return;
        }
    }
}

function __mbutton_popup_click(tag) {
    //__mbutton_popup_cancel();
    __mbutton_clicked.init();
    if (__mbutton_clicked.action != "") {
        eval(__mbutton_clicked.action + "('" + tag + "')");
    }
}

/*
function __mbutton_popup_cancel()
{
try {
document.getElementById("__menupopup" + __mbutton_clicked.id).style.visibility = "hidden";
document.getElementById(__mbutton_clicked.id).className='pinButtonStandard' + __mbutton_clicked.design;
__mbutton_clicked.pressed = false;
} catch(Error) {}
}
*/

function __mbutton_create() {
    //var temp = "<td><table cellspacing=1 cellpadding=0 border=0><tr><td align='center'";
    //temp+= "</td></tr></table></td>";

    var temp = "<td unselectable='on'><table unselectable='on' cellspacing=1 cellpadding=0 border=0><tr><td unselectable='ON' nowrap id='" + this.id + "' ";
    temp += "class='pinButtonStandard" + this.design + "' ";
    temp += "onmouseover='__mbutton_direct(" + this.id + ",\"OVER\")'";
    temp += "onmouseout='__mbutton_direct(" + this.id + ",\"OUT\")'";
    temp += "onmousedown='__mbutton_direct(" + this.id + ",\"DOWN\")'";
    temp += "onmouseup='__mbutton_direct(" + this.id + ",\"UP\")'";

    // MDEARMAN 04-06-2004 - Added for keyboard accessibility
    temp += "onfocus='__mbutton_direct(" + this.id + ",\"FOCUS\")' ";
    temp += "onblur='__mbutton_direct(" + this.id + ",\"BLUR\")' ";
    temp += "onkeypress='if (window.event.keyCode == 32 || window.event.keyCode == 13) __mbutton_direct(" + this.id + ",\"CLICK\")' ";
    temp += "tabindex='1' ";
    temp += "title='" + this.tooltip + "' ";

    temp += ">";
    if (this.image)
        temp += "<img  unselectable='ON' id='__image' title='" + this.tooltip + "' align='absmiddle' border='0' src='" + this.image + "'>";
    if (this.text)
        temp += " " + this.text;
    temp += "</td></tr></table></td>";
    temp += "<iframe unselectable='on' id='__menupopup" + this.id + "' src='popup/" + this.menu + "?language=" + language + "&style=" + design + "&bgcolor=" + globalToolbarColor + "' style='overflow:hidden;visibility:hidden;position:absolute;left:10px;width:" + this.width + ";height:" + this.height + "' frameborder='0' scrolling='no'></iframe>";

    // add the id to the popup collection
    var count = __aAllPopups.length;
    __aAllPopups[count] = this; //"__mbutton_popup_cancel()";
    return temp;
}

function __mbutton_visible(value) {
    this.visible = value;
}

function __mbutton_enable(value) {
    this.enabled = value;
    var button = document.getElementById(this.id);
    if (value) {
        button.className = 'pinButtonDisabled';
        button.innerHTML = "<span class='pinButtonDisabledContainer'><span class='pinButtonDisabledContainer'>" + button.innerHTML + "</span></span>";
    } else {
        button.className = 'pinButtonStandardOffice';
        button.innerHTML = button.firstChild.firstChild.innerHTML;
    }
}

function __mbutton_status(value) {
    this.pressed = value;
    if (value) {
        document.getElementById(this.id).className = 'pinButtonPopup' + this.design;
    } else {
        document.getElementById(this.id).className = 'pinButtonStandard' + this.design;
    }
}

function __mbutton_mouseup() {
    if (!this.enabled)
        return;
}

function __mbutton_mousedown() {
    //__toolbars_reset();

    if (!this.enabled)
        return;

    if (!this.pressed) {
        document.getElementById(this.id).className = 'pinButtonPopup' + this.design;
        document.getElementById("__menupopup" + this.id).style.visibility = "visible";
        this.pressed = true;
    } else {
        __toolbars_reset();
        this.pressed = false;
    }
}

function __mbutton_mouseover() {
    if (!this.enabled)
        return;

    if (this.pressed)
        document.getElementById(this.id).className = 'pinButtonPopup' + this.design;
    else
        document.getElementById(this.id).className = 'pinButtonHover' + this.design;
}

function __mbutton_mouseout() {
    if (!this.enabled)
        return;

    if (this.pressed == false)
        document.getElementById(this.id).className = 'pinButtonStandard' + this.design;
    else
        document.getElementById(this.id).className = 'pinButtonPopup' + this.design;
}

// MDEARMAN 04-07-2004 - Added for keyboard accessibility
function __mbutton_focus() {
    this.onmouseover();
}

function __mbutton_blur() {
    this.onmouseout();
}

function __mbutton_click() {
    this.onmousedown();
}
// MDEARMAN 04-07-2004 - End of keyboard accessibility functions


//-----------------------------------------------------------------------------------------------------
// STYLE COMBO
//-----------------------------------------------------------------------------------------------------
var __scombo_clicked;

function StyleCombo(action, tooltip, design, tag) {
    this.id = "";
    this.width = "100px";
    this.popupwidth = "100px";
    this.popupheight = "";
    this.toolbar = null;
    this.action = action;
    this.tag = tag;
    this.tooltip = tooltip;
    this.design = design;
    this.enabled = true;
    this.visible = true;
    this.selectedItem = null;
    // id of combo text. Needed for changes
    this.textid = "";
    // name of property like "tag1". This value is displayed as combo text
    this.displayValue = null;
    // all combo items
    this.aItems = new Array();
    // define new menu
    this.menu = new Menu("__scombo_item_click");
    // set design
    if (design == "")
        this.menu.design = "Office2000";
    if (design == "Office")
        this.menu.design = "OfficeXP";
    if (design == "Office2003")
        this.menu.design = "Office2003";
    // no image col
    this.menu.imageColumn = false;
    // the callback from pinMenu.html
    this.menu.callbackInternal = "__style_combo_callback";
    // is a popup
    this.menu.isPopupMode = true;

    this.setVisible = __scombo_visible;
    this.setEnabled = __scombo_enable;
    this.setStatus = __scombo_status;

    this.onmouseup = __scombo_mouseup;
    this.onmousedown = __scombo_mousedown;
    this.onmouseover = __scombo_mouseover;
    this.onmouseout = __scombo_mouseout;

    this.create = __scombo_create;
    this.add = __scombo_add;
    this.setSelected = __scombo_setselected;
    this.setSelectedText = __scombo_setselected_text;
    this.getSelected = __scombo_getselected;
    this.init = __scombo_init;
    this.clear = __scombo_clear;
    this.getItemByValue = __scombo_getbyvalue;
}

function __scombo_getbyvalue(value) {
    for (var i = 0; i < this.aItems.length; i++) {
        var item = this.aItems[i];
        if (item.value.toUpperCase() == value)
            return item;
    }
}

function __scombo_init() {
    try {
        if (document.getElementById("__stylepopup" + this.id).style.visibility != "hidden") {
            document.getElementById("__stylepopup" + this.id).style.visibility = "hidden";
            document.getElementById(this.id).className = 'pinComboStandard' + this.design;
            this.pressed = false;
        }
    } catch (Error) { }
}

function __scombo_clear() {
    this.aItems = new Array();
}

function __scombo_setselected_text(value) {
    for (var i = 0; i < this.aItems.length; i++) {
        var item = this.aItems[i];
        if (value == item.value) {
            this.setSelected(item);
            break;
        }
    }
}

function __scombo_getselected() {
    return this.selectedItem;
}

function __scombo_setselected(item) {
    var text = (this.displayValue != null) ? eval("item." + this.displayValue) : item.text;
    if (document.getElementById(this.textid).innerHTML != text) {
        document.getElementById(this.textid).innerHTML = text;
    }
    this.selectedItem = item;
}

function __scombo_add(item) {
    var id = this.aItems.length;
    this.aItems[id] = item;
    item.id = __count;
    item.parent = this;
    __count++;
}

function __style_combo_callback(id) {
    var item = __scombo_clicked.menu.getItemById(id);
    __scombo_clicked.setSelected(item);
    if (__scombo_clicked.action != "") {
        eval(__scombo_clicked.action + "(\"" + item.text + "\",\"" + item.value + "\",\"" + item.tag1 + "\",\"" + item.tag2 + "\")");
    }
    __scombo_clicked.init();
}

function __scombo_direct(id, action) {
    for (var j = 0; j < __aAllComponents.length; j++) {
        if (__aAllComponents[j].id == id) {
            var component = __aAllComponents[j];
            if (action == "OVER")
                component.onmouseover();
            if (action == "OUT")
                component.onmouseout();
            if (action == "DOWN") {
                // get the position
                var tablepopup = document.getElementById("__stylepopup" + component.id);
                var obj = document.getElementById(id);
                var x = globalGetPositonX(obj);
                var y = globalGetPositonY(obj);
                tablepopup.style.left = x;
                tablepopup.style.top = y + obj.offsetHeight + 1;
                // save the current button
                __scombo_clicked = component;
                component.onmousedown();
            }
            if (action == "UP") {
                component.onmouseup();
            }
            return;
        }
    }
}

function __scombo_popup_click(tag) {
    //__scombo_popup_cancel();
    __scombo_clicked.init();
    if (__scombo_clicked.action != "") {
        eval(__scombo_clicked.action + "('" + tag + "')");
    }
}

/*
function __scombo_popup_cancel(id)
{
try {
document.getElementById("__stylepopup" + curId).style.visibility = "hidden";
document.getElementById(curId).className='pinComboStandard' + __scombo_clicked.design;
__scombo_clicked.pressed = false;
} catch(Error) {}
}
*/

function __scombo_create() {
    var text = "";

    if (this.aItems.length == 0)
        text = "";
    else
        text = (this.displayValue != null) ? eval("this.aItems[0]." + this.displayValue) : this.aItems[0].text;

    var temp = "<td unselectable='on'><table style='width:" + this.width + "' title='" + this.tooltip + "' cellspacing=0 cellpadding=0 border=0 id='" + this.id + "' ";
    temp += " class='pinComboStandard" + this.design + "' ";
    temp += " onmouseover='__scombo_direct(" + this.id + ",\"OVER\")'";
    temp += " onmouseout='__scombo_direct(" + this.id + ",\"OUT\")'";
    temp += " onmousedown='__scombo_direct(" + this.id + ",\"DOWN\")'";
    temp += " onmouseup='__scombo_direct(" + this.id + ",\"UP\")'";
    temp += ">";
    temp += "<tr><td unselectable='on' width='100%' nowrap>";
    temp += "<p id='" + this.id + "_text' style='padding-left:3px;padding-right:3px;' unselectable='ON'>" + text + "</p>";
    temp += "</td><td>";
    temp += "<img id='__image' title='" + this.tooltip + "' align='absmiddle' border='0' src='design/image/" + design + "/combo_arrow.gif'>";
    temp += "</td></tr></table></td>";
    if (this.design == "Office2003")
        temp += "<iframe unselectable='ON' src='" + this.menu.path + "pinMenu.html'  id='__stylepopup" + this.id + "' style='border-width:1px;border-style:solid;border-color:#002E96;visibility:hidden;position:absolute;left:10px;width:" + this.popupwidth + ";height:" + this.popupheight + "' frameborder='0' ></iframe>";
    if (this.design == "")
        temp += "<iframe unselectable='ON' src='" + this.menu.path + "pinMenu.html'  id='__stylepopup" + this.id + "' style='border-width:1px;border-style:solid;border-color:black;visibility:hidden;position:absolute;left:10px;width:" + this.popupwidth + ";height:" + this.popupheight + "' frameborder='0' ></iframe>";
    if (this.design == "Office")
        temp += "<iframe unselectable='ON' src='" + this.menu.path + "pinMenu.html'  id='__stylepopup" + this.id + "' style='border-width:1px;border-style:solid;border-color:#8A867A;visibility:hidden;position:absolute;left:10px;width:" + this.popupwidth + ";height:" + this.popupheight + "' frameborder='0' ></iframe>";

    // define container
    this.menu.id = "__stylepopup" + this.id;
    // define text id
    this.textid = this.id + "_text";
    // set selection
    if (this.aItems[0])
        this.selected = this.aItems[0];

    // add the id to the popup collection
    var count = __aAllPopups.length;
    __aAllPopups[count] = this;      //"__scombo_popup_cancel('" + this.id + "')";
    return temp;
}

function __scombo_visible(value) {
    this.visible = value;
}

function __scombo_enable(value) {
    this.enabled = value;
    var button = document.getElementById(this.id);
    if (value) {
        button.className = 'pinButtonDisabled';
        button.innerHTML = "<span class='pinButtonDisabledContainer'><span class='pinButtonDisabledContainer'>" + button.innerHTML + "</span></span>";
    } else {
        button.className = 'pinButtonStandardOffice';
        button.innerHTML = button.firstChild.firstChild.innerHTML;
    }
}

function __scombo_status(value) {
    this.pressed = value;
    if (value) {
        document.getElementById(this.id).className = 'pinComboPopup' + this.design;
    } else {
        document.getElementById(this.id).className = 'pinComboStandard' + this.design;
    }
}

function __scombo_mouseup() {
    if (!this.enabled)
        return;
}

function __scombo_mousedown() {
    //  __toolbars_reset();

    if (!this.enabled)
        return;

    if (!this.pressed) {
        __toolbars_reset();
        // create menu
        this.menu.clear();
        for (i = 0; i < this.aItems.length; i++) {
            var item = this.aItems[i];
            this.menu.add(new MenuItem(item.text, item.image, item.title, item.value, item.tag1, item.tag2));
        }
        document.getElementById(this.id).className = 'pinComboPopup' + this.design;
        document.getElementById("__stylepopup" + this.id).style.visibility = "visible";

        // MenuFrame" + this.design

        // set the html content
        var doc = document.getElementById("__stylepopup" + this.id).contentWindow.document;
        doc.body.style.overflow = "auto";
        doc.body.innerHTML = this.menu.create(30);
        doc.body.style.backgroundColor = "white";
        // set the height if not greater than specified
        var height;
        if (parseInt(this.menu.height) > parseInt(this.popupheight))
            height = this.popupheight;
        else
            height = this.menu.height;
        document.getElementById("__stylepopup" + this.id).style.height = height;
        this.pressed = true;
    } else {
        __toolbars_reset();
        this.pressed = false;
    }
}

function __scombo_mouseover() {
    if (!this.enabled)
        return;

    if (this.pressed)
        document.getElementById(this.id).className = 'pinComboPopup' + this.design;
    else
        document.getElementById(this.id).className = 'pinComboHover' + this.design;
}

function __scombo_mouseout() {
    if (!this.enabled)
        return;

    if (!this.pressed)
        document.getElementById(this.id).className = 'pinComboStandard' + this.design;
    else
        document.getElementById(this.id).className = 'pinComboPopup' + this.design;
}

function ComboItem(text, image, title, value, tag1, tag2) {
    this.id = "";
    this.parent = "";
    this.text = text;
    this.image = image;
    this.title = title;
    this.value = value;
    if (tag1)
        this.tag1 = tag1;
    else
        this.tag1 = "";
    if (tag2)
        this.tag2 = tag2;
    else
        this.tag2 = "";
}


function __toolbar_setkey(value) {
    __isEvaluation = value;
}
function __toolbar_setmode(value) {
    __isMode = value;
}
