<!--投票选项 Begin-->
<ol class="poll_item_list">
	<!--投票在topic列表中使用时要用到tid-->
	<!--{eval if(!isset($tid))$tid=0;}-->
	<!--{eval $bcid = rand(0, 19);}-->
	<!--{loop $option $key $val}-->
	<li>
            <div class="poll_item_list_check">
			<!--{if $allowedvote && !$hasvoted}-->
			<input type="{$vote['input_type']}" name="option[]" value="$val[oid]" <!--{if $vote[multiple]}-->onclick="checkSelect(this.checked)"<!--{/if}-->/>
			<!--{/if}-->
            <label class="poll_item">$val[option]</label>
			</div>
			
			<!--{if $bcid>19}-->
			<!--{eval $bcid=$bcid-19}-->
			<!--{/if}-->
			<div class="bar_bg bc_$bcid">
				<div class="bar_left"></div>
				<div class="bar_middle" id="bar_{$tid}_$key" len="{$val[width]}"></div>
				<div class="bar_right"></div>
			</div>
			<!--{eval $bcid++;}-->
			<div class="poll_percent">$val[vote_num] ($val[percent]%)</div>

	</li>
	<!--{/loop}-->
</ol>
<!--投票选项 End-->

<script type="text/javascript">
	
	var __Bar_Name__ = 'bar_{$tid}_';
	function $$$(id)
	{
		return document.getElementById(id);
	}
<!--{if !$hasvoted}-->
	var maxSelect = $vote[maxchoice];
	var alreadySelect = 0;
	function checkSelect(sel)
	{
		if(sel) {
			alreadySelect++;
			if(alreadySelect == maxSelect) {
				var oObj = document.getElementsByName("option[]");
				for(i=0; i < oObj.length; i++) {
					if(!oObj[i].checked) {
						oObj[i].disabled = true;
					}
				}
			}
		} else {
			alreadySelect--;
			if(alreadySelect < maxSelect) {
				var oObj = document.getElementsByName("option[]");
				for(i=0; i < oObj.length; i++) {
					if(oObj[i].disabled) {
						oObj[i].disabled = false;
					}
				}
			}
		}
	}
	<!--{/if}-->

	//效查
	var optionNum = <!--{eval echo count($option)}-->;
	var maxLength = [0,1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,18,19];

	var timer;
	var length = 0;
	for(i = 0; i < optionNum; i++)
	{
		if ($$$(__Bar_Name__ + i)) {
			maxLength[i] = $$$(__Bar_Name__ + i).getAttribute('len');
		}
	}
	timer = setInterval(function(){
		setLength();
	}, 40);
	function setLength(){
		for (i = 0; i < optionNum; i++)
		{
			if ($$$(__Bar_Name__ + i)) {
				if (length - 1 >= maxLength[i]) {
					$$$(__Bar_Name__ + i).style.width = maxLength[i] + "px";
				} else {
					$$$(__Bar_Name__ + i).style.width = length + "px";
				}
				length = length + 1;
				if (length > 300) {
					clearInterval(timer);
				}
			}
		}
	}
</script>