Fetion.Web.Chat.defined("Fetion.Web.Chat.Button");
Fetion.Web.Chat.Button.create = function (o)
{
    var html = "";
    html += "<table border='0' cellspacing='0' cellpadding='0' width='100' height='100'>";
    html += "<tr>";
    html += "<td></td>";
    html += "<td style='border-top:1px solid red'></td>";
    html += "<td></td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td style='border-left:1px solid red'></td>";
    html += "<td></td>";
    html += "<td style='border-right:1px solid red'></td>";
    html += "</tr>";
    html += "<tr>";
    html += "<td></td>";
    html += "<td style='border-bottom:1px solid red'></td>";
    html += "<td></td>";
    html += "</tr>";

    var frm = document.createElement("SPAN");
    frm.innerHTML = html;
    frm = frm.childNodes[0];
    frm.style.cursor = "hand";
    frm.onclick = o.onclick || null;
    if (o.parent)
        o.parent.appendChild(frm);
    var thumb = o.thumb || "img/chat/loading.gif";
    var html = "";
    html += "<table cellPadding='0' cellSpacing='0' style='width:100%;height:100%'><tr>";
    if (o.img)
        html += "<td><img src='" + thumb + "' style='width:20px;height:20px;margin:0 5px 0 2px'></td>";
    html += "<td align='center' style='font-size:12px;white-space:nowrap;padding-right:2px'>" + o.text + "</td>";
    html += "</tr></table>";
    frm.body.style.padding = 0;
    frm.body.innerHTML = html;
    var row = frm.body.childNodes[0].rows[0];
    if (o.img)
        frm.img = row.cells[0].childNodes[0];
    frm.txt = row.cells[row.cells.length - 1];
    if (o.hover)
    {
        frm.onmouseover = function ()
        {
            this.style.background = this.data.hover;
            this.txt.style.color = "#FFFFFF";
        };
        frm.onmouseleave = function ()
        {
            this.style.background = "";
            this.txt.style.color = "";
        };
    }

    return frm;
};
Fetion.Web.Chat.Button.update = function (ctrl, data)
{
    if (ctrl.img)
        ctrl.img.src = data.thumb = data.thumb || data.thumb_;
};