{include file="$admingentemplates/admin_top.tpl"}
<div class="back">
    <a href="{$site_url}{$site_root}/admin/admin_poll.php">{$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.razdel_name}</div>
<div class="cr">&nbsp;</div>
<div class="cr">&nbsp;</div>
<div class="help_text" style="display:block;">
    <div class="close_help">
        <img src="{$site_root}{$template_root}/images/close_help.png" alt="">
    </div>
    <div class="help_body">
        <span class="help_title">{$lang.help}:</span>{$lang.admin_help.poll_cats}
    </div>
</div>
<div class="cr">&nbsp;</div>
<ul class="tabs">
    <li>
        <a href="admin_poll.php">{$lang.admin_menu.poll_list}</a>
    </li>
    <li>
        <a class="current">{$lang.admin_menu.settings}</a>
    </li>
</ul>
<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}

{if $err}
<div class="sep"></div>
<div class="error_msg">{$err}</div>
{/if}
<div class="panel_section">
<div class="panel_content">
<font class="main_header_text">{$lang.settings.allow_users_create_poll}:</font>&nbsp;
<input type="checkbox" name="allow_users_create_poll" onclick="setSetting($(this).attr('name'), $(this).attr('checked')?1:0,'input[name=allow_users_create_poll]')" {if $settings.allow_users_create_poll}checked="checked"{/if}>
</div>
</div>
<div class="sep"></div>
<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">
	{literal}
	function addCategory(name){
		if (name==''){
			alert("{/literal}{$lang.poll_errors.empty_cat_name|escape:javascript}{literal}");
			return false;
		}
		document.forms.add_cat_form.submit();
	}

	function saveCategory(category_id,name){
		if (category_id==''){
			alert("{/literal}{$lang.poll_errors.empty_cat_id|escape:javascript}{literal}");
			return false;
		}
		if (name==''){
			alert("{/literal}{$lang.poll_errors.empty_cat_name|escape:javascript}{literal}");
			return false;
		}
		ajaxLoadingImage(1, 'loading'+category_id);
		str = "ajax=1&category_id="+category_id+"&name="+name;

		$.post("./admin_poll.php?sel=save_cat",str,function(data){
			ajaxLoadingImage(0, 'loading'+category_id);
			resp = getJQData(data);
			if (resp["code"]=='1'){
				showCatForm(category_id);
				$("#cat_name"+category_id).text(resp["new_val"]);
				showNoticeOnEl(resp["msg"],$("#cat_name"+category_id));
			}else{
				showNoticeOnEl(resp["msg"],$("#cat_name_input"+category_id));
			}
		});
	}

	function showCatForm(category_id){
		$("#cat_name"+category_id).toggle();
		$("#cat_name_input"+category_id).toggle();
		return;
	}

	function deleteCategory(category_id, jq_obj_el){
		ajaxLoadingImage(1, 'loading'+category_id);
		str = "ajax=1&category_id="+category_id;
		$.post("./admin_poll.php?sel=del_cat",str,function(data){
			ajaxLoadingImage(0, 'loading'+category_id);
			showNoticeOnEl(data,$("#loading"+category_id));
			$("#tr_category"+category_id).remove();
		});
	}

	function showAllPolls(){
		filter = $("select[name=created_by]").val();
		username = $("input[name=username]").val();

		if (filter=='user' && username==''){
			alert("{/literal}{$lang.poll_errors.empty_username|escape:javascript}{literal}");
			return false;
		}
		location.href="./admin_poll.php?sel=view_polls&filter="+filter+(filter=="user"?"&username="+username:"");
	}

	{/literal}
</script>
{include file="$admingentemplates/admin_bottom.tpl"}