<?php

// -----------------------------------------------------------------------
// This file is part of aroundme
// 
// Copyright (C) 2003, 2005 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., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, 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="4" cellspacing="0" border="0" width="100%" class="table_nested">
	<tr>
		<td colspan="3">
			<?php echo $poll['poll_question'];?><br />
		</td>
	</tr>
	<?php
	unset($voted);
	if (isset($poll['options'])) {
	foreach($poll['options'] as $key => $p):
	?>
	<tr>
		<td class="txt_footer">
			<?php echo $p['option_body'];?><br />
		</td>
		<td width="50%">
			<table border="0" cellspacing="0" cellpadding="0" width="100%" class="table_stnd">
				<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 class="txt_footer">
			<?php echo $p['percent'];?>&#37;<br />
		</td>
		<td class="txt_footer">
			<?php
			echo $poll['current_answer']['option_id'];
			$selected="";
			if (isset($poll['current_answer']['option_id']) && $poll['current_answer']['option_id'] == $p['option_id']) {
				$selected = "checked=\"checked\"";
			}
			?>

			<input type="radio" name="option_id" value="<?php echo $p['option_id'];?>" <?php echo $selected;?> /><br />
		</td>
	</tr>
	<?php
	endforeach;
	}
	?>
	<tr>
		<td class="txt_footer" colspan="2">
			<?php
			if (isset($poll['current_answer']) && $poll['current_answer'] > 0) {
			?>
			<input type="submit" name="update_poll_answer" value="<?php echo $lang['sub_vote_change'];?>" class="formInput" />
			<?php
			}
			else {
			?>
			<input type="submit" name="insert_poll_answer" value="<?php echo $lang['sub_vote'];?>" class="formInput" />
			<?php
			}
			?>
			
			<?php
			if (!empty($poll['poll_anon'])) {
			    echo "&nbsp;(" . $lang['txt_anonymous'] . ")";
			}
			?>
			<br />
		</td>
		<td class="txt_footer" align="right">
			<?php echo $poll['total_votes'];?>&nbsp;<?php echo $lang['txt_votes'];?><br />
		</td>
	</tr>
</table>
</form>