<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
 // load viewer library
  $libraryPath = 'builder/lib/viewer_functions.php';
  $dirsToCheck = array('/home/rcl618/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load records
  list($categoryRecords, $selectedCategory) = getCategories(array(
    'tableName'   => 'category',
    'selectedCategoryNum' => '',
    'categoryFormat' => 'showall',
  ));
  
   // load records
  list($website_titleRecords, $website_titleMetaData) = getRecords(array(
    'tableName'   => 'website_title',
    'where'       => whereRecordNumberInUrl(1),
    'loadUploads' => '0',
    'limit'       => '1',
  ));
  $website_titleRecord = @$website_titleRecords[0]; // get first record

?>
<?PHP  
  function maxWords($textOrHtml, $maxWords) { 
    $text=str_replace("<p>","*P*",$textOrHtml); 
    $text= str_replace("</p>","*/P*",$text); 
    $text = strip_tags($text);   
    $words = preg_split("/\s+/", $text, $maxWords+1);   
    if (count($words) > $maxWords) { unset($words[$maxWords]); }   
    $output = join(' ', $words);   
    $output=str_replace("*P*","<p>",$output); 
    $output=str_replace("*/P*","</p>",$output); 
    $output.="</p>"; 
 
    return $output;   
  }   
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="X-UA-Compatible" content="chrome=1" />
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<meta name="robots" content="all" />
		<!-- User defined head content such as meta tags and encoding options -->
	<title>RCL 618</title>
	<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/styles.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/colourtag-page0.css" />
	<link rel="stylesheet" type="text/css" media="print" href="rw_common/themes/flexture/print.css" />
	<script type="text/javascript" src="rw_common/themes/flexture/scripts/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="rw_common/themes/flexture/scripts/jquery.nimblehost-scripts.js"></script>
	<script type="text/javascript" charset="utf-8">var rwPathto = "rw_common/themes/flexture/scripts/jspathto.js";</script>
	<script type="text/javascript" src="rw_common/themes/flexture/scripts/jspathto.js"></script>
	<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/font/georgia.css" />
		<script type="text/javascript" src="rw_common/themes/flexture/scripts/nimblehostPulseVIP.js"></script>
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/titleSlogan/georgia.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/titleSlogan/titleSmall.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/menu/nimblehostDropDownMenu.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/menu/smallCapsMenu.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/menu/georgia.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/menu/small.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/headerImage/image2.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/sidebar/20percent.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/ExtraContent/displayEC4.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/ExtraContent/displayEC6.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/ExtraContent/custom6.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/iPhone.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/iPhoneHideHeader.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/css/iPhoneOptimizeStacks.css" />
		<script type="text/javascript" src="rw_common/themes/flexture/scripts/jquery.customFancyZoom.js"></script>
		<script type="text/javascript" src="rw_common/themes/flexture/scripts/nimblehostDropDownMenu.js"></script>
		<!-- Style variations - these are set up in the theme.plist -->
		
		<style type="text/css">
			/* This styles the pop up tips */
			
			a.tip {
				position: relative;
				font-size: 14px; /* The TITLE font size */
			}
			
			a.tip span {
				display: none;
				position: absolute;
				top: 35px; /* The how far below the rollover text the tip appears - in px */
				left: -75px; /* The how far to the left of the rollover text the tip appears - in px */
				width: 250px; /* The width of the box holding the tip - in px */
				padding: 5px; /* Themuch padding there is around the text - in px */
				z-index: 100;
				background: #000000; /* The tip background color */
				color: #ffffff; /* The tip text color */
				-moz-border-radius: 5px; /* dimension of the rounded corners - this works only in camino/firefox */
				-webkit-border-radius: 5px; /* dimension of the rounded corners - this is just for Safari */
			}
			
			a:hover.tip { text-decoration: none;
				font-size: 99%; /* this is just for IE */
			}
			
			a:hover.tip span {
				display: block;
			}
			
			.heading-text {font-family:Arial; font-size: 1.3em; }
			
		</style>
	<!-- User defined styles -->
	<link href="css/calendar5.css" rel="stylesheet" type="text/css" media="all">
	<script type="text/javascript" src="rw_common/themes/flexture/javascript.js"></script>
	<script type="text/javascript">
	/* <![CDATA[ */
		$flexture(document).ready(function(){
			if(((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i))||(navigator.userAgent.match(/Android/))||(navigator.userAgent.match(/webOS/))) && ($flexture('#mobileMenuTab').is(':visible'))){
				mobileMenu();
				mobileImageResize();
			} else {
				menuFunctions();
				iPhoneDesktopAdjustments();
			}
			if( navigator.userAgent.match(/iPad/i) ) {
				iPadAdjustments();
			}
			extraContent();
			standardRwPageEnhancements();
		});
	/* ]]> */
	</script>
	<!-- This site created with the Flexture theme from NimbleHost. http://www.nimblehost.com -->
	<!--[if lte IE 7]><link rel="stylesheet" type="text/css" media="screen" href="rw_common/themes/flexture/ie7.css" /><![endif]-->
	<!-- User defined javascript -->
	
	
</head>
<body>
<div id="container"><!-- Start container -->
	<div id="ec1Wrapper">
		<div id="extraContainer1">
		</div>
	</div>
	<div class="clearer"></div>
	<div id="pageTopShadow"></div>
	<div class="clearer"></div>
	<div id="pageTopContent">
		<div id="logo"><a href="http://www.rcl618.ca/"></a></div>
		<div id="titleSlogan">
			<div class="title"><span><h1><center><?php echo $website_titleRecord['title'] ?></center></span></h1></div>
			<div class="slogan"><h2></h2></div>
		</div>
		<div id="mobileMenuTab"></div>
	</div>
	<div class="clearer"></div>
	<div id="mainContentWrapper">
		<div id="mainContent">
			<div id="menu">
				<?php include 'includes/menuList.php'; ?>
			</div>
			<div class="clearer"></div>
			<div id="extraContainer2"></div>
			<div class="clearer"></div>
			<div class="headerImage">
				<!-- Insert BannerZest code below (or whatever slideshow code you are using. Do no use ExtraContent Area 3 when placing code here. -->
				
				<div id="extraContainer3"></div>			
			</div>
			<div class="clearer"></div>
			<div id="lowerMenuPlaceholder"></div>
			<div class="clearer"></div>
			<div id="extraContainer4">
				
			</div>
			<div class="clearer"></div>
			<div id="contentContainer"><!-- Start main content wrapper -->
				<div id="content"><!-- Start content -->
				
				<!-- calendar --> 
<?php
  
  // <zickey> - get selected month
  $monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); 
  if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n"); 
  if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y"); 
   
  $cMonth = $_REQUEST["month"]; 
  $cYear = $_REQUEST["year"]; 
   
  $prev_year = $cYear; 
  $next_year = $cYear; 
   
  $prev_month = $cMonth-1; 
  $next_month = $cMonth+1; 
   
  if ($prev_month == 0 ) { 
  $prev_month = 12; 
  $prev_year = $cYear - 1; 
  } 
  if ($next_month == 13 ) { 
  $next_month = 1; 
  $next_year = $cYear + 1; 
  }
  // </zickey>
  
  // find all events which overlap with this month
  $this_month_date = sprintf("%04d-%02d-01 00:00:00", $cYear, $cMonth);
  $next_month_date = sprintf("%04d-%02d-01 00:00:00", $next_year, $next_month);
  list($eventsRecords, ) = getRecords(array(
    'tableName' => 'events',
    'where'     => mysql_escapef("start_date < ? AND IF(end_date != '0000-00-00', end_date >= ?, start_date >= ?)", $next_month_date, $this_month_date, $this_month_date),
  ));

  // go through events and build up a mapping of dates to events, respecting repeated events
  $eventsByDay = array();
  $this_month_time = strtotime($this_month_date);
  $next_month_time = strtotime($next_month_date) - 1;
  foreach ($eventsRecords as $record) { 
    if (strtotime($record['end_date'])) { 
      $last_day     = null; 
      $current_time = max($this_month_time, strtotime($record['start_date'])); 
      $end_time     = min($next_month_time, strtotime($record['end_date'])); 
      while ($current_time < $end_time || date("Y-m-d", $current_time) == date("Y-m-d", $end_time)) { 
        $skip = false; 
         
        $current_day = date("Y-m-d", $current_time); 
        // skip if we've already seen this day (necessary because we're skipping forward by 23 hours) 
        if ($current_day == $last_day) { $skip = true; } 
         
        // skip if relevant weekday checkbox isn't checked 
        $current_weekday = strtolower(date('l', $current_time)); 
        if (!$record[$current_weekday]) { $skip = true; } 
         
        // add event to this day
        if (!$skip) {
          $day = intval(date('d', $current_time)); 
          if (!array_key_exists($day, $eventsByDay)) { $eventsByDay[$day] = array(); } 
          $eventsByDay[$day][] = $record; 
        } 
         
        // advance current_time (but not by 24 hours, lest we skip over a springtime daylight-savings day) 
        $current_time += 23*60*60; 
        $last_day = $current_day; 
      } 
    } 
    else { 
      // no end_date, so this is a single-day event 
      $day = intval(date('d', strtotime($record['start_date']))); 
      if (!array_key_exists($day, $eventsByDay)) { $eventsByDay[$day] = array(); } 
      $eventsByDay[$day][] = $record; 
    } 
  }
?> 
<div id="calendar_div" name="calendar_div"><div align="center" class="heading-text">MOUSE OVER AN EVENT TITLE TO LEARN MORE<br /><br />
</div>
<table align="center" border="0" height="550" cellpadding="1" cellspacing="0" bgcolor="#0202D1"> 
  <tr align="center"> 
<td bgcolor="#0202D1"><table width="900"  border="0" cellspacing="0" cellpadding="0"> 
<tr> 
<td width="50%" align="left">&nbsp;&nbsp;<a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" class="CalNextPrevious">Previous</a></td> 
<td width="50%" align="right"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" class="CalNextPrevious">Next</a>&nbsp;&nbsp;</td> 
</tr> 
</table></td> 
</tr> 
<tr> 
<td align="center"><table width="100%" height="500" border="0" cellpadding="0" cellspacing="0" bgcolor="#087BA1"> 
<tr align="center"> 
<td colspan="7" class="CalMonth" ><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></td> 
</tr> 
<tr> 
<td class="CalDayofWeek">Sunday</td> 
<td class="CalDayofWeek">Monday</td> 
<td class="CalDayofWeek">Tuesday</td> 
<td class="CalDayofWeek">Wednesday</td> 
<td class="CalDayofWeek">Thursday</td> 
<td class="CalDayofWeek">Friday</td> 
<td class="CalDayofWeek">Saturday</td> 
</tr> 
<?php 
$timestamp = mktime(0,0,0,$cMonth,1,$cYear); 
$maxday = date("t",$timestamp); 
$thismonth = getdate ($timestamp); 
// To start the calendar on Monday instead of Sunday, switch out the next 2 lines
$startday = $thismonth['wday']; 
// $startday = $thismonth['wday'] -1;  
for ($i=0; $i<($maxday+$startday); $i++) { 
if(($i % 7) == 0 ) echo "<tr>\n"; 
if($i < $startday) { 
  echo "<td></td>\n"; 
} 
else { 
  $day = $i - $startday + 1; 
  echo "<td class='CalDates'>". $day . "<br />"; 
  // check if there are any events for this day 
  if (array_key_exists($day, $eventsByDay)) { 
    // list all events for this day 
    foreach ($eventsByDay[$day] as $record) { 
      ?> <div id="calFonts">
       <a href="#" class="tip"><?php echo $record['title'] ?>
        <span><?php echo $record['title'] ?><br />Time: <?php echo date("g:i a", strtotime($record['start_date'])) ?><br /><br />Where: <?php echo $record['location'] ?><br /><br />What: <?php echo maxWords($record['description'], 25); ?>more...<br /></span></a>
<!--         <h3>Time: <?php echo date("g:i a", strtotime($record['start_date'])) ?></h3>
		 <h3>Where: <?php echo $record['location'] ?></h3>
       <p><?php echo maxWords($record['description'], 9); ?>  
       -->
       <p> <a href="<?php echo $record['_link'] ?>" target="_blank">CLICK FOR DETAILS</a></p><br /><br /></div>
      <?php 
    } 
  } 
  echo "</td>\n"; 
} 
if(($i % 7) == 6 ) echo "</tr>\n"; 
} 
?> 
 
</table></td> 
</tr> 
</table> 
<br />  
<!-- /calendar --></div> 
				
					
				</div><!-- End content -->
				<div class="clearer"></div>
			</div><!-- End main content wrapper -->
			<div id="sidebarContainer">
				<div id="subMenu"> rel="self"></div>
				<div class="clearer"></div>
				<div id="sidebarHeader"></div>
				<div id="sidebar">
					
				</div>
			</div>
			<div class="clearer"></div>
			<div id="extraContainer5"></div>	
			<div class="clearer"></div>
		</div>
		<div id="ec6Wrapper">
			<div id="ec6TopShadow"></div>
			<div class="clearer"></div>
			<div id="extraContainer6"></div>
			<div class="clearer"></div>
		</div>
		<div class="clearer"></div>
	</div>
	<div class="clearer"></div>
	<div id="footerWrapper">
		<div id="breadcrumbContainer"><!-- Start the breadcrumb wrapper -->
			
		</div><!-- End breadcrumb -->
		<div class="clearer"></div>
		<div id="footer"><!-- Start Footer -->	
			<?php include 'includes/footer.php'; ?>
					</div><!-- End Footer -->
	</div>
	<div class="clearer"></div>
	<div id="pageBottomShadow"></div>
</div><!-- End container -->
</body>
<!--[if lte IE 7]><script type="text/javascript" src="rw_common/themes/flexture/scripts/ie7.js"></script><![endif]-->
</html>