function show_emoticon_box() {
	var obj = $('emoticon_box');
	var ctn = $('tail_emoticon_ctn');
	var ctn_xy = Position.cumulativeOffset(ctn);
	if(obj.getStyle('display') == 'none') {
		obj.setStyle({left: ''+ctn_xy[0]+'px', top: ''+(ctn_xy[1]+62)+'px'}); 
		obj.show();
	}
	else {
		obj.hide();
	}
}

function set_tail_emoticon(event) {
	var img_obj = Event.element(event); 
	$('tail_emoticon').src = img_obj.src;
	$('emoticon_box').hide();
}

function show_tail_box(action_page, _article_id) {
	new Ajax.Request(action_page, {   
			encoding: '',
			onSuccess: function(req) {       
				$('tail_box').innerHTML = req.responseText;
				Event.observe('tail_emoticon_ctn', 'click', show_emoticon_box); 
				var imgs = $('emoticon_box').descendants();
				for(var i=0; i<imgs.length; i++) {
					Event.observe(imgs[i], 'click', set_tail_emoticon);
				}
			},
			parameters: { 
				cmd: 'view',
				article_id: _article_id
			}  
		}); 
}

function check_tail_form() {
	$('tail_emoticon_url').value = $('tail_emoticon').src;
	return true;
}

function delete_tail(id) {
	if(confirm('´ñ±ÛÀ» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?')) {
		var form = document.forms['tail_form'];
		location.href = form.action + '?cmd=delete&id=' + id;
	}
}

