{if !$ajax}
	{include file="$admingentemplates/admin_top.tpl"}
<script language="JavaScript" type="text/javascript" src="{$site_root}{$index_theme_path}/js/jquery.form.js"></script>

<div class="back">
    <a href="{$site_url}{$site_root}/admin/admin_modules.php">{$lang.button.back}</a>
</div>
<div class="cr"></div>
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$lang.blog.admin.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.blog_list}
    </div>
</div>
<div class="cr">&nbsp;</div>
<ul class="tabs">
    <li>
        <a class="current">{$lang.blog.blog_menu_5}</a>
    </li>
    <li>
        <a {if $sel eq 'categories'}class="current"{else}href="admin_blog.php?sel=categories"{/if}>{$lang.section.blog_categories}</a>
    </li>
</ul>

	<div class="panel">
	<div class="user_operation_line" style="height: 5px;">
	</div>
	<div class="cr"></div>
		<div style="padding:10px;">
			<font class="main_header_text">{$lang.blog.category} :</font>
			<select onchange="document.location.href=this.value">
				<option value="admin_blog.php" {if $id_category eq '0'}selected='selected'{/if}>{$lang.blog.blog_menu_5}</option>
				{foreach from=$categories item=item}
					<option value="admin_blog.php?id_category={$item.id}" {if $item.sel eq '1'}selected='selected'{/if} >{$item.name}</option>
				{/foreach}
			</select>
		</div>
{/if}
		<div id="blogs_table_div" style="width:100%">
<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}
			<table border="0" cellspacing="0" cellpadding="3" width="100%">
				<tr class="table_header">
					<td align="center" width="20">{$lang.blog.admin.number}</td>
					<td align="left" onclick="document.location.href='admin_blog.php?sorter=1&order={$form.order}&id_category={$id_category}';">{$lang.blog.admin.title}&nbsp;{if $form.sorter eq 1}{if $form.order == 1}&#8595;{else}&#8593;{/if}{/if}</td>
					<td align="left" width="100" onclick="document.location.href='admin_blog.php?sorter=2&order={$form.order}&id_category={$id_category}';">{$lang.blog.admin.user_login}&nbsp;{if $form.sorter eq 2}{if $form.order == 1}&#8595;{else}&#8593;{/if}{/if}</td>
					<td align="left" width="100" onclick="document.location.href='admin_blog.php?sorter=3&order={$form.order}&id_category={$id_category}';">{$lang.blog.admin.creation_date}&nbsp;{if $form.sorter eq 3}{if $form.order == 1}&#8595;{else}&#8593;{/if}{/if}</td>
					<td align="left" width="70" onclick="document.location.href='admin_blog.php?sorter=4&order={$form.order}&id_category={$id_category}';">{$lang.blog.admin.type}&nbsp;{if $form.sorter eq 4}{if $form.order == 1}&#8595;{else}&#8593;{/if}{/if}</td>
					<td align="center" width="50">{$lang.blog.admin.posts}</td>
					<td align="center" width="50">{$lang.blog.admin.comms}</td>
					<td align="left">{$lang.blog.admin.category}</td>
					<td align="center" width="80" onclick="document.location.href='admin_blog.php?sorter=5&order={$form.order}&id_category={$id_category}';">{$lang.blog.admin.status}&nbsp;{if $form.sorter eq 5}{if $form.order == 1}&#8595;{else}&#8593;{/if}{/if}</td>
					<td align="right" width="130">{$lang.button.action}</td>
				</tr>
			{if $blog_profile}
				{section name=spr loop=$blog_profile}
					<tr {if $smarty.section.spr.index mod 2 eq 1}class="even"{else}class="odd"{/if}>
						<td align="center">{$blog_profile[spr].number}</td>
						<td align="left">
							{*<a href="{$file_name}?sel=edit_blog&id={$blog_profile[spr].id}" name="blog_name">{$blog_profile[spr].title}</a>*}
                                    <div id="inform_div{$blog_profile[spr].id}" class="error_msg" style="display:none;float:right;"></div>
                                    <span id="link{$blog_profile[spr].id}">{$blog_profile[spr].title}</span>
									<input id="text_input{$blog_profile[spr].id}" type="text" value="{$blog_profile[spr].title}" style="display:none"/> 
						</td>
						<td align="left"><a href="{$blog_profile[spr].user_link}">{$blog_profile[spr].login}</a></td>
						<td align="left">{$blog_profile[spr].creation_date}</td>
						<td align="left">{if $blog_profile[spr].is_hidden eq 1}{$lang.blog.admin.private}{else}{$lang.blog.admin.public}{/if}</td>
						<td align="center">{$blog_profile[spr].posts_count}</td>
						<td align="center">{$blog_profile[spr].comments_count}</td>
						<td align="left">{$blog_profile[spr].category_name}</td>
						<td align="center"><input type="checkbox" name="active[]" value="{$blog_profile[spr].id}" {if $blog_profile[spr].active eq 1} checked {/if} onclick="ChangeStatus('{$blog_profile[spr].id}', this.checked, document.getElementById('test_div'));"></td>
						<td align="right">
{*							<div>
								<a href="{$file_name}?sel=view_blog&id={$blog_profile[spr].id}">{$lang.blog.blog_menu}</a>
							</div>
							<div>
								<a href="javascript:void(0)" onclick="Dialog({$blog_profile[spr].id});">{$lang.button.delete}</a>
							</div>
							<div>
								<a href="javascript:void(0)" class="button" onclick="javascript: window.open('{$blog_profile[spr].user_comunicate}','comunicate', 'height=800, resizable=yes, scrollbars=yes,width=600, menubar=no,status=no');">{$lang.users.comunicate}</a>
							</div>*}{*
							<div class="block_action fr" style="display: none;">
								<div class="action_edit" style="display: block;float:left;cursor:pointer;">
									<img height="16" alt="" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.delete}');return false" src="{$site_root}{$template_root}/images/photo_delete.png" onclick="Dialog({$blog_profile[spr].id});">
								</div>
							</div>
								<div style="width:10px;float:right;" class="fl">&nbsp;</div>
							<div class="block_action fr" style="display: none;">
								<div class="action_del" style="display: block;float:left;cursor:pointer;">
									<img height="16" alt="" src="{$site_root}{$template_root}/images/communicate.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.comunicate.editform}');return false" onclick="javascript: window.open('{$blog_profile[spr].user_comunicate}','comunicate', 'height=800, resizable=yes, scrollbars=yes,width=600, menubar=no,status=no');">
								</div>
							</div>
								<div style="width:10px;float:right;" class="fl">&nbsp;</div>
							<div class="block_action fr" style="display: none;">
								<div class="action_edit" style="display: block;float:left;cursor:pointer;">
									<img height="16" alt="" src="{$site_root}{$template_root}/images/icn_view.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.view}');return false" onclick="document.location='{$file_name}?sel=view_blog&id={$blog_profile[spr].id}'">
								</div>
							</div>*}
                                    <div class="block_action" >  
                                        <img id="edit_button{$blog_profile[spr].id}" src="{$site_root}{$template_root}/images/edit.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.edit}');return false" alt="" height="13" style="cursor: pointer;" onclick="javascript: editAction({$blog_profile[spr].id});" />&nbsp;
                                        <img id="save_button{$blog_profile[spr].id}" src="{$site_root}{$template_root}/images/success.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.save}');return false" alt="" height="13" style="cursor: pointer; display:none;" onclick="javascript: saveAction({$blog_profile[spr].id});" />&nbsp;
                                        <img src="{$site_root}{$template_root}/images/icn_view.png" alt="" height="13" style="cursor: pointer;" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.view}');return false" onclick="document.location='{$file_name}?sel=view_blog&id={$blog_profile[spr].id}'">&nbsp;
                                        <img src="{$site_root}{$template_root}/images/communicate.png" alt="" height="13" style="cursor: pointer;" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.comunicate.editform}');return false" onclick="javascript: window.open('{$blog_profile[spr].user_comunicate}','comunicate', 'height=800, resizable=yes, scrollbars=yes,width=600, menubar=no,status=no');">&nbsp;
                                        <img src="{$site_root}{$template_root}/images/photo_delete.png" alt="" height="13" style="cursor: pointer;" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.delete}');return false" onclick="Delete({$blog_profile[spr].id});" />&nbsp;
                                    </div>
						</td>
					</tr>
				{/section}
			{else}
				<tr height="40">
					<td class="main_error_text" align="left" colspan="10" bgcolor="#FFFFFF">{$lang.interests_spr.empty}</td>
				</tr>
			{/if}
				<tr class="table_header">
					<td colspan="10">
						&nbsp;&nbsp;
						{if $links}
						{foreach item=item from=$links.pages}
							&nbsp;<a onclick="PageList('blogs_table_div', '{$item.link}');" class="page_link" {if $item.selected} style=" font-weight: bold; text-decoration: none;" {/if}>{$item.name}</a>&nbsp;
						{/foreach}
						{/if}
						<div class="page_navigation">
						{if $links.previous}
							<a onclick="PageList('blogs_table_div', '{$links.previous}');"> {$lang.content.previous} {$per_page}</a>
						{/if}
						{if $links.next}
							<a onclick="PageList('blogs_table_div', '{$links.next}');">{$lang.content.next} {$per_page} ></a>
						{/if}
						</div>
					</td>
				</tr>
			</table>
<script type="text/javascript">
{literal}
function editAction(id){
	link_obj = getById('link'+id);
	text_input_obj = getById('text_input'+id);
	edit_button_ogj = getById('edit_button'+id);
	save_button_ogj = getById('save_button'+id);

	link_obj.style.display = 'none';
	text_input_obj.style.display = '';
	edit_button_ogj.style.display = 'none';
	save_button_ogj.style.display = '';

	text_input_obj.focus();
}

function saveAction(id){
	inform_div_obj = getById('inform_div'+id);
	link_obj = getById('link'+id);
	text_input_obj = getById('text_input'+id);
	edit_button_ogj = getById('edit_button'+id);
	save_button_ogj = getById('save_button'+id);
	value = text_input_obj.value;

	file_name = 'admin_blog.php';
	str = 'sel=save_blog&id_blog='+id+'&name_blog='+value+'&e=1';
	destination_odj = inform_div_obj;
	tmp_text = 'Saving...';
	anisochronous = false;

	ajaxRequest(file_name, str, destination_odj, tmp_text, anisochronous);

	inform_div_obj.style.display = '';

	saved_obj = getById('saved'+id);
	saved = saved_obj.value;
	if (saved == '1'){
		link_obj.style.display = '';
		link_obj.innerHTML = value;
		text_input_obj.style.display = 'none';
		edit_button_ogj.style.display = '';
		save_button_ogj.style.display = 'none';
		edit_button_ogj.focus();
	}
}
		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>
		</div>
{if !$ajax}		
	</div>

{literal}
<script type="text/javascript">
var req = null;
function InitXMLHttpRequest() {
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function ChangeStatus(id_blog, status, destination) {
	InitXMLHttpRequest();
			var parent = document.getElementById('right_panel');
			var newDiv = document.createElement('div');
			newDiv.id = 'error_message';
			newDiv.style.border = '1px solid #D82B2B';
			newDiv.style.background = 'none repeat scroll 0 0 #FFFFAA';
			newDiv.style.color = '#000';
			newDiv.style.fontSize = '13px';
			newDiv.style.fontWeight = 'bold';
			newDiv.style.padding = '20px';
			newDiv.style.position = 'absolute';
			newDiv.style.top = '2px';
			newDiv.style.left = '600px';
	if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				//destination.innerHTML = req.responseText;
				text = req.responseText;
			var text_dis = text;
			var textNode = document.createTextNode(text_dis);
			newDiv.appendChild(textNode);
			parent.appendChild(newDiv);
			setTimeout("document.getElementById('error_message').style.display = 'none';", 5000);  
			}
		}
		req.open("GET", "admin_blog.php?sel=change_status&id_profile=" + id_blog + "&status=" + status, true);
		req.send(null);
	} else {
		//destination.innerHTML = 'Browser unable to create XMLHttp Object';
		text = 'Browser unable to create XMLHttp Object';
			var text_dis = text;
			var textNode = document.createTextNode(text_dis);
			newDiv.appendChild(textNode);
			parent.appendChild(newDiv);
			setTimeout("document.getElementById('error_message').style.display = 'none';", 5000);  
	}
}
var answ;
function Dialog(par) {
	answ = par;
	//e.preventDefault();
	var id = '#dialog';
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	$('#mask').css({'width':maskWidth,'height':maskHeight});
	$('#mask').fadeIn(500);	
	$('#mask').fadeTo("fast",0.8);	
	var winH = $(window).height();
	var winW = $(window).width();
	$(id).css('top',  winH/2-$(id).height()/2);
	$(id).css('left', winW/2-$(id).width()/2);
	$(id).fadeIn(500); 
}
$(document).ready(function() {	
	$('.window .close').click(function (e) {
		e.preventDefault();
		$('#mask, .window').hide();
	});		
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
});
function Delete(par) {
	answ = par;
	document.location.href='{/literal}{$file_name}{literal}?sel=delete_blog&id='+answ;
}

function PageList(id_div, par) {
	ajaxLoadingImage(1, id_div);
	$.post("admin_blog.php", par, function(data){
		ajaxLoadingImage(0, id_div);
		$('#'+id_div).html(data);
	});
}
</script>
{/literal}
{include file="$admingentemplates/admin_bottom.tpl"}
{/if}