Fetion.Web.Chat.defined("Fetion.Web.Chat.IMGS");
Fetion.Web.Chat.IMGS.create = function (o)
{
    var frm = Fetion.Web.Chat.newCtrl("cardfrm");
    frm.setSize(174);
    var html = "";
    html += '<div class="pic_box" style="padding:5px">';
    html += '<div class="pic_box_l"></div>';
    html += '<div class="pic_box_m"><img title="双击查看原图" src="chat/img/chat/LoadingImage_s.gif" style="width:auto;height:auto;margin-top:27px"/></div>';
    html += '<div class="pic_box_r"></div>';
    html += '</div>';
    frm.body.style.height = "";
    frm.body.parentNode.align = "center";
    frm.body.parentNode.vAlign = "middle";
    frm.body.innerHTML = html;

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

    var div = frm.body.childNodes[0];
    var img = frm.body.childNodes[0].childNodes[1].childNodes[0];
    frm.div = div;
    frm.img = img;
    frm.addFootText("共" + o.count + "张");

    if (o.op != false)
    {
        div.data = o;
        div.title = "双击查看原图";
        div.ondblclick = function ()
        {
            var data = this.data;
            window.external.LDblClick(data.id, data.type);
        };
        div.onmouseover = function ()
        {
            if (window.mouseButton == 1 || this.reading || !this.data.path)
                return;
            var reading = document.createElement("IMG");
            this.appendChild(reading);
            this.reading = reading;
            reading.onselectstart = "return false";
            reading.title = "点击查看原图";
            reading.style.margin = "60px 0 0 -24px";
            reading.style.cursor = "hand";
            reading.onmouseover = function ()
            {
                this.src = "chat/img/chat/reading_hover.png";
            };
            reading.onmouseleave = function ()
            {
                this.src = "chat/img/chat/reading_normal.png";
            };
            reading.data = this.data;
            reading.onclick = this.ondblclick;
            reading.onmouseleave();
        };
        div.onmouseleave = function ()
        {
            if (window.mouseButton == 1)
                return;
            if (this.reading)
            {
                this.removeChild(this.reading);
                this.reading = null;
            }
        };
    }

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

    return frm;
};
Fetion.Web.Chat.IMGS.update = function (ctrl, data)
{
    var imgFilePath = unescape(data.path);
    var fileName = imgFilePath.substring(imgFilePath.lastIndexOf("\\") + 1);

    var parent = ctrl.img.parentNode;
    parent.innerHTML = "<img title='双击查看原图' onerror='Fetion.Web.Chat.IMGS.onerror(this);' src='" + data.path + "' id='" + data.id + "' name='" + fileName + "' type='" + data.type + "' shortcut='" + data.textValue + "'>";
    var img = parent.childNodes[0];
    ctrl.img = img;
    
    if (data.op == false)
        return;

    ctrl.removeFootButton();
    ctrl.addFootButton({
        title: "打开",
        data: data,
        onclick: ctrl.div.ondblclick
    });
    ctrl.addFootButton({
        title: "转发",
        data: data,
        onclick: function ()
        {
            var ctrl = this.ctrl;
            var parent = ctrl.parentNode;
            //window.external.ForwardingMsg(parent.id, Fetion.Web.Chat.toString(this.data));
			var p ;
				if(window.point){
					p = window.point;
				}else{
					p = mousePosition(window.event, null);
				}
			window.external.onClickMenu(parent.id, Fetion.Web.Chat.toString(this.data),p.y+10, p.x-10);
        }
    });
}; 
Fetion.Web.Chat.IMGS.onerror = function(img) {
    img.style.width = img.style.height = "auto";
    img.style.marginTop = "27px";
    img.src = "chat/img/chat/LoadingImageFailed_s.png";
};