Fetion.Web.Chat.defined("Fetion.Web.Chat.CardFrm");
Fetion.Web.Chat.CardFrm.create = function ()
{
    var html = "";
    html += '<table onselectstart="return false" border="0" cellspacing="0" cellpadding="0" class="msg_box">';
    html += "<tr>";
    html += '<td class="box_tl"></td>';
    html += '<td class="box_tm" style="width:100%"></td>';
    html += '<td class="box_tr"></td>';
    html += "</tr>";

    html += "<tr>";
    html += '<td class="box_ml"></td>';
    html += '<td class="box_mm" style="overflow:visible" valign="top"><table cellspacing="0" cellpadding="0" style="width:100%;height:100%"><tr><td class="con_pane" valign="top" style="overflow:visible;background:url();height:1px;padding-bottom:4px"></td></tr></table></td>';
    html += '<td class="box_mr"></td>';
    html += "</tr>";

    //foot
    html += '<tr style="display:none">';
    html += '<td class="box_ml"></td>';
    html += '<td class="box_mm" height="22px"><div class="pic_newsb" style="width:100%;height:16px"></div></td>';
    html += '<td class="box_mr"></td>';
    html += '</tr>';

    html += "<tr>";
    html += '<td class="box_bl"></td>';
    html += '<td class="box_bm"></td>';
    html += '<td class="box_br"></td>';
    html += "</tr>";

    html += "</table>";
    var frm = document.createElement("SPAN");
    frm.innerHTML = html;
    frm = frm.childNodes[0];
    frm.body = frm.rows[1].cells[1].childNodes[0].rows[0].cells[0];
    frm.foot = frm.rows[2];
    frm.foot.cell = frm.foot.cells[0];
    frm.foot.cell.style.border = 0;
    frm.foot.cell = frm.foot.cells[1];
    frm.foot.div = frm.foot.cell.childNodes[0];

    frm.setSize = function (width, height)
    {
        this.style.width = width;
        if (height)
            this.style.height = height;
    };
    frm.addFootText = function (txt, style)
    {
        var foot = this.foot;
        foot.style.display = "";
        this.body.style.background = "url(chat/img/line_1.gif) left bottom repeat-x";

        var span = document.createElement("SPAN");
        span.className = "txt_l";
        span.innerHTML = txt;
        foot.div.appendChild(span);

        Fetion.Web.Chat.setStyle(span, style);
        return span;
    };
    frm.removeFootText = function (obj)
    {
        var foot = this.foot;
        if (obj)
        {
            foot.div.removeChild(obj);
            return;
        }

        for (var i = 0; i < foot.div.childNodes.length; i++)
        {
            var childNode = foot.div.childNodes[i];
            if (childNode.tagName != "SPAN")
                continue;
            foot.div.removeChild(childNode);
            i--;
        }
    };
    frm.addFootButton = function (o)
    {
        if (o.data && o.data.op == false)
            return;
        var foot = this.foot;
        foot.style.display = "";
        this.body.style.background = "url(chat/img/line_1.gif) left bottom repeat-x";

        var a = document.createElement("a");
        a.className = "ml_1";
        a.style.margin = "0 10px 0 0";
        a.innerHTML = o.title;
        a.ctrl = this;
        a.arg = o.arg;
        a.data = o.data;
		a.menu=true;
        foot.div.appendChild(a);
        if (o.onclick)
            a.onmousedown = o.onclick;

        Fetion.Web.Chat.setStyle(a, o.style);

        Fetion.Web.Chat.scroll();

        return a;
    };
    frm.removeFootButton = function (obj)
    {
        var foot = this.foot;
        if (obj)
        {
            foot.div.removeChild(obj);
            return;
        }

        for (var i = 0; i < foot.div.childNodes.length; i++)
        {
            var childNode = foot.div.childNodes[i];
            if (childNode.tagName != "A")
                continue;
            foot.div.removeChild(childNode);
            i--;
        }
    };
    frm.updateProgress = function (o)
    {
        var foot = this.foot;
        foot.style.display = "";

        if (!foot.progress)
        {
            foot.cell.removeChild(foot.div);
            foot.progress = Fetion.Web.Chat.newCtrl("progress");
            foot.cell.appendChild(foot.progress);
            foot.cell.appendChild(foot.div);

            var text = foot.progress.text = this.addFootButton({ title: "0%" });
            text.style.cursor = "point";
            foot.progress.text = text;

            this.body.style.background = "url()";
        }
        foot.progress.text.innerHTML = foot.progress.update(o) + "%&nbsp;&nbsp;";
    };
    frm.removeProgress = function (o)
    {
        var foot = this.foot;
        if (!foot.progress)
            return;
        foot.style.display = "none";
        foot.cell.removeChild(foot.progress);
        foot.progress = null;
        this.removeFootText();
    };
    return frm;
};