Fetion.Web.Chat.defined("Fetion.Web.Chat.Focus_Pictext");
Fetion.Web.Chat.Focus_Pictext.create = function (o)
{
    var frm = Fetion.Web.Chat.newCtrl("cardfrm");
    frm.setSize(294);
    frm.body.className = "con_pane h_ie6";
    frm.body.style.padding = "3px";
    var desc = Fetion.Web.Chat.split(o.desc, 23 * 3);
    var html = "";
    html += '<h1><span>' + o.name + '</span><span class="date_01">' + o.time + '</span></h1>';
    html += '<ul class="pic_news_hp">';
    html += '<li class="big_pic">';
    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_s.gif" style="width:auto;height:auto;margin-top:45px"/></div>';
    html += '<div class="pic_box_r"></div>';
    html += '</div>';
    html += '</li>';
    html += '<li class="news_inf" title="' + o.desc + '" style="cursor:hand">' + desc + '</li>';
    html += '</ul>';
    frm.body.innerHTML = html;
    frm.img = frm.body.childNodes[1].childNodes[0].childNodes[0].childNodes[1].childNodes[0];
    frm.div = frm.img.parentNode;
    frm.desc = frm.body.childNodes[1].childNodes[1];
    frm.div.data = frm.desc.data = o;
    frm.div.onclick = frm.desc.onclick = function ()
    {
        var data = this.data;
        window.external.LClick(data.type, data.texturl, "");
    };

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

    if (o.op != false)
    {
        frm.removeFootButton();
        frm.addFootButton({
            title: "打开",
            data: o,
            onclick: function ()
            {
                var ctrl = this.ctrl;
                ctrl.div.click();
            }
        });
        frm.addFootButton({
            title: "转发",
            data: o,
            onclick: function ()
            {
                var ctrl = this.ctrl;
                var parent = ctrl.parentNode;
                /*window.external.ForwardingMsg(parent.id, parent.jsonStr);*/
				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);
            }
        });
    }

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

    return frm;
};
Fetion.Web.Chat.Focus_Pictext.update = function (ctrl, data)
{
    var parent = ctrl.img.parentNode;
    parent.innerHTML = "<img src='" + data.path + "'>";
    ctrl.img = parent.childNodes[0];
	ctrl.img.style.width="auto";
	ctrl.img.style.height="auto";
	ctrl.img.onreadystatechange=function(e){
		ctrl.img.realWidth=ctrl.img.offsetWidth;
		ctrl.img.realHeight=ctrl.img.offsetHeight;
		if((ctrl.img.realWidth/ctrl.img.realHeight)>278/118){
			ctrl.img.style.height="118px";
			var w = ctrl.img.realWidth*118/ctrl.img.realHeight;
			ctrl.img.style.width=w+"px";
			if(w>278){
				ctrl.img.style.marginLeft = (278-w)/2+"px";
			}else{
				ctrl.img.style.marginLeft = "0px";
			}
		}else{
			ctrl.img.style.width="278px";
			var h = ctrl.img.realHeight*278/ctrl.img.realWidth;
			ctrl.img.style.height=h+"px";
			if(h>118){
				ctrl.img.style.marginTop = (118-h)/2+"px";
			}else{
				ctrl.img.style.marginTop = "0px";
			}
		}
	}
    ctrl.img.onerror = this.onerror;
    if (data.op == false)
    {
        ctrl.div.onclick = ctrl.desc.onclick = null;
        ctrl.div.style.cursor = ctrl.desc.style.cursor = "default";
    }
};
Fetion.Web.Chat.Focus_Pictext.onerror = function ()
{
    this.style.width = this.style.height = "auto";
    this.style.marginTop = "45px";
    this.src = "chat/img/chat/LoadingImageFailed_s.png";
};