<?php

// -----------------------------------------------------------------------
// This file is part of Igloo
// 
// Copyright (C) 2003, 2006 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

?>


<form action="vote.php" method="post" name="vote">
<input type="hidden" name="poll_id" value="<?php echo $poll['poll_id'];?>" />
<input type="hidden" name="return_url" value="<?php echo $page_url;?>" />

<table cellpadding="2" cellspacing="0" border="0" width="100%">
	<tr>
		<td colspan="4">
			<label for="id_option"><b><?php echo $poll['poll_question'];?></b></label><br />
		</td>
	</tr>
	<?php
	if (isset($poll['poll_body_display'])) {
	?>
	<tr>
		<td colspan="4">
			<?php echo $poll['poll_body_display'];?><br />
		</td>
	</tr>
	<?php }?>
	
	<?php
	unset($voted);
	if (isset($poll['options'])) {
	foreach($poll['options'] as $key => $p):
	?>
	<tr>
		<td>
			<?php echo $p['option_body'];?><br />
		</td>
		<td width="50%">
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
				<tr>
					<td width="<?php echo $p['percent'];?>%" class="bg1">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="7" /><br />
					</td>
					<td width="<?php echo 100-$p['percent'];?>%" class="bg2">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="7" /><br />
					</td>
				</tr>
			</table>
		</td>
		<td>
			<?php echo $p['percent'];?>&#37;<br />
		</td>
		<td align="right">
			<?php
			//if (isset($allow_vote)) {
				$selected="";
				if (isset($poll['current_answer']['option_id']) && $poll['current_answer']['option_id'] == $p['option_id']) {
					$selected = "checked=\"checked\"";
				}
			?>
			<input type="radio" id="id_option" name="option_id" value="<?php echo $p['option_id'];?>" class="checkbox" <?php echo $selected;?> />
			<?php
			// }
			?>
			<br />
		</td>
	</tr>
	<?php
	endforeach;
	}
	?>
	<tr>
		<td colspan="2">
			<?php
			//if (isset($allow_vote)) {
				if (isset($poll['current_answer']) && $poll['current_answer'] > 0) {
				?>
				<input type="submit" class="input_submit" name="update_poll_answer" value="<?php echo $lang['sub_vote_change'];?>" class="button_urgent" />
				<?php
				}
				else {
				?>
				<input type="submit" class="input_submit" name="insert_poll_answer" value="<?php echo $lang['sub_vote'];?>" class="button_urgent" />
				<?php
				}
				?>
				
				<?php
				if (!empty($poll['poll_anon'])) {
					echo "&nbsp;(" . $lang['txt_anonymous'] . ")";
				}
			//}
			//else {
				/*
			?>
			<p>
				<b><?php echo $lang['txt_login_to_vote'];?></b>
			</p>
			<?php 
*/
//}?>
			<br />
		</td>
		<td align="right" colspan="2">
			<?php echo $poll['total_votes'];?>&nbsp;<?php echo $lang['txt_votes'];?><br />
		</td>
	</tr>
</table>
</form>