Mys.relationItem = function(data, config)
{
	Mys.relationItem.superclass.constructor.call(this, data, config);
};

Ext.extend(Mys.relationItem, Mys.TemplateItem, {
	className : "mys-relation-item",
	id : "item_id",
	classNameImg : "mys-relation-img",
	
	template : (new Ext.Template([
		'<table class="{className}" id="{className}-{item_id}">',
			'<tr>',
				'{imageTD}',
				'<td width="100%" align="left"><div style="padding:12px 0px 12px 0px;"><a href="{viewURL}" class="s11 c66 h14 go-view" title="{summary}" {target}>{title}</a></div></td>',
			'</tr>',
		'</table>'
	])).compile(),
	
	changeImage : function(el)
	{
		//이미지 처리
		var image = new Image(), target = el;
		
		Ext.fly(image).on("load", function(e, el){
			(target.dom || target).src = this.data.image;
		}, this);
		
		image.src = this.data.image;
	},
	
	createImage : function(data)
	{
		if(data.image)
			return '<td style="padding:5px 8px 5px 0px;"><div><img src="' + data.image + '" class="mys-item-image" width="60" height="43" border="0" /></div></td>';
		else
			return '';
	},
	
	prepareData : function(data)
	{
		data = Mys.relationItem.superclass.prepareData.call(this, data);
		
		data.title = (data.title || "제목없음").substrPixel(data.image ? 72: 150, 11, 2);
		
		data.summary = (data.summary || "내용 없음").replace(/\"/g, "");
		
		data.viewURL = ViewManager.getViewURL(data);
		
		data.imageTD = this.createImage(data);
		
		return data;
	},
	
	setEvents : function(el)
	{
		this.changeImage(el.child(".mys-item-image", true));
	}
});