<h2>{$lang.poll.poll_stats}</h2>
<div style="padding:20px;">
	<p>
		{$lang.poll.question}:&nbsp;
		{$poll_stats.poll_info.question}
	</p>
	<p>
		{$lang.poll.created}:&nbsp;
		{$poll_stats.poll_info.date_add}
	</p>
	<p>
		{$lang.poll.category}:&nbsp;
		{$poll_stats.poll_info.cat_name}
	</p>
	<p>
		{$lang.poll.active}:&nbsp;
		{$poll_stats.poll_info.active_time}
	</p>
	<p>
		{$lang.poll.total_answers}:&nbsp;
		{$poll_stats.poll_info.summ_answers_count}
	</p>
	{if $poll_stats.answers_info}
	<h3 class="p-b5">
		{$lang.poll.stats}
	</h3>
	{counter start=0 print=false}
	{foreach from=$poll_stats.answers_info item=item}
	<dl style="height: 33px;">
		<dt style="width:36%">{$lang.poll.answer} {counter}: {$item.text}</dt>
		<dt style="width:23%" style="white-space: nowrap;">{$lang.poll.answers}: {$item.answers_count}</dt>
		<dt style="width:40%" style="white-space: nowrap;">
			<div percent="{$item.answers_percent}" class="vote_bar" style=" background: #{$item.color}"></div>
			{$item.answers_percent_100}%
		</dt>
	</dl>
	{/foreach}
	{/if}
{if $comments}
<h3 class="p-b5">{$lang.poll.comments}</h3>
<table style="width:100%">
	<tr style=" height: 30px;">
		<td>{$lang.poll.login}</td>
		<td>{$lang.poll.comment}</td>
		<td>{$lang.poll.date_create}</td>
		{if $comments[0].user_id eq $user_id}
			<td>&nbsp;</td>
		{/if}
	</tr>
	{foreach from=$comments item=item}
		<tr id="{$item.user}" style=" height: 30px;">
			<td><a href="{$site_root}/{$seo.viewprofile}?id={$item.user_id}" target="_blank">{$item.login}</a></td>
			<td>{$item.comment}</td>
			<td>{$item.date_add}</td>
			{if $comments[0].user eq $user_id}
			<td>
				<a href="#" onclick="DeleteComment({$item.user}, {$poll_id}, {$item.answer_id});">
					{$lang.button.delete}
				</a>
			</td>
			{/if}
		</tr>
	{/foreach}
</table>
<div class="search_link">
	<div class="sorting-long">
	<div class="b-page-n">	
		{foreach item=item from=$links_bottom}
			{if $item.first_page eq 1}
				<a href="{$item.link}" class="first-page-act" title="{$lang.general.first}">&nbsp;</a>
			{elseif $item.first_page eq 2}
				<a href="javascript: void(0);" class="first-page">&nbsp;</a>
			{/if}
			
			{if $item.previous_page eq 1}
				<a href="{$item.link}" class="back-page-act" id="back-page-act_bottom" alt="{$lang.general.prev}" title="{$lang.general.prev}">&nbsp;</a>
			{elseif $item.previous_page eq 2}
				<a href="javascript: void(0);" class="back">&nbsp;</a>
			{/if}
			
			{if $item.selected}
				<a href="javascript: void(0);" class="act-page">{$item.name}</a>
			{else}
				<a href="{$item.link}">{$item.name}</a>
			{/if}
			
			{if $item.delimiter}
				{$item.delimiter}
			{/if}
			
			{if $item.next_page eq 1}
				<a href="{$item.link}" class="next-page-act" id="next-page-act_bottom" alt="{$lang.general.next}" title="{$lang.general.next}>&nbsp;</a>
			{elseif $item.next_page eq 2}
				<a href="javascript: void(0);" class="next">&nbsp;</a>
			{/if}
				
			{if $item.last_page eq 1}
				<a href="{$item.link}" class="last-page-act" title="{$lang.general.last}">&nbsp;</a>
			{elseif $item.last_page eq 2}
				<a href="javascript: void(0);" class="last-page">&nbsp;</a>
			{/if}	
		{/foreach}
	</div>
	</div>
</div>
{/if}
{if $poll_stats.poll_info.author == $user_id}
<div style="margin-top: 10px;">
    <input type="button" style="float_left" onclick="editPoll('{$poll_id}'); return false;" value="{$lang.button.edit}"/>
    <input type="button" style="float_left" id="delete_link{$poll_id}" href="#" onclick="deletePoll('{$poll_id}'); return false;" value="{$lang.button.delete}"/>
</div>
{/if}
</div>
<script type="text/javascript">
	min_width = 2;
	max_width = 200;

	initAnswersBars();
{literal}
	function initAnswersBars(){
		$(".vote_bar").each(function(){
			width = Math.round(min_width+$(this).attr('percent')*max_width);
			$(this).width(width);
		});
	}
	function DeleteComment(user_id, poll_id,  answer_id) {
		str = 'ajax=1&poll_id='+poll_id+'&user_id='+user_id+'&answer_id='+answer_id;
		$.post(SEO_SITE_ROOT+"/backend.php?sel=poll_del_comm",str,function(data){});
		$("#"+user_id).hide();
	}
{/literal}
</script>
