<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
$uid = randString(5);
$controller = "BX('vote-".$uid."')";
if (!empty($arResult["ERROR_MESSAGE"])): 
?>
<div class="vote-note-box vote-note-error">
	<div class="vote-note-box-text"><?=ShowError($arResult["ERROR_MESSAGE"])?></div>
</div>
<?
endif;

/*if (!empty($arResult["OK_MESSAGE"])):
?>
<div class="vote-note-box vote-note-note">
	<div class="vote-note-box-text"><?=ShowNote($arResult["OK_MESSAGE"])?></div>
</div>
<?
endif;*/

if (empty($arResult["VOTE"]) || empty($arResult["QUESTIONS"]) ):
	return true;
endif;

?>
<ol class="vote-questions-list" id="vote-<?=$uid?>">
<?
$iCount = 0;
foreach ($arResult["QUESTIONS"] as $arQuestion):
	$iCount++;
?>
	<li id="question<?=$arQuestion["ID"]?>" class="vote-question-item <?=($iCount == 1 ? "vote-question-first " : "")?><?
		?><?=($iCount == count($arResult["QUESTIONS"]) ? "vote-question-last " : "")?><?
		?><?=($iCount%2 == 1 ? "vote-question-odd " : "vote-question-even ")?><?
		?><?=($arQuestion["REQUIRED"] == "Y" ? "vote-question-required " : "")?><?
		?>">
		<div class="vote-item-header">
			<?if ($arQuestion["IMAGE"] !== false) { ?><div class="vote-question-image"><img src="<?=$arQuestion["IMAGE"]["SRC"]?>" /></div><? } ?>
			<div class="vote-question-title"><?=$arQuestion["QUESTION"]?></div>
			<div class="vote-clear-float"></div>
		</div>
		<ol class="vote-answers-list"><?
		$iCountAnswers = 0;
		foreach ($arQuestion["ANSWERS"] as $arAnswer){
			$iCountAnswers++;
			$percent = round($arAnswer["BAR_PERCENT"] * 0.8);

			?><li id="answer<?=$arAnswer["ID"]?>" class="vote-answer-item <?=($iCountAnswers == 1 ? "vote-answer-first " : "")?><?
				?><?=($iCountAnswers == count($arQuestion["ANSWERS"]) ? "vote-answer-last " : "")?><?
				?><?=($iCountAnswers%2 == 1 ? "vote-answer-odd " : "vote-answer-even ")?>"><?

			?><div class="answer-stat"><?
				?><span class="answer-users"><a rel="<?=$arAnswer["USERS"]?>" href="javascript:void(0);"><?=$arAnswer["COUNTER"]?></a></span><?
				?><span class="answer-percent"><?=$arAnswer["PERCENT"]?>%</span><?
			?></div><?

			?><div class="answer-wrap"><?
				?><span class="answer-container"><?=$arAnswer["MESSAGE"]?></span><?
				?><span class="answer-sidebar"><?
					?><span class="answer-indicator" style="width:<?=$arAnswer["BAR_PERCENT"]?>%;"></span><?
				?></span><?
			?></div><?
			?></li>
		<?}?>
		</ol>
	</li>
<?
endforeach;
?>
</ol>
<script type="text/javascript">
<?if ($arParams['AJAX_MODE'] == 'Y'):?>
	BX.loadCSS('/bitrix/components/bitrix/voting.current/templates/.userfield/style.css');
<?endif;

?>
if (! <?=$controller?>.loaded)
{
	BX.loadScript(
		[
			'<?=CUtil::GetAdditionalFileURL('/bitrix/components/bitrix/voting.current/templates/.userfield/script.js')?>',
			'/bitrix/js/main/core/core_ajax.js',
			'/bitrix/js/main/core/core_dd.js',
			'/bitrix/js/main/core/core_popup.js'
		], function() {
			BX.loadCSS('/bitrix/components/bitrix/rating.vote/templates/like/popup.css');
			<?=$controller?>.loaded = true;
			BVote<?=$uid?> = new BVotedUser({
				'CID' : '<?=$uid?>',
				'controller': <?=$controller?>,
				'urlTemplate' : "",
				'nameTemplate' : "",
				'url' : "<?=POST_FORM_ACTION_URI?>",
				'voteId' : <?=$arParams["VOTE_ID"]?>,
			<?if (true || $arResult["LAST_VOTE"] !== false && $arResult["LAST_VOTE"] < 1800){?>
				'startCheck' : <?=intval($arResult["LAST_VOTE"])?><?
			}?>
			});
		}
	);
}
</script>
<?
$this->__component->arParams["RETURN"] = array("uid" => $uid, "controller" => $controller);
?>