{include file="$gentemplates/$header_tpl"}
<div class="profile_general_table">
<form name="invite" method="post" action="{$form.action}">
	<div class="quick_search_table">	
		<h2>{if $form.friend_hotlist}{$lang.relations.friend_hotlist_header} {$form.friend_hotlist}{else}{$lang.section.friends}{/if}</h2>
		
	<!--<p">{$section.search_result}:&nbsp;{$form.pages_count}&nbsp;{$lang.pages}</p>-->
                
		<!-- main tabs -->	
		<div class="main_tabs">				
			<div class="tab_block first {if $active_tabs eq 'all'} active{/if}">
				<a href="{$form.view_all_link}">
					{$lang.search.friends} ({$total_users})
				</a>
			</div>
			<div class="tab_block {if $active_tabs eq 'sent_r'} active{/if}">
				<a href="{$form.view_sent_r_link}">
					{$lang.search.sent_requests} ({$total_sent})
				</a>
			</div>
			<div class="tab_block {if $active_tabs eq 'received_r'} active{/if}">
				<a href="{$form.view_received_r_link}">
					{$lang.search.received_requests} ({$total_received})
				</a>
			</div>		
			<div class="view">
				{if $form.view eq 'gallery'}
					<a href="{$form.view_list_link}" class="view-list-icon" title="{$lang.button.view_as_list}">&nbsp;</a>
				{else}
					<a href="{$form.view_gallery_link}" class="view-gal-icon" title="{$lang.button.view_as_gal}">&nbsp;</a>
				{/if}					
			</div>
		</div>
		<!-- end main tabs -->	
			
		<!-- begin results list -->
		
		<div class="pagination_top">
			{if $active_tabs eq 'all'}
			<div class="float_left">
				{$lang.search.view_by_relation}:
				<select onchange="ReloadPage(this);">
					<option value="0" {if !$search_param.type}selected="selected"{/if}>{$lang.search.all}</option>
					{foreach item=item from=$types}
						<option value="{$item.id}&view={$view}" {if $search_param.filter==$item.id} selected="selected"{/if}>{$item.name}</option>
					{/foreach}
				</select>
			</div>
			<div class="float_left" style="padding-left:20px;">
				{$lang.search.by_name}:
				<input type="text" maxlength="100" name="to" value="{$data.to}" id="mail_to" onkeyup="SearchVariants(this.value, event);">
			</div>
			{/if}
			{include file="$gentemplates/pagination_top.tpl"}
		</div>
		
		{if $form.friend_hotlist}
			<p><a href="{$form.hotlist_link}">&laquo; {$lang.relations.back_to_hotlist}</a></p>
		{/if}

		{if $form.err}
			<p class="error_msg">*&nbsp;{$form.err}</p>
		{/if}

		{if $empty eq 1}
			<p class="error_msg">*&nbsp;{if $sel eq 'invite'}{$lang.relations.no_friends}{else}{$lang.relations.empty_result}{/if}</p>
		{/if}

		
		
		{if $sel eq 'invite'}
			<div style="vertical-align: middle; display:table; overflow:hidden;width:100%;">
				<p style="float: {$default_right}; "><input type="submit" name="invite_all" value="{$lang.homepage.invite_all}"></p>
			</div>
		{/if}
		
		<div class="search_result_list" style="width:100%;">
			{if $sel eq 'invite'}
				<input type="hidden" id="id_user" name="id_user" value="">
			{/if}	
					
			<div class="search_list_gallery">
			{if $form.view eq 'gallery'}
				{foreach key=key item=item from=$search_res name=s}
				<div class="search_result_gallery" {if $smarty.foreach.s.iteration is div by 6}style="margin-right:0px"{/if} id="variants">
					<div class="table_result_gallery">
					<a class="imgcanvas_container" href="{$item.profile_link}" style="position: relative;">
						<img src="{$item.icon_path}" class="icon imgcanvas" alt="" onmouseover="javascript: CreateBigImage(this, event{if $smarty.foreach.s.last is div by 6}, true{else}, false{/if}, false);">
					</a>
					{if $item.hotlisted}<div style="position:relative;"><a class="small_heart_white" style="top:-38px; {$default_left}:5px; position:absolute;">&nbsp;</a></div>{/if}
					<p>
						<a href="{$item.profile_link}">{$item.name|truncate:18:"...":true}</a><br />
						{if $item.location}{$item.location|truncate:18:"...":true}<br />{/if}
						{$item.age} {$lang.home_page.ans}<br />
						<span class="text_hidden">{$item.photo_count} {$lang.users.upload_1}</span><br/>
						
					</p>
					</div>
				</div>
				{/foreach}			
			{else}
			{foreach key=key item=item from=$search_res name=s}
				<div class="table_result_list {if $item.is_me eq 1} home_menu {/if}" {if $smarty.foreach.s.iteration eq 1 && $smarty.foreach.s.last eq 1}style="height: 200px;"{/if}  id="variants" >					
					<div class="image_col" style="padding:0px; position: relative;">	
						<a class="imgcanvas_container" href="{if $item.is_me ne 1}{$item.profile_link}{else}#{/if}">
							<!-- onmouseover="javascript: CreateBigImage(this, event);"-->								
							<img src="{$item.icon_path}" class="icon imgcanvas" alt="" onmouseover="javascript: CreateBigImage(this, event, false{if $smarty.foreach.s.last eq 1}, true{else}, false{/if});">					
							</a>
							{if $form.friend_hotlist && $item.hotlisted && $form.user != $item.id}
								<a class="small_heart_white" style="top:-38px; {$default_left}:5px; position:absolute;">&nbsp;</a>
							{/if}
							<div style="position:relative;">
								<a style="top:-38px; {$default_left}:5px; position:absolute;" class="small_heart_white">&nbsp;</a>
							</div>
					</div>
					{if $active_tabs eq 'received_r'}
					<input type="button" value="{$lang.relations.accepted}" onclick="location.href='{$item.accepted_link}';return false;">&nbsp;&nbsp;
					<input type="button" value="{$lang.relations.decline}" onclick="location.href='{$item.delfriend_link}&reload=1&received_r=1';return false;">
					{/if}
					<div class="info_col">	
					
						{if $item.is_me ne 1}
							<a class="float_left" href="{$item.profile_link}">
						{/if}
							{$item.name|truncate:20:"...":true}
						{if $item.is_me ne 1}</a>{/if}
						<span class="float_left">&nbsp;&nbsp;</span>
						<span class="float_left status{if $item.status eq $lang.status.on}_link{else}_text{/if}">{$item.status}</span><br /><br />
						{if $item.location}{$item.location|truncate:30}<br />{/if}
						{$item.age} {$lang.home_page.ans}<br />							
						<span class="text_hidden">{$item.photo_count} {$lang.users.upload_1}</span>
													
						{if $form.show_users_group_s eq '1'}					
							<p>{$item.group}</p>				
						{/if}							
						<p class="text_hidden">
							{$lang.users.gender_search}&nbsp;
							{if $item.user_subtypes}{$item.user_subtypes}&nbsp;({$item.user_type})
							{else}{$item.user_type}
							{/if} 
							{$lang.users.from} {$item.age_min} {$lang.users.to} {$item.age_max}
						</p>							
					</div>	
					{if $active_tabs eq 'all'}
					<div class="annonce text_hidden">
						{if $form.show_users_comments eq '1'}
							{$item.annonce}
						{/if}
						{if $item.friend_type ne '0' && $use_friend_types}					
							<p>
								<a onclick="launchWindow('{$item.addfriend_link}&edit=1','',400,300); return false;" href="#" onmouseover="ShowHide(this, 1);" onmouseout="ShowHide(this, 0);">
									{if $item.friend_type}
										{$item.friend_type}
									{else}{$lang.search.no_indicate}
									{/if}
								</a>
							</p>
						{/if}
					</div>	
					{/if}
					{if $sel eq 'invite'}
						<input style="width:40px;margin-top:70px;" class="float_right" id="user" type="checkbox" name="list_invite_users[{$item.id}]" value="{$item.id}">
					{/if}					
				</div>
			{/foreach}
			{/if}
			</div>
		</div>
		<!-- end results list -->
		
		{include file="$gentemplates/pagination_bottom.tpl"}
		
	</div>
    </form>

{literal}
    <script type="text/javascript">
        function ReloadPage(obj){
        {/literal}
            href = "?";
            {if $page > 1}
                href += "page={$page}&";
            {/if}
            href += obj.value +"&{$active_tabs}=1";
            document.location.href = href;
        {literal}
        }
        function ShowHide(obj, val){
            var img_on = '{/literal}{$site_root}{$template_root}{$template_images_root}/icn_friend_edit.gif{literal}';
            var img_off = '{/literal}{$site_root}{$template_root}{$template_images_root}/icn_friend_edit_gray.gif{literal}';
            img = $(obj).find('img');
            if(val == 1){
                img.attr('src', img_on);
            }
            else{
                img.attr('src', img_off);
            }
        }
		
		 function SearchVariants(par, event){
				$('#variants').html('');
				var text = par;
				$.post("hotlist.php?sel=search_name&ajax=1",{async:false, text:text}, function(data){
					$('#variants').html('');
					if (!data) {
						$('#variants').hide();
					} else {
						$('#variants').show();
						resp = getJQData(data);
							for (i=0;i<resp.length;i++) {
								$('#variants').append("<div class='table_result_list ' style='height: 200px;'  id='variants' ><div class='image_col' style='position: relative;'><a class='imgcanvas_container' href='"+resp[i]['profile_link']+"'><img src='"+resp[i]['icon_path']+"' class='icon imgcanvas' alt=''><\/a><\/div><div class='info_col'><a class='float_left' href='"+resp[i]['profile_link']+"'>"+resp[i]['name']+"<\/a><span class='float_left'>&nbsp;&nbsp;<\/span><span class='float_left'>"+resp[i]['status']+"</span><\/div><\/div>");
							}
					}
				});
			}

    </script>
{/literal}

{include file="$gentemplates/$footer_tpl"}