{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>

<div class="back">
    <a href="{$site_url}{$site_root}/admin/admin_settings.php">{$lang.button.back}</a>
</div>
<div class="cr"></div>
{if $ref eq '16' || $ref eq '22'}
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{if $ref eq '16'}{$lang.admin_menu.ref_hotlist_types}{elseif $ref eq '22'}{$lang.admin_menu.uploads_gallery_categories}{/if}</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 $ref eq '16'}{$lang.admin_help.ref_hotlist}{elseif $ref eq '22'}{$lang.admin_help.uploads_gallery_categories}{/if}
    </div>
</div>
<div class="cr">&nbsp;</div>
<ul class="tabs">
	<li>
        <a {if $tab eq '3'}class="current"{else}href="admin_settings.php?section=3"{/if}>{$lang.admin_menu.ref_languages}</a>
    </li>
    <li>
        <a {if $tab eq '1'}class="current"{else}href="admin_addition_info.php"{/if}>{$lang.admin_menu.area_editor}</a>
    </li>
    <li>
        <a {if $tab eq '2'}class="current"{else}href="admin_news.php"{/if}>{$lang.news.razdel_name}</a>
    </li>
    <li style="padding-right:0px;">
        <a {if $ref eq '16'}class="current"{else}href="admin_reference.php?ref=16"{/if}>{$lang.admin_menu.ref_hotlist_types}</a>
    </li>
    <li style="padding-right:0px;">
        <a {if $ref eq '22'}class="current"{else}href="admin_reference.php?ref=22"{/if}>{$lang.admin_menu.uploads_gallery_categories}</a>
    </li>
    <li style="padding-right:0px;">
        <a href="admin_kisses.php">{$lang.admin_menu.ref_kiss_types}</a>
    </li>
</ul>
{else}
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$lang.admin_menu.profile_fields}</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>{$top_help}
    </div>
</div>
<div class="cr">&nbsp;</div>
<ul class="tabs">
    <li>
        <a {if $ref eq '1'}class="current"{else}href="admin_reference.php?ref=1"{/if}>{$lang.admin_menu.ref_description}</a>
    </li>
    <li>
        <a {if $ref eq '5'}class="current"{else}href="admin_reference.php?ref=5"{/if}>{$lang.admin_menu.ref_nationalities}</a>
    </li>
    <li style="padding-right:0px;">
        <a {if $ref eq '6'}class="current"{else}href="admin_reference.php?ref=6"{/if}>{$lang.admin_menu.ref_personal_data}</a>
    </li>
    <li style="padding-right:0px;">
        <a {if $ref eq '8'}class="current"{else}href="admin_reference.php?ref=8"{/if}>{$lang.admin_menu.ref_my_portrait}</a>
    </li>
    <li style="padding-right:0px;">
        <a {if $ref eq '3'}class="current"{else}href="admin_reference.php?ref=3"{/if}>{$lang.admin_menu.ref_interests}</a>
    </li>
    <li style="padding-right:0px;">
        <a {if $ref eq '14'}class="current"{else}href="admin_reference.php?ref=14"{/if}>{$lang.admin_menu.ref_relationship}</a>
    </li>
    <li style="padding-right:0px;">
        <a {if $ref eq '12'}class="current"{else}href="admin_reference.php?ref=12"{/if}>{$lang.admin_menu.ref_weight}</a>
    </li>
    <li style="padding-right:0px;">
        <a {if $ref eq '13'}class="current"{else}href="admin_reference.php?ref=13"{/if}>{$lang.admin_menu.ref_height}</a>
    </li>
</ul>
{/if}
<div class="panel">
    <div class="user_operation_line">
    	<div style="padding: 12px;">
            <table cellSpacing="3" cellPadding="0">
                <tr>
                	<td><span style="color:white;">{$lang.settings.translate_into}:</span>
						<select onchange="javascript:window.open(this.value,'lang_edit', 'height=750, width=1050, left=10, top=50, resizable=yes, scrollbars=yes, menubar=no,status=no'); return false;">
						{section name=s loop=$lang_link}
							<option value="{$lang_link[s].link}">{$lang_link[s].name}</option>
						{/section}
						</select>
					</td>
                </tr>
            </table>
		</div>
    </div>
    <div class="cr"></div>
    <div class="user_status_line">
        <div id="users_table_div">
            <div id="ref_block" class="fl" style="width:45%;margin:10px;float:left;">
{/if}
            <div>
{if $ref eq '16'}
		<form id="settings_form" name="settings_form" class="settings_form" action="{$site_url}{$site_root}/admin/admin_reference.php?sel=save" method="POST">
		<table border=0 cellspacing=0 cellpadding=5>
			<tr bgcolor="#FFFFFF">
				<td align="left" nowrap class="main_header_text" width="auto" style="margin-right:10px;padding-left:0px;">{$lang.settings.use_friend_types}:&nbsp;</td>
				<td class="main_content_text" align="left"><input type="checkbox" name="use_friend_types" id="use_friend_types" value="1" {if $data.use_friend_types}checked{/if}></td>
				<td align="left">
					<div id="error_box" class="error_box_blue"></div>
				</td>
			</tr>
		</table>
		</form>
		<script language="JavaScript" type="text/javascript">
		{literal}
			var options = { 
				success: function(data){
					ShowAjaxError(data, '', 'success');
					return false;
				},
				beforeSubmit: function() { 
					ajaxIndicator(1, 'error_box');
				}
			};
			$(document).ready(function(){
				$("#use_friend_types").change(function (){
					$('.settings_form').ajaxSubmit(options);
					return false;
				});
			});
		{/literal}
		</script>
		<div class="cr">&nbsp;</div>
{/if}
                <form method="post" action="{$form.action}"  enctype="multipart/form-data" name="types_form">
                {$form.hiddens}
                <div class="fl" style="text-align:left;padding-top:5px;">
                    {$lang.descr_spr.editform_opt}:&nbsp;
                </div>
                <div class="fl" style="width:46%;text-align:left;padding-top:5px;padding-right:5px;">
                    <input type="text" name="name_ref" id="name_ref" style="width: 200px;">
                </div>
                <div class="fl" style="text-align:left;">
                    <a href="#" class="admin_button_major" style="margin:0px;"  id="ref_add">{$lang.button.add}<span>&nbsp;</span></a>
                </div>
                <form>
            </div>
            <div class="cr">&nbsp;</div>
            
            <div class="cr"></div>
            <form action="{$form.action}" method="POST">
<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">
                    <tr class="table_header">
                        {*<td align="center" width="5%">{$header.number}</td>*}
                        <td align="left" width="85%">{$header.name}</td>
                        {if $ref eq 23}<td align="center">{$header.pair_profile}</td>{/if}
                        {if $form.options eq 1}<td align="center" width="15%">{$header.option}</td>{/if}
                        <td align="right" width="15%">{$lang.button.action}</td>
                    </tr>
                    {section name=spr loop=$types}
                    <tr id="tr_{$types[spr].id}" {if $smarty.section.spr.index mod 2 eq 1}class="table_row even"{else}class="table_row odd"{/if} style="height: 27px">
                        {*<td align="center" width="20">{$types[spr].number}</td>*}
                        <td align="left">
                            {*<a href="{$types[spr].editlink}">
                            {$types[spr].name}</a>*}
                            <div>
                                <input type="hidden" name="id_ref" value="{$types[spr].id}">
                                <div id="ref_{$types[spr].id}" onkeypress="return event.keyCode != 13;">{$types[spr].name}</div>
                            </div>
                        </td>
                        {if $ref eq 23}<td align="center"><input type="checkbox" id="{$smarty.section.spr.index}" name="{$smarty.section.spr.index}" value="{$types[spr].id}" {if $types[spr].pair eq Y}checked{/if}></td>{/if}
                        {if $form.options eq 1}
                            <td align="center">
                                <div>
                                    <a onclick="ShowOption('{$types[spr].editoptionlink}', '{$types[spr].id}');">{$types[spr].option_count}</a>
                                </div>
                                {*<input type="button" value="{$header.edit_option}" class="button" onclick="javascript: document.location.href='{$types[spr].editoptionlink}'">*}</input>
                            </td>
                        {/if}
                        <td align="center">
                            <div class="block_action fr" style="display: none;">
                                <div class="action_edit" style="display: block;float:left;"><img onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.edit}');return false" width="16" alt="" src="{$site_root}{$template_root}/images/edit.png"></div>
                                <div class="action_save" style="float:left;"><img width="16" alt="" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.save}');return false" src="{$site_root}{$template_root}/images/success.png"></div>
                                <div style="width:5px;" class="fl">&nbsp;</div>
                                <div class="action_del" style="display: block;float:left;"><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"></div>
                            </div>
                        </td>
                    </tr>
		    {sectionelse}
                    <tr height="40">
                        <td class="main_error_text" align="left" colspan="{if $form.options eq 1}3{else}2{/if}">{$header.empty}</td>
                    </tr>
                    {/section}
                    {if $ref eq 23}
                    <tr>
                        <td colspan="1"></td>
                        <td align="center"><div id="refresh"><input type="button" value="{$lang.button.refresh}" onclick="Refresh();" class="button"></div></td>
                        {if $ref eq 23 || $ref eq 1 || $ref eq 6 || $ref eq 8}<td></td>{/if}
                    </tr>
                    {/if}
                    <tr class="table_header">
                        <td colspan="{if $form.options eq 1}4{else}3{/if}">
                            &nbsp;&nbsp;
                            {if $links}
                            {foreach item=item from=$links.pages}
                                &nbsp;<a onclick="PageList('ref_block', '{$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('ref_block', '{$links.previous}');">< {$lang.content.previous} {$per_page}</a>
                            {/if}
                            {if $links.next}
                                <a onclick="PageList('ref_block', '{$links.next}');">{$lang.content.next} {$per_page} ></a>
                            {/if}
                            </div>
                        </td>
                    </tr>
                    {*{if $links}
                    <tr bgcolor="#ffffff">
                        <td height="20"  colspan="{if $form.options eq 1}4{else}3{/if}" align="left">{$links}</td>
                    </tr>
                    {/if}*}
                </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>
            </form>
{if $ajax eq 0}
            </div>
            <div class="fl" id="options" style="width:50%;margin:10px;">
                &nbsp;
            </div>
            <div class="cr"></div>
        </div>
    </div>
</div>
{/if}
<script type="text/javascript">
var ref = {$ref};
{literal}
var REF_OLD = "";
var REF_OPEN_OPTION = "";
function Refresh() {
	file_name = '{/literal}{$form.action}{literal}';
	var s='';
	i = 0;
	while(document.getElementById(i)) {
		if (document.getElementById(i).checked == true) {
			if (s != '') {
				s=s+','+document.getElementById(i).value;
			} else {
				s=document.getElementById(i).value;
			}
		}
		i++;
	}
	tmp_text = 'Saving...';
	ShowAjaxError(tmp_text, '', 'success');
	//$('#refresh').html(tmp_text);
	$.post(file_name , {sel:'refresh', end:i, val:s}, function(data){
		CloseAjaxError(1);
		$('#refresh').html(data);
	});
}
$(document).ready(function() {	
    $("tr .table_row .action_edit").live('click',
        function(){
            var ref_id = $("tr .select_tr").find('input[type="hidden"]').val();
            REF_OLD = $('#ref_'+ref_id).text();
            str = '<input type="text" name="ref_new" id="ref_new_'+ref_id+'" value="'+REF_OLD+'" size="18">';
            $('#ref_'+ref_id).html(str);
            $('tr .select_tr').find('div .action_edit, .action_del').css('display', 'none');
            $('tr .select_tr').find('div .action_save').css('display', 'block');
        }
    );
    $("tr .table_row .action_save").live('click',
        function(){
            var ref_id = $("tr .select_tr").find('input[type="hidden"]').val();
            var ref_new = $('#ref_new_'+ref_id).val();
            if (ref_new == '') return;
            ajaxIndicator(1, 'ref_'+ref_id);
            $.post('admin_reference.php', {sel:'change',ref:ref, id:ref_id,name:ref_new},
                function(data){
                    ajaxIndicator(0, 'ref_'+ref_id);
                    if (data=="")
                        $('#ref_'+ref_id).html(REF_OLD);
                    else 
                        $('#ref_'+ref_id).html(data);
                    REF_OLD = "";
                }
            );
            $('tr .select_tr').find('div .action_edit, .action_del').css('display', 'block');
            $('tr .select_tr').find('div .action_save').css('display', 'none');
        }
    );
    $("tr .table_row .action_del").live('click',
        function(){
            var ref_id = $("tr .select_tr").find('input[type="hidden"]').val();
            ajaxIndicator(1, 'ref_'+ref_id);
            $.post('admin_reference.php', {sel:'del',ref:ref, id:ref_id},
                function(data){
                    ajaxIndicator(0, 'ref_'+ref_id);
                    if (data == 'deleted'){
                        if (ref_id == REF_OPEN_OPTION)
                            $("#options").html('');
                        //$("#tr_"+ref_id).remove();
                        ShowReference('')
                    }
                }
            );
        }
    );
    $("#ref_add").live('click',
        function(){
            var name_ref_add = $("#name_ref").val();
            if (name_ref_add == "") return;
            document.types_form.submit();
        }
    );
});
function ShowOption(par, open_ref) {
    REF_OPEN_OPTION = open_ref;
    ajaxLoadingImage(1, 'options');
    $.post(par,'',function(data){
        ajaxLoadingImage(0, 'options');
        $('#options').html(data);
    });
}
function ShowReference(par) {
    ajaxLoadingImage(1, 'ref_block');
    if(par == '')
        $.post('admin_reference.php',{ref:ref,ajax:'1'},function(data){
            ajaxLoadingImage(0, 'ref_block');
            $('#ref_block').html(data);
        });
    else
        $.post(par,'',function(data){
            ajaxLoadingImage(0, 'ref_block');
            $('#ref_block').html(data);
        });
}
function PageList(id_div, par) {
    ShowReference(par);
}
{/literal}
</script>
{if $ajax eq 0}
{include file="$admingentemplates/admin_bottom.tpl"}
{/if}