Fetion.Web.Chat.defined("Fetion.Web.Chat.Progress");
Fetion.Web.Chat.Progress.create = function (o)
{
    var html = "";
    html += '<table cellspacing="0" cellpadding="0" style="width:100%;height:5px"><tr>';
    html += '<td><div style="font-size:0px;border-top:1px solid #CCCCCC;border-bottom:1px solid #FFFFFF;background:#F0F0F0;width:100%;height:3px"></div></td>';
    html += '<td width="1px" valign="top"><div style="font-size:0px;border-top:1px solid #ECECEC;border-bottom:1px solid #F9F9F9;background:#D7D7D7;width:1px;height:2px"></div></td>';
    html += '</tr></table>';
    html += '<table cellspacing="0" cellpadding="0" style="width:1px;margin-top:-5px"><tr>';
    html += '<td><div style="font-size:0px;border-top:1px solid #93C057;border-bottom:1px solid #A5D451;background:#A5D451;width:100%;height:2px"></div></td>';
    html += '<td width="1px"><div style="font-size:0px;border-top:1px solid #D5E8BC;border-bottom:1px solid #D5E8BC;background:#92C34F;width:1px;height:2px"></div></td>';
    html += '</tr></table>';

    var progress = document.createElement("DIV");
    progress.innerHTML = html;
    progress.bar = progress.childNodes[1];
    progress.size = o && o.size ? o.size : 0;
    progress.value = 0;
    progress.update = this.update;

    Fetion.Web.Chat.setStyle(progress, o ? o.style : "");

    return progress;
};
Fetion.Web.Chat.Progress.update = function (data)
{
    if (!data)
        return 0;

    var progress = this != Fetion.Web.Chat.Progress ? this : window[data.id];
    if (!progress)
        return 0;
    progress.style.display = "block";
    progress.size = data.size || progress.size;
    progress.value = data.value || 0;

    if (!progress.value || progress.value <= 0)
    {
        progress.bar.style.display = "none";
        return 0;
    }
    else
        progress.bar.style.display = "block";

    progress.value = data.value;
    if (progress.value > progress.size)
        progress.value = progress.size;
    var value = parseInt(progress.value / progress.size * 100);
    progress.bar.style.width = value + "%";
    return value;
};