<?php
	if(session_is_registered('mobile_logged_in'))
	{
		if(!isset($_SESSION['moj_mobil']))
		{
			$moj_mobil = $dba->GetOne('mobile_users', $_SESSION['my_id'], 'moj_mobil');
			$_SESSION['moj_mobil'] = $moj_mobil;
		}
		else 
		{
			$moj_mobil = $_SESSION['moj_mobil'];
		}
		
		if($moj_mobil!=0)
		{
			if(!isset($_SESSION['roz']))
			{
				$roz = $dba->GetOne('mobile_mobil', $moj_mobil, 'menu_res');
				$_SESSION['roz'] = $roz;
			}
			else 
			{
				$roz = $_SESSION['roz'];
			}
			if($roz==0) $roz = 1;
		}
		else 
		{
			$roz = 1;
		}
	}
	else $roz = 1;
	
?>
<script language="JavaScript" type="text/javascript">
	function AccessConfirm(link)
	{
		if (confirm('Táto kategória obsahuje pozadia s erotickou tématikou. Vstup len od 18 rokov!!! V prípade, že ešte nemáte 18 rokov, kliknite na tlačidlo Zrušiť.')) window.location = link;
	}
</script>
	
  <div id="menu03">
    <div id="menu01_head">:: kategórie</div>
    <div id="menu01_item">
    <?php
    	
    	foreach($categories as $k => $v)
    	{
    		if($k == $cat && $action=='')
    		{
    			echo "<img src='images/arrow-left.png' class='sipka' alt='4mobile' /> <span class='red'>$v</span><br />";
    		}
    		else 
    		{
	    		if($v=='erotika') echo "<img src='images/arrow-left.png' class='sipka' alt='4mobile' /> <a href=\"javascript:AccessConfirm('index.php?module=pozadia&amp;cat=$k&amp;i=1&amp;res=$roz');\" id=\"menu01_link\">$v</a><br />\n";
	    		else echo "<img src='images/arrow-left.png' class='sipka' alt='4mobile' /> <a href=\"index.php?module=pozadia&amp;cat=$k&amp;i=1&amp;res=$roz\" id=\"menu01_link\">$v</a><br />\n";
    		}
    	}
    	if(session_is_registered('my_id') && in_array($_SESSION['my_id'], $admins))
    	{
    		echo '<br />';
    		if(!session_is_registered('pozadia_edit'))
    		{
    			echo "- <a href=\"index.php?module_top=pozadia_sort&amp;action=on\" id=\"menu01_link\">zapni triedenie</a> ";
    		}
    		else 
    		{
    			echo "- <a href=\"index.php?module_top=pozadia_sort&amp;action=off\" id=\"menu01_link\">vypni triedenie</a> ";
    		}
    	}
    ?>

    </div>
  </div>
  
<?php
  	
//if(session_is_registered('mobile_logged_in'))
{
	(key_exists('cat', $_GET) && $_GET['cat']<>'') ? $cat = $_GET["cat"] : $cat = 1;
	(key_exists('res', $_GET) && $_GET['res']<>'') ? $res = $_GET["res"] : $res = '';
	(key_exists('action', $_GET) && $_GET['action']<>'') ? $action = $_GET["action"] : $action = '';

	if(!isset($_SESSION['menu_res_array']))
	{
		$query = ($action == 'new') ? 'SELECT distinct(res) FROM mobile_pozadia' : "SELECT distinct(res) FROM mobile_pozadia WHERE cat='$cat'";
		$t_dist = $dba->GetArray($query);
		$menu_res = array();
		if(is_array($t_dist))
		{
			foreach($t_dist as $d)
			{
				$menu_res[] = $d['res'];
			}
		}
		$_SESSION['menu_res_array'] = $menu_res;
	}
	else 
	{
		$menu_res = $_SESSION['menu_res_array'];
	}
	
//	$query = "SELECT res FROM mobile_pozadia WHERE cat=$cat";
//	$result = $dba->GetResult($query);
//	
	$menu_rozlisenia = $rozlisenia;
//	
//	$menu_res = array();
//	
//	while($row = mysql_fetch_array($result))
//	{
//		if(!in_array($row['res'], $menu_res))
//		{
//			$menu_res[] = $row['res'];
//		}
//	}
	
	if($action=='new' || $action=='')
	{
?>
  
  <div id="menu03">
    <div id="menu01_head">:: rozlíšenia</div>
    <div id="menu01_item">
    <?php
    	foreach($menu_rozlisenia as $xr)
    	{
    		if(in_array($xr['res'], $menu_res) || $action == 'new')
    		{
    			echo "<img src='images/arrow-left.png' class='sipka' alt='4mobile' /> <a href=\"index.php?module=pozadia&amp;cat=$cat&amp;res=".$xr['res']."&amp;action=$action\" id=\"menu01_link\">";
    			if($res==$xr['res'] && $res<>'') echo "<span id=\"red\">";
    			echo $xr['menu'];
    			if($res==$xr['res'] && $res<>'') echo "</span>";
    			echo "</a><br />\n";
    		}
    	}
    	echo "<img src='images/arrow-left.png' class='sipka' alt='4mobile' /> <a href=\"index.php?module=pozadia&amp;cat=".$cat."&amp;res=&amp;action=$action\" id=\"menu01_link\">všetky</a> ";
    ?>
    </div>
  </div>
  <?php
	}
	
//	dump($menu_rozlisenia);
//	dump($menu_res);
  ?>
  
    <div id="menu03">
    <div id="menu01_head">:: rebríčky</div>
    <div id="menu01_item">
    	<img src='images/arrow-left.png' class='sipka' alt='4mobile' /> <a href="index.php?module=pozadia&amp;action=new&amp;res=<?php echo $roz; ?>" id="menu01_link">NEW <?php echo $pozadia_charts; ?></a><br />
    	<img src='images/arrow-left.png' class='sipka' alt='4mobile' /> <a href="index.php?module=pozadia&amp;action=top" id="menu01_link">TOP <?php echo $pozadia_charts; ?></a><br />
    	<img src='images/arrow-left.png' class='sipka' alt='4mobile' /> <a href="index.php?module=pozadia&amp;action=dload" id="menu01_link">TOP DLOAD<?php echo $pozadia_charts; ?></a>
    </div>
  </div>
  
  
<?php
}
?>

<div id="menu03">
    <div id="menu01_head">:: reklama</div>
    <div id="news_item">
    <script type="text/javascript"><!--
		google_ad_client = "pub-4917301309934013";
		//120x600, bola vytvorená 14.1.2008
		google_ad_slot = "2443565869";
		google_ad_width = 120;
		google_ad_height = 600;
		//--></script>
		<script type="text/javascript"
		src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
		</script>
    </div>
  </div>