{if $ajax eq'0'}
{include file="$admingentemplates/admin_top.tpl"}
	<div class="error" style="padding: 10px;display: none;">
	</div>
<div class="back">
    <a href="{$site_url}{$site_root}/admin/admin_users.php">{$lang.button.back}</a>
</div>
<div class="cr"></div>
<div class="cr"></div>
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$lang.users.upload_link}</div>
<div class="cr">&nbsp;</div>
{*	<font class=red_header>{$lang.users.razdel_name}</font><font class=red_sub_header>&nbsp;|&nbsp;{$lang.users.editform_upload}&nbsp;{$data.username}</font><br><br><br>*}
<font class="user_status_elem" style="padding:0px;">{$data.username}</font>
<script language="JavaScript" type="text/javascript" src="{$site_root}{$template_root}/js/area-editor.js"></script>
<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}
<div class="cr">&nbsp;</div>
<ul class="tabs">
    <li>
        <a {if $type_upload eq '1'}class="current"{/if} href="{$form.action}?type_upload=1&id={$data.id}">{$lang.users.upload_1}</a>
    </li>
    <li>
        <a {if $type_upload eq '2'}class="current"{/if} href="{$form.action}?type_upload=2&id={$data.id}">{$lang.users.upload_2}</a>
    </li>
    <li>
        <a {if $type_upload eq '3'}class="current"{/if} href="{$form.action}?type_upload=3&id={$data.id}">{$lang.users.upload_3}</a>
    </li>
</ul>
		<div class="user_operation_line">
			<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.button.delete}</div>
			</div>
		</div>

<div style="float:left;display:none;" class="delete_status"></div>
<div id="show_block" style="width: 100%">{/if}
    <div class="cr">&nbsp;</div>

	<form action="{$form.action}" method="post" name="type">
		<input type="hidden" name=id value="{$data.id}">
	</form>
	<form action="{$form.action}" method="post" enctype="multipart/form-data" name="upload_form" style="display:table;width:100%;">
		<input type="hidden" name=sel value="change">
		<input type="hidden" name=id value="{$data.id}">
		<input type="hidden" name=upload_type value="{$type_upload}">
		<div id="show_icon" style="display:none;">
		<table border=0 cellspacing=0 cellpadding=0 width="100%">
			{if $type_upload eq "1" || $type_upload eq ""}
			<tr class="table_header">
				<td width="5%" align="center">
					<input type="checkbox" name="select_all_icon" onclick="PutAllIcon()">
				</td>
				<td colspan="4" align="center">&nbsp;<b>{$lang.users.icon_name}</b>&nbsp;</td>						
			</tr>
			<tr class="even">
				<td align="center" valign="top" style="padding-top:5px;"><input type="checkbox" name="delete" value=""></td>
				<td width="30%"  align="left" class="main_header_text" valign="top" style="padding-top:5px;">&nbsp;<b>{$icon.file}</b>&nbsp;</td>
				<td class="main_content_text" colspan=2 valign="top" style="padding-top:5px;">&nbsp;<input type="file" name="icon" size="40" {*{if $icon.delete_link}&nbsp;<br><br><a href="{$icon.delete_link}">{$lang.button.delete}</a>{/if}*}&nbsp;</td>
				<td valign="top" style="padding-top:5px;">
					{if $icon.delete_link}
					<div class="block_action fr" style="display: none;">
						<div style="width:10px;" class="fl">&nbsp;</div>
						<div class="action_del" style="display: block;float:left;" onclick="javascript:location.href='{$icon.delete_link}'"><img height="16" alt="" src="{$site_root}{$template_root}/images/photo_delete.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.delete}');return false"></div>
						<div style="width:10px;" class="fl">&nbsp;</div>
					</div>
					{/if}
				</td>
			</tr>
			<tr class="table_header"><td colspan="5">&nbsp;</td>
			</tr>
			{/if}
		</table>
		</div>
		<div id="show_photo" style="display:block;">
		<table border=0 cellspacing=0 cellpadding=0 width="100%">
			<tr class="table_header">
				<td width="4%" align="center">
					<input type="checkbox" name="select_all" onclick="PutAll()">
				</td>
				<td width="{if $type_upload eq '1'}14{else}29{/if}%" align="left" class="main_header_text">
				{if $type_upload eq '1'}{$lang.users.upload_1}{/if}
				{if $type_upload eq '2'}{$lang.users.upload_2}{/if}
				{if $type_upload eq '3'}{$lang.users.upload_3}{/if}
				</td>
				{if $type_upload eq '1'}<td width="15%" align="left" class="main_header_text">{$lang.users.icon_name}</td>{/if}
				<td width="43%" align="left" class="main_header_text">&nbsp;{$lang.admin_games.comment}</td>
				<td width="15%" align="left" class="main_header_text">&nbsp;{$lang.users.allow_type}&nbsp;</td>
				<td width="9%" align="right" class="main_header_text">{$lang.button.action}</td>
			</tr>
		
		{if $upload ne 'empty'}
		{section name=f loop=$upload}
		<tr userid="1" {if $smarty.section.f.index mod 2 eq 1}class="even"{else}class="odd"{/if} style="overflow:hidden;height:auto;margin:0">
			<td style="padding-top: 5px;">
				<input type="checkbox" name="delete" value="{$upload[f].id}">
			</td>
			<td style="padding:5;">
				<a href="admin_user_upload.php?sel=view&id_file={$upload[f].id}">
					{if $type_upload eq 1}
					<img src="{$upload[f].file_path}" border="0">
					{else}
					<b>{$upload[f].file_path}</b>
					{/if}
				</a>
				{if $type_upload eq 2}
					<span id="player{$smarty.section.f.index}" align=absmiddle>
						<script type="text/javascript">
							var fv = "file={$upload[f].file}&autostart=false&title={$upload[f].name|escape}&lightcolor=0xD12627";
							{literal}
								var FO = {
									movie:"{/literal}{$site_root}{literal}/include/mp3player/mp3player.swf",width:"235",height:"20",majorversion:"7",build:"0",bgcolor:"#FFFFFF", flashvars:fv
								};
							{/literal}
							UFO.create(FO, "player{$smarty.section.f.index}");
						</script>
					</span>							
				{elseif $type_upload eq 3 && $upload[f].file_type != 'embed'}
					<div>
                        {*<a href="{$upload[f].file}" class="player" style="display:block;width:300px;height:200px;"></a>*}
						<div class="player" data-engine="flash" style="width:250px;height:150px;">
							<video src="{$upload[f].file}"></video>
						</div>
                    <!--embed src="{$upload[f].file}" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" autostart=0></embed-->
                    </div>
				{/if}
			</td>
			{if $type_upload eq '1'}
			<td style="padding:10px;">
				<input type="radio" id="main_photo" value="{$upload[f].id}" name="main_photo" onclick="change_main_photo({$upload[f].id})" {if $upload[f].id eq $icon.id_icon}checked{/if}>
			</td>
			{/if}
			<td style="padding:10px; vertical-align: top;">
				<div style="width:100%;overflow:hidden;">
					<input type="file" style="float:right;" size="40" name="upload{$smarty.section.f.index}" >
				</div>
				{if $upload[f].id}
					<div style="margin-bottom:10px;margin-top:10px;overflow:hidden;">
						<span style="float:left;width:90px;text-align:right;">{$lang.taketour.comment}:&nbsp;</span>
						<textarea style="float:left; margin-left:5px;" name="user_comments[{$smarty.section.f.index}]" cols="40" >{$upload[f].user_comment}</textarea>
					</div>
				{/if}
			</td>	
			<td style="padding:10px; vertical-align: top;">
				<input type=hidden name="id_files[{$smarty.section.f.index}]" value="{$upload[f].id}">
				<select name="upload_allow[{$smarty.section.f.index}]"   style="width: 100px;float:left;">
					<option value=1{if $upload[f].allow eq 1} selected{/if}>{$header.allow_1}</option>
					<option value=2{if $upload[f].allow eq 2} selected{/if}>{$header.allow_2}</option>
					<option value=3{if $upload[f].allow eq 3} selected{/if}>{$header.allow_3}</option>
				</select>
			</td>
			<td valign="top" style="padding:10px;">
				{if $upload[f].id}
					<div class="block_action fr" style="display: none;">
						<div style="width:10px;" class="fl">&nbsp;</div>
						<div class="action_del" style="display: block;float:left; cursor: pointer;" onclick="javascript:location.href='{$upload[f].del_link}'"><img height="16" alt="" src="{$site_root}{$template_root}/images/photo_delete.png" onmouseout="javascript:hideToolTip();" onmouseover="javascript: showToolTip(event,'{$lang.button.delete}');return false"></div>
						<div style="width:10px;" class="fl">&nbsp;</div>
					</div>
				{/if}
			</td>						
		</tr>
		{/section}
			{if $type_upload eq 3}
				{*<script type="text/javascript" src="{$server}/flowplayer/flowplayer-3.2.8.min.js"></script>
				<script type="text/javascript" src="{$server}/flowplayer/flowplayer.ipad-3.2.8.js"></script>*}
				<script type="text/javascript" src="{$server}/flowplayer5/flowplayer.min.js"></script>
				<link rel="stylesheet" type="text/css" href="{$server}/flowplayer5/skin/minimalist.css" />
				<script>
					{literal}
						//$f(".player", "{/literal}{$server}{literal}/flowplayer/flowplayer-3.2.8.swf").ipad();
						$('.player').flowplayer({
							engine: 'flash', 
							swf: "{/literal}{$server}{literal}/flowplayer5/flowplayer.swf"
						});
					{/literal}
				</script>
			{/if}
		{else}
			<tr style="width:100%;margin:0px;text-align:center;"><td colspan="6" style="text-align: center; padding: 10px">{$lang.badwords.empty}</td></tr>
		{/if}
		<tr style="width:100%;margin:0px;" class="table_header"><td colspan="6">&nbsp;</td></tr>
        </table>
		</div>
	</form>
{if $ajax eq '0'}
</div>
</div>
<div>
	<a class="admin_button_major" onclick="javascript: document.upload_form.submit();" >{$lang.button.save}<span>&nbsp;</span></a>
</div>
<div class="cr">&nbsp;</div>
<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>
{literal}
<script type="text/javascript">
    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_user_upload.php',
				data: 'sel=delete_mas&flag=true&type_upload={/literal}{$type_upload}{literal}&id={/literal}{$data.id}{literal}&' + 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(200);
		$('.delete_status').oneTime(10000, function() {
			$('.delete_status').fadeOut(1000);
		});
    }
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 PutAllIcon() {
         var o=document.getElementsByName('select_all_icon')	
         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 show_icon(){			
			$('#tab_list').css('class', 'user_status_elem_active');
			$('#tab_edit').css('class', 'user_status_elem');
			$('#show_icon').css('display', 'block');
			$('#show_photo').css('display', 'none');
			$('#tab_list').html("<a>"+$('#tab_list').text()+"<\/a>");
			$('#tab_edit').text($('#tab_edit').text());
			$('#tab_list').removeClass('user_status_elem_active');
			$('#tab_list').addClass('user_status_elem');
			$('#tab_edit').removeClass('user_status_elem');
			$('#tab_edit').addClass('user_status_elem_active');
		}
		function show_photo(){
			$('#tab_list').css('class', 'user_status_elem');
			$('#tab_edit').css('class', 'user_status_elem_active');
			$('#show_icon').css('display', 'none');
			$('#show_photo').css('display', 'block');
			$('#tab_edit').html("<a>"+$('#tab_edit').text()+"<\/a>");
			$('#tab_list').text($('#tab_list').text());
			$('#tab_edit').removeClass('user_status_elem_active');
			$('#tab_edit').addClass('user_status_elem');
			$('#tab_list').removeClass('user_status_elem');
			$('#tab_list').addClass('user_status_elem_active');
		}

function change_main_photo(id_file){
	$.ajax({
		type: 'POST',
		url: 'admin_user_upload.php',
		data: 'sel=change_icon&id_file=' + id_file+'&id={/literal}{$data.id}{literal}&',
		success: function(msg){
			if(msg == "ok"){
				
			} else {
				alert("bad");
			}
		}
	});
}		
</script>
{/literal}
<script type="text/javascript">
var tab_last = 'list';
var tab_link = 'admin_user_upload.php?type_upload=1&id={$data.id}&ajax=1';
{literal}
var options = { 
	success: function(data){
		ajaxIndicator(0, 'error_box');
		data = data.replace(/\<\/?(head|body)\>/g,'');
		if (data == 'saved'){
			ShowBlock('show_block', tab_link);
		} else {
			$('.error').html(data).fadeIn(100);
			if ( $.browser.msie) {
    			DD_roundies.addRule('div.error', '10px');
			} else {
    			$('div.error').corner();
			}
			$("body").animate({"scrollTop":0},"slow");
			$('.error').oneTime(15000, function() {
				$('.error').fadeOut(500);
			});
		}
		return false;
	},
	beforeSubmit: function() { 
		ajaxIndicator(1, 'error_box');
	}
};	
{/literal}
</script>
{include file="$admingentemplates/admin_bottom.tpl"}{/if}