{include file="$admingentemplates/admin_top.tpl"}
<div class="back">
    <a href="./admin_poll.php?sel=view_polls&category_id={$category_id}&filter={$filter}&username={$username}&page={$page}">{$lang.button.back}</a>
</div>
<div class="cr"></div>
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$lang.admin_poll.stats}</div>
<div class="cr">&nbsp;</div>
<div class="cr">&nbsp;</div>

{literal}
<style>
.panel_section td{
  padding-left:5px;
  background:#EEF6EF;
}
</style>
{/literal}
<div id="tooltip" onclick="hideToolTip()" style="text-align:center; background-color: #FFFFFF; border: 1px dotted; text-align: {$default_left}; position:absolute; display:none; padding:5px;"></div>
{literal}
<script type="text/javascript">
$(function() {
$('#tool_tip_4 *').tooltip();
});
</script>
{/literal}

<table cellpadding="0" cellspacing="0">
	<tr class="odd">
		<td width="50%">{$lang.admin_poll.question}:</td>
		<td colspan="3">{$poll_stats.poll_info.question}</td>
	</tr>
	<tr class="even">
		<td>
			{$lang.admin_poll.created_by_header} (
			{if $user_id == $poll_stats.poll_info.user_id}
			{$poll_stats.poll_info.login}
			{else}
			<a href="#" onclick="window.open('admin_users.php?sel=edituser&editpage=1&page=1&id={$poll_stats.poll_info.user_id}','info','width=600, height=800, resizable=yes, scrollbars=yes, menubar=no,status=no');">{$poll_stats.poll_info.login}</a>
			{/if}
			)
		</td>
		<td colspan="3">{$poll_stats.poll_info.date_add}</td>
	</tr>
	<tr class="odd">
		<td>{$lang.admin_poll.category}:</td>
		<td colspan="3">{$poll_stats.poll_info.cat_name}</td>
	</tr>
	<tr class="even">
		<td>{$lang.admin_poll.active}:</td>
		<td colspan="3">{$poll_stats.poll_info.active_time}</td>
	</tr>
	<tr class="odd">
		<td>{$lang.admin_poll.total_answers}:</td>
		<td colspan="3">{$poll_stats.poll_info.summ_answers_count}</td>
	</tr>
	{if $poll_stats.answers_info}
	<tr>
		<td colspan="4" class="red_sub_header" style="color:#208B2F;padding:10px;">
			<b>{$lang.admin_poll.stats}</b>
		</td>
	</tr>
	{counter start=0 print=false}
	{foreach from=$poll_stats.answers_info item=item name=i}
	<tr {if $smarty.foreach.i.iteration mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if}>
		<td width="30%">{$lang.admin_poll.answer} {counter}: {$item.text}</td>
		<td width="10%">{$lang.admin_poll.answers}: {$item.answers_count}</td>
		<td width="10%" style="white-space: nowrap;">
			<div percent="{$item.answers_percent}" class="vote_bar" style=" background: #{$item.color}"></div>
			{$item.answers_percent_100}%
		</td>
		<td>{if $item.answers_per_day}({$item.answers_per_day}) {$lang.admin_poll.answers_per_day}{/if}</td>
	</tr>
	{/foreach}
	{/if}
</table>
{if $comments}
<div style="width:30px">&nbsp;</div>
<font class=red_sub_header  style="color: #208B2F;padding:10px;">{$lang.admin_poll.comments}</font>
<div class="sep"></div>
<table cellpadding="0" cellspacing="0" width="100%" {*style="border-width: 0px 1px 0px 1px; border-color: #29B43D;border-style: solid;"*}>
	<tr class="table_header">
		<td width="20%" align="left">{$lang.admin_poll.login}</td>
		<td width="40%" align="left">{$lang.admin_poll.comment}</td>
		<td width="20%" align="left">{$lang.admin_poll.date_create}</td>
		<td width="40%" align="right">{$lang.button.action}</td>
	</tr>
	{foreach from=$comments item=item}
	<tr id="{$item.user}" {if  $smarty.foreach.index is div by 2}class="odd"{else}class="even"{/if}>
		<td align="left"><a href="#" onclick="window.open('admin_users.php?sel=edituser&editpage=1&page=1&id={$item.user_id}','info','width=600, height=800, resizable=yes, scrollbars=yes, menubar=no,status=no');">{$item.login}</a></td>
		<td align="left">{$item.comment}</td>
		<td align="left">{$item.date_add}</td>
		<td align="right">
			<div class="block_action fr" style="display: none;">
				<div class="action_del" style="display: block;cursor:pointer;">
					<img width="16" alt="" src="{$site_root}{$template_root}/images/photo_delete.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.delete}');return false" onclick="DeleteComment({$item.user}, {$poll_id}, {$item.answer_id});">
				</div>
			</div>			
			<div style="width:10px;float:right;" class="fl">&nbsp;</div>
			<div class="block_action fr" style="display: none;">
				<div class="action_edit" style="display: block;cursor:pointer;">
					<img width="16" alt="" src="{$site_root}{$template_root}/images/communicate.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.comunicate.editform}');return false"  onclick="javascript:window.open('./admin_comunicate.php?id={$item.user_id}&commit=1','comunicate', 'height=800, resizable=yes, scrollbars=yes,width=600, menubar=no,status=no');">
				</div>
			</div>			
		</td>
	</tr>
	{foreachelse}
		<tr height="40">
			<td class="main_error_text" align="left" colspan="4">{$lang.interests_spr.empty}</td>
		</tr>
	{/foreach}

	<tr  class="table_header">
		<td height="20" colspan=4 align="left" >
		  {foreach item=item from=$links.pages}
		    <a class="page_link" href="{$item.link}" 
			 {if $item.selected}style=" font-weight: bold; text-decoration: none;"{/if}>
			 {$item.name}</a>
		  {/foreach}
		</td>
	</tr>
</table>
{/if}
<script type="text/javascript">
{literal}
		function showToolTip(e,text){
			if(document.all)e = event;
			var obj = document.getElementById('tooltip');
			obj.innerHTML = text;
			obj.style.display = 'block';
			var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
			if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0;
			var leftPos = e.clientX - $('#tooltip').width()-10;
			if(leftPos<0)leftPos = 0;
			obj.style.left = leftPos + 'px';
			obj.style.top = e.clientY - obj.offsetHeight -10 + st + 'px';
		}
		function hideToolTip(){
			document.getElementById('tooltip').style.display = 'none';
		}
{/literal}		
</script>

<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(SERVER+"/backend.php?sel=poll_del_comm",str,function(data){});
		$("#"+user_id).hide();
	}
{/literal}
</script>
{include file="$admingentemplates/admin_bottom.tpl"}