<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
<div class="vote-container vote-container-form">
<?
	$this->IncludeLangFile("form.php");
	if ($_REQUEST["VOTE_ID"] == $arParams["VOTE_ID"] && $_REQUEST["AJAX_POST"] == "Y" && check_bitrix_sessid()):
		ob_start();
	endif;
	$params = $APPLICATION->IncludeComponent(
		"bitrix:voting.form",
		".default",
		Array(
			"VOTE_ID" => $arResult["VOTE_ID"],
			"VOTE_ASK_CAPTCHA" => $arParams["VOTE_ASK_CAPTCHA"],
			"PERMISSION" => $arParams["PERMISSION"],
			"VOTE_RESULT_TEMPLATE" => $arResult["VOTE_RESULT_TEMPLATE"],
			"ADDITIONAL_CACHE_ID" => $arResult["ADDITIONAL_CACHE_ID"],
			"CACHE_TIME" => $arParams["CACHE_TIME"],
			"CACHE_TYPE" => $arParams["CACHE_TYPE"],
		),
		($this->__component->__parent ? $this->__component->__parent : $component)
	);
?>
	<div class="vote-buttons">
		<a href="javascript:void(0)" class="feed-add-button feed-add-com-button" <?
		?>onclick="voteSendForm(BX('vote-form-<?=$params["uid"]?>'));" <?
			?>onmousedown="BX.addClass(this, 'feed-add-button-press')" <?
			?>onmouseup="BX.removeClass(this,'feed-add-button-press')"><?
			?><span class="feed-add-button-left"></span><?
			?><span class="feed-add-button-text" onclick="MPFbuttonShowWait(this);"><?=GetMessage("VOTE_SUBMIT_BUTTON")?></span><?
			?><span class="feed-add-button-right"></span><?
			?></a><?
	if (!($_REQUEST["VOTE_ID"] == $arParams["VOTE_ID"] && $_REQUEST["AJAX_POST"] == "Y" && check_bitrix_sessid())):
		?><a href="<?=$APPLICATION->GetCurPageParam("view_result=Y",
		array("VOTE_ID","VOTING_OK","VOTE_SUCCESSFULL", "view_result", "view_form", "sessid", "AJAX_RESULT", "AJAX_POST", "VOTE_ID"))?>" <?
		?> onclick="return voteGetResult(<?=$params["controller"]?>, '<?=$params["uid"]?>', this)"><?=GetMessage("VOTE_RESULTS")?></a><?
	endif;
	?>
	</div>
<?
	if ($_REQUEST["VOTE_ID"] == $arParams["VOTE_ID"] && $_REQUEST["AJAX_POST"] == "Y" && check_bitrix_sessid()):
		$res = ob_get_clean();
		$APPLICATION->RestartBuffer();
		echo $res;
		$res = CUtil::PhpToJSObject($res);
		echo "<script>top.SetVoteAjaxPostTmp(".$res.");top.VoteAjaxResponse();</script>";
		die();
	endif;
	?>
</div>
<script type="text/javascript">
if (! <?=$params["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');
			<?=$params["controller"]?>.loaded = true;
			BVote<?=$params["uid"]?> = new BVotedUser({
				'CID' : '<?=$params["uid"]?>',
				'controller': <?=$params["controller"]?>,
				'urlTemplate' : "",
				'nameTemplate' : "",
				'url' : "<?=(str_replace(array("view_form=Y", "view_result=Y"), "", POST_FORM_ACTION_URI))?>",
				'voteId' : <?=$arParams["VOTE_ID"]?>
			});
		}
	);
}

</script>