  <div id="register_form01">
	<div id="menu01_head">:: môj mobil</div>
	<div id="melodia_div">
	<script language="JavaScript" type="text/javascript">
		function Compare()
		{
			document.forms.form2.submit();
		}
	</script>
<?php 

	$items = array
		(
			'rozmery' => 'Rozmery',
			'hmotnost' => 'Hmotnosť',
			'pasma' => 'Pásma (MHz)',
			'pohotovost' => 'Pohotovostný režim',
			'hovor' => 'Čas hovoru',
			'rozlisenie' => 'Rozlíšenie',
			'farby' => 'Počet farieb displeja',
			'user_mem' => 'Užívateľská pamäť',
			'karty' => 'Pamäťové karty',
			'kontaktov' => 'Pamäť na kontakty',
			'sms' => 'Max počet uložených SMS',
			'foto' => 'Fotoaparát',
			'mp3' => 'Mp3 prehrávač',
			'radio' => 'Rádio',
			'java' => 'Java',
			'ir' => 'Infračervený port',
			'btooth' => 'Bluetooth',
			'wap' => 'Wap',
			'gprs' => 'GPRS',
			'edge' => 'EDGE',
			'3G' => '3G',
			'wifi' => 'WiFi',
			'gps' => 'GPS',
			'tv' => 'TV Výstup',
			'email' => 'E-mail klient',
		);

	function fnShowDetails($id)
	{
		global $dba, $items;
		
		
		
		$row = $dba->GetRow('mobile_mobil', $id, '*');
		if(is_array($row) && sizeof($row) > 0)
		{
			echo "
			<table border='0' cellspacing='10'>\n
				<tr>
					<td width='30%'>
						<span class='red'><b>".$row['nazov']."</b></span>
					</td>
					<td width='36%'>
						<span class='red'><b>Informácie</b></span>
					</td>
					<td width='33%'>
						<span class='red'><b>Čo hľadať u nás?</b></span>
					</td>
				</tr>
				<tr>\n
				<td valign='top'><img src='images/moj_mobil_new/".$row['main_image']."' alt=''></td>\n
					<td>";
			foreach ($items as $field => $name)
			{
				echo "<b>".$name."</b>: ".$row[$field]."<br/>";
			}		
			echo"	</td>
					<td valign='top'>
					<b>Pozadia</b>: ".$row['pozadia']."<br />\n
					<b>Melódie</b>: ".$row['melodie']."<br />\n
					<b>Videá</b>: ".$row['videa']."<br />\n
					<b>Témy</b>: ".$row['temy']."<br />\n
					<b>Hry</b>: ".$row['hry']."<br />\n
					<b>Aplikácie</b>: ".$row['aplikacie']."<br />\n
					</td>\n
				</tr>\n
			</table>\n";
		}
	}

	$actions = array('show', 'compare');

	$moj_mobil_id = $dba->GetOne('mobile_users', $_SESSION['my_id'], 'moj_mobil');
	
	$action = (key_exists('action', $_GET) && $_GET['action']!='' && in_array($_GET['action'], $actions) && session_is_registered('mobile_logged_in')) ? $_GET['action'] : '';
	
	echo "
		<form name='form1' action='index.php?module=moj_mobil&amp;module_top=moj_mobil_change&amp;action=change' method='POST'>\n
			Môj mobil: <select name='mobil' id='form_field02'>\n";
	
	if($moj_mobil_id==0) echo "<option value=''>Vyberte si Váš mobil</option>\n";
	
	$query = "SELECT ID, nazov FROM mobile_mobil ORDER by nazov ASC";
	$result = $dba->GetResult($query);
	$data = array();
	while($row=mysql_fetch_array($result))
	{
		array_push($data, $row);
		echo "<option value='".$row['ID']."'";
		if($moj_mobil_id==$row['ID']) echo " selected=\"selected\"";
		echo ">".$row['nazov']."</option>\n";
	}
	
	echo"	</select>&nbsp;<input type='submit' name='Submit' value='OK' id='form_button01'>
		</form>";
	
	if($moj_mobil_id!=0)
	{
		fnShowDetails($moj_mobil_id);
	}
	echo "</div>";
	echo "<div id=\"melodia_div\">";
	echo "<table width='100%' border='0' cellspacing='0' cellpadding='2'>";
	echo "
		<form name='form2' action='index.php?module=moj_mobil&amp;action=compare' method='POST'>\n
		<input type='hidden' name='action' value='compare' />
			<tr><td>Porovnaj telefóny: </td>";
	if(is_array($data))
	{
		for($i=1;$i<=3;$i++)
		{
			echo "<td width='25%' align='center'>";
			echo "<select name='compare_phones[$i]' id='form_field02' onChange='Compare();'>";
			echo "<option value=''>Vyberte telefón</option>";
			foreach ($data as $phone)
			{
				echo "<option value='".$phone['ID']."'";
				if(isset($_POST['compare_phones'][$i]) && $_POST['compare_phones'][$i] == $phone['ID'])
				{
					echo " selected";
				}
				echo ">".$phone['nazov']."</option>\n";
			}
			echo "</select> ";
			echo "</td>";
		}
	}
	echo "</tr>";
	echo "	</form>";
	
	if($action == 'compare')
	{
		$compare_items = array
		(
//			'pozadia' => 'Pozadia',
//			'melodie' => 'Melódie',
//			'videa' => 'Videá',
//			'temy' => 'Témy',
//			'hry' => 'Hry',
//			'aplikacie' => 'Aplikácie',
			'rozmery' => 'Rozmery',
			'hmotnost' => 'Hmotnosť',
			'farby' => 'Počet farieb displeja',
			'rozlisenie' => 'Rozlíšenie',
			'ir' => 'Infračervený port',
			'btooth' => 'Bluetooth',
			'user_mem' => 'Užívateľská pamäť',
			'kontaktov' => 'Pamäť na kontakty',
			'sms' => 'Max počet uložených SMS',
			'karty' => 'Pamäťové karty',
			'zvuky' => 'Zvonenia',
			'budik' => 'Budík',
			'organizer' => 'Organizér',
			'kalkulacka' => 'Kalkulačka',
			'java' => 'Java',
			'mp3' => 'Mp3 prehrávač',
			'radio' => 'Rádio',
			'foto' => 'Fotoaparát',
			'wap' => 'Wap',
			'gprs' => 'GPRS',
			'edge' => 'EDGE',
			'3G' => '3G',
			'wifi' => 'WiFi',
		);
		$compare_items = $items;
		$phones = array();
		for($i=1; $i<=3; $i++)
		{
			$phones[$i] = (isset($_POST['compare_phones'][$i])) ? $dba->GetRow('mobile_mobil', $_POST['compare_phones'][$i], '*') : false;
		}
		
		echo "<tr>";
		echo "<td></td>"; //prazdne miesto nad atributmi
		$new_height = 150; 
		for($i=1; $i<=3; $i++)
		{
			echo "<td align='center' style='padding: 5px;'>";
			if(isset($phones[$i]['main_image']))
			{
				list($width, $height, $type, $attr) = getimagesize("images/moj_mobil_new/".$phones[$i]['main_image']);
//				$pomer = $height / $width;
				$new_width = round($width * $new_height / $height);
				echo "<img src='images/moj_mobil_new/".$phones[$i]['main_image']."' width='$new_width' height='$new_height' alt=''/>";
			}
			echo "</td>";
		}
		echo "</tr>";
		if(isset($_POST['action']))
		{
			$stripe = true;
			foreach ($compare_items as $item => $item_name)
			{
				$bg_color = ($stripe) ? ' bgcolor="#333333"' : '';
				$stripe = !$stripe;
				echo "<tr $bg_color>";
				echo "<td  width='25%'><b>$item_name</b></td>";
				for($i=1; $i<=3; $i++)
				{
					echo "<td align='center'>";
					if(isset($phones[$i][$item]))
					{
						echo $phones[$i][$item];
					}
					echo "</td>";
				}
				echo "</tr>";
			}
		}
	}
	echo "</table>";
	
?>
    </div>
	</div>