<?
include_once('./_common.php');

if(AMINA != "g4s") include_once(AMINA_PATH.'/lib/head.lib.php');

if (!$bo_table) {
	alert_close("값이 넘어오지 않았습니다.");
}

?>
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<? if (G4_IS_MOBILE) {?>
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=0,maximum-scale=10,user-scalable=yes">
<meta name="HandheldFriendly" content="true">
<meta name="format-detection" content="telephone=no">
<? } ?>
<title>이모티콘</title>
<style>
	body { 
		margin:0; padding:0; font:normal 12px dotum; -webkit-text-size-adjust:100%; 
	}
	.title { 
		padding:12px; text-align:center; font:bold 14px dotum; color:gold; background:#333; border:0px; 
	}
	.box {
		text-align:center; padding:15px;
	}
	.emo { 
		width:50px; height:50px; margin:10px 10px 0px 0px; cursor:pointer; border:1px solid #ddd;
	}
	.win-close { 
		cursor:pointer; padding:12px; text-align:center; font:bold 12px dotum; color:white; background:#333; border:0px; 
	}
</style>
<script> 
	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}
</script>
</head>
<body>
<div class="title">이모티콘 선택하기</div>
<div class="box">
	<? for($k=1; $k<=$amina['emo_cnt']; $k++) echo "<img src=\"{$emo_skin_url}/{$k}.gif\" onclick=\"emo_insert('{$k}');\" class=\"emo\" alt=\"\" />\n"; ?>
</div>

<div class="win-close" onclick="javascript:window.close();">창닫기</div>

<script> 
	function move_center() {
		var sw = screen.width;
	    var sh = screen.height;
		var cw = document.body.clientWidth;
	    var ch = document.body.clientHeight;
	    var top  = sh / 2 - ch / 2 - 100;
		var left = sw / 2 - cw / 2;
	    moveTo(left, top);
	}

	function emo_insert(emo){
		var skin_url = "<?=$emo_skin_url?>";
		opener.document.fwrite.emo_icon.src = skin_url + "/" + emo + ".gif";
		opener.document.fwrite.post_icon.value = emo;
		opener.document.fwrite.wr_subject.focus();
		window.close();
	}

	addLoadEvent(function() {
		move_center();
	});
</script>
</body>
</html>