<?php
/**
* @file $id: index.php (17-12-2009)
* @pack Integral-Education
* @copyright Copyright (C) 2009 Integral-Group. All rights reserved.
* This package can be modified by the licencee, but the license is non-transferrable.
*/
	 if(!isset($_REQUEST['CREATEPDF']))
	 {
		if(Preferences('CALENDAR')=='Mon')
		{
		    $firstDay = '1';
		}else{
		    $firstDay = '0';
		}
		if($_REQUEST['choose_room']!='true'  && !isset($_REQUEST['rTypec']) && !$_REQUEST['student_id'] && !$_REQUEST['user_id'])
		{
			echo '
			<script language=javascript>
			function dateChanged(calendar) {
			// Beware that this function is called even if the end-user only
			// changed the month/year.  In order to determine if a date was
			// clicked you can use the dateClicked property of the calendar:
			if (calendar.dateClicked) {
			  // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
			  var y = calendar.date.getFullYear().toString();
			  var m = (calendar.date.getMonth()+1).toString();     // integer, 0..11
			  if(m.length==1)
				m = "0"+m;
			  var d = calendar.date.getDate().toString();      // integer, 1..31
			  if(d.length==1)
				d = "0"+d;
			  // redirect...
				window.location = "modloader.php?servicemod='.$_REQUEST['servicemod'].'&resource_id='.$_REQUEST['resource_id'].'&choose_room='.$_REQUEST['choose_room'].'&useontop='.$_REQUEST['useontop'].'&date=" + y + "-" + m + "-" + d;
			}
			};

			currentDate = new Date('.(substr($_REQUEST['date'],0,4)).','.((substr($_REQUEST['date'],5,7)*1)-1).','.(substr($_REQUEST['date'],8,10)*1).');
			Calendar.setup(
			{
			  firstDay     : '.$firstDay.',	//numeric: 0 to 6.  "0" means display Sunday first, "1" means display Monday first, etc.
			  flat         : "calendar-container", // ID of the parent element
			  flatCallback : dateChanged,           // our callback function
			  date	       : currentDate,
			  weekNumbers  : false
			}
			);

			</script>';
		}
	}
?>