<?@header("Content-Type: text/html; charset=UTF-8");?><html>
<head>
	<link href="/public/css/naptar.css" rel="stylesheet" type="text/css" />
	
	<script type="text/javascript" src="/public/js/naptar.js"></script>
	
</head>
<body>

<style>
		font-size: 11px;
	</style>

<?php
define("oneday", (60*60*24));
$most123 = getdate();
$mosanihonap = $most123['mon'];


$uri = explode("/", str_ireplace( "", "", $_SERVER[ 'REQUEST_URI'] ) );
//print_r($uri);
if( is_numeric($uri[3]) && is_numeric(4) && is_numeric(5) ){
	$honap = $uri[3];
	$ev = $uri[4];
	$ma = $uri[5];
}
else{
	$most = getdate();
	$honap = $most['mon'];
	$ev = $most['year'];
	$ma = $most['mday'];
}

$kezdet = mktime (12, 0, 0, $honap, 1, $ev);
$elsoNap = getdate($kezdet);

if(hun()){
	$napok = array("H", "K", "Sz", "Cs", "P", "Sz", "V");
	$honapok=array("", "január","február","március","április","május","június","július","augusztus","szeptember","október","november","december");
}
else{
	$napok = array("S","M", "T", "W", "T", "F", "S");
	$honapok=array("", "january","february","march","april","may","june","july","august","september","october","november","december");
}
$szhonap=$honapok[$honap];

$vanesemeny=array();
$esemenycim = array();
$esemenyidk = array();
foreach($esemenyek as $k => $esemeny){
	if($esemeny['nap'] < 10){
		$index = substr($esemeny['nap'],1,1);
	}else{
		$index = $esemeny['nap'];
	}
	
	$vanesemeny[$index] = $esemeny['nap'];
	$esemenycim[$index] = $esemeny['nev'];
	$esemenyidk[$index] = $esemeny['foid'];
}


$elozoev=$ev;
$elozoho=$honap-1;

if ($elozoho==0){
   $elozoho=12;
   $elozoev--;
}

$kovev=$ev;
$kovho=$honap+1;
if ($kovho==13){
	$kovho=1;
	$kovev++;
}
 ?>
 
<TABLE CLASS=naptar BORDER = 0 CELLPADDING=1 CELLSPACING=1 width="250">
	<tr>
		<td>
			<div align='center'>
			<font size="1"><a href='/temp_course/naptargen/<?=$elozoho?>/<?=$elozoev?>/<?=$ma?>'><<</a>
			&nbsp;<?=$ev?>&nbsp;<?=$szhonap?>&nbsp;
			<a href='/temp_course/naptargen/<?=$kovho?>/<?=$kovev?>/<?=$ma?>'>>></a></font>
			</div>
		</td>
	</tr>
</table><TABLE CLASS=naptar BORDER = 0 CELLPADDING=1 CELLSPACING=1 width="250">
<?

if($honap != $mosanihonap)
	$ma = 0;

//napok kiírása
foreach ($napok as $nap) {
	?>
	<td bgcolor=#CCCCCC align=center><font size="1"><?=$nap?></font></td>
	<?
}
?>
	</tr><tr>
<?
$x="1";



if(hun()){
	$pirosmaradek = 6;
}
elseif(eng()){
	$pirosmaradek = 0;
	$elsoNap['wday'] += 1;
}



for ($szamlalo=0; $szamlalo < (6*7); $szamlalo++) {
	$napTomb = getdate($kezdet);
	
	
	if (($szamlalo % 7) == 0) {
		if ($napTomb['mon'] != $honap) {
			break;
		} else {
		?>
			</tr><tr>
		<?
		}
	}
	// hónap vége
	
	if (in_array($napTomb['mday'],$vanesemeny)){
		$ki1='<a title="'.$esemenycim[$napTomb['mday']].'">';
		$ki2='</a>';
		$ki3 = "<div style=\"position: absolute; background: #AAAAAA; padding: 5px; display: none; -moz-border-radius: 0px 15px 15px 15px; font-size: 11px;";
		
		if (($szamlalo % 7) == 6 || ($szamlalo % 7) == 5 || ($szamlalo % 7) == 4 )
			$ki3 .= " left: 150px; ";
		
		
		$ki3 .= "\" id=\"azon".$napTomb['mday']."\" onmousedown=\"elrejt('azon".$napTomb['mday']."')\">"
		.$esemenycim[$napTomb['mday']].
		"</div>";
	}
	else{
		$ki1="";
		$ki2="";
		$ki3="";
	};
	if ( $szamlalo < (($elsoNap['wday'] +6) % 7) || $napTomb['mon'] != $honap) {
	?>
		<td class="nincsnap"><font size="1">&nbsp;</font></td>
	<?
	} else {
		// napokat listázza
		if ($ma == $napTomb['mday']){
		?>
			<td class="mainap" align=center><b><font size="1"><?=$ki1.$napTomb['mday'].$ki2?></font></b></td>
		<?
		}
		elseif( $ki3 != "" ){
		?>
			<td class="esemeny" align=center title="<?=$esemenycim[$napTomb['mday']]?>" onclick="szovegmutat('azon<?=$napTomb['mday']?>')">
				<b><font size="1"><?=$napTomb['mday']?></font></b>
				<?=$ki3?>
			</td>
		<?
		}
		else {?>
			<td class="vannap" align=center>
			<font size="1" <?=(($szamlalo % 7== $pirosmaradek )?" color=\"red\">":">").$ki1.$napTomb['mday'].$ki2?></font>
			</td>
		<?
		}
		$kezdet += oneday;
		
	}$x++;
}
?>
</tr></table>
</body>
</html>