<?
include_once("$g4[path]/_common.php");

$mktime = time();

$sum = 20; //출력갯수

$sql = mysql_query(" select * from $g4[table_prefix]tag order by date desc ");
for ($i=0; $row=mysql_fetch_array($sql); $i++) {
	$tag[$i] = $row;	
    $sql1 = mysql_query(" select * from $g4[popular_table] where pp_word = '{$tag[$i][tag]}' ");
    $tagsum[$i] = mysql_num_rows($sql1);
}

$sql = mysql_query(" select * from $g4[table_prefix]tag order by date desc limit  0, $sum ");
?>

<style>
#tags {
	line-height:200%;
	padding:1 1 1 1;	
}

#tags a {
	line-height:200%;
	padding:1 1 1 1;	
}

/*#tags a:hover {
	border:1px solid #555555;
	background:#dddddd;
	color:#555555;
	line-height:200%;	
	padding:1 1 1 1;
	text-decoration:none;	
}*/
</style>

<table align="center" cellpadding="0" cellspacing="0" width="100%" border="0">
	<tr height="1">
		<td bgcolor="#d8d8d8" colspan="3"></td>
	</tr>
	<tr>
		<td width="1" bgcolor="#d8d8d8"></td>
		<td>
		<table cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td width="10"></td>
				<td>
				<table cellpadding="0" cellspacing="0" width="100%" border="0">
					<tr height="5"><td colspan="2"></td></tr>
					<tr height="27">
						<td><font color="#555555" ><b>회원 테그</b></font></td>
						<td align="right"><? if ($is_admin == "super" || $is_auth) { ?>
						<A style="cursor:pointer" onclick="javascript:window.open('<?=$g4[path]?>/skinlib/admin.tag.php','tag_admin','scrollbars=auto,width=800,height=500');"><img src='<?=$g4[path]?>/img/icon2.gif'><span style="font-size:11px; color: #646464; font-family:dotum; letter-spacing:-1;">관리자</span></a><?}?></td>
					</tr>
					<tr height="1"><td colspan="2" background="<?=$g4[path]?>/img/line_dot.gif" border="0"></td></tr>
					<tr height="5"><td colspan="2"></td></tr>
				</table>
				</td>
				<td width="10"></td>
			</tr>
		</table>
		<table align="center" cellpadding="0" cellspacing="0" width="100%" border="0">
			<tr height="4"><td colspan="3"></td></tr>
			<tr>
				<td width="10"></td>
				<td valign="top">
				<table align="center" cellpadding="0" cellspacing="0" width="100%" border="0">
					<tr>
						<td id=tags>
						<?
						for ($i=0; $tags=mysql_fetch_array($sql); $i++) {

						if ($tagsum[$i] < 10) { ?>
						<a 
						title="Hit <?=$tagsum[$i]?>"
						href='<?=$g4[path]?>/bbs/search.php?sfl=wr_subject%7C%7Cwr_content&sop=and&gr_id=&stx=<?=$tags[tag]?>'>
						<span style='font-size:9pt;'><?=$tags[tag]?></span>
						</a>
						<? } elseif ($tagsum[$i] < 100) { ?>
						<a 
						title="Hit <?=$tagsum[$i]?>" 
						href='<?=$g4[path]?>/bbs/search.php?sfl=wr_subject%7C%7Cwr_content&sop=and&gr_id=&stx=<?=$tags[tag]?>'>
						<span style='font-size:9pt;font-weight:bold;color:#7fd5e1;'><?=$tags[tag]?></span>
						</a>
						<? } elseif ($tagsum[$i] < 300) {?>
						<a 
						title="Hit <?=$tagsum[$i]?>" 
						href='<?=$g4[path]?>/bbs/search.php?sfl=wr_subject%7C%7Cwr_content&sop=and&gr_id=&stx=<?=$tags[tag]?>'>
						<span style='font-size:9pt;font-weight:bold;color:#006875;'><?=$tags[tag]?></span>
						</a>

						<? } else { ?>

						<a 
						title="Hit <?=$tagsum[$i]?>" 
						href='<?=$g4[path]?>/bbs/search.php?sfl=wr_subject%7C%7Cwr_content&sop=and&gr_id=&stx=<?=$tags[tag]?>'>
						<span style='font-size:12pt;font-weight:bold;color:#dc6800;'><?=$tags[tag]?></span>
						</a>
						<? }} ?>
					</td>
					</tr>
					<tr height="6"><td></td></tr>
					<tr height="1"><td bgcolor=#eeeeee></td></tr>
					<tr height="6"><td></td></tr>
					<tr>
						<td>
						<? if ($member[mb_id]) { ?>
						<table align=center cellpadding='0' cellspacing='0' border='0'>
						<form method="post" action="<?=$g4[path]?>/skinlib/tag.update.php">
						<tr>
						<td>
						<input type="hidden" name="sum" value="<?=$sum?>">
						<input type="hidden" name="memberid" value="<?=$member[mb_id]?>">
						<input type="hidden" name="ip" value="<?=$_SERVER['REMOTE_ADDR']?>">
						<input type="hidden" name="date" value="<?=$mktime?>">
						<input type="text"  name="tag" size=10 maxlength=6 style='height:20;'>
						</td>
						<td width=3></td>
						<Td>
						<input style="font-family:돋움; font-size:8pt;" type="submit" value="태그등록">
						</td></tr>
						</form>
						</table>

						<? } else { ?>
						<table align=center cellpadding='0' cellspacing='0' border='0'>
						<tr>
						<td>
						<input type="text"  name="tag" onclick="alert('태그등록을 위해서 로그인을 하셔야 합니다');" size=10 maxlength=6 style='height:20;'>
						</td>
						<td width=3></td>
						<Td>
						<input type="button" style="font-family:돋움; font:bold; font-size:8pt;" value="태그등록" onclick="alert('태그등록을 위해서 로그인을 하셔야 합니다');">
						</td></tr>
						</table>
						<? } ?>
						</td>
					</tr>
				</table>																
				</td>
				<td width="10"></td>
			</tr>
		</table>
		</td>
		<td width="1" bgcolor="#d8d8d8"></td>
	</tr>
	<tr height="5">
		<td width="1" bgcolor="#d8d8d8"></td>
		<td></td>
		<td width="1" bgcolor="#d8d8d8"></td>
	</tr>
	<tr height="1">
		<td bgcolor="#d8d8d8" colspan="3"></td>
	</tr>
</table>