Fetion.Web.Chat.defined("Fetion.Web.Chat.Pub_Video");
Fetion.Web.Chat.Pub_Video.create = function (o)
{
    var frm = Fetion.Web.Chat.newCtrl("cardfrm");
    frm.setSize(261);
    frm.updateProgress();
    frm.foot.style.display = "none";
    frm.body.className = "con_pane lzsp_pane";
    var html = "";
    html += '<ul class="pic_news">';
    html += '<li class="pic_t">';
    html += '<div class="pic_box">';
    html += '<div class="pic_box_l"></div>';
    html += '<div class="pic_box_m" style="cursor:hand"><img src="chat/img/chat/LoadingImage_m.gif"/></div>';
    html += '<div class="pic_box_r"></div>';
    html += '</div>';
    html += '</li>';
    o.name = "飞信视频消息";
    html += '<li class="news_tit" style="text-align:left">' + o.name + '</li>';
    html += '<li class="news_type" style="text-align:left">时长：' + Fetion.Web.Chat.formatDatetime(o.time) + '</li>';
    html += '</ul>';
    frm.body.innerHTML = html;
    frm.img = frm.body.childNodes[0].childNodes[0].childNodes[0].childNodes[1].childNodes[0];
    frm.div = frm.img.parentNode;
    frm.div.data = o;
    frm.div.onclick = function ()
    {
        var data = this.data;
        window.external.LClick(data.type, data.path, "");
    };

    if (o.thumb)
        this.update(frm, o);

    if (o.parent)
        o.parent.appendChild(frm);

    return frm;
};
Fetion.Web.Chat.Pub_Video.update = function (ctrl, data)
{
    var msg = null;
    if (data.status == "overdue")
    {
        ctrl.updateProgress({ size: 100, value: 0 });
        ctrl.foot.progress.text.innerHTML = "<span style='color:red'>文件已过期</span>";
        return;
    }
    else if (data.status == "failure")
    {
        ctrl.updateProgress({ size: 100, value: 0 });
        if (ctrl.retry)
        {
            ctrl.removeFootButton(ctrl.retry);
            ctrl.retry = null;
        }
        ctrl.foot.progress.text.innerHTML = "<span style='color:red'>接收失败</span>";
        ctrl.retry = ctrl.addFootButton({
            title: "重试",
            data: data,
            onclick: function ()
            {
				if((isIE&&window.event.button==1)||(!isIE&&window.event.button==0)){  
					var rst = window.external.DownLoadObj(this.data.id);
					if (rst)
					{
						var ctrl = this.ctrl;
						ctrl.foot.progress.text.innerHTML = "";
						ctrl.removeFootButton(ctrl.retry);
						ctrl.retry = null;
					}
				}
            }
        });
        return;
    }
    else if (data.status == "thumbfailure")
    {
        var parent = ctrl.img.parentNode;
        parent.innerHTML = "<img src='" + "chat/img/chat/loading_fail.png" + "'>";
        ctrl.img = parent.childNodes[0];
        return;
    }

    var parent = ctrl.img.parentNode;
    parent.innerHTML = "<img src='" + data.thumb + "' onerror='this.src=\"chat/img/chat/LoadingImageFailed_m.png\"'>";
    ctrl.img = parent.childNodes[0];
    ctrl.div.data = data;

    if (data.path)
        data.progress = 100;

    if (ctrl.retry)
    {
        ctrl.removeFootButton(ctrl.retry);
        ctrl.retry = null;
    }

    ctrl.updateProgress({ size: 100, value: data.progress });
    if (ctrl.foot.progress.value == ctrl.foot.progress.size)
    {
        ctrl.removeProgress();
        ctrl.removeFootButton();

        if (data.op == false)
        {
            ctrl.div.onclick = null;
            ctrl.div.style.cursor = "default";
            return;
        }

        ctrl.addFootButton({
            title: "播放",
            data: data,
            onclick: function ()
            {
				if((isIE&&window.event.button==1)||(!isIE&&window.event.button==0)){  
					var ctrl = this.ctrl;
					ctrl.div.click();
				}
            }
        });
        ctrl.addFootButton({
            title: "另存为",
            data: data,
            onclick: function ()
            {
				if((isIE&&window.event.button==1)||(!isIE&&window.event.button==0)){  
					var data = this.data;
					window.external.SaveFileAs(data.path);
				}
            }
        });
        ctrl.addFootButton({
            title: "转发",
            data: data,
            onclick: function ()
            {
				if((isIE&&window.event.button==1)||(!isIE&&window.event.button==0)){  
					var ctrl = this.ctrl;
					var parent = ctrl.parentNode;
					//window.external.ForwardingMsg(parent.id, parent.jsonStr);
					window.external.onClickMenu(parent.id, parent.jsonStr, point.y+10, point.x-10);
				}
            }
        });
        return;
    }
};