Mys.Scrap = function(){
	this.scrapDlg = Ext.get('scrapDlg');
	this.scrapDlg.child('.close-btn').on('click', this.closeScrap, this);
	this.scrapDlg.child('.cancel-btn').on('click', this.closeScrap, this);
	this.scrapDlg.child('.scrap-btn').on('click', this.processScrap, this);

};

Mys.Scrap.prototype = {
	setData : function(data)
	{
		this.data = data;
		this.fillScrap();
	},
	
	show : function(el, position){
		this.scrapDlg.show();
		this.scrapDlg.alignTo(el, position);
	}

	,fillScrap : function(){
		var title = this.scrapDlg.child('.scrap-title');
		var from = this.scrapDlg.child(".from");
		var first;
		
		if(this.data.board_type == 1)
			first = "지식행사";
		else if(this.data.board_type == 2)
			first = "HRD 교육";
		else if(this.data.board_type == 3)
			first = "지식창고";
		
		
		title.dom.innerHTML = this.data.title;
		//XXX switch문으로 변경해야함
		from.dom.innerHTML = first + " > " + this.data.board_name;
	}

	,processScrap : function(){
		Global.modelItem.scrap(this.data.item_id, this.onScrap, this);
	}

	,onScrap : function(data){
		if(data && data.response.code == 100)
		{
			this.data.scrap_date = 1;
			
			if(confirm("스크랩 하였습니다. 내 스크랩 함으로 가시겠습니까?")){
				location = "/my_kma/myitem.htm#state=list&tab=scrap_date";
			}
		}
		this.closeScrap();
	}
	,closeScrap : function(){
		this.scrapDlg.hide();
	}

};