Fetion.Web.Chat.defined("Fetion.Web.Chat.Multi_PicText");
Fetion.Web.Chat.Multi_PicText.create = function (o)
{
    var frm = Fetion.Web.Chat.newCtrl("cardfrm");
    frm.setSize(294);
    frm.body.className = "con_pane no_line";
    frm.body.style.padding = "0 3px 0 3px";
    var html = "";
    //html += '<h1><span class="date_01">' + o.time + '</span></h1>';
    html += '<ul class="pic_news_hp" style="margin:0">';
    html += '<li title="' + o.name + '" class="big_pic">';
    html += '<div class="pic_box">';
    html += '<div class="pic_box_l"></div>';
    html += '<div class="pic_box_m" style="cursor:hand;width:278px;height:118px;overflow:hidden;"><img src="chat/img/chat/LoadingImage_s.gif" style="width:auto;height:auto;margin-top:35px"/></div>';
    html += '<div class="pic_box_r"></div>';
    html += '</div>';
    html += '</li>';
	if(o.subpictext.length>1){
		html +='<div title="' + o.name + '" class="tit_yy" style="cursor:hand;margin:-28px 0 0 2px;overflow:hidden;text-overflow:ellipsis;width:270px;white-space:nowrap;">' + o.name + '</div>';
	}else{
		html += '<div title="' + o.name + '" class="tit_yy" style="cursor:hand;margin:-28px 0 0 2px">' + o.name + '</div>';
	}
    html += '<span>';
    for (var i = 0; i < o.subpictext.length; i++)
    {
        var data = o.subpictext[i];
        html += '<span id="' + Fetion.Web.Chat.formatID(data.id) + '" name="' + data.id + '" type="' + data.type + '" title="' + data.name + '">';
        html += '<li class="news_inf' + (i < o.subpictext.length - 1 ? ' line_bg' : '') + '" onmousedown="if ((window.e || window.event).button > 1)return;window.external.LClick(\'' + data.type + '\', \'' + data.texturl + '\', \'\')">';
        html += '<div style="cursor:hand" class="per_comment">' + data.name + '</div>';
        html += '<div style="cursor:hand" class="per_icon"><img src="chat/img/chat/LoadingImage_s.gif" style="width:auto;height:auto;margin-top:13px"/></div>';
        html += '</li></span>';
    }
    html += '</span>';
    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.desc = frm.body.childNodes[0].childNodes[1];
    frm.div.data = frm.desc.data = o;
    frm.div.onmousedown = frm.desc.onmousedown = function (e)
    {
        if ((e || window.event).button > 1)
            return;
        var data = this.data;
        window.external.LClick(data.type, data.texturl, "");
    };

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

    frm.sub = frm.body.childNodes[0].childNodes[2];
    for (var i = 0; i < o.subpictext.length; i++)
    {
        var data = o.subpictext[i];
        var span = frm.sub.childNodes[i];
        if (!span)
            continue;
        if (data.path)
            Fetion.Web.Chat.Sub_PicText.update(span, data);
    }

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

    return frm;
};
Fetion.Web.Chat.Multi_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;
};
Fetion.Web.Chat.Multi_PicText.onerror = function ()
{
    this.style.width = this.style.height = "auto";
    this.style.marginTop = "35px";
    this.src = "chat/img/chat/LoadingImageFailed_s.png";
};
Fetion.Web.Chat.defined("Fetion.Web.Chat.Sub_PicText");
Fetion.Web.Chat.Sub_PicText.update = function (ctrl, data)
{
    var parent = ctrl.childNodes[0].childNodes[1];
    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)>1){
			ctrl.img.style.height="50px";
			var subW=ctrl.img.realWidth*50/ctrl.img.realHeight;
			ctrl.img.style.width=subW+"px";
			if(subW>50){
				ctrl.img.style.marginLeft = (50-subW)/2+"px";
			}else{
				ctrl.img.style.marginLeft = "0px";
			}
		}else{
			ctrl.img.style.width="50px";
			var subH = ctrl.img.realHeight*50/ctrl.img.realWidth;
			ctrl.img.style.height=subH+"px";
			if(subH>50){
				ctrl.img.style.marginLeft = (50-subH)/2+"px";
			}else{
				ctrl.img.style.marginLeft = "0px";
			}
		}
	}
    ctrl.img.onerror = this.onerror;
};
Fetion.Web.Chat.Sub_PicText.onerror = function ()
{
    this.style.width = this.style.height = "auto";
    this.style.marginTop = "13px";
    this.src = "chat/img/chat/LoadingImageFailed_s.png";
};