<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 
global $is_admin;

// 투표번호가 넘어오지 않았다면 가장 큰(최근에 등록한) 투표번호를 얻는다
if (!$po_id) 
{
    $po_id = $config[cf_max_po_id];

    if (!$po_id) return;
}

$po = sql_fetch(" select * from $g4[poll_table] where po_id = '$po_id' ");
?> 
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td width="10"><img src="<?=$poll_skin_path?>/img/box_01.gif" width="10" height="10"></td>
    <td background="<?=$poll_skin_path?>/img/box_03.gif" align="center"><img src="<?=$poll_skin_path?>/img/box_03.gif" width="1" height="10"></td>
    <td width="10"><img src="<?=$poll_skin_path?>/img/box_05.gif" width="10" height="10"></td>
  </tr>
  <tr> 
    <td background="<?=$poll_skin_path?>/img/box_09.gif"><img src="<?=$poll_skin_path?>/img/box_09.gif" width="10" height="2"></td>
    <td bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <form name="fpoll" method="post" action="<?=$g4[bbs_path]?>/poll_update.php" onsubmit="return fpoll_submit(this);" target="winPoll">
    <input type="hidden" name="po_id" value="<?=$po_id?>">
    <input type="hidden" name="skin_dir" value="<?=$skin_dir?>">
  <tr> 
    <td ><table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFA046">
        <tr> 
          <td width="2"><img src="<?=$poll_skin_path?>/img/poll_img_26.gif" width="2" height="11"></td>
          <td align="center"><img src="<?=$poll_skin_path?>/img/poll_img_24.gif" width="66" height="5"></td>
          <td width="2"><img src="<?=$poll_skin_path?>/img/poll_img_27.gif" width="2" height="11"></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td height="10"></td>
  </tr>
  <tr> 
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="20" valign="top" style="padding-left:5px;"><img src="<?=$poll_skin_path?>/img/poll_img_02.gif" width="16" height="15"></td>
          <td style="padding: 2 5 0 1px; font-size:11px; letter-spacing: -1px;"><font color="#21635B"><?=$po[po_subject]?></font>
              <? if ($is_admin == "super") { ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <a href="<?=$g4[admin_path]?>/poll_form.php?w=u&po_id=<?=$po_id?>"><img src="<?=$poll_skin_path?>/img/admin.gif"  border=0 align=absmiddle></a> 
              <? } ?></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td height="10"></td>
  </tr>
  <tr> 
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="3"><img src="<?=$poll_skin_path?>/img/poll_box_01.gif" width="3" height="15"></td>
            <td background="<?=$poll_skin_path?>/img/poll_box_04.gif"><img src="<?=$poll_skin_path?>/img/poll_img_01.gif" width="16" height="15" hspace="2"></td>
            <td width="3"><img src="<?=$poll_skin_path?>/img/poll_box_06.gif" width="3" height="15"></td>
          </tr>
          <tr> 
            <td background="<?=$poll_skin_path?>/img/poll_img_16.gif"><img src="<?=$poll_skin_path?>/img/poll_img_16.gif" width="3" height="1"></td>
            <td bgcolor="#F8F8F8"><table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr height="5"><td colspan="2"></td></tr>
                <? for ($i=1; $i<=9 && $po["po_poll{$i}"]; $i++) { ?>
                <tr height="25"> 
                  <td width="10"><input type="radio" name="gb_poll" value="<?=$i?>"></td>
                  <td style="padding: 4 0 0 2px; font-size:11px; letter-spacing: -1px;"> 
                    <?=$po['po_poll'.$i]?>
                  </td>
                </tr>
                <? } ?>
				<tr height="5"><td colspan="2"></td></tr>
              </table></td>
            <td background="<?=$poll_skin_path?>/img/poll_img_14.gif"><img src="<?=$poll_skin_path?>/img/poll_img_14.gif" width="3" height="1"></td>
          </tr>
          <tr> 
            <td><img src="<?=$poll_skin_path?>/img/poll_img_18.gif" width="3" height="3"></td>
            <td align="center" background="<?=$poll_skin_path?>/img/poll_img_20.gif"><img src="<?=$poll_skin_path?>/img/poll_img_20.gif" width="1" height="3"></td>
            <td><img src="<?=$poll_skin_path?>/img/poll_img_22.gif" width="3" height="3"></td>
          </tr>
        </table></td>
  </tr>
  <tr>
    <td style="padding-top:10px;"><table width="132" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="66"><input type="image" src="<?=$poll_skin_path?>/img/poll_img_04.gif" width="66" height="20" hspace="4"  border="0"></td>
          <td width="66"><a href="javascript:;" onclick="poll_result('<?=$po_id?>');"><img src="<?=$poll_skin_path?>/img/poll_img_05.gif" width="66" height="20" hspace="4" border="0"></a></td>
        </tr>
      </table></td>
  </tr>
</form>
</table></td>
    <td background="<?=$poll_skin_path?>/img/box_11.gif"><img src="<?=$poll_skin_path?>/img/box_11.gif" width="10" height="2"></td>
  </tr>
  <tr> 
    <td><img src="<?=$poll_skin_path?>/img/box_15.gif" width="10" height="10"></td>
    <td background="<?=$poll_skin_path?>/img/box_17.gif" align="center"><img src="<?=$poll_skin_path?>/img/box_17.gif" width="1" height="10"></td>
    <td><img src="<?=$poll_skin_path?>/img/box_19.gif" width="10" height="10"></td>
  </tr>
</table>


<script language='JavaScript'>
function fpoll_submit(f)
{
    var chk = false;
    for (i=0; i<f.gb_poll.length;i ++) {
        if (f.gb_poll[i].checked == true) {
            chk = f.gb_poll[i].value;
            break;
        }
    }

    <?
    if ($member[mb_level] < $po[po_level])
        echo " alert('권한 $po[po_level] 이상의 회원만 투표에 참여하실 수 있습니다.'); return false; ";
    ?>

    if (!chk) {
        alert("항목을 선택하세요");
        return false;
    }

    win_poll();
    return true;
}

function poll_result(po_id)
{
    <?
    if ($member[mb_level] < $po[po_level])
        echo " alert('권한 $po[po_level] 이상의 회원만 결과를 보실 수 있습니다.'); return false; ";
    ?>

    win_poll("<?=$g4[bbs_path]?>/poll_result.php?po_id="+po_id+"&skin_dir="+document.fpoll.skin_dir.value);
}
</script>