<include target="_header.html" />
<script>
	var poll_alert_lang = "{$lang->msg_check_poll_item}";
	var poll_checkcount_lang = "{$lang->poll_checkcount}";
	var poll_member_lang = "{$lang->poll_item_members}";
	jQuery(document).ready(function() {
			var data = {json_encode($poll_data)};
			if (data.poll.is_polled == 0) {
				loadRxSmplPoll({$poll_srl},data);
			}
			else {
				loadRxSmplPollResult({$poll_srl},data);
			}
		});
</script>
<div style="{$style}" class="rx_poll_smpl_wrap">
	<div id="poll_{$poll_srl}" class="pollWidget" style="display:none;">
		<script id="smpl-template-{$poll_srl}" type="text/x-handlebars-template">
			{{#each questions as |question questionid|}}
				<div class="poll_vote">
					<input type="hidden" name="checkcount_{{question.poll_index_srl}}" value="{{question.checkcount}}" />
					<div class="title">Q : {{question.title}}</div>

					{{#if question.isMultipleChoice}}
					<div class="checkcount">
						{$lang->poll_checkcount} : {{question.checkcount}}
					</div>
					{{/if}}

					{{#each question.items as |item itemid|}}
					<div class="poll_item">
						<label for="item_{{item.poll_item_srl}}">
							{{#if question.isMultipleChoice}}
							<input type="checkbox" name="item_{{question.poll_srl}}_{{question.poll_index_srl}}" value="{{item.poll_item_srl}}" id="item_{{item.poll_item_srl}}" />
							{{else}}
							<input type="radio" name="item_{{question.poll_srl}}_{{question.poll_index_srl}}" value="{{item.poll_item_srl}}" id="item_{{item.poll_item_srl}}" />
							{{/if}}
							{{item.title}}
						</label>
						{{#if item.my_item}}
						<input type="button" value="x" title="{$lang->delete_poll_item}" onclick="deleteRxSmplItem({{question.poll_srl}},{{question.poll_index_srl}},{{item.poll_item_srl}}); return false;" class="btn poll_item_delete" />
						{{/if}}
					</div>
					{{/each}}
					{{#if question.additem}}
					<div class="poll_item_add">
						<input type="text" name="new_item" id="new_item_{{question.poll_index_srl}}" class="poll_item_add" placeholder="{$lang->msg_can_add_item}" /> <input type="button" value="+" title="{$lang->add_poll_item}" onclick="addRxSmplItem({{question.poll_srl}},{{question.poll_index_srl}}); return false;" style="float: right;" class="btn poll_item_add" />
					</div>
					{{/if}}
				</div>
			{{/each}}
		</script>
		<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'widgets/pollWidget/skins/simple/form/' . $poll_srl" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
			<p>{$XE_VALIDATOR_MESSAGE}</p>
		</div>
		<form ruleset="poll" action="./" method="post" onsubmit="return doRxSmplPoll(this)">
			<input type="hidden" name="module" value="poll" />
			<input type="hidden" name="act" value="procPoll" />
			<input type="hidden" name="poll_srl" value="{$poll_srl}" />
			<input type="hidden" name="poll_srl_indexes" value="" />
			<input type="hidden" name="skin" value="{$skin}" />
			<input type="hidden" name="success_return_url" value="{getRequestUriByServerEnviroment()}" />
			<input type="hidden" name="xe_validator_id" value="widgets/pollWidget/skins/simple/form/{$poll_srl}" />
			<section class="rx_poll_smpl">
				<div class="rx_poll_header">
					<div style="float:left">
						{$lang->poll_stop_date}: <time class="rx_poll_h_strong" id="stop_date_{$poll_srl}"></time>
					</div>
				</div>
				<div id="poll_content_{$poll_srl}" class="rx_poll_content">
				</div>
				<div class="poll_button">
					<input type="button" value="{$lang->cmd_view_result}" class="btn" onclick="loadRxSmplPollResult({$poll_srl}); return false;" />
					<input type="submit" value="{$lang->cmd_apply_poll}" class="btn" />
				</div>
			</section>

		</form>
	</div>
	<div id="poll_{$poll_srl}_result" class="pollWidget poll_box" style="display:none;">
		<script id="smpl-template-result-{$poll_srl}" type="text/x-handlebars-template">
			{{#each questions as |question questionid|}}
			<div class="title">{{question.title}} ({{question.poll_count}})</div>
			{{#each question.items as |item itemid|}}
			<div class="rx_poll_smpl_item">
				<div class="item_text">
					{{#if question.showMembers}}
					<strong>{{item.number}}</strong> <a href="#" onclick="showRxSmplPollMember({{question.poll_srl}},{{item.poll_item_srl}});return false;">{{item.title}}</a>
					{{else}}
					<strong>{{item.number}}</strong> {{item.title}}
					{{/if}}
				</div>

				<div class="item_bar">
					{{#if item.isVote}}
						<div class="item_bar" title="{{item.per}}%" style="width:{{item.per}}%;height:22px;">&nbsp;</div>
					{{else}}
						<div class="item_bar" style="width:1px;height:22px;">&nbsp;</div>
					{{/if}}
					<div class="item_bar_text">{{item.poll_count}}</strong> ({{item.per}}%)</div>
				</div>
			</div>
			{{/each}}
			{{/each}}
		</script>
		<script id="smpl-template-members-{$poll_srl}" type="text/x-handlebars-template">
			{{#each members as |member memberid|}}
			{{#if member.isImage}}
			<li><img src="{{member.profile_image}}" width="16" height="16" /> <a href="#popup_menu_area" class="member_{{member.member_srl}}" onclick="return false">{{member.nick_name}}</a></li>
			{{else}}
			<li><img class="dummy" src="{{dummy_profile}}" width="16" height="16" /> <a href="#popup_menu_area" class="member_{{member.member_srl}}" onclick="return false">{{member.nick_name}}</a></li>
			{{/if}}
			{{/each}}
			{{#if isPage}}
			<input type="button" id="btn_load_more_{{poll_item_srl}}" value="{$lang->more}" onclick="showRxSmplPollMemberNext({{poll_srl}},{{poll_item_srl}});return false;" style="width:100%;" class="btn" />
			{{/if}}
		</script>
		<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/poll/skins/simple/form/1' . $poll_srl" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
			<p>{$XE_VALIDATOR_MESSAGE}</p>
		</div>
		<section class="rx_poll_smpl">
			<div class="rx_poll_header">
				<div style="float:left">
					{$lang->poll_stop_date}: <time class="rx_poll_h_strong" id="stop_date_result_{$poll_srl}"></time>
				</div>
				<div style="float:right">
					{$lang->poll_join_count}: <span class="rx_poll_h_strong" id="poll_count_result_{$poll_srl}"></span>
				</div>
			</div>
			<div id="poll_content_{$poll_srl}_result" class="rx_poll_content">
			</div>
			<div id="poll_{$poll_srl}_result_button" class="rx_poll_footer" style="width:100%;display: none;">
				<div class="poll_button">
					<input type="button" value="{$lang->btn_poll_gotovote}" class="btn" onclick="loadRxSmplPoll({$poll_srl}); return false;" />
				</div>
			</div>
			<div id="poll_{$poll_srl}_gotoresult_button" class="rx_poll_footer" style="width:100%;display: none;">
				<div class="poll_button">
					<input type="button" value="{$lang->cmd_view_result}" class="btn" onclick="loadRxSmplPollResult({$poll_srl}); return false;" />
				</div>
			</div>
		</section>
	</div>
</div>
