{if $ajax eq 0}
{include file="$admingentemplates/admin_top.tpl"}
<script language="JavaScript" type="text/javascript" src="{$site_root}{$index_theme_path}/js/jquery.form.js"></script>
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/area-editor.js"></script>
<script>
{literal}
var tab_link = 'admin_users.php?sel=import&ajax=1';
var options = { 
	success: function(data){
		ajaxIndicator(0, 'error_box');
		data = data.replace(/\<\/?(head|body)\>/g,'');
		$('#users_table_div').html(data);
			if ( $.browser.msie) {
    			DD_roundies.addRule('div.error', '10px');
			} else {
    			$('div.error').corner();
			}
			
			$('.error').oneTime(15000, function() {
				$('.error').fadeOut(500);
			});
		
		return false;
	},
	beforeSubmit: function() { 
		ajaxIndicator(1, 'error_box');
	}
};
{/literal}
</script>
<div class="back">
    <a href="{$site_url}{$site_root}/admin/admin_users.php">{$lang.button.back}</a>
</div>
<div class="error_message"></div>
<div class="cr"></div>
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$lang.users.list}</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>{if $import}{$lang.admin_help.users_import}{else}{$lang.admin_help.users_list}{/if}
    </div>
</div>
<ul class="tabs">
    <li>
        <a {if $import} href="admin_users.php" {else} class="current" {/if}>{$lang.users.razdel_name}</a>
    </li>
    <li>
        <a href="admin_groups.php">{$lang.groups.razdel_name}</a>
    </li>
    <li>
        <a {if $import} class="current" {else} href="admin_users.php?sel=import" {/if}>{$lang.admin_user.import.sub_header}</a>
    </li>
</ul>
<div class="panel" style="float: left; width: 100%">
{if $import}
{else}
	<div class="user_operation_line">
        <div class="uol_item" onclick="javascript: location.href='{$add_link}'">
            <div class="uol_in_item">{$lang.users.add}</div>
        </div>       
        <div class="uol_item">
            <div class="uol_in_item2" style="position:relative;width: 100%">
                <div class="select_box_option" style="text-align: center; border: 0;width:100%; position: relative;margin-left: -15px;">
                    {$lang.users.move_group}
                    <div class="option_box" id="active_themes" style="position: absolute;width:100%; top:20px; left:0;">
	                    {foreach from=$groups item=item}
	                        <div class='option_box_item' style="width:100%;">
	                            <div class='option_box_item_box' id='{$item.id}' onclick="MoveGroup({$item.id});">
	                                <div style='width:82%;float:left;'>{$item.name}</div>	                               
	                                <div class="cr"></div>
	                            </div>
	                        </div>
	                    {/foreach}
	                    <div id='bottom_corner' style='height:5px;'></div>
	                </div>
                </div>
                
            </div>
        </div>
        
        <div class="uol_item" onclick="AddFunds()">
            <div class="uol_in_item">{$lang.voip.add_founds}</div>
        </div>
        <div class="uol_item" {literal}onclick="javascript: if (window.confirm('{/literal}{$lang.users.del_confirm|escape:javascript}{literal}'))  { DeleteList(); } else return false;"{/literal}>
            <div class="uol_in_item">{$lang.users.delete}</div>
        </div>
        <div class="uol_item" onclick="ResendList();">
            <div class="uol_in_item">{$lang.users.resend}</div>
        </div>
    </div>
	<div class="cr"></div>
{/if}
    {if !$import}
    <div style="float: left; width:100%">
		<div style="float:left;display:none;" class="delete_status"></div>
        <input type=hidden name="sorter" value="{$sorter}">
		<table style="float:right;"><tr>
		<form name="search_form" action="{$form.action}" method="post">
			<td class="main_content_text" ><input type="text" name="search" value="{$search}"></td>
			<td class="main_content_text" ><select name="s_type" style="">
			{section name=s loop=$types}
			<option value="{$smarty.section.s.index_next}" {if $types[s].sel}selected{/if}>{$types[s].value}</option>
			{/section}
			</select></td>
			<td class="main_content_text"><a class="admin_button btn_upload" onclick="javascript: document.search_form.submit();" name="search_submit">{$lang.button.search}<span>&nbsp;</span></a></td>
		</form>
		</tr></table>
        </div>	
        <div align="right">
            <select name="pays_numpage" onchange="NumUsers(); return false;">                        
				<option value="10" {if $users_num eq 10} selected {/if}>10 {$lang.button.users}</option>
				<option value="30" {if $users_num eq 30} selected {/if}>30 {$lang.button.users}</option>
				<option value="50" {if $users_num eq 50} selected {/if}>50 {$lang.button.users}</option>
				<option value="100" {if $users_num eq 100} selected {/if}>100 {$lang.button.users}</option>
			</select>
        </div>	  
    {/if}
    <div id="user_status_line" class="user_status_line" style="margin-top: -30px;">
        {if $import}
        {else}
        <div id="tab_all_users" onclick="UsersList('all')" class="user_status_elem_active" width="80px">
            {$lang.groups.all_users} ({$form.stat_total_users})</a>
        </div>
        <div id="tab_inactive_users" onclick="UsersList('inactive')" class="user_status_elem" width="80px">
			<a>{$lang.users.inactive} ({$form.stat_inactive_users})</a>
        </div>
        <div id="tab_top_users" onclick="UsersList('top')" class="user_status_elem" width="80px">
            <a>{$lang.users.topten}</a>
        </div>
        {/if}

        <div id="users_table_div" style="width:100%;">
		{/if}
		    {if $import}
		    <div class="cr">&nbsp;</div>
		    {if $err}
			
				<div class="error" style="padding: 10px;display: none;">
					{$error}
				</div>
			{/if}
		    <link href="{$site_root}{$template_root}/css/alert.css" rel="stylesheet" type="text/css">
			<div id="boxes">
    			<div id="close" class="close" onclick="Close()"></div>
				<div id="dialog" class="window">
				</div>
			</div>
			<div id="mask"></div>
	<div style="width: 100%;margin-top:12px;" class="panel_section ">
		<div style="width: 97%" class="panel_content">
			<table width="100%">
		        <tr valign="top">
		        {if $par eq ''}
		            <td width="50%">
		                <form name="import_form" id="import_form" action="{$file_name}" method="POST" enctype="multipart/form-data">
		                    <input type="hidden" name="sel" value="import">
		                    <input type="hidden" name="par" value="step_1">
		                    <table border="0" cellspacing="1" cellpadding="5" width="100%">
		                        <tr>
		                            <td align="left" width="20%">{$lang.admin_user.import.upload_csv}</td>
		                            <td align="left" width="20%">
		                                <input type="file" size="25" name="database">
		                            </td>
		                        </tr>
		                        <tr>
		                            <td align="left" width="20%">
		                                {$lang.admin_user.import.upload_zip}
		                            </td>
		                            <td align="left" width="20%">
		                                <input type="file" size="25" name="uploads">
		                            </td>
		                        </tr>
		                        <tr>
		                            <td align="left" width="20%">
		                                {$lang.admin_user.import.delimiter}
		                            </td>
		                            <td align="left" width="20%">
		                                <select id="delimiter" name="delimiter">
		                                    <option value=";" selected>;</option>
		                                    <option value=",">,</option>
		                                </select>
		                            </td>
		                        </tr>
		                        <tr>
		                            <td align="left" width="20%">
		                                {$lang.admin_user.import.date_format}
		                            </td>
		                            <td align="left" width="20%">
		                                <input type="text" name="format_date" size="25" value="YYYY-MM-DD HH:MM:SS">
		                            </td>
		                        </tr>
		                        <tr>
		                            <td align="left" width="20%"></td>
		                            <td align="left" width="20%"></td>
		                        </tr>
{*		                        <tr>
		                            <td align="center" colspan="2">
		                                <a href="#" class="admin_button_major" onclick="SaveBlock('users_table_div','import_form'); return false;">{$lang.button.next_step}<span>&nbsp;</span></a>
		                            </td>
		                        </tr>*}
		                    </table>
		                </form>
		            </td>
		            <td width="50%" align="left">
		                <table width="100%" cellspacing="1" cellpadding="5" border="0">
		                    <tr>
		                        <td colspan="2">
		                            {$lang.admin_user.dont_have_user_database}
		                        </td>
		                    </tr>
		                    <tr>
		                        <td valign="top">
		                            <a href="http://www.saledatingprofiles.com/?from=pilotgroup.net" target="_blank">
		                                <img alt="SaleDatingProfiles.com" border="0" src="{$site_root}{$template_root}/images/saledatingprofiles_logo.jpg">
		                            </a>
		                        </td>
		                        <td width="100%" valign="top">
		                            <a href="http://www.saledatingprofiles.com/?from=pilotgroup.net" target="_blank">http://www.saledatingprofiles.com</a><br><br>
		                                {$lang.admin_user.user_database_promo}
		                        </td>
		                    </tr>
		                </table>
		            </td>
			{elseif $par eq 'step_1'}
		            <td width="100%" colspan="2">
		                <form action="{$file_name}" method="POST" id="import_form_2">
		                <input type="hidden" name="sel" value="import">
		                <input type="hidden" name="par" value="step_2">
		                <input type="hidden" name="format" id="format" value="">
		                    <table border="0" cellspacing="0" cellpadding="0" width="100%">
		                        <tr class="table_header">
		                            <td width="30">
		                                {$lang.admin_user.import.fields_new_database}
		                            </td> 
		                            <td width="30%">
		                                {$lang.admin_user.import.fields_exist_database}
		                            </td>
		                            <td width="20%"></td>
		                            <td width="30%"></td>
		                        </tr>
		                        {section name=i loop=$headers}
                                {if $headers[i] != ""}
		                        <tr {if $smarty.section.i.index mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if}>
		                            <td>
		                                {$headers[i]}
		                            </td>
		                            <td >
		                                <select name="dp_{$headers[i]}" id="dp_{$headers_id[i]}" onchange="ShowType('dp_{$headers_id[i]}');">
		                                    <option></option>
		                                    {section name=j loop=$headers_dp}
		                                    <option value="val_dp_{$headers_dp[j]}">{$headers_dp[j]}</option>
		                                    {/section}
		                                </select>
		                            </td>
		                            <td >
		                                <div id="format_dp_{$headers[i]}"></div>
		                            </td>
		                            <td >
		                                <div id="type_dp_{$headers[i]}"></div>
		                            </td>
		                        </tr>
                                {/if}
		                        {/section}
{*		                        <tr>
		                            <td>
		                            	<a class="admin_button_major" onclick="Import();">{$lang.button.import}<span>&nbsp;</span></a>*}
		                                {*<input type="button" class="button" value="{$lang.button.import}" onclick="Import();">*}{*
		                            </td>
		                            <td colspan="3">
		                                <div id="status_import"></div>
		                            </td>
		                        </tr>*}
		                    </table>
		                </form>
		            </td>

<script language="JavaScript" type="text/javascript">
	user_type_load = false;
	var ut_format, ut_type;
	var arr = new Array();
	var arr_id = new Array();
	{section name=j loop=$headers}
		arr.push("{$headers[j]}");
		arr_id.push("{$headers_id[j]}");
	{/section}
		
{literal}
	function ShowType(par) {
		text = $('#'+par+' option:selected').val();
		if(text == 'val_dp_password') {
			for(i=0;i<{/literal}{$headers|@sizeof}{literal};i++) {
				$("#format_dp_"+arr[i]).html("");
				$("#type_dp_"+arr[i]).html("");
			}
			$('#format').val("");
			$("#format_"+par).html("{/literal}{$lang.admin_user.import.format}{literal}");
			$("#type_"+par).html("<div><input type=\"radio\" name=\"type\" value=\"0\" onclick=\"SetFormat('0')\">{/literal}{$lang.admin_user.import.format_md5_yes}{literal}</div><div><input type=\"radio\" name=\"type\" value=\"1\" onclick=\"SetFormat('1')\">{/literal}{$lang.admin_user.import.format_md5_no}{literal}</div>");
		}else if(text == 'val_dp_user_type') {
			$("#check_cont_"+par).remove();
			$("#"+par).parent().append('<span id="check_cont_'+par+'"><input type="button" id="check_'+par+'" onclick="analizeDB(\''+par+'\', \''+text+'\', this)" value="{/literal}{$lang.button.check}{literal}" /><span id="indicator_'+par+'"></span></span>');
			$("#format_"+par).html('');
			$("#type_"+par).html('');
		}else if(text == 'val_dp_looking_for') {
			$("#check_cont_"+par).remove();
			$("#"+par).parent().append('<span id="check_cont_'+par+'"><input type="button" id="check_'+par+'" onclick="analizeDB(\''+par+'\', \''+text+'\', this)" value="{/literal}{$lang.button.analize}{literal}" /><span id="indicator_'+par+'"></span></span>');
			$("#format_"+par).html('');
			$("#type_"+par).html('');
		}else{
			$("#check_cont_"+par).remove();
			$("#format_"+par).html('');
			$("#type_"+par).html('');
		}
	}
	
	function analizeDB(field, dp_field, btn){
		var par = field;
		var field = field.substr(3);
		var dp_field = dp_field.substr(7);
		if($('[id^="format_dp_"]').find('input[name="field_'+dp_field+'[0]"]').length){
			$("#format_"+par).html('{/literal}{$lang.err.exists_option}{literal}');
			return;
		}
		var use_couple = (dp_field == 'looking_for') ? 1 : 0;
		$(btn).attr('disabled','disabled');
		ajaxIndicator(1, 'indicator_'+par);
		$.post(
			SERVER+"/backend.php?language_code={/literal}{$lang_code}{literal}",
			{
				sel: 'analizeDB',
				field: field,
				dp_field: dp_field,
				use_couple: use_couple
			},
			function(data){
				$(btn).removeAttr('disabled');
				ajaxIndicator(0, 'indicator_'+par)
				if(data.status == 'ok'){
					user_type_load = data;
					ut_format = createUserTypesFormat(dp_field);
					ut_type = createUserTypesType(dp_field);
					$("#format_"+par).html(ut_format);
					$("#type_"+par).html(ut_type);
					$("#check_cont_"+par).remove();
				}else if(data.status == 'error'){
					ShowAjaxError('error');
					$("#format_"+par).html('error');
				}
			},
			'json'
		);
	}
	
	function createUserTypesFormat(dp_field){
		var elem = '';
		var k = 0;
		for(var i in user_type_load.field_vals){
			elem += "<div style='height: 23px; overflow:hidden;'>"+user_type_load.field_vals[i]+"<input type='hidden' name='field_"+dp_field+"["+k+"]' value='"+user_type_load.field_vals[i]+"'></div>";
			k++;
		}
		return $(elem);
	}
	function createUserTypesType(dp_field){
		var elem = '';
		var k = 0;
		for(var i in user_type_load.field_vals){
			elem += "<div style='height: 23px;'><select name='dp_field_"+dp_field+"["+k+"]' onchange='setUserTypeVal(this)'>";
			for(var j in user_type_load.user_types){
				elem += "<option value='"+user_type_load.user_types[j].id+"' subtype='0'>"+user_type_load.user_types[j].name+"</option>";
				if(typeof user_type_load.user_types[j].subtypes !== 'undefined'){
					for(var s in user_type_load.user_types[j].subtypes){
						elem += "<option value='"+user_type_load.user_types[j].id+"' subtype='"+user_type_load.user_types[j].subtypes[s].id+"'>"+user_type_load.user_types[j].name+" ("+user_type_load.user_types[j].subtypes[s].name+")"+"</option>";
					}
				}
			}
			elem += "</select><input type='hidden' name='dp_field_"+dp_field+"_sub["+k+"]' value='0'></div>";
			k++;
		}
		return $(elem);
	}
	function setUserTypeVal(obj){
		var subtype = $(obj).find('option:selected').attr('subtype');
		$(obj).parent().find('input').val(subtype);
	}
	
	function SetFormat(par) {
		$('#format').val(par);
	}
	function Import() {
		i=0;
		arr_select = new Array();
		arr_select_sort = new Array();
		arr_sort = new Array();
		arr_post = new Array();
		for (j=0;j<{/literal}{$headers|@sizeof}{literal};j++) {
			text = $('#dp_'+arr_id[j]).val();
			if(text != "") {
				arr_select[i] = text;
				arr_select_sort[i] = text;
				arr_post[i] = arr[j];
				i++;
				}
		}
		arr_select_sort.sort();
		k=0
		for(i=0;i<arr_select_sort.length-1;i++){
			if(arr_select_sort[i] != arr_select_sort[i+1]) {
				arr_sort[k] = arr_select_sort[i];
				k++;
			}
			if (i==arr_select_sort.length-2) {
				if(arr_select_sort[i] != arr_select_sort[i+1]) {
					arr_sort[k] = arr_select_sort[i+1];
				}
			}
		}

		if (arr_sort.length>0 && arr_sort.length<arr_select.length) {
			//несколько раз одно и то же поле
			$("#status_import").text("{/literal}{$lang.admin_user.import.err_fields_copy}{literal}");
			return;
		}

		format = $('#format').val();
		format_date = $('#format_date').val();
		str = '&sel=import&format='+format;
		for (i=0;i<{/literal}{$headers_dp|@sizeof}{literal};i++) {
			str = str+'&'+arr_select[i]+'='+arr_post[i];
		}
		$("#status_import").text("{/literal}{$lang.admin_user.import.process}{literal}");
		
		var analized_arr = $('div[id^="format_"],div[id^="type_"]').find('input,select').serializeArray();
		var analized_obj = {};
		for(var i in analized_arr){
			analized_obj[analized_arr[i].name] = analized_arr[i].value;
		}
		
		$.post(
			SERVER+"/backend.php?language_code={/literal}{$lang_code}{literal}"+str,
			analized_obj,
			function(data){
				ShowAjaxError(data);
				$("#status_import").html(data)
			}
		);
	}
	$(function() {
		$('#block_action img').tooltip({
			track: true,
			delay: 0,
			showURL: false,
			fade: 200
		});
	});
</script>
{/literal}

			{/if}
			</tr>
		    </table>
		</div>
	</div>{if $par eq ''}<a href="#" class="admin_button_major" onclick="SaveBlock('users_table_div','import_form'); return false;">{$lang.button.next_step}<span>&nbsp;</span></a>
			{elseif $par eq 'step_1'}<a class="admin_button_major" onclick="Import();" style="float:left;">{$lang.button.import}<span>&nbsp;</span></a><div id="status_import" style="float:left;margin-left:10px;margin-top:11px;"></div>{/if}
		    {else}
<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 width="100%" cellspacing="0" cellpadding="0" border="0">
		                <tbody>
		                    <tr class="table_header">
		                        <td width="5%" align="center">
		                            <input type="checkbox" id="select_all" name="select_all" onclick="PutAll()">
		                        </td>
		                        <td width="10%" align="left" onclick="PageList('users_table_div','ajax=1&sorter=1&letter={$letter}&search={$search}&s_type={$s_type}&s_stat={$s_stat}&group={$group}&order={if $sorter eq 1}{$form.new_order}{else}{$form.order}{/if}')">
		                            {$lang.users.nick} 
		                        </td>
		                        <td width="10%" align="left" onclick="PageList('users_table_div','ajax=1&sorter=10&letter={$letter}&search={$search}&s_type={$s_type}&s_stat={$s_stat}&group={$group}&order={if $sorter eq 10}{$form.new_order}{else}{$form.order}{/if}')">
		                            {$lang.users.gender}
		                        </td>
		                        <td width="15%" align="left">
		                            {$lang.users.group}
		                        </td>
		                        <td width="10%" align="left">
		                            {$lang.users.balance}
		                        </td>
		                        <td width="7%" align="center" onclick="PageList('users_table_div','ajax=1&sorter=4&letter={$letter}&search={$search}&s_type={$s_type}&s_stat={$s_stat}&group={$group}&order={if $sorter eq 4}{$form.new_order}{else}{$form.order}{/if}')">
		                            {$lang.users.age}
		                        </td>
		                        <td width="15%" align="left" onclick="PageList('users_table_div','ajax=1&sorter=5&letter={$letter}&search={$search}&s_type={$s_type}&s_stat={$s_stat}&group={$group}&order={if $sorter eq 5}{$form.new_order}{else}{$form.order}{/if}')">
		                            {$lang.users.date_registration}
		                        </td>
		                        <td width="15%" align="left" onclick="PageList('users_table_div','ajax=1&sorter=6&letter={$letter}&search={$search}&s_type={$s_type}&s_stat={$s_stat}&group={$group}&order={if $sorter eq 6}{$form.new_order}{else}{$form.order}{/if}')">
		                            {$lang.users.date_last_login}
		                        </td>
		                        <td width="13%" align="right">
		                            {$lang.users.actions}
		                        </td>
		                    </tr>
		                    {section name=u loop=$user}
		                    <tr userid="1" {if $smarty.section.u.index mod 2 eq 1}class="even"{else}class="odd"{/if}>
		                        <td align="center" valign="top"><input type="checkbox" name="delete" value="{$user[u].id}" {if $user[u].group_type eq "r" || $user[u].group_type eq "g" || $user[u].group_type eq "m"}disabled{/if}></td>
								<!-- {if $user[u].root_user}{else}{/if} {$user[u].nick}-->
		                        <td style="padding-left: 10px;" align="left" valign="top">
									{if $user[u].guest_user}
										{$user[u].nick}
									{else}<a href="{$user[u].edit_link}">{$user[u].nick}</a>{/if}
								</td>
		                        <td style="padding-left: 10px;" align="left" valign="top">{$user[u].type}{if $user[u].gender}, {$user[u].gender}{/if}</td>
		                        <td style="padding-left: 10px;" align="left" valign="top">{$user[u].groupname}</td>
		                        <td  valign="top">
		                            <div style="float: left; margin-left: 15px;" >
		                                {$user[u].account_curr}&nbsp;
		                            </div>
		                            <div class="block_action" style="float:left;margin-top:4px;">                               
		                                {if $user[u].group_type ne "r" && $user[u].group_type ne "g" && $user[u].group_type ne "m"}
                                            <img src="{$site_root}{$template_root}/images/add_money_n.png" alt="" height="13" style="cursor: pointer;" onclick="WindowShow({$user[u].id})" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.pays.account}');return false"/>
                                        {/if}                               
		                            </div>
		                        </td>
		                        <td align="center" valign="top">{$user[u].age}</td>
		                        <td style="padding-left: 10px;" align="left" valign="top">{$user[u].date_rigistration}</td>
		                        <td style="padding-left: 10px;" align="left" valign="top">{$user[u].last_login} {if $user[u].ip}({$user[u].ip}){/if}</td>
		                        {*
		                        {if !$invite_users}
		                        <td class="main_content_text" align="center" bgcolor="#FFFFFF"><input type="checkbox" name="active[{$user[u].number}]" value="1" {if $user[u].status}checked{/if} {if $user[u].root_user}disabled{/if}><input type="hidden" name="hactive[{$user[u].number}]" value="{$user[u].id}"></td>
		                        {/if}
		                        <td class="main_content_text" align="left" bgcolor="#FFFFFF">
		                        {section name=p loop=$pp}
		                            {if !$user[u].root_user}
		                                &nbsp;&nbsp;[<a href="#" onclick="javascript: window.open('./admin_users.php?sel=edituser&id={$user[u].id}&editpage={$pp[p]}&popup=1','description', 'height=750, resizable=yes, scrollbars=yes,width=900, menubar=no,status=no'); return false;">{assign var=pps value=$pp[p]}{$lang.users.page[$pps]}</a>]<br>{/if}
		                        {/section}
		                            &nbsp;&nbsp;[<a href="#" onclick="javascript: window.open('{$user[u].upload_link}','upload', 'height=750, resizable=yes, scrollbars=yes,width=750, menubar=no,status=no'); return false;">{$lang.users.upload_link}</a>]<br>
		                        {if $user[u].invited_link}&nbsp;&nbsp;[<a href="{$user[u].invited_link}">{$user[u].invited_link_name}</a>]<br>{/if}
					</td>
		                        {if !$invite_users}
		                        <td class="main_content_text" align="center" bgcolor="#FFFFFF" width="100">
		                            <table cellspacing=1 cellpadding=0>
		                                <tr>
		                                    <td width=80><input type="button" value="{$lang.users.comunicate}" class="button" onclick="javascript:window.open('{$user[u].comunicate}','comunicate', 'height=800, resizable=yes, scrollbars=yes,width=700, menubar=no,status=no');"></td>
		                                </tr>
		                            </table>
		                        </td>
		                        {else}
		                        <td class="main_content_text" align="center" bgcolor="#FFFFFF" width="100">
		                        {if $user[u].invite_link}
		                        <input type="button" value="{$lang.club.admin.invite_butt}" onclick="javascript: location.href='{$user[u].invite_link}'" />
		                        {/if}
		                        </td>
		                        {/if}*}
		                        <td align="center" valign="top">
									{if $user[u].root_user ne 1 && $user[u].guest_user ne 1}
		                            <div class="block_action" id="block_action">  
		                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   																		
		                                <img src="{$site_root}{$template_root}/images/communicate.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.comunicate.editform}');return false" alt="" height="13" style="cursor: pointer;" onclick="javascript:window.open('{$user[u].comunicate}','comunicate', 'height=800, resizable=yes, scrollbars=yes,width=700, menubar=no,status=no');" />&nbsp;&nbsp;				
		                                {if $user[u].status}
		                                    <img src="{$site_root}{$template_root}/images/user_inactive.png"  onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.users.use_inactive}');return false" alt="" height="13" style="cursor: pointer;" {literal}onclick="javascript: if (window.confirm('{/literal}{$lang.users.use_inactive|escape:javascript}{literal}?'))  {ChangeStatus({/literal}{$user[u].id}{literal}, 0); } else return false;"{/literal}/>&nbsp;&nbsp;
		                                {else}
		                                    <img src="{$site_root}{$template_root}/images/user_active.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.activate}');return false" alt="" height="13" style="cursor: pointer;" {literal}onclick="javascript: if (window.confirm('{/literal}{$lang.button.activate|escape:javascript}{literal}?'))  {ChangeStatus({/literal}{$user[u].id}{literal}, 1); } else return false;"{/literal}/>&nbsp;&nbsp;
		                                {/if}
										
		                                <img src="{$site_root}{$template_root}/images/photo_delete.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.delete}');return false" alt="" height="13" style="cursor: pointer;" {literal}onclick="if(window.confirm('{/literal}{$lang.users.del_confirm|escape:javascript}{literal}')==true){document.location.href='admin_users.php?sel=del&id='+{/literal}{$user[u].id}{literal};} else return false;"{/literal} />
										</div>
									{/if}
		                        </td>
		                        
		                    </tr>
					{sectionelse}

					<tr height="40">
						<td class="main_error_text" align="left" colspan="9" bgcolor="#FFFFFF">{$lang.users.empty}</td>
					</tr>
		                    {/section}
		                    <tr class="table_header">
		                        <td colspan="11">
		                            &nbsp;&nbsp;
		                            {if $links}
		                            {foreach item=item from=$links.pages}
		                                &nbsp;<a onclick="PageList('users_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('users_table_div', '{$links.previous}');">< {$lang.content.previous} {$per_page}</a>
		                            {/if}
		                            {if $links.next}
		                                <a onclick="PageList('users_table_div', '{$links.next}');">{$lang.content.next} {$per_page} ></a>
		                            {/if}
		                            </div>
		                        </td>
		                    </tr>
		                </tbody>
		            </table>
<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>
		    {/if}            
{if $ajax eq 0}
        </div>
    </div>
</div>

{literal}
<script language="JavaScript" type="text/javascript" >
    $(document).ready(function(){ 
       if (!$.browser.msie)
            $('#bottom_corner').corner("bottom 3px");
            $('.select_box_option').live('click',function(){
                $("#active_themes").toggle();
            });
            $(".option_box_item_box").hover(
                function(){
                    $(this).addClass('option_box_item_box_hover');
                },
                function () {
                    $(this).removeClass('option_box_item_box_hover');
                }
            );
            $(".option_box_item_box").click(function(){               
                $(".theme_list").css('display','none');
                $("#active_"+this.id).css('display','block');
                $('#active_themes').oneTime(500, function() {
                    $("#active_themes").css('display','none');
                });
            });
		sel = '{/literal}{$sel}{literal}';
		if (sel=="add_money"){
			Close();
		}
});
</script>
{/literal}
{/if}
{literal}
<script language="JavaScript" type="text/javascript" >    
    
    if ( {/literal} "{$ajax}"{literal} == 0) 
        var tab_id_last = 'all';

    function DeleteList(){
        var str = "";
        $('tr[userid=1]').attr('forremove', '0');
        $('input[name=delete]:checked').each(function(){
            str += 'delete[]='+$(this).val()+'&';
            $(this).parents('tr[userid=1]').attr('forremove', '1');
        });
        $('.delete_status').html('{/literal}{$lang.users.deleting}{literal}');
		if(str != ""){
			$.ajax({
				type: 'POST',
				url: 'admin_users.php',
				data: 'sel=delusermass&' + str,
				success: function(msg){
					if(msg == "OK"){
						ShowAjaxError('{/literal}{$lang.users.deleted}{literal}', '', 'success');
						$('.delete_status').html('{/literal}{$lang.users.deleted}{literal}');
						$('tr[forremove=1]').detach();
					} else {
						ShowAjaxError('{/literal}{$lang.users.delete_error}{literal}', '', 'error');
						$('.delete_status').html('{/literal}{$lang.users.delete_error}{literal}');
					}
				}
			});
		} else {
			ShowAjaxError('{/literal}{$lang.users.delete_pleaseselect}{literal}', '', 'warning');
			$('.delete_status').html('{/literal}{$lang.users.delete_pleaseselect}{literal}');
		}
		//$('.delete_status').fadeIn(100);
		$('.delete_status').oneTime(5000, function() {
			$('.delete_status').fadeOut(500);
		});
    }
    function ResendList(){
        var str = "";
        $('input[resend=1]').removeAttr('resend');
        $('input[name=delete]:checked').each(function(){
            str += 'id[]='+$(this).val()+'&';
            $(this).attr('resend', '1');
        });
        $('.delete_status').html('{/literal}{$lang.users.resending}{literal}');
		if(str != ""){
			$.ajax({
				type: 'POST',
				url: 'admin_users.php',
				data: 'sel=resend&' + str,
				success: function(msg){
					if(msg == "OK"){
						ShowAjaxError('{/literal}{$lang.users.resended}{literal}', '', 'success');
						$('.delete_status').html('{/literal}{$lang.users.resended}{literal}');
						$('input[resend=1]').attr('checked', false);
					} else {
						ShowAjaxError('{/literal}{$lang.users.resend_error}{literal}', '', 'error');
						$('.delete_status').html('{/literal}{$lang.users.resend_error}{literal}');
					}
				}
			});
		} else {
			ShowAjaxError('{/literal}{$lang.users.resend_pleaseselect}{literal}', '', 'warning');
			$('.delete_status').html('{/literal}{$lang.users.resend_pleaseselect}{literal}');
		}
		//$('.delete_status').fadeIn(100);
		$('.delete_status').oneTime(5000, function() {
			$('.delete_status').fadeOut(500);
		});
    }
    function UsersList(par) {
        if ($('#tab_'+par+'_users').find('a').text() == '') return;
        
        $('#tab_'+tab_id_last+'_users').html("<a>"+$('#tab_'+tab_id_last+'_users').text()+"<\/a>");
        $('#tab_'+par+'_users').text($('#tab_'+par+'_users').text());
        $('#tab_'+tab_id_last+'_users').removeClass('user_status_elem_active');
        $('#tab_'+tab_id_last+'_users').addClass('user_status_elem');
        $('#tab_'+par+'_users').removeClass('user_status_elem');
        $('#tab_'+par+'_users').addClass('user_status_elem_active');
        
        tab_id_last = par;
        num_users = $("select[name=pays_numpage]").val();   
        ajaxLoadingImage(1, 'users_table_div');
        $.post("admin_users.php", {par:par,ajax:'1', num_on_page: num_users}, function(data){
            ajaxLoadingImage(0, 'users_table_div');
            $('#users_table_div').html(data);
        });
        
 
    }
    function PageList(id_div, par) {
        ajaxLoadingImage(1, 'users_table_div');
        $.post("admin_users.php", par, function(data){
            ajaxLoadingImage(0, 'users_table_div');
            $('#users_table_div').html(data);
        });
    }
    
function AddFunds(){
    var mas=[];
    var i=0;
    $('input[name=delete]:checked').each(function(){
        mas[i] = $(this).val()  ; 
        i++ ;   
    });
    if (mas == ""){
		ShowAjaxError('{/literal}{$lang.pays.add_users_for_add_funds}{literal}', '', 'warning');
    }else{
        WindowShow(mas);
    }
}
    
function WindowShow(par) {

	//Get the screen height and width
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();

	//Set heigth and width to mask to fill up the whole screen
	$('#mask').css({'width':maskWidth,'height':maskHeight});
	
	//Get the window height and width
	var winH = $(window).height();
	var winW = $(window).width();
		  
	//Set the popup window to center
	$('#dialog').css('top',  winH/2-$('#dialog').height()/2);
	$('#dialog').css('left', winW/2-$('#dialog').width()/2);
	$('#close').css('top',  winH/2-$('#dialog').height()/2+9);
	$('#close').css('left', winW/2+$('#dialog').width()/2-25);        

	//transition effect		
	$('#mask').fadeIn(500);	
	$('#mask').fadeTo("fast",0.8);
	var par = 'sel=add_billing&id='+par+'&user=1&par={/literal}{$par}{literal}&page={/literal}{$page}{literal}'
	$.ajax({
		type: "POST",
		url: "admin_pays.php",        
		data: (par),
		success: function(data){
			$('#dialog').html(data);
			$('#dialog').fadeIn(500);
			$('#close').fadeIn(500); 
		}
	});
     
	//transition effect
}
function Close(){
    $('#mask').fadeOut(500);
    $('#close').fadeOut(500)
    $('#dialog').fadeOut(500)	
}
function PutAll() {
	var o=document.getElementsByName('select_all')	
	var i
	if (o[0].checked){                    
		o=document.getElementsByName('delete')
		for (i=0; i<o.length; i++){                
			if (!o[i].disabled)
				o[i].checked = true
		}            
	}
	else{
		o=document.getElementsByName('delete')
		for (i=0; i<o.length; i++){                
			o[i].checked = false
		}            
	}             
}

function NumUsers(){
    num_users = $("select[name=pays_numpage]").val();    
    ajaxLoadingImage(1, 'users_table_div');
    $.ajax({
        type: "POST",
        dataType: "text",
        data: 'num_on_page='+num_users+'&ajax=1&par={/literal}{$par}{literal}',
        url: "admin_users.php",
        success: function(data){
            ajaxLoadingImage(0, 'users_table_div');
            $('#users_table_div').html(data);
        }
    })
}
{/literal}{if !$import}{literal}
function ChangeStatus(id, status){
    var chislo = {/literal}{$form.stat_inactive_users}{literal};      
    if (status == 1){
        chislo = chislo - 1        
        var div = document.getElementById('tab_inactive_users')
        if("{/literal}{$par}{literal}" == "inactive")
            div.innerHTML = {/literal}"{$lang.users.inactive} ("+chislo+")"{literal}
        else
            div.innerHTML = {/literal}"<a>{$lang.users.inactive} ("+chislo+")</a>"{literal}
    }
    else{
        chislo = chislo + 1 
        var div = document.getElementById('tab_inactive_users')
        if("{/literal}{$par}{literal}" == "inactive")
            div.innerHTML = {/literal}"{$lang.users.inactive} ("+chislo+")"{literal}
        else
            div.innerHTML = {/literal}"<a>{$lang.users.inactive} ("+chislo+")</a>"{literal}
    } 
    var num_users = $("select[name=pays_numpage]").val();
    $.ajax({
        type: "POST",
        dataType: "text",
        data: 'num_on_page='+num_users+'&ajax=1&id='+id+'&status='+status+'&sel=active&page={/literal}{$page}{literal}'+'&par={/literal}{$par}{literal}',
        url: "admin_users.php",
        success: function(data){
            $('#users_table_div').html(data);
        }
    });
}
{/literal}{/if}{literal}

function MoveGroup(id){
    $("#active_themes").toggle();
    var str=[]
    var i = 0
    $('input[name=delete]:checked').each(function(){
        str[i] = $(this).val()
        i++        	  
     });
     $("#active_themes").css('display','none');
     num_users = $("select[name=pays_numpage]").val();    
     $.ajax({
        type: "POST",
        dataType: "text",
        data: 'num_on_page='+num_users+'&ajax=1&sel=move_group&id_group='+id+'&id_users='+str+'&par={/literal}{$par}{literal}',
        url: "admin_users.php",
        success: function(data){            
            $('#users_table_div').html(data);
        }
     })
}
</script>
{/literal}
<link href="{$site_root}{$template_root}/css/alert.css" rel="stylesheet" type="text/css">
<div id="boxes">
    <div id="close" class="close" onclick="Close()"></div>
	<div id="dialog" class="window">
	</div>
</div>
<div id="mask"></div>

{if $ajax eq 0}
{include file="$admingentemplates/admin_bottom.tpl"}
{/if}