{if $ajax eq 0}
{include file="$admingentemplates/admin_top.tpl"}
<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">{$header.razdel_name}</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>{$help.chat_rooms}
    </div>
</div>
<div class="cr">&nbsp;</div>
<div style="float:right;"><a href="{$site_url}{$site_root}/flash_chat/flashchat.php" target="_blank">{$lang.admin_menu.chat_login}</a></div>
<div class="cr">&nbsp;</div>
<ul class="tabs">
    <li>
        <a href="msglist.php">{$lang.admin_menu.chat_messages}</a>
    </li>
    <li>
        <a class="current">{$lang.admin_menu.settings}</a>
    </li>
{*    <li>
        <a href="connlist.php">{$lang.admin_menu.chat_connections}</a>
    </li>
    <li>
        <a href="banlist.php">{$lang.admin_menu.chat_bans}</a>
    </li>*}
    <li>
        <a href="ignorelist.php">{$lang.admin_menu.object_moderation}</a>
    </li>
{*    <li>
        <a href="botlist.php">{$lang.admin_menu.chat_bots}</a>
    </li>
    <li>
        <a href="modlist.php">{$lang.admin_menu.chat_moderators}</a>
    </li>
    <li>
        <a href="modules.php">{$lang.admin_menu.chat_modules}</a>
    </li>
    <li>
        <a href="{$site_url}{$site_root}/flash_chat/flashchat.php" target="_blank">{$lang.admin_menu.chat_login}</a>
    </li>*}
</ul>
{/if}
<div id="aff_ads_div">

		<div class="user_operation_line">
			<div onclick="add_form();" class="uol_item">
				<div class="uol_in_item">{$header.add_new_room}</div>
			</div>
		</div>
<!-- transfer vars from php to javascript -->
<script type="text/javascript">
	var permanent = '{$room_permanent_post}';
	var ispublic = '{$room_public_post}';
	var name = '{$room_name_post}';
	var password = '{$room_password_post}';
	var selectstr = '{$room_order_post}';
	var optionstr = '{$room_option}';
	var hidden = '{$room_identification_post}';
	var option_count = {$rowcount};
	var deleteroom = '{$room_delete_post}';
	var maxorder = '{$max_order_post}';
</script>
<script src="{$server}/flash_chat/admin/funcs.js" type="text/javascript" language="JavaScript">
</script>
{literal}
<script type="text/javascript">
	function add_form(){
		$('#add_form').css("display", "block");
	}
	function links_load(url){
		ajaxLoadingImage(1, 'aff_ads_div');
		$.post(url+"ajax=1", function(data){
			ajaxLoadingImage(0, 'aff_ads_div');
			$('#aff_ads_div').html(data);
		});			
	}
	$(document).ready(function() {
		var mod = '{/literal}{$mod}{literal}';
		if (mod==1){links_load('modules.php?');}
	});
</script>
{/literal}
<div id="add_form" style="display:none;float:left;">
<form name="room" action="room.php" method="post">
	<input type="hidden" name="id" value="{$smarty.request.id}">
	<input type="hidden" name="add">
	<input type="hidden" name="set">
	<input type="hidden" name="del">
	<table border=0 cellspacing=1 cellpadding=3 width="100%">
		<tr bgcolor="#FFFFFF">
			<td class="main_header_text" align="right">{$header.name}:</td>
			<td><input type="text" name="name" value="{$smarty.request.name}"></td>
		</tr>
		<tr bgcolor="#FFFFFF">
			<td class="main_header_text" align="right">{$header.password}:</td>
			<td><input type="text" name="password" value="{$smarty.request.password}"></td>
		</tr>
		<tr bgcolor="#FFFFFF">
			<td class="main_header_text" align="right">{$header.public}:</td>
			<td><input type="checkbox" name="ispublic" value="{if $smarty.request.ispublic}{$smarty.request.ispublic}{else}y{/if}" {if $smarty.request.ispublic} checked {/if}></td>
		</tr>
		<tr bgcolor="#FFFFFF">
			<td class="main_header_text" align="right">{$header.permanent}:</td>
			<td><input type="checkbox" name="ispermanent" value="{if $smarty.request.ispermanent}{$smarty.request.ispermanent}{else}1{/if}" {if $smarty.request.ispublic} checked{/if}></td>
		</tr>
		<tr bgcolor="#FFFFFF">
			<td colspan="2" align="left">
{*				<input type="submit" name="add" value="{$header.add_new_room_btn}">
				<input type="submit" name="set" value="{$header.update_room_btn}" {if (!$smarty.request.id) || ($smarty.request.id=='0')}disabled{/if}>
				<input type="submit" name="del" value="{$header.remove_room_btn}" {if (!$smarty.request.id) || ($smarty.request.id=='0')}disabled{/if}>*}
				<a class="admin_button_major" href="#" name="add" id="add" onclick='document.room.add.value="1";document.room.submit();'>{$header.add_new_room_btn}<span>&nbsp;</span></a>			
				<a class="admin_button" href="#" name="set" id="set" onclick='document.room.set.value="1";document.room.submit();' {if (!$smarty.request.id) || ($smarty.request.id == '0')}style="display:none;"{/if}>{$header.update_room_btn}<span>&nbsp;</span></a>
				<a class="admin_button" href="#" name="del" id="del" onclick='document.room.del.value="1";document.room.submit();' {if (!$smarty.request.id) || ($smarty.request.id == '0')}style="display:none;"{/if}>{$header.remove_room_btn}<span>&nbsp;</span></a>
			</td>
		</tr>
	</table>
</form>
</div>
    <div class="user_status_line" style="margin-bottom:0px;width:100%;">
        <div id="tab_news" class="user_status_elem_active">
            {$lang.admin_menu.chat_rooms}
        </div>
        <div id="tab_feeds" class="user_status_elem" onclick="links_load('connlist.php?');">
            <a>{$lang.admin_menu.chat_connections}</a>
        </div>
        <div class="user_status_elem" onclick="links_load('banlist.php?');">
            <a>{$lang.admin_menu.chat_bans}</a>
        </div>
        <div class="user_status_elem" onclick="links_load('modules.php?');">
            <a>{$lang.admin_menu.chat_modules}</a>
        </div>
	</div>
<div style="float:left;width:100%;">
	<form id="roomlist" name="roomlist" action="roomlist.php" method="post" enctype="multipart/form-data">
		<table border=0 cellspacing=0 cellpadding=0 width="100%" style="margin-bottom:15px;">
			<tr class="table_header">
				<td align="center" style="width: 5%;"><a href="javascript:my_getbyid('sort').value = 'id'; my_getbyid('roomlist').submit()">{$header.id}</a></td>
				<td align="left" style="width: 20%;"><a href="javascript:my_getbyid('sort').value = 'name'; my_getbyid('roomlist').submit()">{$header.name}</a></td>
				<td align="left" style="width: 20%;"><a href="javascript:my_getbyid('sort').value = 'password'; my_getbyid('roomlist').submit()">{$header.password}</a></td>
				<td align="center" style="width: 10%;">{$header.public}</td>
				<td align="center" style="width: 10%;"><a href="javascript:my_getbyid('sort').value = 'permanent'; my_getbyid('roomlist').submit()">{$header.permanent}</a></td>
				<td align="center" style="width: 10%;"><a href="javascript:my_getbyid('sort').value = 'row_nr'; my_getbyid('roomlist').submit()">{$header.number}</a></td>
				<td align="center" style="width: 10%;">{$header.bump_up}</td>
				<td align="center" style="width: 10%;">{$header.delete}</td>
			</tr>
{foreach name=i from=$rooms item=room}
			{* assign javascript variables *}
			<input type="hidden" name="{$room.hidden_id}" id="{$room.hidden_id}" value={$room.id} disabled >
            <tr {if $smarty.foreach.i.iteration mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if}>
				<td class="main_content_text" align="center">
					{$room.id}
				</td>
				<td class="main_content_text" align="left">
					<div style="float:left;"><input type="text" name="room_name[{$room.row_nr}]" value="{$room.name}" id="room_name[{$room.row_nr}]" onchange="javascript:row_change('{$room.row_nr}');" onfocus="javascript: onnamefocus('bttn_{$room.row_nr}','room_name[{$room.row_nr}]');" style="border: 0px;"></div>
					<div class="block_action fr" style="display: none;float:left; height: 15px;">
						<div class="action_edit" style="display: block;">
							<img id="edit_bttn_{$room.row_nr}" width="16" alt="" src="{$site_root}{$template_root}/images/edit.png" onclick="javascript: onbttnclick_new('edit_bttn_{$room.row_nr}', 'save_bttn_{$room.row_nr}', 'room_name[{$room.row_nr}]');">
							<img id="save_bttn_{$room.row_nr}" 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: submit_form();document.roomlist.submited.value='1';document.roomlist.submit();" />&nbsp;
						</div>
					</div>
				</td>
				<td class="main_content_text" align="left">
					<div style="float:left;"><input type="text" name="room_password[{$room.row_nr}]" value="{$room.password}" id="room_password[{$room.row_nr}]" onchange="javascript:row_change('{$room.row_nr}');" onfocus="javascript: onnamefocus('bttn_pass_{$room.row_nr}','room_password[{$room.row_nr}]');" style="border: 0px;"></div>
					<div class="block_action fr" style="display: none;float:left;">
						<div class="action_edit" style="display: block;">
							<img id="edit_bttn_pass_{$room.row_nr}" width="16" alt="" src="{$site_root}{$template_root}/images/edit.png" onclick="javascript: onbttnclick_new('edit_bttn_pass_{$room.row_nr}', 'save_bttn_pass_{$room.row_nr}','room_password[{$room.row_nr}]');">
							<img id="save_bttn_pass_{$room.row_nr}" 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: submit_form();document.roomlist.submited.value='1';document.roomlist.submit();" />&nbsp;
						</div>
					</div>
				</td>
				<td class="main_content_text" align="center">
				<input type="checkbox" name="{$room.public_id}" id="{$room.public_id}" onchange="javascript:row_change('{$room.row_nr}');" {$room.ispublic}>
				</td>
				<td class="main_content_text" align="center">
				<input type="checkbox" value="1" name="{$room.permanent_id}" id="{$room.permanent_id}" onchange="javascript:perm_change('{$room.row_nr}'); change({$room.row_nr});" {$room.ispermanent}>
				<td class="main_content_text" align="center">
				{if $room.ispermanent}
					{assign var=room_order_name value=$room_order_post[`$room.row_nr`]}
					<select name={$room_order_name} onchange="javascript: change({$room.row_nr});" onfocus="javascript:focused('{$room.row_nr}');">
						{assign var=selected value=$room_option[`$room.row_nr`][`$room.row_nr`]}
						{foreach from=$room.ordersel key=key item=ordersel}
							<option id="{$key}" {if $key==$selected}selected{/if}>{$ordersel}</option>
						{/foreach}
					</select>
				{else}
					&nbsp;
				{/if}
				</td>
				<td class="main_content_text" align="center">
					<a href="javascript: bump_up({$room.row_nr});">
						<img src="bumper.gif" border="0" alt="{$header.bump_up}">
					</a>
				</td>
				<td class="main_content_text" align="center">
					<input type="checkbox" name="{$room.delete_id}" id="{$room.delete_id}" onchange="javascript: row_change('{$room.row_nr}');">
				</td>
				
			</tr>
{foreachelse}
			<tr height="40">
				<td class="main_error_text" align="left" colspan="8" bgcolor="#FFFFFF">{$header.err_no_rooms_found}</td>
			</tr>
{/foreach}
		<tr class="table_header"><td colspan="8">&nbsp;</td></tr>
		</table>
		<input type="hidden" value="{$maxnumb}" name="{$max_order_post}">
		<input type="hidden" value="" name="submited">
		<table><tr><td>
		<a class="admin_button_major" onclick="javascript: submit_form();document.roomlist.submited.value='1';document.roomlist.submit();">{$header.submit_all_btn}<span>&nbsp;</span></a></td>
		</tr><tr><td><input type="hidden" id="sort" name="sort" value="none">
		<span class="main_error_text" style="float:left;">{$header.room_bottom_note}</span></td></tr></table>
	</form>
</div>
{if $ajax eq 0}
</div>
<div class="cr">&nbsp;</div>
{*<p align="right" class="main_header_text">&copy;<a href="http://tufat.com/" target="_blank">TUFaT.com</a> </p>*}
{include file="$admingentemplates/admin_bottom.tpl"}{/if}