<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

if(!defined('POLL_BASIC')) {
	define('POLL_BASIC', true);
	echo '<link rel="stylesheet" href="'.$poll_skin_url.'/poll.css">'."\n";
}

?>
<table border=0 class="poll-tbl">
<tbody>
<tr><td>
	<form id="amina_poll<?php echo $wr_id; ?>" name="amina_poll<?php echo $wr_id; ?>" action="<?php echo AMINA_URL; ?>/poll.php" method="post">
	<fieldset>
	<?php if($poll_subject) echo '<div class="poll_subj">'.$poll_subject.'</div>'."\n"; ?>

	<div class="poll_item_box">

	<?php if($poll_status) { //설문에 참여했거나 조사기간이 끝났으면... ?>
		<ol>
		<?php 
			for($i=1; $i < 10; $i++) { 
				$item = 'poll_item'.$i;
				$cnt = 'poll_cnt'.$i;

				if(!$poll[$item]) continue;

				$ani_time = 1000 * $i;
				if($poll[$cnt] > 0) {
					$poll_per = round(($poll[$cnt] / $poll['poll_cnt']) * 100);
				} else {
					$poll_per = 0;
				}
		?>
		<li><?php echo $poll[$item]; ?>
			<dl>
			<dd class="poll_item">
				<div class="poll_item_bg poll_item_bg<?php echo $i; ?> poll_item_<?php echo $wr_id; ?>_size<?php echo $i; ?>"></div>
				<script>
				    $(document).ready(function(){
					    $('.poll_item_<?php echo $wr_id; ?>_size<?php echo $i; ?>').delay(<?php echo $ani_time; ?>/3).animate({
				            width: '<?php echo $poll_per; ?>%'
					    }, 2000);
			       });
		        </script>
			</dd>
			<dd class="poll_item_cnt">
				<b><?php echo number_format($poll[$cnt]); ?>명</b>(<?php echo $poll_per; ?>%)
			</dd>
			</dl>
		</li>		
		<?php } ?>
		<li class="poll_info">
		<?php 
			if($poll_status == "done") {
				echo '이미 참여하셨습니다. ';
			} else {
				echo '이미 종료되었습니다. ';
			} 
			echo ' (총 '.number_format($poll['poll_cnt']).'명 참여 / '.date("Y년 m월 d일 H시 i분", $poll_endtime).' 종료)'."\n";
		?>
		</li>
		</ol>
		<script>
		    $(document).ready(function(){
				var poll_wrap = $("#amina_poll<?php echo $wr_id; ?> fieldset").width();
				$("#amina_poll<?php echo $wr_id; ?> .poll_item").delay(0).animate({ width: poll_wrap - 120 + "px"}, 0);
	       });
		</script>
	<?php } else { //설문참여가 가능하면 ?>

		<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">
		<input type="hidden" name="wr_id"  value="<?php echo $wr_id; ?>">
		<input type="hidden" name="frame"  value="<?php echo $frame; ?>">
		<input type="hidden" name="bo_it"  value="<?php echo $bo_it; ?>">
		<input type="hidden" name="bo_linked"  value="<?php echo $bo_linked; ?>">
		<input type="hidden" name="bo_row"  value="<?php echo $bo_row; ?>">
	    <input type="hidden" name="page" value="<?php echo $page; ?>">
	    <input type="hidden" name="sca" value="<?php echo $sca; ?>">
		<ol>
		<?php for($i=1; $i < 10; $i++) { $item = "poll_item".$i; if(!$poll[$item]) continue; ?>
			<li><input id="poll<?php echo $wr_id.'_'.$i; ?>" type="radio" name="poll" value="<?php echo $i; ?>"> <label for="poll<?php echo $wr_id.'_'.$i; ?>"><?php echo $poll[$item]; ?></label></li>
		<?php } ?>
		<li class="poll_btn">
			<input type="button" value=" 투표하기 " onclick="amina_poll('<?php echo AMINA_URL; ?>/poll.php','amina_poll<?php echo $wr_id; ?>','view_poll<?php echo $wr_id; ?>');">
			<noscript><input type="submit" value=" 투표하기 "></noscript>
		</li>
		<li class="poll_info">
		<?php 
			if($poll['poll_level']) { 
				echo '회원만 투표가능';
			} else {
				echo '비회원도 투표가능';
			}
			if($poll['poll_point'] > 0) echo ' / 투표시 <span class="poll_point">'.number_format($poll['poll_point']).'</span> MP 획득';
			echo ' ('.date("Y년 m월 d일 H시 i분", $poll_endtime).' 종료)'."\n";
		?>
		</li>
		</ol>
	<?php } ?>
	</div>
	</fieldset>
	</form>
</td></tr>
</tbody>
</table>
