<?
	$user = $this->phpsession->get('fuser');
	if(!$user){
		$user = $this->phpsession->get('feltolto');
	}
	
	$user_id = $user['user_id'];
	
	if(hun())
		$lang = "hun";
	else
		$lang = "eng";
?>

<script type="text/javascript">
jQuery(document).ready(function($){
	$('#galeriakepszerk').dialog({
		autoOpen: false,
		modal: true,
		width: 560
	});
	
	$('#ujkepelem').dialog({
		autoOpen: false,
		modal: true,
		width: 560
	});
	
	
	$('.szerkikon').click(function(){
		var con = $('#modositas_form');
		var event = $(this).parents('.kepinfo');
		$('#fajl_id', con).val(event.attr('fajlid'));
		$('#leiras', con).val(event.attr('leiras'));
		$('#tid', con).val(event.attr('tid'));
		
		if(event.attr('pipa') == "1"){
			$('#megosztas', con).attr('checked', 'checked');
		}else{
			$('#megosztas', con).attr('checked', '');
		}
		
		$('#elokep').attr('src', "/public/forum-galeria/<?=$lang?>/<?=$user_id?>/"+event.attr('elokep'));
		
		//open the dialog
		$('#galeriakepszerk').dialog('open');
		$('div.ui-dialog-titlebar').css({'display': 'none'});
		$('div.ui-widget-content').css({'background': 'none'});
		$('div.ui-widget-content').css({'border': 'none'});
		$('div.ui-icon').css({'background': 'none'});
		
		return false;
	});
	
	// új kép
	$('.ujkep').click(function(){
		//open the dialog
		$('#ujkepelem').dialog('open');
		$('div.ui-dialog-titlebar').css({'display': 'none'});
		$('div..ui-widget-content').css({'background': 'none'});
		$('div..ui-widget-content').css({'border': 'none'});
		$('div..ui-icon').css({'background': 'none'});
		return false;
	});
	
	$('.bezargomb').click(function(){
		$('#galeriakepszerk').dialog('close');
		$('#ujkepelem').dialog('close');
		return false;
	});
});
</script>

<style>
	input, textarea{
		border: 0px none;
	}
	
	div.fwel img{
		margin-right: -8px;
		max-width: 150px;
	}
	
	div.ujkep{
		cursor: pointer;
	}
	
	.szerkikon{
		position: relative;
		left: 130px;
		top: -115px; 
		width: 20px;
		cursor: pointer;
	}
	
	.delikon{
		position: relative;
		left: 95px;
		top: -115px; 
		width: 20px;
		cursor: pointer;
	}

	
</style>



<div class="fweltop"></div>
<div class="fwel">
	<h2 class="forumh2" style="color: #fff;"><?=lang('forum_galeria')?></h2>
	<div class="gombst ujkep" style="background: url('/public/img/forum/stilus/buttons_big_upload-green.png'); width: 189px; float: right;"><?=lang('forum_ujfajl')?></div>
	<div class="clear"></div>
	
	<table>
	<?if($fajlok):?>
		<?$i=0;?>
		<?foreach($fajlok as $fajl):?>
			<?if($i%5 == 0):?>
			<tr>
			<?endif;?>
			
			<td valign="bottom" style="padding-right: 10px; height: 140px;">
			<a href="/public/forum-galeria/<?=$lang?>/<?=$user['user_id']?>/<?=$fajl->fajl?>" class="fancy" rel="group">
				<?if( file_exists('public/forum-galeria/'.$lang.'/'.$user['user_id'].'/elo_'.$fajl->fajl) ):?>
				<img src="/public/forum-galeria/<?=$lang?>/<?=$user['user_id']?>/elo_<?=$fajl->fajl?>" />
				<?else:?>
				<img src="/public/forum-galeria/<?=$lang?>/<?=$user['user_id']?>/<?=$fajl->fajl?>" />
				<?endif;?>
				<br />
			</a>
			<span class="kepinfo" fajlid="<?=$fajl->fajl_id?>" leiras="<?=$fajl->info?>" pipa="<?=$fajl->megosztas?>" elokep="<?=$fajl->fajl?>">
			<span class="szerkikon" style="">
				<img src="/public/img/forum/stilus/button_onpicture_edit.png" />
			</span></span>
			<span class="delikon" onclick="javascript:delQue('forum/delfajl/<?=$fajl->fajl_id?>','<?=lang('forum_torlesmegerosites')?>')">
				<img src="/public/img/forum/stilus/button_onpicture_delete.png" />
			</span>
			</td>
			
			<?if($i%5 == 4):?>
			</tr>
			<?endif;?>
			
			<?$i++;?>
		<?endforeach;?>
		<?
			$iii = $i-1;
			while($iii%5 != 4) { print "<td>&nbsp;</td>\n\t"; $iii++; }
		?>
		<?if(($i-1)%5 != 4):?>
			</tr>
		<?endif;?>
	<?endif;?>
	</table>
</div>
<div class="fwelbottom"></div>


<div class="medium_top"></div>
<div class="medium">
	<h2 class="forumh2" style="color: #fff; margin-bottom: 3px;"><?=lang('forum_galmegoszt')?></h2>
	<div style="margin-bottom: 5px; padding: 5px;">
		<?=lang('forum_galmegosztleiras')?>
	</div>
	<input type="text" value="http://<?=$_SERVER['SERVER_NAME']?>/forum/galeria/<?=$user_id?>" style="width: 410px;" readonly="true" />
</div>
<div class="medium_bottom"></div>



<div id="galeriakepszerk" style="display: none;">
	<div class="forumpopuptop"></div>
	<div class="forumpopup" style="min-height: 160px;">
	<h2><?=lang('forum_fajlszerk')?></h2>
	
	
	<img src="" id="elokep" style="max-height:150px; max-width:150px; float: left;" />
	
	<form action="/forum/editgaleria" method="post" id="modositas_form">
	<input type="hidden" name="fajl_id" id="fajl_id" value="" />
	
	<div style="margin-left: 155px;">
	<div style="float: left; margin: 0px 5px 0px 5px;">
		<strong><?=lang('forum_info')?>:</strong>
	</div>
	<textarea name="leiras" id="leiras" cols="25" rows="2" style="padding: 3px; width: 230px;"></textarea><br />
	
	<input type="checkbox" name="megosztas" id="megosztas" />
	<strong><?=lang('forum_megoszt')?></strong>
	</div>
	
	<div style="text-align: right; margin-top: 20px;">
		<input type="submit" name="do" value="<?=lang('forum_ment')?>" class="ngomb" style="width: 120px; background: url('/public/img/forum/stilus/button_normal.png');" />
		<button class="bezargomb megsem" style="width: 120px; background: url('/public/img/forum/stilus/button_grey.png');">
			<?=lang('forum_megsem')?>
		</button>
	</div>
	</form>
	
	</div>
	<div class="forumpopupbottom"></div>
	
</div>

<div id="ujkepelem" class="gombst" style="display: none;">
	<div class="forumpopuptop"></div>
	<div class="forumpopup">
	<div style="float: right; width: 200px; text-align: right; font-weight: normal;">
		<?=lang('forum_szabadhely')?>: <?if( $szabad_hely < 1024*1024 ):?><?=ceil($szabad_hely/1024)?> KB
		<?else:?><?=round($szabad_hely/(1024*1024),1)?> MB
		<?endif;?>
	</div>
	<h1 style="margin-top: 0px"><strong><?=lang('forum_ujfajl')?></strong></h1>
	<form action="/forum/feltolt" method="post" enctype="multipart/form-data">
		<input type="hidden" name="MAX_FILE_SIZE" value="10485760" />
		<table>
			<tr>
				<td><?=lang('forum_fajl')?>:</td>
				<td><input type="file" name="fajl"></td>
			</tr>
			<tr>
				<td valign="top"><?=lang('forum_info')?>:</td>
				<td><textarea name="leiras" rows="3" cols="30" style="padding: 2px; width: 230px;"></textarea></td>
			</tr>
			<tr>
				<td valign="middle"><input type="checkbox" name="megosztas" checked="true"><?=lang('forum_megoszt')?></td>
				<td>&nbsp;</td>
			</tr>
		</table>
		<div style="text-align: right;">
		<input type="submit" value="<?=lang('forum_feltolt')?>" class="ngomb" style="width: 120px; background: url('/public/img/forum/stilus/button_normal.png');" />
		<button class="bezargomb megsem" class="megsem" style="width: 120px; background: url('/public/img/forum/stilus/button_grey.png');">
			<?=lang('forum_megsem')?>
		</button>
		</div>
	</form>
	</div>
	<div class="forumpopupbottom"></div>
</div>


<script type="text/javascript">
	function delQue(uri, strQue){
		if(confirm(strQue))
			window.location.href="/" + uri;
	}
</script>