diff --git a/agres_availability/agres_availability-calendar-month-1.tpl.php b/agres_availability/agres_availability-calendar-month-1.tpl.php
index 30ddc5b..4f521de 100644
--- a/agres_availability/agres_availability-calendar-month-1.tpl.php
+++ b/agres_availability/agres_availability-calendar-month-1.tpl.php
@@ -19,28 +19,30 @@
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
-<div class="calendar-calendar"><div class="month-view">
-<table>
-  <thead>
-    <tr>
-      <?php foreach ($day_names as $cell): ?>
-        <th class="<?php print $cell['class']; ?>">
-          <?php print $cell['data']; ?>
-        </th>
-      <?php endforeach; ?>
-    </tr>
-  </thead>
-  <tbody>
-    <?php foreach ((array) $rows as $row): ?>
-      <tr>
-        <?php foreach ($row as $cell): ?>
-          <td id="<?php print $cell['id']; ?>" class="<?php print $cell['class']; ?>">
-            fffffffffffffffffffffff
-            <?php print $cell['data']; ?>
-          </td>
+<div class="calendar-calendar">
+  <div class="month-view">
+    <table>
+      <thead>
+        <tr>
+          <?php foreach ($day_names as $cell): ?>
+            <th class="<?php print $cell['class']; ?>">
+              <?php print $cell['data']; ?>
+            </th>
+          <?php endforeach; ?>
+        </tr>
+      </thead>
+      <tbody>
+        <?php foreach ((array) $rows as $row): ?>
+          <tr>
+            <?php foreach ($row as $cell): ?>
+              <td id="<?php print $cell['id']; ?>" class="<?php print $cell['class']; ?>">
+                fffffffffffffffffffffff
+                <?php print $cell['data']; ?>
+              </td>
+            <?php endforeach; ?>
+          </tr>
         <?php endforeach; ?>
-      </tr>
-    <?php endforeach; ?>
-  </tbody>
-</table>
-</div></div>
\ No newline at end of file
+      </tbody>
+    </table>
+  </div>
+</div>
\ No newline at end of file
diff --git a/agres_availability/agres_availability-calendar-month-c.tpl.php b/agres_availability/agres_availability-calendar-month-c.tpl.php
index 46f6d38..c6a5c63 100644
--- a/agres_availability/agres_availability-calendar-month-c.tpl.php
+++ b/agres_availability/agres_availability-calendar-month-c.tpl.php
@@ -20,118 +20,93 @@
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
 <?php if ($view->name == 'bookingcalendar4') : ?>
-
-
-<div class="agreservations-calendar"><div class="agreservations-month-view">
-        <table class="agreservations-table" style="float:left; text-align: left;">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (!isset($currentcategory)) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedmonth);?>"><?php print (t('show all categories')); ?></a>
-                </th>
-                <?php foreach ($categories as $category): ?>
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (isset($currentcategory)&&$currentcategory==$category->nid) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedmonth."/".$category->nid);?>"><?php print ($category->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>
-        <table class="agreservations-table">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (!isset($currentunittype)) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedmonth."/".$currentcategory);?>"><?php print (t('show all units')); ?></a>
-                </th>
-                <?php foreach ($unittypes as $unittype): ?>
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (isset($currentunittype)&&$currentunittype==$unittype->nid) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedmonth."/".$currentcategory."/".$unittype->nid);?>"><?php print ($unittype->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>    
-<table class="agreservations-table"  style="table-layout:fixed">
-<!--  <thead>
-    <tr>
-      <?php foreach ($day_names as $cell): ?>
-        <th class="<?php print $cell['class']; ?>">
-          <?php print $cell['data']; ?>
-        </th>
-      <?php endforeach; ?>
-    </tr>
-  </thead>-->
-<!--  <tbody>-->
-   
-  <?php foreach ((array) $units as $unit): ?>
-        <tr>
-                    <td class="agreservations-calendar unitname" rowspan="2" style="width:40px;">
-
-                        <a href="<?php print(base_path());?>node/<?php print $unit->nid ?>"><?php print $unit->title  ?></a>
-                  
-                    </td>  
-                    
-      <?php foreach ((array) $agmonth_rows[$unit->title] as $roomrow): ?>
-                     <?php if (!empty($roomrow['datebox'])) : ?>
-                    <td>                     
-                      <?php print_r($roomrow['datebox']);?>
-                    </td> 
-                     <?php endif; ?>  
-      <?php endforeach; ?>
-        <tr>
-  
-    <?php foreach ((array) $agmonth_rows[$unit->title] as $roomrow): ?>
-          
-          <?php if (!empty($roomrow['datebox'])) : ?>
-         
-                               <?php if (!empty($roomrow['data'])) : ?>
-                                 <?php foreach ((array) $roomrow['data'] as $key => $roomrowres): ?>
-<!--          <pre><?php print_r($key); ?></pre>-->
-                                     <?php if (($roomrowres)!=='***busy***') : ?>                                
-                                       <td  <?php print isset($agmonth_rows[$unit->title]['spaninfo'][$key]) ? "colspan=".'"'.$agmonth_rows[$unit->title]['spaninfo'][$key].'"' : "5"; ?>>
-                                         <div class="agreservations-inner">
-                                            <?php print($roomrowres); ?>
-                                         </div>
-                                        </td>
-                                     <?php endif; ?>
-                                 <?php endforeach; ?>                                                     
-                               <?php else: ?>
-                                 <td >
-                                   <a href="<?php print(base_path().rawurldecode('node/add/agreservation?&agres_sel_unit='.$unit->nid.'&default_agres_title=Reservation&default_agres_date='.$roomrow['date'].' 14:00'));?>"> +</a>                                
-                                 </td>
-                               <?php endif; ?>                              
-                  
-
-                  
-
- 
-          <?php endif; ?> 
-    <?php endforeach; ?>
-            </tr>
-            <tr>
- <?php endforeach; ?>
-<!--  </tbody>-->
-</table>
-</div></div>
+  <div class="agreservations-calendar"><div class="agreservations-month-view">
+      <table class="agreservations-table" style="float:left; text-align: left;">
+        <tr class="agreservations-calendar">
+          <th class="agreservations-calendar th categories">
+            <a class="<?php print (!isset($currentcategory)) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedmonth); ?>"><?php print (t('show all categories')); ?></a>
+          </th>
+          <?php foreach ($categories as $category): ?>
+            <th class="agreservations-calendar th categories">
+              <a class="<?php print (isset($currentcategory) && $currentcategory == $category->nid) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedmonth . "/" . $category->nid); ?>"><?php print ($category->title); ?></a>
+            </th>
+          <?php endforeach; ?>
+        </tr>
+      </table>
+      <table class="agreservations-table">
+        <tr class="agreservations-calendar">
+          <th class="agreservations-calendar th unittypes">
+            <a class="<?php print (!isset($currentunittype)) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedmonth . "/" . $currentcategory); ?>"><?php print (t('show all units')); ?></a>
+          </th>
+          <?php foreach ($unittypes as $unittype): ?>
+            <th class="agreservations-calendar th unittypes">
+              <a class="<?php print (isset($currentunittype) && $currentunittype == $unittype->nid) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedmonth . "/" . $currentcategory . "/" . $unittype->nid); ?>"><?php print ($unittype->title); ?></a>
+            </th>
+          <?php endforeach; ?>
+        </tr>
+      </table>    
+      <table class="agreservations-table"  style="table-layout:fixed">
+        <?php foreach ((array) $units as $unit): ?>
+          <tr>
+            <td class="agreservations-calendar unitname" rowspan="2" style="width:40px;">
+              <a href="<?php print(base_path()); ?>node/<?php print $unit->nid ?>"><?php print $unit->title ?></a>
+            </td>  
+            <?php foreach ((array) $agmonth_rows[$unit->title] as $roomrow): ?>
+              <?php if (!empty($roomrow['datebox'])) : ?>
+                <td>                     
+                  <?php print_r($roomrow['datebox']); ?>
+                </td> 
+              <?php endif; ?>  
+            <?php endforeach; ?>
+          <tr>
+            <?php foreach ((array) $agmonth_rows[$unit->title] as $roomrow): ?>
+              <?php if (!empty($roomrow['datebox'])) : ?>
+                <?php if (!empty($roomrow['data'])) : ?>
+                  <?php foreach ((array) $roomrow['data'] as $key => $roomrowres): ?>
+                    <?php if (($roomrowres) !== '***busy***') : ?>                                
+                      <td  <?php print isset($agmonth_rows[$unit->title]['spaninfo'][$key]) ? "colspan=" . '"' . $agmonth_rows[$unit->title]['spaninfo'][$key] . '"' : "5"; ?>>
+                        <div class="agreservations-inner">
+                          <?php print($roomrowres); ?>
+                        </div>
+                      </td>
+                    <?php endif; ?>
+                  <?php endforeach; ?>                                                     
+                <?php else: ?>
+                  <td >
+                    <a href="<?php print(base_path() . rawurldecode('node/add/agreservation?&agres_sel_unit=' . $unit->nid . '&default_agres_title=Reservation&default_agres_date=' . $roomrow['date'] . ' 14:00')); ?>"> +</a>                                
+                  </td>
+                <?php endif; ?>                              
+              <?php endif; ?> 
+            <?php endforeach; ?>
+          </tr>
+          <tr>
+          <?php endforeach; ?>
+          <!--  </tbody>-->
+      </table>
+    </div></div>
 <?php else: ?>
-<div class="calendar-calendar"><div class="month-view">
-<table>
-  <thead>
-    <tr>
-      <?php foreach ($day_names as $cell): ?>
-        <th class="<?php print $cell['class']; ?>">
-          <?php print $cell['data']; ?>
-        </th>
-      <?php endforeach; ?>
-    </tr>
-  </thead>
-  <tbody>
-    <?php foreach ((array) $rows as $row): ?>
-      <tr>
-        <?php foreach ($row as $cell): ?>
-          <td id="<?php print $cell['id']; ?>" class="<?php print $cell['class']; ?>">
-            <?php print $cell['data']; ?>
-          </td>
-        <?php endforeach; ?>
-      </tr>
-    <?php endforeach; ?>
-  </tbody>
-</table>
-</div></div>
+  <div class="calendar-calendar"><div class="month-view">
+      <table>
+        <thead>
+          <tr>
+            <?php foreach ($day_names as $cell): ?>
+              <th class="<?php print $cell['class']; ?>">
+                <?php print $cell['data']; ?>
+              </th>
+            <?php endforeach; ?>
+          </tr>
+        </thead>
+        <tbody>
+          <?php foreach ((array) $rows as $row): ?>
+            <tr>
+              <?php foreach ($row as $cell): ?>
+                <td id="<?php print $cell['id']; ?>" class="<?php print $cell['class']; ?>">
+                  <?php print $cell['data']; ?>
+                </td>
+              <?php endforeach; ?>
+            </tr>
+          <?php endforeach; ?>
+        </tbody>
+      </table>
+    </div></div>
 <?php endif; ?>
diff --git a/agres_availability/agres_availability-month.tpl.php b/agres_availability/agres_availability-month.tpl.php
index 2fd56cf..6832286 100644
--- a/agres_availability/agres_availability-month.tpl.php
+++ b/agres_availability/agres_availability-month.tpl.php
@@ -2,7 +2,7 @@
 /**
  * @file
  * Template to display a view as a calendar month.
- * 
+ *
  * @see template_preprocess_calendar_month.
  *
  * $day_names: An array of the day of week names for the table header.
@@ -13,33 +13,35 @@
  * $block: Whether or not this calendar is in a block.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
  * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
- * $date_id: a css id that is unique for this date, 
+ * $date_id: a css id that is unique for this date,
  *   it is in the form: calendar-nid-field_name-delta
- * 
+ *
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
-<div class="calendar-calendar"><div class="month-view">
-<table>
-  <thead>
-    <tr>
-      <?php foreach ($day_names as $cell): ?>
-        <th class="<?php print $cell['class']; ?>">
-          <?php print $cell['data']; ?>
-        </th>
-      <?php endforeach; ?>
-    </tr>
-  </thead>
-  <tbody>
-    <?php foreach ((array) $rows as $row): ?>
-      <tr>
-        <?php foreach ($row as $cell): ?>
-          <td id="<?php print $cell['id']; ?>" class="<?php print $cell['class']; ?>">
-            <?php print $cell['data']; ?>
-          </td>
+<div class="calendar-calendar">
+  <div class="month-view">
+    <table>
+      <thead>
+        <tr>
+          <?php foreach ($day_names as $cell): ?>
+            <th class="<?php print $cell['class']; ?>">
+              <?php print $cell['data']; ?>
+            </th>
+          <?php endforeach; ?>
+        </tr>
+      </thead>
+      <tbody>
+        <?php foreach ((array) $rows as $row): ?>
+          <tr>
+            <?php foreach ($row as $cell): ?>
+              <td id="<?php print $cell['id']; ?>" class="<?php print $cell['class']; ?>">
+                <?php print $cell['data']; ?>
+              </td>
+            <?php endforeach; ?>
+          </tr>
         <?php endforeach; ?>
-      </tr>
-    <?php endforeach; ?>
-  </tbody>
-</table>
-</div></div>
\ No newline at end of file
+      </tbody>
+    </table>
+  </div>
+</div>
\ No newline at end of file
diff --git a/agres_availability/agres_availability.css b/agres_availability/agres_availability.css
index 3be617c..2454218 100644
--- a/agres_availability/agres_availability.css
+++ b/agres_availability/agres_availability.css
@@ -1,26 +1,22 @@
 /*  calendar calendar table styles  */
 
 .agreservations-month-view {
-    float: left;
-/*    width:600px;
-    overflow:scroll;*/
-}/*
-
-.agreservations-calendar {
-     width:600px;
-}*/
+  float: left;
+}
+
 .unitname{
-    width:50px;
+  width:50px;
 }
+
 .agreservations-table{
-    clear: both;
- 
-   table-layout: fixed; 
-   left: 55px;
-   
-    border:solid;
-   border-width: 1px;
-   
+  clear: both;
+
+  table-layout: fixed;
+  left: 55px;
+
+  border:solid;
+  border-width: 1px;
+
 }
 .agreservations-calendar tr.odd, .agreservations-calendar tr.even {
   background-color:#fff;
@@ -51,13 +47,13 @@ td.agres_availability_partlyfree {
   color: #fff;
 }
 td.agres_availability_fullybooked div.month a {
-  color:#fff;  
+  color:#fff;
 }
 td.agres_availability_partlyfree div.month a {
-  color:#fff;  
+  color:#fff;
 }
 
-  /* IE needs a little help to get the side by side tables to the right size */
+/* IE needs a little help to get the side by side tables to the right size */
 .agreservations-calendar .year-view td {
   width:32%;
   padding:1px;
@@ -75,9 +71,9 @@ td.agres_availability_partlyfree div.month a {
   background-color: white;
 }
 .agreservations-calendar th {
-    width: 1px;
-    border:solid;
-   border-width: 1px;
+  width: 1px;
+  border:solid;
+  border-width: 1px;
   color: #fff;
   background-color: #AAA;
   text-align: center;
@@ -85,7 +81,7 @@ td.agres_availability_partlyfree div.month a {
   margin: 3em;
   font-size:smaller;
 
-  
+
 }
 
 .agreservations-calendar th.unittypes {
@@ -145,16 +141,16 @@ td.agres_availability_partlyfree div.month a {
 /* simplify the mini calendar by removing borders */
 .agreservations-calendar .mini {
   border:none;
- }
+}
 
 /* format for the week number in the first cell */
 .agreservations-calendar td.week {
   width:1%;
   min-width:1%;
-  }
+}
 
-  .agreservations-calendar .unittitle td {
-        font-weight:lighter;
+.agreservations-calendar .unittitle td {
+  font-weight:lighter;
   padding:0em;
   background-color: #f2f;
 }
@@ -207,14 +203,14 @@ td.agres_availability_partlyfree div.month a {
   text-align: center;
   padding:1px;
   margin:0;
- }
+}
 .agreservations-calendar th.agreservations-calendar-agenda-hour .agreservations-calendar-hour {
   font-size: 1.1em;
   padding: 1px;
-      margin:0;
+  margin:0;
 }
 .agreservations-month-view agreservations-monthcell{
-    width:2.1em;
+  width:2.1em;
 }
 /*  floating day number div  */
 .agreservations-calendar div.day  {
@@ -223,8 +219,8 @@ td.agres_availability_partlyfree div.month a {
   padding: 0 0 0 0;
   margin: 0;
   background-color: #fff;
-/*  border: 1px solid gray;*/
-/*  border-width: 0 0 1px 1px;*/
+  /*  border: 1px solid gray;*/
+  /*  border-width: 0 0 1px 1px;*/
   clear:both;
   width:auto;
   font-size:xx-small;
@@ -250,7 +246,7 @@ table.agreservations-table tbody tr td div.month  {
   width: 96%;
   float:right; /* needed to keep IE from hiding the floating day number */
   clear:both;
-  
+
 }
 /* No floating of day view content because there is no floating day number */
 .agreservations-calendar .day-view div.calendar {
@@ -284,10 +280,10 @@ table th.mini,
 table.mini td.week {
   padding:0 1px 0 0;
   margin:0;
-  }
+}
 table td.mini a {
   font-weight:normal;
-  }
+}
 .agreservations-calendar .mini-day-off {
   padding:0px;
 }
@@ -296,13 +292,13 @@ table td.mini a {
 }
 table .mini-day-on a {
   text-decoration:underline;
-  }
+}
 .agreservations-calendar .mini .title {
   font-size:.8em;
-  }
+}
 .mini .agreservations-calendar .week {
   font-size:.7em;
-  }
+}
 .mini-row {
   width:100%;
   border:none;
@@ -310,8 +306,7 @@ table .mini-day-on a {
 .mini{
   width:32%;
   vertical-align:top;
-  }
-
+}
 
 /* formatting for the legend stripe and block */
 .agreservations-calendar .stripe {
@@ -347,24 +342,20 @@ table.agreservations-legend tr.even .stripe {
 /* formatting for the full day view */
 .agreservations-calendar td.agreservations-agenda-hour {
   font-family:serif;
- /* text-align:right;*/
   border:activeborder;
   border-top:1px #333 dotted;
-  
- /* padding-top:.25em;*/
   width:1%;
   height:100px;
 
   font-size: 1em;
 }
 .agreservations-calendar td.agreservations-agenda-no-hours {
-   font-size: 1em;
+  font-size: 1em;
   min-width:1%;
   max-height: 1%;
 }
 .agreservations-i td.agreservations-agenda-hour .agreservations-hour {
   font-size: 1em;
-  /*font-weight:bold;*/
   max-height: 1%;
 }
 .agreservations-calendar td.agreservations-agenda-hour .agreservations-ampm {
@@ -378,14 +369,12 @@ table.agreservations-legend tr.even .stripe {
 }
 .agreservations-calendar td.agreservations-agenda-items div.calendar {
   width:auto;
-  /*padding:.25em;*/
   margin:0;
 }
 .agreservations-calendar div.calendar div.inner .agreservations-agenda-empty {
   width:100%;
   text-align:center;
   vertical-align:middle;
- /* padding:1em 0;*/
   background-color:#fff;
 }
 
@@ -454,180 +443,142 @@ table.agreservations-legend tr.even .stripe {
 .agreservations-calendar div.calendar {
   border:none;
   font-size:x-small;
-/*  height:auto;*/
-   
-
 }
 .agreservations-calendar td .agreservations-inner div.calendar div,
 .agreservations-calendar td .agreservations-inner div.calendar div a {
-/*  border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:9px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;   
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .agresitemcontinues {
-/*   border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:4px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;      
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .agresitemcutoff {
-/*   border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:4px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;      
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .monthview {
-      width: 100%;
+  width: 100%;
   height: 100%;
-/*      border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
 }
 .agreservations-inner-black{
   background-color:#111;
   text-align: center;
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:7px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;  
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .agreservations-inner-red{
   background-color:#911;
   text-align: center;
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:7px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;  
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .agreservations-inner{
   background-color:#44f;
   text-align: center;
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:7px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;  
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .itemwithorder a{
-  color:#fff; 
+  color:#fff;
 }
 
-.itemwithoutorder a{   
-  color:#fff; 
+.itemwithoutorder a{
+  color:#fff;
 }
 .itemwithorder {
-    background-color:#44f;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px; 
-  color:#fff; 
+  background-color:#44f;
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
+  color:#fff;
 }
 
 .itemwithoutorder {
-    background-color:#E87400;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;     
-  color:#fff; 
+  background-color:#E87400;
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
+  color:#fff;
 }
 .agreservations-inner-green{
   background-color:#191;
   text-align: center;
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:7px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;  
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .agreservations-inner a{
-    text-decoration: none;
-/*  background-color:#44f;*/
-  color:#fff;  
+  text-decoration: none;
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:7px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;  
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 
 .agreservations-calendar-cell{
-/*    border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
-  color:#fff;  
+  color:#fff;
   width: 100%;
   height: 10px;
   font-size:9px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;    
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
   text-align: center;
 }
 a {
- color:#fff;   
+  color:#fff;
 }
-/*.agreservations-calendar-cell a{
-    color:#fff;
-    text-decoration: none;
-
-    
-}*/
 
 .calendar weekview{
-/*    border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:9px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;     
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 
 .agreservations-calendar-agenda-items view-field {
-/*    border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:9px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;     
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .agreservations-calendar td .inner div.calendar div.agreservations-more,
 .agreservations-calendar td .inner div.calendar div.agreservations-more a {
   color:#444;
   background:#fff;
   text-align:right;
-  
+
 
 }
 .agreservations-calendar td .inner .view-field,
@@ -641,7 +592,6 @@ a {
 .agreservations-calendar td span.date-display-start,
 .agreservations-calendar td span.date-display-end,
 .agreservations-calendar td span.date-display-separator {
- /* font-weight:bold;*/
 }
 .agreservations-calendar td .inner div.day a {
   color:#4b85ac;
diff --git a/agres_availability/agres_availability.info b/agres_availability/agres_availability.info
index 66df6c5..b8debc3 100644
--- a/agres_availability/agres_availability.info
+++ b/agres_availability/agres_availability.info
@@ -1,12 +1,8 @@
-name = agres_availability
-description = Based on the original Drupal Calendar Module by KarenS: display of basic availability calculcated over all units
-dependencies[] = agreservations
-dependencies[] = agres_categories
-dependencies[] = calendar
-package = agreservations - extra
+name = Agreservations Availabilty
+description = Display of basic availability for all units. Based on the original Drupal Calendar Module by KarenS
+package = Agreservations - Extra
 core = 7.x
 
-
 files[] = agres_availability.module
 files[] = includes/agres_availability.views.inc
 files[] = includes/agres_availability_plugin_style.inc
@@ -14,3 +10,7 @@ files[] = includes/agres_availability_plugin_row_node.inc
 files[] = theme/theme.inc
 files[] = theme/agres_availability-style.tpl.php
 files[] = theme/agres_availability-row-node.tpl.php
+
+dependencies[] = agreservations
+dependencies[] = agres_categories
+dependencies[] = calendar
\ No newline at end of file
diff --git a/agres_availability/agres_availability.module b/agres_availability/agres_availability.module
index 48c3ca6..ded0b74 100644
--- a/agres_availability/agres_availability.module
+++ b/agres_availability/agres_availability.module
@@ -1,19 +1,25 @@
 <?php
+
 /**
  * @file
+ *
  * agres_availability.module additional preprocessors and views for agres_availability
  * based on the calendar module by KarenS
+ *
+ * Adds agres_availability filtering and displays to Views.
  */
 
-
+/**
+ * Implements hook_init().
+ */
 function agres_availability_init() {
-//     if (substr($_GET['q'], 0, 24) == 'admin/build/modules/list') {
-//       return;
-//     }
   drupal_add_css(drupal_get_path('module', 'agres_availability') . '/agres_availability.css');
   require_once('./' . drupal_get_path('module', 'agres_availability') . '/theme/theme.inc');
 }
 
+/**
+ * Implements hook_theme().
+ */
 function agres_availability_theme() {
   $path = drupal_get_path('module', 'agres_availability');
   require_once "./$path/theme/theme.inc";
@@ -24,48 +30,43 @@ function agres_availability_theme() {
   );
   return array(
     'agres_availability_item' => $base + array(
-      'template' => 'agres-availability-item',
-      'variables' => array('view' => NULL, 'rendered_fields' => NULL, 'item' => NULL),
+    'template' => 'agres-availability-item',
+    'variables' => array('view' => NULL, 'rendered_fields' => NULL, 'item' => NULL),
     ),
     'agres_availability_datebox' => $base + array(
-      'template' => 'agres-availability-datebox',
-      'variables' => array(
-        'date' => NULL,
-        'view' => NULL,
-        'items' => NULL,
-        'selected' => NULL,
-      ),
+    'template' => 'agres-availability-datebox',
+    'variables' => array(
+      'date' => NULL,
+      'view' => NULL,
+      'items' => NULL,
+      'selected' => NULL,
+    ),
     ),
     'agres_availability_empty_day' => $base + array(
-      'variables' => array('curday' => NULL, 'view' => NULL),
+    'variables' => array('curday' => NULL, 'view' => NULL),
     ),
     'agres_availability_stripe_legend' => $base + array(
-      'variables' => array('stripe_labels' => NULL),
+    'variables' => array('stripe_labels' => NULL),
     ),
     'agres_availability_stripe_stripe' => $base + array(
-      'variables' => array('node' => NULL),
+    'variables' => array('node' => NULL),
     ),
     'agres_availability_time_row_heading' => $base + array(
-      'variables' => array('start_time' => NULL, 'next_start_time' => NULL, 'curday_date' => NULL),
+    'variables' => array('start_time' => NULL, 'next_start_time' => NULL, 'curday_date' => NULL),
     ),
     'agres_availability_month_col' => $base + array(
-      'template' => 'agres-availability-month-col',
-      'variables' => array('item' => NULL),
+    'template' => 'agres-availability-month-col',
+    'variables' => array('item' => NULL),
     ),
     'agres_availability_month_row' => $base + array(
-      'template' => 'agres-availability-month-row',
-      'variables' => array('inner' => NULL, 'class' => NULL, 'iehint' => NULL),
+    'template' => 'agres-availability-month-row',
+    'variables' => array('inner' => NULL, 'class' => NULL, 'iehint' => NULL),
     ),
   );
 }
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 define('agres_availability_SHOW_ALL', 0);
 define('agres_availability_HIDE_ALL', -1);
-/**
- * @file
- * Adds agres_availability filtering and displays to Views.
- */
 
 /**
  * Implements hook_views_api().
@@ -94,7 +95,6 @@ function agres_availability_help($section, $arg) {
   }
 }
 
-
 /**
  * Implements hook_node_view().
  *
@@ -221,7 +221,7 @@ function agres_availability_block_view($delta = '') {
 function agres_availability_granularity_path(&$view, $granularity) {
   foreach ($view->display as $id => $display) {
     if ($display->display_options['style_plugin'] == 'agres_availability_style' && !empty($display->display_options['path'])) {
-      // @TODO Why is this sometimes empty for a style that uses the default value?
+      // @todo Why is this sometimes empty for a style that uses the default value?
       $type = !empty($display->display_options['style_options']['agres_availability_type']) ? $display->display_options['style_options']['agres_availability_type'] : 'month';
       if ($type == $granularity) {
         return $display->display_options['path'];
@@ -247,11 +247,7 @@ function agres_availability_remove($view_name) {
   views_invalidate_cache();
 }
 
-
 /**
- *
- * 
- *
  * Takes the calendar links created in calendar_preprocess_date_views_pager()
  * and reconfigures them as action items and tabs. The links can be altered
  * before they are displayed using hook_calendar_links_alter().
@@ -259,18 +255,19 @@ function agres_availability_remove($view_name) {
  * We do this with an alter rather than in hook_menu() because the
  * specific path we want to go to will vary depending on the page we
  * are looking at at the time.
+ *
+ * @todo Documentation
  */
 function agres_availability_menu_local_tasks_alter(&$data, $router_item, $root_path) {
-//    drupal_set_message('<pre>agres_availability_menu_local_tasks_alter'.print_r($data,true).'</pre>');
   if (!empty($_SESSION['agres_availability_links']) && array_key_exists($root_path, $_SESSION['agres_availability_links'])) {
     $agres_availability_data = $_SESSION['agres_availability_links'][$root_path];
     if (!empty($agres_availability_data['actions'])) {
       foreach ($agres_availability_data['actions'] as $action) {
         $item = menu_get_item($action['path']);
         $item['title'] = $action['title'];
-        // The add new content page would redirect to the new event
-        // if we did not override that here. This way they will
-        // redirect back to the agres_availability.
+        // The add new content page would redirect to the new event if we did
+        // not override that here. This way they will redirect back to
+        // the agres_availability.
         $item['localized_options'] += array('query' => array());
         $item['localized_options']['query'] += drupal_get_destination();
         if ($item['access']) {
@@ -291,7 +288,7 @@ function agres_availability_menu_local_tasks_alter(&$data, $router_item, $root_p
         // links to the other views will have been adjusted to keep information
         // about the right year/month/week/day to go to.
         $item['href'] = $tab['path'];
-        if ($item['access']) {
+        if (isset($item['access'])) {
           $data['tabs'][0]['output'][$delta] = array(
             '#theme' => 'menu_local_task',
             '#link' => $item,
@@ -318,4 +315,4 @@ function agres_availability_permission() {
       'description' => t('can view the availability calendar'),
     ),
   );
-}
+}
\ No newline at end of file
diff --git a/agres_availability/includes/agres_availability.views.inc b/agres_availability/includes/agres_availability.views.inc
index 477a014..8eac2b9 100644
--- a/agres_availability/includes/agres_availability.views.inc
+++ b/agres_availability/includes/agres_availability.views.inc
@@ -5,8 +5,9 @@
  *
  * Creates agres_availability displays of Views results.
  */
+
 /**
- * Implementation of hook_views_plugins
+ * Implements hook_views_plugins().
  */
 function agres_availability_views_plugins() {
   $views_path = drupal_get_path('module', 'views');
@@ -56,4 +57,4 @@ function agres_availability_views_plugins() {
     ),
   );
   return $data;
-}
+}
\ No newline at end of file
diff --git a/agres_availability/includes/agres_availability.views_default.inc b/agres_availability/includes/agres_availability.views_default.inc
index e8d256a..9fe8448 100644
--- a/agres_availability/includes/agres_availability.views_default.inc
+++ b/agres_availability/includes/agres_availability.views_default.inc
@@ -109,16 +109,15 @@ function agres_availability_views_construct($options = NULL) {
   }
 
   $type = '';
-  if (!empty($types) && is_array($types) && count($types) > 0 ) {
+  if (!empty($types) && is_array($types) && count($types) > 0) {
     $types = array_keys($types);
     $type = $types[0];
   }
 
   // Can handle core node timestamp fields or Field date fields.
-
   $aliases = array();
   foreach ($date_fields as $field_name) {
-    if (substr($field_name, 0, 6) == 'field_') {
+    if (drupal_substr($field_name, 0, 6) == 'field_') {
       $table = 'field_data_' . $field_name;
       $alias = $table . '.' . $field_name . '_value';
       $cck_field = TRUE;
@@ -131,338 +130,337 @@ function agres_availability_views_construct($options = NULL) {
     $aliases[] = $alias;
   }
 
-$view = new view;
-$view->name = 'agres_availability';
-$view->description = 'A bookingcalendar';
-$view->tag = 'agres_availability';
-$view->base_table = 'node';
-$view->human_name = 'Availability Calendar';
-$view->core = 7;
-$view->api_version = '3.0';
-$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+  $view = new view;
+  $view->name = 'agres_availability';
+  $view->description = 'A bookingcalendar';
+  $view->tag = 'agres_availability';
+  $view->base_table = 'node';
+  $view->human_name = 'Availability Calendar';
+  $view->core = 7;
+  $view->api_version = '3.0';
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
 
-/* Display: Master */
-$handler = $view->new_display('default', 'Master', 'default');
-$handler->display->display_options['title'] = 'Availability Calendar';
-$handler->display->display_options['link_display'] = 'page_1';
-$handler->display->display_options['access']['type'] = 'perm';
-$handler->display->display_options['access']['perm'] = 'view agreservations availability calendar';
-$handler->display->display_options['cache']['type'] = 'none';
-$handler->display->display_options['query']['type'] = 'views_query';
-$handler->display->display_options['query']['options']['query_comment'] = FALSE;
-$handler->display->display_options['exposed_form']['type'] = 'basic';
-$handler->display->display_options['pager']['type'] = 'date_views_pager';
-$handler->display->display_options['pager']['options']['date_id'] = 'month';
-$handler->display->display_options['style_plugin'] = 'agres_availability_style';
-$handler->display->display_options['style_options']['name_size'] = '3';
-$handler->display->display_options['style_options']['with_weekno'] = '0';
-$handler->display->display_options['style_options']['multiday_theme'] = '1';
-$handler->display->display_options['style_options']['theme_style'] = '1';
-$handler->display->display_options['style_options']['max_items'] = '0';
-$handler->display->display_options['row_plugin'] = 'agres_availability_node';
-/* Field: Content: Title */
-$handler->display->display_options['fields']['title']['id'] = 'title';
-$handler->display->display_options['fields']['title']['table'] = 'node';
-$handler->display->display_options['fields']['title']['field'] = 'title';
-$handler->display->display_options['fields']['title']['label'] = '';
-$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
-$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['title']['alter']['external'] = 0;
-$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
-$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
-$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['title']['alter']['html'] = 0;
-$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
-$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['title']['hide_empty'] = 0;
-$handler->display->display_options['fields']['title']['empty_zero'] = 0;
-$handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
-$handler->display->display_options['fields']['title']['link_to_node'] = 1;
-/* Field: Content: Booking Date */
-$handler->display->display_options['fields']['field_agres_rdate']['id'] = 'field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['table'] = 'field_data_field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['field'] = 'field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['exclude'] = TRUE;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['alter_text'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['external'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['word_boundary'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['ellipsis'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['html'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['element_label_colon'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['hide_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['empty_zero'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['hide_alter_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['settings'] = array(
-  'format_type' => 'long',
-  'fromto' => 'both',
-  'multiple_number' => '',
-  'multiple_from' => '',
-  'multiple_to' => '',
-  'show_repeat_rule' => 'show',
-);
-$handler->display->display_options['fields']['field_agres_rdate']['field_api_classes'] = 0;
-/* Sort criterion: Content: Updated date */
-$handler->display->display_options['sorts']['changed']['id'] = 'changed';
-$handler->display->display_options['sorts']['changed']['table'] = 'node';
-$handler->display->display_options['sorts']['changed']['field'] = 'changed';
-/* Filter criterion: Content: Published */
-$handler->display->display_options['filters']['status']['id'] = 'status';
-$handler->display->display_options['filters']['status']['table'] = 'node';
-$handler->display->display_options['filters']['status']['field'] = 'status';
-$handler->display->display_options['filters']['status']['value'] = 1;
-$handler->display->display_options['filters']['status']['group'] = 0;
-$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
+  /* Display: Master */
+  $handler = $view->new_display('default', 'Master', 'default');
+  $handler->display->display_options['title'] = 'Availability Calendar';
+  $handler->display->display_options['link_display'] = 'page_1';
+  $handler->display->display_options['access']['type'] = 'perm';
+  $handler->display->display_options['access']['perm'] = 'view agreservations availability calendar';
+  $handler->display->display_options['cache']['type'] = 'none';
+  $handler->display->display_options['query']['type'] = 'views_query';
+  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
+  $handler->display->display_options['exposed_form']['type'] = 'basic';
+  $handler->display->display_options['pager']['type'] = 'date_views_pager';
+  $handler->display->display_options['pager']['options']['date_id'] = 'month';
+  $handler->display->display_options['style_plugin'] = 'agres_availability_style';
+  $handler->display->display_options['style_options']['name_size'] = '3';
+  $handler->display->display_options['style_options']['with_weekno'] = '0';
+  $handler->display->display_options['style_options']['multiday_theme'] = '1';
+  $handler->display->display_options['style_options']['theme_style'] = '1';
+  $handler->display->display_options['style_options']['max_items'] = '0';
+  $handler->display->display_options['row_plugin'] = 'agres_availability_node';
+  /* Field: Content: Title */
+  $handler->display->display_options['fields']['title']['id'] = 'title';
+  $handler->display->display_options['fields']['title']['table'] = 'node';
+  $handler->display->display_options['fields']['title']['field'] = 'title';
+  $handler->display->display_options['fields']['title']['label'] = '';
+  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['title']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
+  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
+  /* Field: Content: Booking Date */
+  $handler->display->display_options['fields']['field_agres_rdate']['id'] = 'field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['table'] = 'field_data_field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['field'] = 'field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['exclude'] = TRUE;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['element_label_colon'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['hide_alter_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['settings'] = array(
+    'format_type' => 'long',
+    'fromto' => 'both',
+    'multiple_number' => '',
+    'multiple_from' => '',
+    'multiple_to' => '',
+    'show_repeat_rule' => 'show',
+  );
+  $handler->display->display_options['fields']['field_agres_rdate']['field_api_classes'] = 0;
+  /* Sort criterion: Content: Updated date */
+  $handler->display->display_options['sorts']['changed']['id'] = 'changed';
+  $handler->display->display_options['sorts']['changed']['table'] = 'node';
+  $handler->display->display_options['sorts']['changed']['field'] = 'changed';
+  /* Filter criterion: Content: Published */
+  $handler->display->display_options['filters']['status']['id'] = 'status';
+  $handler->display->display_options['filters']['status']['table'] = 'node';
+  $handler->display->display_options['filters']['status']['field'] = 'status';
+  $handler->display->display_options['filters']['status']['value'] = 1;
+  $handler->display->display_options['filters']['status']['group'] = 0;
+  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
 
-/* Display: Month */
-$handler = $view->new_display('page', 'Month', 'page_1');
-$handler->display->display_options['defaults']['pager'] = FALSE;
-$handler->display->display_options['pager']['type'] = 'date_views_pager';
-$handler->display->display_options['pager']['options']['date_id'] = 'month';
-$handler->display->display_options['pager']['options']['link_format'] = 'clean';
-$handler->display->display_options['defaults']['style_plugin'] = FALSE;
-$handler->display->display_options['style_plugin'] = 'agres_availability_style';
-$handler->display->display_options['style_options']['name_size'] = '3';
-$handler->display->display_options['style_options']['mini'] = '0';
-$handler->display->display_options['style_options']['with_weekno'] = '0';
-$handler->display->display_options['style_options']['multiday_theme'] = '1';
-$handler->display->display_options['style_options']['theme_style'] = '1';
-$handler->display->display_options['style_options']['max_items'] = '0';
-$handler->display->display_options['defaults']['style_options'] = FALSE;
-$handler->display->display_options['defaults']['row_plugin'] = FALSE;
-$handler->display->display_options['row_plugin'] = 'agres_availability_node';
-$handler->display->display_options['row_options']['colors']['legend'] = 'type';
-$handler->display->display_options['defaults']['row_options'] = FALSE;
-$handler->display->display_options['defaults']['arguments'] = FALSE;
-/* Contextual filter: Date: Date (node) */
-$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
-$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
-$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
-$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
-$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
-$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
-  'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
-  'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
-);
-$handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
-$handler->display->display_options['path'] = 'agres_availability/month';
-$handler->display->display_options['menu']['type'] = 'normal';
-$handler->display->display_options['menu']['title'] = 'Availability Calendar';
-$handler->display->display_options['menu']['description'] = 'An Availability Calendar';
-$handler->display->display_options['menu']['weight'] = '0';
-$handler->display->display_options['menu']['name'] = 'main-menu';
-$handler->display->display_options['tab_options']['type'] = 'normal';
-$handler->display->display_options['tab_options']['title'] = 'Month';
-$handler->display->display_options['tab_options']['weight'] = '0';
+  /* Display: Month */
+  $handler = $view->new_display('page', 'Month', 'page_1');
+  $handler->display->display_options['defaults']['pager'] = FALSE;
+  $handler->display->display_options['pager']['type'] = 'date_views_pager';
+  $handler->display->display_options['pager']['options']['date_id'] = 'month';
+  $handler->display->display_options['pager']['options']['link_format'] = 'clean';
+  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
+  $handler->display->display_options['style_plugin'] = 'agres_availability_style';
+  $handler->display->display_options['style_options']['name_size'] = '3';
+  $handler->display->display_options['style_options']['mini'] = '0';
+  $handler->display->display_options['style_options']['with_weekno'] = '0';
+  $handler->display->display_options['style_options']['multiday_theme'] = '1';
+  $handler->display->display_options['style_options']['theme_style'] = '1';
+  $handler->display->display_options['style_options']['max_items'] = '0';
+  $handler->display->display_options['defaults']['style_options'] = FALSE;
+  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
+  $handler->display->display_options['row_plugin'] = 'agres_availability_node';
+  $handler->display->display_options['row_options']['colors']['legend'] = 'type';
+  $handler->display->display_options['defaults']['row_options'] = FALSE;
+  $handler->display->display_options['defaults']['arguments'] = FALSE;
+  /* Contextual filter: Date: Date (node) */
+  $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['table'] = 'node';
+  $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
+  $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
+  $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
+  $handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
+  $handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
+    'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
+    'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
+  );
+  $handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
+  $handler->display->display_options['path'] = 'agres_availability/month';
+  $handler->display->display_options['menu']['type'] = 'normal';
+  $handler->display->display_options['menu']['title'] = 'Availability Calendar';
+  $handler->display->display_options['menu']['description'] = 'An Availability Calendar';
+  $handler->display->display_options['menu']['weight'] = '0';
+  $handler->display->display_options['menu']['name'] = 'main-menu';
+  $handler->display->display_options['tab_options']['type'] = 'normal';
+  $handler->display->display_options['tab_options']['title'] = 'Month';
+  $handler->display->display_options['tab_options']['weight'] = '0';
 
-/* Display: Week */
-$handler = $view->new_display('page', 'Week', 'page_2');
-$handler->display->display_options['defaults']['pager'] = FALSE;
-$handler->display->display_options['pager']['type'] = 'date_views_pager';
-$handler->display->display_options['pager']['options']['date_id'] = 'week';
-$handler->display->display_options['pager']['options']['link_format'] = 'clean';
-$handler->display->display_options['defaults']['style_plugin'] = FALSE;
-$handler->display->display_options['style_plugin'] = 'agres_availability_style';
-$handler->display->display_options['style_options']['name_size'] = '3';
-$handler->display->display_options['style_options']['mini'] = '0';
-$handler->display->display_options['style_options']['with_weekno'] = '0';
-$handler->display->display_options['style_options']['multiday_theme'] = '1';
-$handler->display->display_options['style_options']['theme_style'] = '0';
-$handler->display->display_options['style_options']['max_items'] = '0';
-$handler->display->display_options['style_options']['agres_availability_type'] = 'week';
-$handler->display->display_options['defaults']['style_options'] = FALSE;
-$handler->display->display_options['defaults']['row_plugin'] = FALSE;
-$handler->display->display_options['row_plugin'] = 'agres_availability_node';
-$handler->display->display_options['defaults']['row_options'] = FALSE;
-$handler->display->display_options['defaults']['arguments'] = FALSE;
-/* Contextual filter: Date: Date (node) */
-$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
-$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
-$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
-$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
-$handler->display->display_options['arguments']['date_argument']['granularity'] = 'week';
-$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
-$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
-  'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
-  'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
-);
-$handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
-$handler->display->display_options['path'] = 'agres_availability/week';
-$handler->display->display_options['menu']['title'] = 'Week';
-$handler->display->display_options['menu']['weight'] = '2';
+  /* Display: Week */
+  $handler = $view->new_display('page', 'Week', 'page_2');
+  $handler->display->display_options['defaults']['pager'] = FALSE;
+  $handler->display->display_options['pager']['type'] = 'date_views_pager';
+  $handler->display->display_options['pager']['options']['date_id'] = 'week';
+  $handler->display->display_options['pager']['options']['link_format'] = 'clean';
+  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
+  $handler->display->display_options['style_plugin'] = 'agres_availability_style';
+  $handler->display->display_options['style_options']['name_size'] = '3';
+  $handler->display->display_options['style_options']['mini'] = '0';
+  $handler->display->display_options['style_options']['with_weekno'] = '0';
+  $handler->display->display_options['style_options']['multiday_theme'] = '1';
+  $handler->display->display_options['style_options']['theme_style'] = '0';
+  $handler->display->display_options['style_options']['max_items'] = '0';
+  $handler->display->display_options['style_options']['agres_availability_type'] = 'week';
+  $handler->display->display_options['defaults']['style_options'] = FALSE;
+  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
+  $handler->display->display_options['row_plugin'] = 'agres_availability_node';
+  $handler->display->display_options['defaults']['row_options'] = FALSE;
+  $handler->display->display_options['defaults']['arguments'] = FALSE;
+  /* Contextual filter: Date: Date (node) */
+  $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['table'] = 'node';
+  $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
+  $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
+  $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
+  $handler->display->display_options['arguments']['date_argument']['granularity'] = 'week';
+  $handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
+  $handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
+    'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
+    'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
+  );
+  $handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
+  $handler->display->display_options['path'] = 'agres_availability/week';
+  $handler->display->display_options['menu']['title'] = 'Week';
+  $handler->display->display_options['menu']['weight'] = '2';
 
-/* Display: Day */
-$handler = $view->new_display('page', 'Day', 'page_3');
-$handler->display->display_options['defaults']['pager'] = FALSE;
-$handler->display->display_options['pager']['type'] = 'date_views_pager';
-$handler->display->display_options['pager']['options']['date_id'] = 'day';
-$handler->display->display_options['defaults']['style_plugin'] = FALSE;
-$handler->display->display_options['style_plugin'] = 'agres_availability_style';
-$handler->display->display_options['style_options']['name_size'] = '3';
-$handler->display->display_options['style_options']['mini'] = '0';
-$handler->display->display_options['style_options']['with_weekno'] = '0';
-$handler->display->display_options['style_options']['multiday_theme'] = '0';
-$handler->display->display_options['style_options']['theme_style'] = '1';
-$handler->display->display_options['style_options']['max_items'] = '0';
-$handler->display->display_options['style_options']['agres_availability_type'] = 'day';
-$handler->display->display_options['defaults']['style_options'] = FALSE;
-$handler->display->display_options['defaults']['row_plugin'] = FALSE;
-$handler->display->display_options['row_plugin'] = 'agres_availability_node';
-$handler->display->display_options['defaults']['row_options'] = FALSE;
-$handler->display->display_options['defaults']['arguments'] = FALSE;
-/* Contextual filter: Date: Date (node) */
-$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
-$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
-$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
-$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
-$handler->display->display_options['arguments']['date_argument']['granularity'] = 'day';
-$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
-  'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
-  'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
-);
-$handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
-$handler->display->display_options['path'] = 'agres_availability/day';
-$handler->display->display_options['menu']['title'] = 'Day';
-$handler->display->display_options['menu']['weight'] = '3';
+  /* Display: Day */
+  $handler = $view->new_display('page', 'Day', 'page_3');
+  $handler->display->display_options['defaults']['pager'] = FALSE;
+  $handler->display->display_options['pager']['type'] = 'date_views_pager';
+  $handler->display->display_options['pager']['options']['date_id'] = 'day';
+  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
+  $handler->display->display_options['style_plugin'] = 'agres_availability_style';
+  $handler->display->display_options['style_options']['name_size'] = '3';
+  $handler->display->display_options['style_options']['mini'] = '0';
+  $handler->display->display_options['style_options']['with_weekno'] = '0';
+  $handler->display->display_options['style_options']['multiday_theme'] = '0';
+  $handler->display->display_options['style_options']['theme_style'] = '1';
+  $handler->display->display_options['style_options']['max_items'] = '0';
+  $handler->display->display_options['style_options']['agres_availability_type'] = 'day';
+  $handler->display->display_options['defaults']['style_options'] = FALSE;
+  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
+  $handler->display->display_options['row_plugin'] = 'agres_availability_node';
+  $handler->display->display_options['defaults']['row_options'] = FALSE;
+  $handler->display->display_options['defaults']['arguments'] = FALSE;
+  /* Contextual filter: Date: Date (node) */
+  $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['table'] = 'node';
+  $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
+  $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
+  $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
+  $handler->display->display_options['arguments']['date_argument']['granularity'] = 'day';
+  $handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
+    'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
+    'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
+  );
+  $handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
+  $handler->display->display_options['path'] = 'agres_availability/day';
+  $handler->display->display_options['menu']['title'] = 'Day';
+  $handler->display->display_options['menu']['weight'] = '3';
 
-/* Display: Year */
-$handler = $view->new_display('page', 'Year', 'page');
-$handler->display->display_options['defaults']['pager'] = FALSE;
-$handler->display->display_options['pager']['type'] = 'date_views_pager';
-$handler->display->display_options['pager']['options']['date_id'] = 'year';
-$handler->display->display_options['defaults']['style_plugin'] = FALSE;
-$handler->display->display_options['style_plugin'] = 'agres_availability_style';
-$handler->display->display_options['style_options']['name_size'] = '1';
-$handler->display->display_options['style_options']['mini'] = '0';
-$handler->display->display_options['style_options']['with_weekno'] = '0';
-$handler->display->display_options['style_options']['multiday_theme'] = '1';
-$handler->display->display_options['style_options']['theme_style'] = '1';
-$handler->display->display_options['style_options']['max_items'] = '0';
-$handler->display->display_options['style_options']['agres_availability_type'] = 'year';
-$handler->display->display_options['defaults']['style_options'] = FALSE;
-$handler->display->display_options['defaults']['row_plugin'] = FALSE;
-$handler->display->display_options['row_plugin'] = 'agres_availability_node';
-$handler->display->display_options['defaults']['row_options'] = FALSE;
-$handler->display->display_options['defaults']['arguments'] = FALSE;
-/* Contextual filter: Date: Date (node) */
-$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
-$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
-$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
-$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
-$handler->display->display_options['arguments']['date_argument']['granularity'] = 'year';
-$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
-$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
-  'node.changed' => 'node.changed',
-);
-$handler->display->display_options['path'] = 'agres_availability/year';
-$handler->display->display_options['menu']['title'] = 'Year';
-$handler->display->display_options['menu']['weight'] = '4';
+  /* Display: Year */
+  $handler = $view->new_display('page', 'Year', 'page');
+  $handler->display->display_options['defaults']['pager'] = FALSE;
+  $handler->display->display_options['pager']['type'] = 'date_views_pager';
+  $handler->display->display_options['pager']['options']['date_id'] = 'year';
+  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
+  $handler->display->display_options['style_plugin'] = 'agres_availability_style';
+  $handler->display->display_options['style_options']['name_size'] = '1';
+  $handler->display->display_options['style_options']['mini'] = '0';
+  $handler->display->display_options['style_options']['with_weekno'] = '0';
+  $handler->display->display_options['style_options']['multiday_theme'] = '1';
+  $handler->display->display_options['style_options']['theme_style'] = '1';
+  $handler->display->display_options['style_options']['max_items'] = '0';
+  $handler->display->display_options['style_options']['agres_availability_type'] = 'year';
+  $handler->display->display_options['defaults']['style_options'] = FALSE;
+  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
+  $handler->display->display_options['row_plugin'] = 'agres_availability_node';
+  $handler->display->display_options['defaults']['row_options'] = FALSE;
+  $handler->display->display_options['defaults']['arguments'] = FALSE;
+  /* Contextual filter: Date: Date (node) */
+  $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['table'] = 'node';
+  $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
+  $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
+  $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
+  $handler->display->display_options['arguments']['date_argument']['granularity'] = 'year';
+  $handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
+  $handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
+    'node.changed' => 'node.changed',
+  );
+  $handler->display->display_options['path'] = 'agres_availability/year';
+  $handler->display->display_options['menu']['title'] = 'Year';
+  $handler->display->display_options['menu']['weight'] = '4';
 
-/* Display: Block */
-$handler = $view->new_display('block', 'Block', 'block_1');
-$handler->display->display_options['defaults']['pager'] = FALSE;
-$handler->display->display_options['pager']['type'] = 'date_views_pager';
-$handler->display->display_options['pager']['options']['date_id'] = 'mini';
-$handler->display->display_options['pager']['options']['link_format'] = 'clean';
-$handler->display->display_options['defaults']['style_plugin'] = FALSE;
-$handler->display->display_options['style_plugin'] = 'agres_availability_style';
-$handler->display->display_options['style_options']['name_size'] = '3';
-$handler->display->display_options['style_options']['mini'] = '1';
-$handler->display->display_options['style_options']['with_weekno'] = '0';
-$handler->display->display_options['style_options']['multiday_theme'] = '0';
-$handler->display->display_options['style_options']['theme_style'] = '1';
-$handler->display->display_options['style_options']['max_items'] = '0';
-$handler->display->display_options['defaults']['style_options'] = FALSE;
-$handler->display->display_options['defaults']['row_plugin'] = FALSE;
-$handler->display->display_options['row_plugin'] = 'agres_availability_node';
-$handler->display->display_options['defaults']['row_options'] = FALSE;
-$handler->display->display_options['defaults']['arguments'] = FALSE;
-/* Contextual filter: Date: Date (node) */
-$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
-$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
-$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
-$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
-$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
-$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
-  'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
-  'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
-);
-$handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
+  /* Display: Block */
+  $handler = $view->new_display('block', 'Block', 'block_1');
+  $handler->display->display_options['defaults']['pager'] = FALSE;
+  $handler->display->display_options['pager']['type'] = 'date_views_pager';
+  $handler->display->display_options['pager']['options']['date_id'] = 'mini';
+  $handler->display->display_options['pager']['options']['link_format'] = 'clean';
+  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
+  $handler->display->display_options['style_plugin'] = 'agres_availability_style';
+  $handler->display->display_options['style_options']['name_size'] = '3';
+  $handler->display->display_options['style_options']['mini'] = '1';
+  $handler->display->display_options['style_options']['with_weekno'] = '0';
+  $handler->display->display_options['style_options']['multiday_theme'] = '0';
+  $handler->display->display_options['style_options']['theme_style'] = '1';
+  $handler->display->display_options['style_options']['max_items'] = '0';
+  $handler->display->display_options['defaults']['style_options'] = FALSE;
+  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
+  $handler->display->display_options['row_plugin'] = 'agres_availability_node';
+  $handler->display->display_options['defaults']['row_options'] = FALSE;
+  $handler->display->display_options['defaults']['arguments'] = FALSE;
+  /* Contextual filter: Date: Date (node) */
+  $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['table'] = 'node';
+  $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
+  $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
+  $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
+  $handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
+  $handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
+    'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
+    'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
+  );
+  $handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
 
-/* Display: Upcoming */
-$handler = $view->new_display('block', 'Upcoming', 'block_2');
-$handler->display->display_options['display_description'] = 'Upcoming events block';
-$handler->display->display_options['defaults']['pager'] = FALSE;
-$handler->display->display_options['pager']['type'] = 'some';
-$handler->display->display_options['pager']['options']['items_per_page'] = '5';
-$handler->display->display_options['pager']['options']['offset'] = '0';
-$handler->display->display_options['defaults']['style_plugin'] = FALSE;
-$handler->display->display_options['style_plugin'] = 'list';
-$handler->display->display_options['defaults']['style_options'] = FALSE;
-$handler->display->display_options['defaults']['row_plugin'] = FALSE;
-$handler->display->display_options['row_plugin'] = 'fields';
-$handler->display->display_options['defaults']['row_options'] = FALSE;
-$handler->display->display_options['defaults']['filters'] = FALSE;
-/* Filter criterion: Content: Published */
-$handler->display->display_options['filters']['status']['id'] = 'status';
-$handler->display->display_options['filters']['status']['table'] = 'node';
-$handler->display->display_options['filters']['status']['field'] = 'status';
-$handler->display->display_options['filters']['status']['value'] = 1;
-$handler->display->display_options['filters']['status']['group'] = 0;
-$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
-/* Filter criterion: Date: Date (node) */
-$handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
-$handler->display->display_options['filters']['date_filter']['table'] = 'node';
-$handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
-$handler->display->display_options['filters']['date_filter']['operator'] = '>=';
-$handler->display->display_options['filters']['date_filter']['default_date'] = 'now';
-$handler->display->display_options['filters']['date_filter']['add_delta'] = 'yes';
-$handler->display->display_options['filters']['date_filter']['date_fields'] = array(
-  'node.changed' => 'node.changed',
-);
-$translatables['agres_availability'] = array(
-  t('Master'),
-  t('Availability Calendar'),
-  t('more'),
-  t('Apply'),
-  t('Reset'),
-  t('Sort by'),
-  t('Asc'),
-  t('Desc'),
-  t('Booking Date'),
-  t('Month'),
-  t('All'),
-  t('Week'),
-  t('Day'),
-  t('Year'),
-  t('Block'),
-  t('Upcoming'),
-  t('Upcoming events block'),
-);
+  /* Display: Upcoming */
+  $handler = $view->new_display('block', 'Upcoming', 'block_2');
+  $handler->display->display_options['display_description'] = 'Upcoming events block';
+  $handler->display->display_options['defaults']['pager'] = FALSE;
+  $handler->display->display_options['pager']['type'] = 'some';
+  $handler->display->display_options['pager']['options']['items_per_page'] = '5';
+  $handler->display->display_options['pager']['options']['offset'] = '0';
+  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
+  $handler->display->display_options['style_plugin'] = 'list';
+  $handler->display->display_options['defaults']['style_options'] = FALSE;
+  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
+  $handler->display->display_options['row_plugin'] = 'fields';
+  $handler->display->display_options['defaults']['row_options'] = FALSE;
+  $handler->display->display_options['defaults']['filters'] = FALSE;
+  /* Filter criterion: Content: Published */
+  $handler->display->display_options['filters']['status']['id'] = 'status';
+  $handler->display->display_options['filters']['status']['table'] = 'node';
+  $handler->display->display_options['filters']['status']['field'] = 'status';
+  $handler->display->display_options['filters']['status']['value'] = 1;
+  $handler->display->display_options['filters']['status']['group'] = 0;
+  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
+  /* Filter criterion: Date: Date (node) */
+  $handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
+  $handler->display->display_options['filters']['date_filter']['table'] = 'node';
+  $handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
+  $handler->display->display_options['filters']['date_filter']['operator'] = '>=';
+  $handler->display->display_options['filters']['date_filter']['default_date'] = 'now';
+  $handler->display->display_options['filters']['date_filter']['add_delta'] = 'yes';
+  $handler->display->display_options['filters']['date_filter']['date_fields'] = array(
+    'node.changed' => 'node.changed',
+  );
+  $translatables['agres_availability'] = array(
+    t('Master'),
+    t('Availability Calendar'),
+    t('more'),
+    t('Apply'),
+    t('Reset'),
+    t('Sort by'),
+    t('Asc'),
+    t('Desc'),
+    t('Booking Date'),
+    t('Month'),
+    t('All'),
+    t('Week'),
+    t('Day'),
+    t('Year'),
+    t('Block'),
+    t('Upcoming'),
+    t('Upcoming events block'),
+  );
 
 
   return $view;
-
-}
+}
\ No newline at end of file
diff --git a/agres_availability/includes/agres_availability_plugin_row_node.inc b/agres_availability/includes/agres_availability_plugin_row_node.inc
index f529a80..423950c 100644
--- a/agres_availability/includes/agres_availability_plugin_row_node.inc
+++ b/agres_availability/includes/agres_availability_plugin_row_node.inc
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * @file
  * Contains the agres_availability row style plugin.
@@ -23,167 +24,18 @@
  */
 class agres_availability_plugin_row_node extends calendar_plugin_row_node {
 
-  // Basic properties that let the row style follow relationships.
-//  var $base_table = 'node';
-//  var $base_field = 'nid';
-  //
-//  // Stores the nodes loaded with pre_render.
-//  var $nodes = array();
-
-  /**
-   * Helper function to find the date argument handler for this view.
-   */
-//  function date_argument_handler() {
-//    foreach ($this->view->argument as $name => $handler) {
-//      if (date_views_handler_is_date($handler, 'argument')) {
-//        return $handler;
-//      }
-//    }
-//  }
-
-//  function option_definition() {
-//    $options = parent::option_definition();
-//    $options['date_fields'] = array('default' => array());
-//    $options['agres_availability_date_link'] = array('default' => '');
-//    $options['colors'] = array(
-//      'contains' => array(
-//        'legend' => array('default' => ''),
-//        'agres_availability_colors_type' => array('default' => array()),
-//        'taxonomy_field' => array('default' => ''),
-//        'agres_availability_colors_vocabulary' => array('default' => array()),
-//        'agres_availability_colors_taxonomy' => array('default' => array()),
-//        'agres_availability_colors_group' => array('default' => array()),
-//    ));
-//    return $options;
-//  }
-
   /**
-   * Provide a form for setting options.
+   * @todo Documentation
+   * @param type $values 
    */
-//  function options_form(&$form, &$form_state) {
-//    parent::options_form($form, $form_state);
-//
-//    $form['markup']['#markup'] = t("The agres_availability row plugin will format view results as agres_availability items. Make sure this display has a 'agres_availability' format and uses a 'Date' contextual filter, or this plugin will not work correctly.");
-//    $form['agres_availability_date_link'] = array(
-//      '#title' => t('Add new date link'),
-//      '#type' => 'select',
-//      '#default_value' => $this->options['agres_availability_date_link'],
-//      '#options' => array('' => t('No link')) + node_type_get_names(),
-//      '#description' => t('Display a link to add a new date of the specified content type. Displayed only to users with appropriate permissions.'),
-//      );
-//    $form['colors'] = array(
-//      '#type' => 'fieldset',
-//      '#title' => t('Legend Colors'),
-//      '#description' =>  t('Set a hex color value (like #ffffff) to use in the agres_availability legend for each content type. Items with empty values will have no stripe in the agres_availability and will not be added to the legend.'),
-//      'colorpicker' => array(
-//        '#type' => 'agres_availability_colorpicker',
-//        '#prefix' => '<div class="clear-block"><div style="float:left">',
-//        '#suffix' => '</div>',
-//      ),
-//    );
-//    $form['colors']['legend'] = array(
-//      '#title' => t('Stripes'),
-//      '#description' => t('Add stripes to agres_availability items.'),
-//      '#type' => 'select',
-//      '#options' => array('' => t('None'), 'type' => t('Based on Order status'), 'taxonomy' => t('Based on Taxonomy'), 'group' => t('Based on Organic Group')),
-//      '#default_value' => $this->options['colors']['legend'],
-//    );
-//    if (!module_exists('og')) {
-//      unset($form['colors']['legend']['#options']['group']);
-//    }
-//    $colors = $this->options['colors']['agres_availability_colors_type'];
-//    $orderconditions = array('noorder'=>'no order (manual order)',
-//                            'order'=>'Reservation has an UC order.'
-//        );
-//    foreach ($orderconditions as $key => $name) {
-//      $form['colors']['agres_availability_colors_type'][$key] = array(
-//        '#title' => $name,
-//        '#type' => 'textfield',
-//        '#default_value' => isset($colors[$key]) ? $colors[$key] : '#ffffff',
-//        '#size' => 7,
-//        '#maxlength' => 7,
-//        '#dependency' => array('edit-row-options-colors-legend' => array('type')),
-//      );
-//    }
-  //
-//    $field_options = array();
-//    $fields = $this->display->handler->get_option('fields');
-//    foreach ($fields as $name => $field) {
-//      if ($field['type'] == 'taxonomy_term_reference_link') {
-//        $field_options[$field['field']] = $field['field'];
-//      }
-//    }
-//    $form['colors']['taxonomy_field'] = array(
-//      '#title' => t('Term field'),
-//      '#type' => 'select',
-//      '#default_value' => $this->options['colors']['taxonomy_field'],
-//      '#description' => t("Select the taxonomy term field to use when setting stripe colors."),
-//      '#options' => $field_options,
-//      '#dependency' => array('edit-row-options-colors-legend' => array('taxonomy')),
-//      '#required' => TRUE,
-//      );
-//    if (empty($field_options)) {
-//      $form['colors']['taxonomy_field']['#suffix'] = t('You must add a term field to this view to use for taxonomy stripe values.');
-//    }
-  //
-//    $taxonomies = taxonomy_get_vocabularies();
-//    $options = array();
-//    foreach ($taxonomies as $vid => $vocab) {
-//      $options[$vid] = $vocab->name;
-//    }
-//    $vocabularies = $this->options['colors']['vocabulary'];
-//    $form['colors']['vocabulary'] = array(
-//      '#title' => t('Vocabulary Legend Types'),
-//      '#type' => 'checkboxes',
-//      '#default_value' => isset($vocabularies) ? $vocabularies : array(),
-//      '#multiple' => TRUE,
-//      '#options' => $options,
-//      '#description' => t('Select vocabularies to use for setting agres_availability legend colors by taxonomy term. This works best for vocabularies with only a limited number of possible terms.'),
-//      '#dependency' => array('edit-row-options-colors-legend' => array('taxonomy')),
-//      '#access' => !empty($field_options),
-//    );
-  //
-//    $vocabularies = (array) $this->options['colors']['vocabulary'];
-//    $term_colors = $this->options['colors']['term_colors'];
-//    foreach ($vocabularies as $vid) {
-//      $vocab = taxonomy_get_tree($vid);
-//      foreach ($vocab as $tid => $term) {
-//        $form['colors']['term_colors'][$term->tid] = array(
-//          '#title' => t($term->name),
-//          '#type' => 'textfield',
-//          '#default_value' => isset($term_colors[$term->tid]) ? $term_colors[$term->tid] : '#ffffff',
-//          '#size' => 7,
-//          '#maxlength' => 7,
-//          '#access' => !empty($field_options),
-//          '#dependency' => array('edit-row-options-colors-legend' => array('taxonomy')),
-//        );
-//      }
-//    }
-//    if (module_exists('og')) {
-//      $colors_group = $this->option['colors']['agres_availability_colors_group'];
-//      $groups = og_all_groups_options();
-//      foreach ($groups as $gid => $group_name){
-//        $form['colors']['agres_availability_colors_group'][$gid] = array(
-//  	      '#title' => t($group_name),
-//  	      '#type' => 'agres_availability_colorfield',
-//  	      '#default_value' => isset($colors_group[$gid]) ? $colors_group[$gid] : '#ffffff',
-//  	      '#agres_availability_colorpicker' => 'agres_availability-colors-group-colorpicker',
-//          '#dependency' => array('edit-row-options-colors-legend' => array('group')),
-//  	    );
-//  	  }
-//    }
-//  }
-
   function pre_render($values) {
 
-    // @TODO When the date is coming in through a relationship, the nid
-    // of the view is not the right node to use, then we need the related node.
-    // Need to sort out how that should be handled.
-
-    // Preload each node used in this view from the cache.
-    // Provides all the node values relatively cheaply, and we don't
-    // need to do it repeatedly for the same node if there are
-    // multiple results for one node.
+    // @todo When the date is coming in through a relationship, the nid of the 
+    // view is not the right node to use, then we need the related node. Need to 
+    // sort out how that should be handled. Preload each node used in this view 
+    // from the cache. Provides all the node values relatively cheaply, and we 
+    // do not need to do it repeatedly for the same node if there are multiple 
+    // results for one node.
     $nids = array();
     foreach ($values as $row) {
       // Use the $nid as the key so we don't create more than one value per node.
@@ -207,13 +59,13 @@ class agres_availability_plugin_row_node extends calendar_plugin_row_node {
         if ($handler->definition['handler'] != 'date_views_argument_handler') {
           $alias = $handler->table_alias . '.' . $handler->field;
           $info = $data[$alias];
-          $field_name  = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
+          $field_name = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
           $date_fields[$field_name] = $info;
         }
         else {
           foreach ($handler->options['date_fields'] as $alias) {
             $info = $data[$alias];
-            $field_name  = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
+            $field_name = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
             $date_fields[$field_name] = $info;
           }
         }
@@ -247,12 +99,12 @@ class agres_availability_plugin_row_node extends calendar_plugin_row_node {
     $rows = array();
     foreach ($this->date_fields as $field_name => $info) {
 
-      $table_name  = $info['table_name'];
+      $table_name = $info['table_name'];
       $delta_field = $info['delta_field'];
       $tz_handling = $info['tz_handling'];
-      $tz_field    = $info['timezone_field'];
+      $tz_field = $info['timezone_field'];
       $rrule_field = $info['rrule_field'];
-      $is_field = substr($info['real_field_name'], 0, 6) == 'field_';
+      $is_field = drupal_substr($info['real_field_name'], 0, 6) == 'field_';
 
       // Retrieve the field value that matched our query from the cached node.
       // Find the date and set it to the right timezone.
@@ -260,9 +112,9 @@ class agres_availability_plugin_row_node extends calendar_plugin_row_node {
       $item = $node->$field_name;
       $node->date_id = array();
       $item_start_date = NULL;
-      $item_end_date   = NULL;
+      $item_end_date = NULL;
 
-      $db_tz   = date_get_timezone_db($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
+      $db_tz = date_get_timezone_db($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
       $to_zone = date_get_timezone($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
       $granularity = 'second';
       $increment = 1;
@@ -280,18 +132,17 @@ class agres_availability_plugin_row_node extends calendar_plugin_row_node {
 
         if (!empty($item['value'])) {
           $item_start_date = new dateObject($item['value'], $db_tz);
-          $item_end_date   = array_key_exists('value2', $item) ? new dateObject($item['value2'], $db_tz) : $item_start_date;
+          $item_end_date = array_key_exists('value2', $item) ? new dateObject($item['value2'], $db_tz) : $item_start_date;
         }
 
         $cck_field = field_info_field($field_name);
         $instance = field_info_instance($this->view->base_table, $field_name, $node->type);
         $granularity = date_granularity_precision($cck_field['settings']['granularity']);
         $increment = $instance['widget']['settings']['increment'];
-
       }
       elseif (!$is_field && !empty($item)) {
         $item_start_date = new dateObject($item, $db_tz);
-        $item_end_date   = $item_start_date;
+        $item_end_date = $item_start_date;
         $node->date_id = array('agres_availability.' . $node->nid . '.' . $field_name . '.0');
       }
 
@@ -336,7 +187,6 @@ class agres_availability_plugin_row_node extends calendar_plugin_row_node {
         }
         $rows[] = $node;
       }
-
     }
 //    drupal_set_message('<pre>$rows$rows$rows '.print_r( $rows,true).'</pre>');
     return $rows;
@@ -358,7 +208,7 @@ class agres_availability_plugin_row_node extends calendar_plugin_row_node {
     // and possibly create additional nodes so that we have a 'node'
     // for each day that this item occupies in this view.
     $now = max($date_info->min_zone_string, $item_start_date->format(DATE_FORMAT_DATE));
-    $to  = min($date_info->max_zone_string, $item_end_date->format(DATE_FORMAT_DATE));
+    $to = min($date_info->max_zone_string, $item_end_date->format(DATE_FORMAT_DATE));
     $next = new DateObject($now . ' 00:00:00', $date_info->display_timezone);
     if ($date_info->display_timezone_name != $to_zone) {
       // Make $start and $end (derived from $node) use the timezone $to_zone, just as the original dates do.
@@ -419,7 +269,6 @@ class agres_availability_plugin_row_node extends calendar_plugin_row_node {
       date_modify($next, '+1 second');
       $now = date_format($next, DATE_FORMAT_DATE);
       $pos++;
-
     }
     return $rows;
   }
@@ -464,7 +313,6 @@ class agres_availability_plugin_row_node extends calendar_plugin_row_node {
   /**
    * Create a stripe based on a taxonomy term.
    */
-
   function agres_availability_node_taxonomy_stripe(&$event) {
     $term_colors = isset($this->options['colors']['term_colors']) ? $this->options['colors']['term_colors'] : array();
     if (empty($term_colors)) {
@@ -555,5 +403,5 @@ class agres_availability_plugin_row_node extends calendar_plugin_row_node {
     }
     return $stripe;
   }
-}
 
+}
\ No newline at end of file
diff --git a/agres_availability/includes/agres_availability_plugin_style.inc b/agres_availability/includes/agres_availability_plugin_style.inc
index 4b2f6c6..a5d85c9 100644
--- a/agres_availability/includes/agres_availability_plugin_style.inc
+++ b/agres_availability/includes/agres_availability_plugin_style.inc
@@ -14,18 +14,6 @@
  * Default style plugin to render an iCal feed.
  */
 class agres_availability_plugin_style extends calendar_plugin_style {
-  //
-//  var $date_info;
-//  var $items;
-//  var $curday;
-  //
-//  function init(&$view, &$display, $options = NULL) {
-//    parent::init($view, $display, $options);
-//    if (empty($view->date_info)) {
-//      $this->date_info = new stdClass();
-//    }
-//    $this->date_info = &$this->view->date_info;
-//  }
 
   /**
    * Add custom option definitions.
@@ -33,16 +21,6 @@ class agres_availability_plugin_style extends calendar_plugin_style {
   function option_definition() {
     $options = parent::option_definition();
     $options['agres_availability_type'] = array('default' => 'month');
-//    $options['name_size'] = array('default' => 3);
-//    $options['mini'] = array('default' => 0);
-//    $options['with_weekno'] = array('default' => 0);
-//    $options['multiday_theme'] = array('default' => 1);
-//    $options['theme_style'] = array('default' => 1);
-//    $options['max_items'] = array('default' => 0);
-//    $options['max_items_behavior'] = array('default' => 'more');
-//    $options['groupby_times'] = array('default' => 'hour');
-//    $options['groupby_times_custom'] = array('default' => '');
-//    $options['groupby_field'] = array('default' => '');
     return $options;
   }
 
@@ -171,64 +149,11 @@ class agres_availability_plugin_style extends calendar_plugin_style {
     );
   }
 
-//  function options_validate(&$form, &$form_state) {
-//    $values = $form_state['values']['style_options'];
-//    if ($values['groupby_times'] == 'custom' && empty($values['groupby_times_custom'])) {
-//      form_set_error('style_options][groupby_times_custom', t('Custom groupby times cannot be empty.'));
-//    }
-//    if (!empty($values['theme_style']) && empty($values['groupby_times'])) {
-//      form_set_error('style_options][theme_style', t('You cannot use overlapping items unless there are groupby times selected.'));
-//    }
-//  }
-  //
-//  /**
-//   * Helper function to find the date argument handler for this view.
-//   */
-//  function date_argument_handler() {
-//    $i = 0;
-//    foreach ($this->view->argument as $name => $handler) {
-//      if (date_views_handler_is_date($handler, 'argument')) {
-//        $this->date_info->date_arg_pos = $i;
-//        return $handler;
-//      }
-//      $i++;
-//    }
-//    return FALSE;
-//  }
-
   /**
-   * Inspect argument and view information to see which agres_availability
-   * period we should show. The argument tells us what to use
-   * if there is no value, the view args tell us what to use
-   * if there are values.
+   * @todo Documentation
+   * @return type
    */
-//  function granularity() {
-//
-//    if (!$handler = $this->date_argument_handler()) {
-//      return 'month';
-//    }
-//    $default_granularity = !empty($handler) && !empty($handler->granularity) ? $handler->granularity : 'month';
-//    $wildcard = !empty($handler) ? $handler->options['exception']['value'] : '';
-//    $argument = $handler->argument;
-  //
-//    // TODO Anything else we need to do for 'all' arguments?
-//    if ($argument == $wildcard) {
-//      $this->view_granularity = $default_granularity;
-//    }
-//    elseif (!empty($argument)) {
-//      module_load_include('inc', 'date_api', 'date_api_sql');
-  //
-//      $date_handler = new date_sql_handler();
-//      $this->view_granularity = $date_handler->arg_granularity($argument);
-//    }
-//    else {
-//      $this->view_granularity = $default_granularity;
-//    }
-//    return $this->view_granularity;
-//  }
-
   function render() {
-//      drupal_set_message('<pre>$this->row_plugin$this->row_plugin$this->row_plugin'.print_r($this->row_plugin).'</pre>');
     if (empty($this->row_plugin) || $this->row_plugin->definition['handler'] != 'agres_availability_plugin_row_node') {
       debug('agres_availability_plugin_style: Missing agres_availability row plugin');
       return;
@@ -239,7 +164,6 @@ class agres_availability_plugin_style extends calendar_plugin_style {
     }
 
     if (empty($argument->min_date)) {
-      //debug('agres_availability_plugin_style: Empty date argument');
       return;
     }
 
@@ -277,7 +201,7 @@ class agres_availability_plugin_style extends calendar_plugin_style {
     }
     $this->date_info->style_groupby_field = $this->options['groupby_field'];
 
-    // TODO make this an option setting.
+    // @todo Make this an option setting.
     $this->date_info->style_show_empty_times = !empty($this->options['groupby_times_custom']) ? TRUE : FALSE;
 
     // Set up parameters for the current view that can be used by the row plugin.
@@ -363,68 +287,62 @@ class agres_availability_plugin_style extends calendar_plugin_style {
       $this->definition['theme'] .= '_overlap';
     }
 
-    $output = theme($this->theme_functions(),
-      array(
+    $output = theme($this->theme_functions(), array(
       'view' => $this->view,
       'options' => $this->options,
       'rows' => $rows,
-    ));
+      ));
     unset($this->view->row_index);
     return $output;
   }
 
   function agres_availability_build_month() {
     $curday = $this->curday;
-    $items  = $this->items;
+    $items = $this->items;
     $view = $this->view;
     $month = date_format($curday, 'n');
-    date_modify($curday, '-' . strval(date_format($curday, 'j') -1) . ' days');
+    date_modify($curday, '-' . strval(date_format($curday, 'j') - 1) . ' days');
 
     $rows = array();
     do {
       $rows = array_merge($rows, $this->agres_availability_build_week(TRUE));
       $curday_date = date_format($curday, DATE_FORMAT_DATE);
       $curday_month = date_format($curday, 'n');
-//    drupal_set_message('<pre>$curday_month '.print_r( $curday_month,true).'</pre>');
-//    drupal_set_message('<pre>*agres_availability_build_month**'. print_r($curday_date, TRUE) .'</pre>');
     } while ($curday_month == $month && $curday_date <= $view->date_info->max_date_date);
+
     // Merge the day names in as the first row.
     $rows = array_merge(array(agres_availability_week_header($this->view)), $rows);
 
     return $rows;
   }
 
-
-
   /**
    * Build one week row.
    */
   function agres_availability_build_week($check_month = FALSE) {
     $curday_date = date_format($this->curday, DATE_FORMAT_DATE);
     $weekdays = agres_availability_untranslated_days($this->items, $this->view);
-//     drupal_set_message('<pre>$curday_month '.print_r( $this->items,true).'</pre>');
+
     $month = date_format($this->curday, 'n');
     $first_day = variable_get('date_first_day', 0);
     $week = date_week($curday_date);
     $today = date_format(date_now(date_default_timezone()), DATE_FORMAT_DATE);
+
     // Set up buckets
     $total_rows = 0;
     $multiday_buckets = array(array(), array(), array(), array(), array(), array(), array());
     $singleday_buckets = array(array(), array(), array(), array(), array(), array(), array());
 
-    // move backwards to the first day of the week
+    // Move backwards to the first day of the week
     $day_wday = date_format($this->curday, 'w');
     date_modify($this->curday, '-' . strval((7 + $day_wday - $first_day) % 7) . ' days');
 
 
     for ($i = 0; $i < 7; $i++) {
       $curday_date = date_format($this->curday, DATE_FORMAT_DATE);
-      $class = strtolower($weekdays[$i] .
-         ($this->view->style_plugin->date_info->mini ? ' mini' : ''));
-//   if ($check_month && ($curday_date < $view->date_info->min_date_date || $curday_date > $view->date_info->max_date_date || date_format($curday, 'n') != $month)) {
+      $class = drupal_strtolower($weekdays[$i] . ($this->view->style_plugin->date_info->mini ? ' mini' : ''));
       if ($check_month && ($curday_date < $this->date_info->min_date_date || $curday_date > $this->date_info->max_date_date || date_format($this->curday, 'n') != $month)) {
-
-        $class = strtolower($weekdays[$i]) . ' empty';
+        $class = drupal_strtolower($weekdays[$i]) . ' empty';
         $singleday_buckets[$i][][] = array(
           'entry' => theme('agres_availability_empty_day', array(
             'curday' => $curday_date,
@@ -450,9 +368,9 @@ class agres_availability_plugin_style extends calendar_plugin_style {
 
         $content = $this->agres_availability_build_day();
         $class .= ($curday_date == $today ? ' today' : '') .
-        ($curday_date < $today ? ' past' : '') .
-        ($curday_date > $today ? ' future' : '') .
-        (empty($items[$curday_date]) ? ' has-no-events' : ' has-events');
+          ($curday_date < $today ? ' past' : '') .
+          ($curday_date > $today ? ' future' : '') .
+          (empty($items[$curday_date]) ? ' has-no-events' : ' has-events');
       }
       $rows[$week][] = array(
         'data' => $content,
@@ -460,7 +378,6 @@ class agres_availability_plugin_style extends calendar_plugin_style {
         'id' => $this->view->name . '-' . $curday_date,
       );
       date_modify($this->curday, '+1 day');
-
     }
     return $rows;
   }
@@ -526,10 +443,9 @@ class agres_availability_plugin_style extends calendar_plugin_style {
                   if ($wday == 0 || $start_ydate == $cur_ydate || ($this->date_info->granularity == 'month' && $day_no == 1) || ($all_day && !$is_multi_day)) {
                     $cur_cnt++;
                     // Calculate the colspan for this event
-
                     // If the last day of this event exceeds the end of the current month or week,
                     // truncate the remaining days
-                    $diff =  $this->curday->difference($this->date_info->max_date, 'days');
+                    $diff = $this->curday->difference($this->date_info->max_date, 'days');
                     $remaining_days = ($this->date_info->granularity == 'month') ? min(6 - $wday, $diff) : $diff - 1;
                     // The bucket_cnt defines the colspan.  colspan = bucket_cnt + 1
                     $days = $this->curday->difference($item->date_end, 'days');
@@ -547,7 +463,7 @@ class agres_availability_plugin_style extends calendar_plugin_style {
                     }
 
                     // Add continuation attributes
-                    $item->continuation =  ($item->date_start < $this->curday);
+                    $item->continuation = ($item->date_start < $this->curday);
                     $item->continues = ( $days > $bucket_cnt );
 
                     // Assign the item to the available bucket
@@ -570,7 +486,7 @@ class agres_availability_plugin_style extends calendar_plugin_style {
 
                       // Fill up the preceding buckets - these are available for future
                       // events
-                      for ( $j = 0; $j < $row_diff; $j++) {
+                      for ($j = 0; $j < $row_diff; $j++) {
                         $bucket[($bucket_row_count + $j)] = array(
                           'entry' => '&nbsp;',
                           'colspan' => 1,
@@ -624,7 +540,6 @@ class agres_availability_plugin_style extends calendar_plugin_style {
         'item' => 'NULL',
       );
     }
-//     drupal_set_message('<pre>weeeeeekdayyyy '.print_r( $multiday_buckets,true).'</pre>');
   }
 
   /**
@@ -640,7 +555,6 @@ class agres_availability_plugin_style extends calendar_plugin_style {
     $empty = '';
     $link = '';
     $count = 0;
-//    drupal_set_message('<pre>dayday '.print_r( $this->items,true).'</pre>');
     foreach ($this->items as $date => $day) {
       if ($date == $curday_date) {
         $count = 0;
@@ -652,18 +566,9 @@ class agres_availability_plugin_style extends calendar_plugin_style {
             if (isset($item->type)) {
               $types[$item->type] = $item;
             }
-            //empty($this->date_info->mini) &&
-            if ( ($max_events == agres_availability_SHOW_ALL || $count <= $max_events || ($count > 0 && $max_events == agres_availability_HIDE_ALL))) {
+            if (($max_events == agres_availability_SHOW_ALL || $count <= $max_events || ($count > 0 && $max_events == agres_availability_HIDE_ALL))) {
               $key = date_format($item->date_start, 'H:i:s');
               $inner[$key][] = $item;
-//                drupal_set_message('<pre>dayday '.print_r( $item,true).'</pre>');
-//              if ($item->agres_availability_all_day) {
-//                $all_day[] = $item;
-//              }
-//              else {
-//                $key = date_format($item->date_start, 'H:i:s');
-//                $inner[$key][] = $item;
-//              }
             }
           }
         }
@@ -685,8 +590,7 @@ class agres_availability_plugin_style extends calendar_plugin_style {
         'count' => $count,
         'view' => $this->view,
         'types' => $types,
-      ));
-
+        ));
     }
 
     $content = array(
@@ -704,7 +608,6 @@ class agres_availability_plugin_style extends calendar_plugin_style {
     );
 
     return $content;
-
   }
 
   /**
@@ -712,22 +615,20 @@ class agres_availability_plugin_style extends calendar_plugin_style {
    */
   function agres_availability_build_mini_month() {
     $curday = $this->curday;
-    $items  = $this->items;
+    $items = $this->items;
     $view = $this->view;
     $month = date_format($curday, 'n');
-    date_modify($curday, '-' . strval(date_format($curday, 'j') -1) . ' days');
+    date_modify($curday, '-' . strval(date_format($curday, 'j') - 1) . ' days');
 
     $rows = array();
     do {
       $rows = array_merge($rows, $this->agres_availability_build_week(TRUE));
       $curday_date = date_format($curday, DATE_FORMAT_DATE);
       $curday_month = date_format($curday, 'n');
-
-//    drupal_set_message('<pre>*agres_availability_build_month**'. print_r($curday_date, TRUE) .'</pre>');
     } while ($curday_month == $month && $curday_date <= $view->date_info->max_date_date);
     // Merge the day names in as the first row.
     $rows = array_merge(array(agres_availability_week_header($this->view)), $rows);
-//  drupal_set_message('<pre>$curday_month '.print_r( $rows,true).'</pre>');
+
     return $rows;
   }
 
@@ -745,17 +646,16 @@ class agres_availability_plugin_style extends calendar_plugin_style {
     $day_wday = date_format($this->curday, 'w');
     date_modify($this->curday, '-' . strval((7 + $day_wday - $first_day) % 7) . ' days');
     $curday_date = date_format($this->curday, DATE_FORMAT_DATE);
-//
+
     for ($i = 0; $i < 7; $i++) {
       $curday_date = date_format($this->curday, DATE_FORMAT_DATE);
-      $class = strtolower($weekdays[$i] . ' mini');
+      $class = drupal_strtolower($weekdays[$i] . ' mini');
       if ($check_month && ($curday_date < $this->date_info->min_date_date || $curday_date > $this->date_info->max_date_date || date_format($this->curday, 'n') != $month)) {
         $class .= ' empty';
         $variables = array(
           'curday' => $curday_date,
           'view' => $this->view,
         );
-        drupal_set_message('<pre>agres_availability_build_mini_week ' . print_r($this->items, true) . '</pre>');
         $content = array(
           'date' => '',
           'datebox' => '',
@@ -793,4 +693,4 @@ class agres_availability_plugin_style extends calendar_plugin_style {
     return $rows;
   }
 
-}
+}
\ No newline at end of file
diff --git a/agres_availability/theme/agres-availability-day-overlap.tpl.php b/agres_availability/theme/agres-availability-day-overlap.tpl.php
index 0e88090..b12837f 100644
--- a/agres_availability/theme/agres-availability-day-overlap.tpl.php
+++ b/agres_availability/theme/agres-availability-day-overlap.tpl.php
@@ -2,7 +2,7 @@
 /**
  * @file
  * Template to display a view as a calendar day, grouped by time with overlapping items
- * 
+ *
  * @see template_preprocess_calendar_day.
  *
  * $rows: The rendered data for this day.
@@ -13,122 +13,126 @@
  * $rows['items'] - an array of timed items for the day.
  * $rows['items'][$time_period]['hour'] - the formatted hour for a time period.
  * $rows['items'][$time_period]['ampm'] - the formatted ampm value, if any for a time period.
- * $rows['items'][$time_period][$column]['values'] - An array of formatted 
+ * $rows['items'][$time_period][$column]['values'] - An array of formatted
  *   items for a time period and field column.
- * 
+ *
  * $view: The view.
  * $columns: an array of column names.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
  * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
- * 
- * The width of the columns is dynamically set using <col></col> 
+ *
+ * The width of the columns is dynamically set using <col></col>
  * based on the number of columns presented. The values passed in will
- * work to set the 'hour' column to 10% and split the remaining columns 
+ * work to set the 'hour' column to 10% and split the remaining columns
  * evenly over the remaining 90% of the table.
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
-<div class="calendar-calendar"><div class="day-view">
-<div id="multi-day-container">
-  <table class="full">
-    <tbody>
-      <tr class="holder">
-        <td class="calendar-time-holder"></td>
-        <td class="calendar-day-holder"></td>
-      </tr>
-      <tr>
-        <td class="<?php print $agenda_hour_class ?> first">
-           <span class="calendar-hour"><?php print t('All day', array(), array('context' => 'datetime')) ?></span>
-        </td>
-        <td class="calendar-agenda-items multi-day last">
-          <?php foreach ($columns as $column): ?>
-          <div class="calendar">
-            <div class="inner">
-             <?php print isset($rows['all_day'][$column]) ? implode($rows['all_day'][$column]) : '&nbsp;';?>
-            </div>
-          </div>
-          <?php endforeach; ?>   
-        </td>
-      </tr>
-    </tbody>
-  </table>
-</div>
-<div class="header-body-divider">&nbsp;</div>
-<div id="single-day-container">
-  <script>
-    try {
-  	  // Hide container while it renders...  Degrade w/o javascript support
-      jQuery('#single-day-container').css('visibility','hidden');
-    }catch(e){ 
-      // swallow 
-    }
-  </script>
-  <table class="full">
-    <tbody>
-      <tr class="holder">
-        <td class="calendar-time-holder"></td>
-        <td class="calendar-day-holder"></td>
-      </tr>
-      <tr>
-        <td class="first">
-          <?php $is_first = TRUE; ?>
-          <?php foreach ($rows['items'] as $time_cnt => $hour): ?>
-            <?php 
-              if ($time_cnt == 0) {
-                $class = 'first ';
-              }
-              elseif ($time_cnt == count($start_times) - 1) {
-                $class = 'last ';
-              }
-              else {
-                $class = '';
-              } ?>
-            <div class="<?php print $class?>calendar-agenda-hour">
-              <span class="calendar-hour"><?php print $hour['hour']; ?></span>
-              <span class="calendar-ampm"><?php print $hour['ampm']; ?></span>
-            </div>
-          <?php endforeach; ?>   
-        </td>
-        <td class="last">
-          <?php foreach ($rows['items'] as $time_cnt => $hour): ?>
-            <?php 
-              if ($time_cnt == 0) {
-                $class = 'first ';
-              }
-              elseif ($time_cnt == count($start_times) - 1) {
-                $class = 'last ';
-              }
-              else {
-                $class = '';
-              } ?>
-          <div class="<?php print $class?>calendar-agenda-items single-day">
-            <div class="half-hour">&nbsp;</div>
-            <?php if ($is_first && isset($hour['values'][$column])) :?>
-            <div class="calendar item-wrapper first_item">
-            <?php $is_first = FALSE; ?>
-            <?php else : ?>
-            <div class="calendar item-wrapper">
-            <?php endif; ?>
-              <div class="inner">
-               <?php print isset($hour['values'][$column]) ? implode($hour['values'][$column]) : '&nbsp;'; ?>
-              </div>
-            </div>
-          </div>
-          <?php endforeach; ?>   
-        </td>
-      </tr>
-    </tbody>
-  </table>
+<div class="calendar-calendar">
+  <div class="day-view">
+    <div id="multi-day-container">
+      <table class="full">
+        <tbody>
+          <tr class="holder">
+            <td class="calendar-time-holder"></td>
+            <td class="calendar-day-holder"></td>
+          </tr>
+          <tr>
+            <td class="<?php print $agenda_hour_class ?> first">
+              <span class="calendar-hour"><?php print t('All day', array(), array('context' => 'datetime')) ?></span>
+            </td>
+            <td class="calendar-agenda-items multi-day last">
+              <?php foreach ($columns as $column): ?>
+                <div class="calendar">
+                  <div class="inner">
+                    <?php print isset($rows['all_day'][$column]) ? implode($rows['all_day'][$column]) : '&nbsp;'; ?>
+                  </div>
+                </div>
+              <?php endforeach; ?>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="header-body-divider">&nbsp;</div>
+    <div id="single-day-container">
+      <script>
+        try {
+          // Hide container while it renders...  Degrade w/o javascript support
+          jQuery('#single-day-container').css('visibility','hidden');
+        }catch(e){
+          // swallow
+        }
+      </script>
+      <table class="full">
+        <tbody>
+          <tr class="holder">
+            <td class="calendar-time-holder"></td>
+            <td class="calendar-day-holder"></td>
+          </tr>
+          <tr>
+            <td class="first">
+              <?php $is_first = TRUE; ?>
+              <?php foreach ($rows['items'] as $time_cnt => $hour): ?>
+                <?php
+                if ($time_cnt == 0) {
+                  $class = 'first ';
+                }
+                elseif ($time_cnt == count($start_times) - 1) {
+                  $class = 'last ';
+                }
+                else {
+                  $class = '';
+                }
+                ?>
+                <div class="<?php print $class ?>calendar-agenda-hour">
+                  <span class="calendar-hour"><?php print $hour['hour']; ?></span>
+                  <span class="calendar-ampm"><?php print $hour['ampm']; ?></span>
+                </div>
+              <?php endforeach; ?>
+            </td>
+            <td class="last">
+              <?php foreach ($rows['items'] as $time_cnt => $hour): ?>
+                <?php
+                if ($time_cnt == 0) {
+                  $class = 'first ';
+                }
+                elseif ($time_cnt == count($start_times) - 1) {
+                  $class = 'last ';
+                }
+                else {
+                  $class = '';
+                }
+                ?>
+                <div class="<?php print $class ?>calendar-agenda-items single-day">
+                  <div class="half-hour">&nbsp;</div>
+                  <?php if ($is_first && isset($hour['values'][$column])) : ?>
+                    <div class="calendar item-wrapper first_item">
+                      <?php $is_first = FALSE; ?>
+                    <?php else : ?>
+                      <div class="calendar item-wrapper">
+                      <?php endif; ?>
+                      <div class="inner">
+                        <?php print isset($hour['values'][$column]) ? implode($hour['values'][$column]) : '&nbsp;'; ?>
+                      </div>
+                    </div>
+                  </div>
+                <?php endforeach; ?>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="single-day-footer">&nbsp;</div>
+  </div>
 </div>
-<div class="single-day-footer">&nbsp;</div>
-</div></div>
 <script>
-try {
-  // Size and position the viewport inline so there are no delays
-  calendar_resizeViewport(jQuery);
-  calendar_scrollToFirst(jQuery);
-  jQuery('#single-day-container').css('visibility','visible');
-}catch(e){ 
-  // swallow 
-}
+  try {
+    // Size and position the viewport inline so there are no delays
+    calendar_resizeViewport(jQuery);
+    calendar_scrollToFirst(jQuery);
+    jQuery('#single-day-container').css('visibility','visible');
+  }catch(e){
+    // swallow
+  }
 </script>
\ No newline at end of file
diff --git a/agres_availability/theme/agres-availability-day.tpl.php b/agres_availability/theme/agres-availability-day.tpl.php
index 187e0c0..ce5beb8 100644
--- a/agres_availability/theme/agres-availability-day.tpl.php
+++ b/agres_availability/theme/agres-availability-day.tpl.php
@@ -3,7 +3,7 @@
  * @file
  * Template to display a view as a calendar day, grouped by resources
  * and optionally organized into columns by a field value.
- * 
+ *
  * @see template_preprocess_calendar_day.
  * $resources: An Array of the rooms or resources which can be booked.
  * $resources[$name][$rows] - An array of resourcenames each containing
@@ -18,9 +18,9 @@
  * $rows['items'] - an array of timed items for the day.
  * $rows['items'][$time_period]['hour'] - the formatted hour for a time period.
  * $rows['items'][$time_period]['ampm'] - the formatted ampm value, if any for a time period.
- * $rows['items'][$time_period][$column]['values'] - An array of formatted 
+ * $rows['items'][$time_period][$column]['values'] - An array of formatted
  *   items for a time period and field column.
- * 
+ *
  * $view: The view.
  * $columns: an array of column names.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
@@ -29,108 +29,104 @@
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
-<div  class="agreservations-calendar"><div class="day-view">
-            <table class="agreservations-table">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (!isset($currentcategory)) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedday);?>"><?php print (t('show all categories')); ?></a>
-                </th>
-                <?php foreach ($categories as $category): ?>
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (isset($currentcategory)&&$currentcategory==$category->nid) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedday."/".$category->nid);?>"><?php print ($category->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>
-        <table class="agreservations-table">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (!isset($currentunittype)) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedday);?>"><?php print (t('show all units')); ?></a>
-                </th>
-                <?php foreach ($unittypes as $unittype): ?>
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (isset($currentunittype)&&$currentunittype==$unittype->nid) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedday."/".$unittype->nid);?>"><?php print ($unittype->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>
-        <table class="agreservations-table">
-              <colgroup>
-            <col width=70>
-            <col width="20">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-             <col width="15">
-             
-          </colgroup>
-            <thead >
-                <tr>
-                    <th class="agreservations-calendar-dayview-hour"></th>
-                    <?php foreach ($header_columns as $column): ?>
-                    <th class="agreservations-calendar-agenda-items" <?php print ($column['span'] > 0) ? 'colspan='. $column['span']:''; ?> >
-
-                    </th>
-                    <?php endforeach; ?>
-                </tr>
-            </thead>
-            <tbody>
-                <?php foreach ($units as $unit): ?>
-                <tr>
-                    <th class="agreservations-calendar-agenda-hour">
-                    </th>
-                        <?php foreach ($rows['items'][$unit->title] as $hour): ?>
-                    <th class="agreservations-calendar-agenda-hour">
-                        <span class="agreservations-calendar-hour"><?php print $hour['hour']; ?></span>
-                        <span <?php print $hour['ampm']; ?></span>
-                    </th>
-                        <?php endforeach; ?>
-                <tr>
-                    <td class="agreservations-calendar unitname"><a href="<?php print(base_path());?>node/<?php print $unit->nid ?>"><?php print $unit->title  ?></a>
-                    </td>
-
-                        <?php foreach ($rows['items'][$unit->title] as $hour): ?>
-                            <?php foreach ($columns as $column): ?>
-                                <?php if($hour['values'][$column] != '***busy***') : ?>
-                    <td class="agreservations-agenda-items <?php print ($hour['values'][$column])?'calendar-has-item':'';  ?>" <?php print isset($hour['span'][$column]) ? "colspan=".$hour['span'][$column] : ""; ?> >
-                        <div class="agreservations-calendar">
-<!--                            <div class="agreservations-inner">-->
-                                                <?php if(isset($hour['values'][$column])) : ?>
-                                                    <?php print isset($hour['values'][$column]) ? $hour['values'][$column] : '&nbsp;'; ?>
-                                                <?php endif; ?>
-                                                <?php if(!isset($hour['values'][$column])) : ?>
-                              <a href="<?php print(base_path());?>node/add/agreservation?&agres_sel_unit=<?php print $unit->nid ?>&default_agres_title=Reservation&default_agres_date=<?php print $currentselectedday?> <?php print $hour['hour']; ?>">+</a>
-                                
-                                                <?php endif; ?>
-<!--                            </div>-->
-                        </div>
-                    </td>
-                                <?php else: ?>
-                                <?php endif ?>
-                            <?php endforeach; ?>
-                        <?php endforeach; ?>
-                    <?php endforeach; ?>
+<div  class="agreservations-calendar">
+  <div class="day-view">
+    <table class="agreservations-table">
+      <tr class="agreservations-calendar">
+        <th class="agreservations-calendar th categories">
+          <a class="<?php print (!isset($currentcategory)) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedday); ?>"><?php print (t('show all categories')); ?></a>
+        </th>
+        <?php foreach ($categories as $category): ?>
+          <th class="agreservations-calendar th categories">
+            <a class="<?php print (isset($currentcategory) && $currentcategory == $category->nid) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedday . "/" . $category->nid); ?>"><?php print ($category->title); ?></a>
+          </th>
+        <?php endforeach; ?>
+      </tr>
+    </table>
+    <table class="agreservations-table">
+      <tr class="agreservations-calendar">
+        <th class="agreservations-calendar th unittypes">
+          <a class="<?php print (!isset($currentunittype)) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedday); ?>"><?php print (t('show all units')); ?></a>
+        </th>
+        <?php foreach ($unittypes as $unittype): ?>
+          <th class="agreservations-calendar th unittypes">
+            <a class="<?php print (isset($currentunittype) && $currentunittype == $unittype->nid) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedday . "/" . $unittype->nid); ?>"><?php print ($unittype->title); ?></a>
+          </th>
+        <?php endforeach; ?>
+      </tr>
+    </table>
+    <table class="agreservations-table">
+      <colgroup>
+        <col width=70>
+        <col width="20">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+      </colgroup>
+      <thead >
+        <tr>
+          <th class="agreservations-calendar-dayview-hour"></th>
+          <?php foreach ($header_columns as $column): ?>
+            <th class="agreservations-calendar-agenda-items" <?php print ($column['span'] > 0) ? 'colspan=' . $column['span'] : ''; ?> >
+            </th>
+          <?php endforeach; ?>
+        </tr>
+      </thead>
+      <tbody>
+        <?php foreach ($units as $unit): ?>
+          <tr>
+            <th class="agreservations-calendar-agenda-hour">
+            </th>
+            <?php foreach ($rows['items'][$unit->title] as $hour): ?>
+              <th class="agreservations-calendar-agenda-hour">
+                <span class="agreservations-calendar-hour"><?php print $hour['hour']; ?></span>
+                <span <?php print $hour['ampm']; ?></span>
+              </th>
+            <?php endforeach; ?>
+          <tr>
+            <td class="agreservations-calendar unitname"><a href="<?php print(base_path()); ?>node/<?php print $unit->nid ?>"><?php print $unit->title ?></a>
+            </td>
+            <?php foreach ($rows['items'][$unit->title] as $hour): ?>
+              <?php foreach ($columns as $column): ?>
+                <?php if ($hour['values'][$column] != '***busy***') : ?>
+                  <td class="agreservations-agenda-items <?php print ($hour['values'][$column]) ? 'calendar-has-item' : ''; ?>" <?php print isset($hour['span'][$column]) ? "colspan=" . $hour['span'][$column] : ""; ?> >
+                    <div class="agreservations-calendar">
+                      <?php if (isset($hour['values'][$column])) : ?>
+                        <?php print isset($hour['values'][$column]) ? $hour['values'][$column] : '&nbsp;'; ?>
+                      <?php endif; ?>
+                      <?php if (!isset($hour['values'][$column])) : ?>
+                        <a href="<?php print(base_path()); ?>node/add/agreservation?&agres_sel_unit=<?php print $unit->nid ?>&default_agres_title=Reservation&default_agres_date=<?php print $currentselectedday ?> <?php print $hour['hour']; ?>">+</a>
+                      <?php endif; ?>
+                    </div>
+                  </td>
+                <?php else: ?>
+                <?php endif ?>
+              <?php endforeach; ?>
+            <?php endforeach; ?>
+          <?php endforeach; ?>
 
-                </tr>
-            </tbody>
-        </table>
-    </div></div>
\ No newline at end of file
+        </tr>
+      </tbody>
+    </table>
+  </div>
+</div>
\ No newline at end of file
diff --git a/agres_availability/theme/agres-availability-item.tpl.php b/agres_availability/theme/agres-availability-item.tpl.php
index 8583b0a..bd62d1d 100644
--- a/agres_availability/theme/agres-availability-item.tpl.php
+++ b/agres_availability/theme/agres-availability-item.tpl.php
@@ -1,32 +1,29 @@
 <?php
 /**
  * @file
- *originally the calendar-item.tpl.php rewritten to display
+ * originally the calendar-item.tpl.php rewritten to display
  * agreservations in a booking calendar showing a matrix of rooms/resources
  * and days / times.
  */
 $index = 0;
 ?>
-<!--<pre><?php print_r($continues) ?></pre>-->
 <div class="<?php print !empty($item->class) ? $item->class : 'item'; ?>">
   <div class="view-item view-item-<?php print $view->name ?>">
-  <div class="<?php print !empty($itemclass) ? $itemclass : 'agreservations-inner'; ?> <?php print $item->granularity; ?>view">
-    <?php print theme('agres_availability_stripe_stripe', array('item' => $item)); ?>
-    <div class="<?php print $item->date_id ?> contents">
-               <?php if (isset($continuation) && $continuation == 1) : ?>
-             <span style="text-align:left">&laquo;&nbsp;&nbsp;&nbsp;</span>
-        <?php endif;?>
-      <?php foreach ($rendered_fields as $field): ?>
-        <?php print $field; ?>
-      <?php endforeach; ?>
-    <?php if (isset($continues) && $continues == 1) : ?>
-             
-             <span style="text-align:right">&nbsp;&nbsp;&nbsp;&raquo;</span>    
-    <?php else : ?>
-    &nbsp;
-    <?php endif;?>        
-    </div>  
-
-  </div> 
-  </div>   
+    <div class="<?php print !empty($itemclass) ? $itemclass : 'agreservations-inner'; ?> <?php print $item->granularity; ?>view">
+      <?php print theme('agres_availability_stripe_stripe', array('item' => $item)); ?>
+      <div class="<?php print $item->date_id ?> contents">
+        <?php if (isset($continuation) && $continuation == 1) : ?>
+          <span style="text-align:left">&laquo;&nbsp;&nbsp;&nbsp;</span>
+        <?php endif; ?>
+        <?php foreach ($rendered_fields as $field): ?>
+          <?php print $field; ?>
+        <?php endforeach; ?>
+        <?php if (isset($continues) && $continues == 1) : ?>
+          <span style="text-align:right">&nbsp;&nbsp;&nbsp;&raquo;</span>
+        <?php else : ?>
+          &nbsp;
+        <?php endif; ?>
+      </div>
+    </div>
+  </div>
 </div>
\ No newline at end of file
diff --git a/agres_availability/theme/agres-availability-mini.tpl.php b/agres_availability/theme/agres-availability-mini.tpl.php
index d9ed2e7..cc12bfa 100644
--- a/agres_availability/theme/agres-availability-mini.tpl.php
+++ b/agres_availability/theme/agres-availability-mini.tpl.php
@@ -2,7 +2,7 @@
 /**
  * @file
  * Template to display a view as a mini calendar month.
- * 
+ *
  * @see template_preprocess_calendar_mini.
  *
  * $day_names: An array of the day of week names for the table header.
@@ -10,10 +10,10 @@
  * $view: The view.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
  * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
- * 
+ *
  * $show_title: If the title should be displayed. Normally false since the title is incorporated
  *   into the navigation, but sometimes needed, like in the year view of mini calendars.
- * 
+ *
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);dsm($day_names);
 $params = array(
@@ -22,66 +22,65 @@ $params = array(
   'link' => FALSE,
 );
 ?>
-<div class="calendar-calendar"><?php print $yearinfo ?><div class="month-view">
-<?php if ($show_title): ?>
-<div class="date-nav-wrapper clear-block">
-  <div class="date-nav">
-    <div class="date-heading">
-      <?php print theme('date_nav_title', $params) ?>
-    </div>
-  </div>
-</div> 
-<?php endif; ?> 
-        <?php if (module_exists('agres_categories')): ?>
-      
-        <table class="mini">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (!isset($currentcategory)) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."?mini=".$currentselectedmonth);?>"><?php print (t('show all categories')); ?></a>
-                </th>
-                <?php foreach ($categories as $category): ?>
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (isset($currentcategory)&&$currentcategory==$category->nid) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."?mini=".$currentselectedmonth."&cat=".$category->nid);?>"><?php print ($category->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>
-        <?php endif; ?>    
-<table class="mini">
-  <thead>
-    <tr>
-      <?php foreach ($day_names as $cell): ?>
-        <th class="<?php print $cell['class']; ?>">
-          <?php print $cell['data']; ?>
-        </th>
-      <?php endforeach; ?>
-    </tr>
-  </thead>
-  <tbody>
-    <?php foreach ((array) $agdaysresitems as $row): ?>
-      <tr>
-        <?php foreach ($row as $cell): ?>
-          <?php if (!empty($cell['availability1'])&&$cell['availability1']==2) : ?>
-            <td id="<?php print $cell['id']; ?>" class="agres_availability_free">
-  <!--              <pre> <?php print_r($cell) ?> </pre>-->
-              <?php print $cell['data']['datebox']; ?>
-            </td>
-          <?php endif; ?>
-          <?php if (!empty($cell['availability1'])&&$cell['availability1']==1) : ?>
-            <td id="<?php print $cell['id']; ?>" class="agres_availability_partlyfree">
-  <!--              <pre> <?php print_r($cell) ?> </pre>-->
-              <?php print $cell['data']['datebox']; ?>
-            </td>
-          <?php endif; ?>
-          <?php if (!empty($cell['availability1'])&&$cell['availability1']==99) : ?>
-            <td id="<?php print $cell['id']; ?>" class="agres_availability_fullybooked">
-  <!--              <pre> <?php print_r($cell) ?> </pre>-->
-              <?php print $cell['data']['datebox']; ?>
-            </td>
-          <?php endif; ?>            
+<div class="calendar-calendar">
+  <?php print $yearinfo ?>
+  <div class="month-view">
+    <?php if ($show_title): ?>
+      <div class="date-nav-wrapper clear-block">
+        <div class="date-nav">
+          <div class="date-heading">
+            <?php print theme('date_nav_title', $params) ?>
+          </div>
+        </div>
+      </div>
+    <?php endif; ?>
+    <?php if (module_exists('agres_categories')): ?>
+      <table class="mini">
+        <tr class="agreservations-calendar">
+          <th class="agreservations-calendar th categories">
+            <a class="<?php print (!isset($currentcategory)) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "?mini=" . $currentselectedmonth); ?>"><?php print (t('show all categories')); ?></a>
+          </th>
+          <?php foreach ($categories as $category): ?>
+            <th class="agreservations-calendar th categories">
+              <a class="<?php print (isset($currentcategory) && $currentcategory == $category->nid) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "?mini=" . $currentselectedmonth . "&cat=" . $category->nid); ?>"><?php print ($category->title); ?></a>
+            </th>
+          <?php endforeach; ?>
+        </tr>
+      </table>
+    <?php endif; ?>
+    <table class="mini">
+      <thead>
+        <tr>
+          <?php foreach ($day_names as $cell): ?>
+            <th class="<?php print $cell['class']; ?>">
+              <?php print $cell['data']; ?>
+            </th>
+          <?php endforeach; ?>
+        </tr>
+      </thead>
+      <tbody>
+        <?php foreach ((array) $agdaysresitems as $row): ?>
+          <tr>
+            <?php foreach ($row as $cell): ?>
+              <?php if (!empty($cell['availability1']) && $cell['availability1'] == 2) : ?>
+                <td id="<?php print $cell['id']; ?>" class="agres_availability_free">
+                  <?php print $cell['data']['datebox']; ?>
+                </td>
+              <?php endif; ?>
+              <?php if (!empty($cell['availability1']) && $cell['availability1'] == 1) : ?>
+                <td id="<?php print $cell['id']; ?>" class="agres_availability_partlyfree">
+                  <?php print $cell['data']['datebox']; ?>
+                </td>
+              <?php endif; ?>
+              <?php if (!empty($cell['availability1']) && $cell['availability1'] == 99) : ?>
+                <td id="<?php print $cell['id']; ?>" class="agres_availability_fullybooked">
+                  <?php print $cell['data']['datebox']; ?>
+                </td>
+              <?php endif; ?>
+            <?php endforeach; ?>
+          </tr>
         <?php endforeach; ?>
-      </tr>
-    <?php endforeach; ?>
-  </tbody>
-</table>
-</div></div>
\ No newline at end of file
+      </tbody>
+    </table>
+  </div>
+</div>
\ No newline at end of file
diff --git a/agres_availability/theme/agres-availability-month.tpl.php b/agres_availability/theme/agres-availability-month.tpl.php
index 64d1cf7..71c4f38 100644
--- a/agres_availability/theme/agres-availability-month.tpl.php
+++ b/agres_availability/theme/agres-availability-month.tpl.php
@@ -2,9 +2,9 @@
 /**
  * @file
  * Template to display a view as a calendar month.
- * 
+ *
  * @see template_preprocess_calendar_month.
- * agdaysresitems agreservations 
+ * agdaysresitems agreservations
  * $day_names: An array of the day of week names for the table header.
  * $rows: An array of data for each day of the week.
  * $view: The view.
@@ -13,117 +13,90 @@
  * $block: Whether or not this calendar is in a block.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
  * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
- * $date_id: a css id that is unique for this date, 
+ * $date_id: a css id that is unique for this date,
  *   it is in the form: calendar-nid-field_name-delta
- * 
+ *
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
-<div class="agreservations-calendar"><div class="agreservations-month-view">
-        <?php if (module_exists('agres_categories')): ?>
-      
-        <table class="agreservations-table" style="float:left; text-align: left;">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (!isset($currentcategory)) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedmonth);?>"><?php print (t('show all categories')); ?></a>
-                </th>
-                <?php foreach ($categories as $category): ?>
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (isset($currentcategory)&&$currentcategory==$category->nid) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedmonth."/".$category->nid);?>"><?php print ($category->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>
-        <?php endif; ?>  
-        <table class="agreservations-table">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (!isset($currentunittype)) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedmonth."/".$currentcategory);?>"><?php print (t('show all units')); ?></a>
-                </th>
-                <?php foreach ($unittypes as $unittype): ?>
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (isset($currentunittype)&&$currentunittype==$unittype->nid) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedmonth."/".$currentcategory."/".$unittype->nid);?>"><?php print ($unittype->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>    
-<table class="agreservations-table"  style="table-layout:fixed">
-<!--  <thead>
-    <tr>
-      <?php foreach ($day_names as $cell): ?>
-        <th class="<?php print $cell['class']; ?>">
-          <?php print $cell['data']; ?>
+<div class="agreservations-calendar">
+  <div class="agreservations-month-view">
+    <?php if (module_exists('agres_categories')): ?>
+      <table class="agreservations-table" style="float:left; text-align: left;">
+        <tr class="agreservations-calendar">
+          <th class="agreservations-calendar th categories">
+            <a class="<?php print (!isset($currentcategory)) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedmonth); ?>"><?php print (t('show all categories')); ?></a>
+          </th>
+          <?php foreach ($categories as $category): ?>
+            <th class="agreservations-calendar th categories">
+              <a class="<?php print (isset($currentcategory) && $currentcategory == $category->nid) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedmonth . "/" . $category->nid); ?>"><?php print ($category->title); ?></a>
+            </th>
+          <?php endforeach; ?>
+        </tr>
+      </table>
+    <?php endif; ?>
+    <table class="agreservations-table">
+      <tr class="agreservations-calendar">
+        <th class="agreservations-calendar th unittypes">
+          <a class="<?php print (!isset($currentunittype)) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedmonth . "/" . $currentcategory); ?>"><?php print (t('show all units')); ?></a>
         </th>
-      <?php endforeach; ?>
-    </tr>
-  </thead>-->
-<!--  <tbody>-->
-   
-  <?php foreach ((array) $units as $unit): ?>
+        <?php foreach ($unittypes as $unittype): ?>
+          <th class="agreservations-calendar th unittypes">
+            <a class="<?php print (isset($currentunittype) && $currentunittype == $unittype->nid) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedmonth . "/" . $currentcategory . "/" . $unittype->nid); ?>"><?php print ($unittype->title); ?></a>
+          </th>
+        <?php endforeach; ?>
+      </tr>
+    </table>
+    <table class="agreservations-table"  style="table-layout:fixed">
+      <?php foreach ((array) $units as $unit): ?>
         <tr>
-                    <td class="agreservations-calendar unitname" rowspan="2" style="width:40px;">
-
-                        <a href="<?php print(base_path());?>node/<?php print $unit->nid ?>"><?php print $unit->title  ?></a>
-                  
-                    </td>  
-                    
-      <?php foreach ((array) $agmonth_rows[$unit->title] as $roomrow): ?>
-                     <?php if (!empty($roomrow['datebox'])) : ?>
-                    <td>                     
-                     <?php print($roomrow['datebox']);?>
-                    </td> 
-                     <?php endif; ?>  
-      <?php endforeach; ?>
+          <td class="agreservations-calendar unitname" rowspan="2" style="width:40px;">
+            <a href="<?php print(base_path()); ?>node/<?php print $unit->nid ?>"><?php print $unit->title ?></a>
+          </td>
+          <?php foreach ((array) $agmonth_rows[$unit->title] as $roomrow): ?>
+            <?php if (!empty($roomrow['datebox'])) : ?>
+              <td>
+                <?php print($roomrow['datebox']); ?>
+              </td>
+            <?php endif; ?>
+          <?php endforeach; ?>
+        <tr>
+          <?php foreach ((array) $agmonth_rows[$unit->title] as $roomrow): ?>
+            <?php if (!empty($roomrow['datebox'])) : ?>
+              <?php if (!empty($roomrow['data'])) : ?>
+                <?php foreach ((array) $roomrow['data'] as $key => $roomrowres): ?>
+                  <?php if ($roomrowres !== '***busy***') : ?>
+                    <td  <?php print isset($agmonth_rows[$unit->title]['spaninfo'][$key]) ? "colspan=" . '"' . $agmonth_rows[$unit->title]['spaninfo'][$key] . '"' : "5"; ?>>
+                      <?php print($roomrowres); ?>
+                    </td>
+                  <?php endif; ?>
+                <?php endforeach; ?>
+              <?php else: ?>
+                <td >
+                  <a href="<?php print(base_path() . rawurldecode('node/add/agreservation?&agres_sel_unit=' . $unit->nid . '&default_agres_title=Reservation&default_agres_date=' . $roomrow['date'] . ' 14:00')); ?>"> +</a>
+                </td>
+              <?php endif; ?>
+            <?php endif; ?>
+          <?php endforeach; ?>
+        </tr>
         <tr>
-  
-    <?php foreach ((array) $agmonth_rows[$unit->title] as $roomrow): ?>
-          
-          <?php if (!empty($roomrow['datebox'])) : ?>
-         
-                               <?php if (!empty($roomrow['data'])) : ?>
-
-                                 <?php foreach ((array) $roomrow['data'] as $key => $roomrowres): ?>
-          
-                                     <?php if ($roomrowres!=='***busy***') : ?>                                
-                                       <td  <?php print isset($agmonth_rows[$unit->title]['spaninfo'][$key]) ? "colspan=".'"'.$agmonth_rows[$unit->title]['spaninfo'][$key].'"' : "5"; ?>>
-<!--                                         <div class="agreservations-inner">-->
-                                            <?php print($roomrowres); ?>
-<!--                                         </div>-->
-                                        </td>
-                                     <?php endif; ?>
-                                 <?php endforeach; ?>                                                     
-                               <?php else: ?>
-                                 <td >
-                                   <a href="<?php print(base_path().rawurldecode('node/add/agreservation?&agres_sel_unit='.$unit->nid.'&default_agres_title=Reservation&default_agres_date='.$roomrow['date'].' 14:00'));?>"> +</a>                                
-                                 </td>
-                               <?php endif; ?>                              
-                  
-
-                  
-
- 
-          <?php endif; ?> 
-    <?php endforeach; ?>
-            </tr>
-            <tr>
- <?php endforeach; ?>
-<!--  </tbody>-->
-</table>
-</div></div>
-
+        <?php endforeach; ?>
+    </table>
+  </div>
+</div>
 <script>
-try {
-  // ie hack to make the single day row expand to available space
-  if ($.browser.msie ) {
-    var multiday_height = $('tr.multi-day')[0].clientHeight; // Height of a multi-day row
-    $('tr[iehint]').each(function(index) {
-      var iehint = this.getAttribute('iehint');
-      // Add height of the multi day rows to the single day row - seems that 80% height works best
-      var height = this.clientHeight + (multiday_height * .8 * iehint); 
-      this.style.height = height + 'px';
-    });
+  try {
+    // ie hack to make the single day row expand to available space
+    if ($.browser.msie ) {
+      var multiday_height = $('tr.multi-day')[0].clientHeight; // Height of a multi-day row
+      $('tr[iehint]').each(function(index) {
+        var iehint = this.getAttribute('iehint');
+        // Add height of the multi day rows to the single day row - seems that 80% height works best
+        var height = this.clientHeight + (multiday_height * .8 * iehint);
+        this.style.height = height + 'px';
+      });
+    }
+  }catch(e){
+    // swallow
   }
-}catch(e){
-  // swallow 
-}
 </script>
\ No newline at end of file
diff --git a/agres_availability/theme/agres-availability-row-node.tpl.php b/agres_availability/theme/agres-availability-row-node.tpl.php
index 0479cf2..255581d 100644
--- a/agres_availability/theme/agres-availability-row-node.tpl.php
+++ b/agres_availability/theme/agres-availability-row-node.tpl.php
@@ -2,17 +2,17 @@
 /**
  * @file
  * Template to display a view item as a calendar month node.
- * 
- * $node 
+ *
+ * $node
  *   A node object for this calendar item. Note this is
  *   not a complete node object, but it will have $node->nid
  *   that you can use to load the full object, and
  *   $node->type to tell the content type of the node.
- * 
+ *
  * $fields
  *   An array of information for every field selected in the 'Fields'
  *   section of this view, formatted as requested in the View setup.
- * 
+ *
  * Calendar info for this individual calendar item is in local time --
  * the user timezone where configurable timezones are allowed and set,
  * otherwise the site timezone. If this item has extends over more than
@@ -20,20 +20,20 @@
  * date and calendar_start will be no earlier than the start of
  * the current day and calendar_end will be no later than the end
  * of the current day.
- * 
+ *
  * $calendar_start - A formatted datetime start date for this item.
  *   i.e. '2008-05-12 05:26:15'.
  * $calendar_end - A formatted datetime end date for this item,
  *   the same as the start date except for fields that have from/to
- *   fields defined, like Date module dates. 
+ *   fields defined, like Date module dates.
  * $calendar_start_date - a PHP date object for the start time.
  * $calendar_end_date - a PHP date object for the end time.
- * 
+ *
  * You can use PHP date functions on the date object to display date
  * information in other ways, like:
- * 
+ *
  *   print date_format($calendar_start_date, 'l, j F Y - g:ia');
- * 
+ *
  * @see template_preprocess_calendar_row_node.
  */
 ?>
@@ -41,5 +41,5 @@
   <div class="<?php print $item->class; ?>">
     <?php print theme('calendar_stripe_stripe', array('node' => $item)); ?>
     <?php print $item->body; ?>
-  </div>    
+  </div>
 </div>
\ No newline at end of file
diff --git a/agres_availability/theme/agres-availability-style.tpl.php b/agres_availability/theme/agres-availability-style.tpl.php
index bdc4e8f..67c94a5 100644
--- a/agres_availability/theme/agres-availability-style.tpl.php
+++ b/agres_availability/theme/agres-availability-style.tpl.php
@@ -1 +1,2 @@
-<?php  ?>
\ No newline at end of file
+<?php
+?>
\ No newline at end of file
diff --git a/agres_availability/theme/agres-availability-week-overlap.tpl.php b/agres_availability/theme/agres-availability-week-overlap.tpl.php
index bd00106..eb7938e 100644
--- a/agres_availability/theme/agres-availability-week-overlap.tpl.php
+++ b/agres_availability/theme/agres-availability-week-overlap.tpl.php
@@ -2,12 +2,12 @@
 /**
  * @file
  * Template to display a view as a calendar week with overlapping items
- * 
+ *
  * @see template_preprocess_calendar_week.
  *
  * $day_names: An array of the day of week names for the table header.
  * $rows: The rendered data for this week.
- * 
+ *
  * For each day of the week, you have:
  * $rows['date'] - the date for this day, formatted as YYYY-MM-DD.
  * $rows['datebox'] - the formatted datebox for this day.
@@ -17,216 +17,218 @@
  * $rows['items'][$time_period]['hour'] - the formatted hour for a time period.
  * $rows['items'][$time_period]['ampm'] - the formatted ampm value, if any for a time period.
  * $rows['items'][$time_period]['values'] - An array of formatted items for a time period.
- * 
+ *
  * $view: The view.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
  * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
- * 
+ *
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
 
-<div class="calendar-calendar"><div class="week-view">
-  <div id="header-container">
-  <table class="full">
-  <tbody>
-    <tr class="holder"><td class="calendar-time-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder margin-right"></td></tr>
-    <tr>
-      <th class="calendar-agenda-hour">&nbsp;</th>
-      <?php foreach ($day_names as $cell): ?>
-        <th class="<?php print $cell['class']; ?>">
-          <?php print $cell['data']; ?>
-        </th>
-      <?php endforeach; ?>
-      <th class="calendar-day-holder margin-right"></th>
-    </tr>
-  </tbody>
-  </table>
-  </div>
-  <div id="multi-day-container">
-  <table class="full">
-  <tbody>
-  <tr class="holder"><td class="calendar-time-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td></tr>
-    <?php for ($i = 0; $i < $multiday_rows; $i++): ?>
-    <?php 
-      $colpos = 0; 
-      $rowclass = "all-day";
-      if ($i == 0) {
-        $rowclass .= " first";
-      }
-      if ($i == $multiday_rows - 1) {
-        $rowclass .= " last";
-      }
-    ?>
-    <tr class="<?php print $rowclass?>">
-      <?php if($i == 0 && ($by_hour_count > 0 || !empty($start_times))) :?>
-      <td class="<?php print $agenda_hour_class ?>" rowspan="<?php print $multiday_rows?>">
-        <span class="calendar-hour"><?php print t('All day', array(), array('context' => 'datetime'))?></span>
-      </td>
-      <?php endif; ?>
-      <?php for($j = 0; $j < 7; $j++): ?>
-        <?php $cell = (empty($all_day[$j][$i])) ? NULL : $all_day[$j][$i]; ?>
-        <?php if($cell != NULL && $cell['filled'] && $cell['wday'] == $j): ?>
-          <?php for($colpos; $colpos < $cell['wday']; $colpos++) : ?>
-          <?php 
-            $colclass = "calendar-agenda-items multi-day";
-            if ($colpos == 0) {
-              $colclass .= " first";
-            }
-            if ($colpos == 6) {
-              $colclass .= " last";
+<div class="calendar-calendar">
+  <div class="week-view">
+    <div id="header-container">
+      <table class="full">
+        <tbody>
+          <tr class="holder"><td class="calendar-time-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder margin-right"></td></tr>
+          <tr>
+            <th class="calendar-agenda-hour">&nbsp;</th>
+            <?php foreach ($day_names as $cell): ?>
+              <th class="<?php print $cell['class']; ?>">
+                <?php print $cell['data']; ?>
+              </th>
+            <?php endforeach; ?>
+            <th class="calendar-day-holder margin-right"></th>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div id="multi-day-container">
+      <table class="full">
+        <tbody>
+          <tr class="holder"><td class="calendar-time-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td></tr>
+          <?php for ($i = 0; $i < $multiday_rows; $i++): ?>
+            <?php
+            $colpos = 0;
+            $rowclass = "all-day";
+            if ($i == 0) {
+              $rowclass .= " first";
             }
-          ?>
-          <td class="<?php print $colclass?>"><div class="inner">&nbsp;</div></td>
-          <?php endfor;?>
-          <?php 
-            $colclass = "calendar-agenda-items multi-day";
-            if ($colpos == 0) {
-              $colclass .= " first";
+            if ($i == $multiday_rows - 1) {
+              $rowclass .= " last";
             }
-            if ($colpos == 6) {
-              $colclass .= " last";
-            }
-          ?>
-          <td colspan="<?php print $cell['colspan']?>" class="<?php print $colclass?>">
-            <div class="inner">
-            <?php print $cell['entry']?>
-            </div>
-          </td>
-          <?php $colpos += $cell['colspan']; ?>
-        <?php endif; ?>
-      <?php endfor; ?>  
-      <?php while($colpos < 7) : ?>
-      <?php 
-        $colclass = "calendar-agenda-items multi-day no-entry";
-        if ($colpos == 0) {
-          $colclass .= " first";
-        }
-        if ($colpos == 6) {
-          $colclass .= " last";
-        }
-      ?>
-      <td class="<?php print $colclass?>"><div class="inner">&nbsp;</div></td>
-      <?php $colpos++; ?>
-      <?php endwhile;?>
-    </tr>
-    <?php endfor; ?>
-    <?php if ($multiday_rows == 0) :?>
-    <tr>
-      <td class="<?php print $agenda_hour_class ?>">
-        <span class="calendar-hour"><?php print t('All day', array(), array('context' => 'datetime'))?></span>
-      </td>
-      <?php for($j = 0; $j < 7; $j++): ?>
-      <?php 
-        $colclass = "calendar-agenda-items multi-day no-entry";
-        if ($j == 0) {
-          $colclass .= " first";
-        }
-        if ($j == 6) {
-          $colclass .= " last";
-        }
-      ?>
-      <td class="<?php print $colclass?>"><div class="inner">&nbsp;</div></td>
-      <?php endfor; ?>
-    </tr>
-    <?php endif; ?>
-    <tr class="expand">
-      <td class="<?php print $agenda_hour_class ?>">
-        <span class="calendar-hour">&nbsp;</span>
-      </td>
-      <?php for($j = 0; $j < 7; $j++): ?>
-      <?php 
-        $colclass = "calendar-agenda-items multi-day no-entry";
-        if ($j == 0) {
-          $colclass .= " first";
-        }
-        if ($j == 6) {
-          $colclass .= " last";
-        }
-      ?>
-      <td class="<?php print $colclass?>"><div class="inner">&nbsp;</div></td>
-      <?php endfor; ?>
-     </tr>
-  </thead> 
-  </table>
-  </div>
-  <div class="header-body-divider">&nbsp;</div>
-  <div id="single-day-container">
-    <script>
-      try {
-        // Hide container while it renders...  Degrade w/o javascript support
-        jQuery('#single-day-container').css('visibility','hidden');
-      }catch(e){ 
-        // swallow 
-      }
-    </script>
-    <table class="full">
-      <tbody>
-        <tr class="holder"><td class="calendar-time-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td></tr>
-        <tr>
-          <?php for ($index = 0; $index < 8; $index++): ?>
-          <?php if ($index == 0 ): ?>
-          <td class="first">
-          <?php elseif ($index == 7 ) : ?>
-          <td class="last">
-          <?php else : ?>
-          <td>
-          <?php endif; ?>
-            <?php foreach ($start_times as $time_cnt => $start_time): ?>
-              <?php 
-                if ($time_cnt == 0) {
-                  $class = 'first ';
+            ?>
+            <tr class="<?php print $rowclass ?>">
+              <?php if ($i == 0 && ($by_hour_count > 0 || !empty($start_times))) : ?>
+                <td class="<?php print $agenda_hour_class ?>" rowspan="<?php print $multiday_rows ?>">
+                  <span class="calendar-hour"><?php print t('All day', array(), array('context' => 'datetime')) ?></span>
+                </td>
+              <?php endif; ?>
+              <?php for ($j = 0; $j < 7; $j++): ?>
+                <?php $cell = (empty($all_day[$j][$i])) ? NULL : $all_day[$j][$i]; ?>
+                <?php if ($cell != NULL && $cell['filled'] && $cell['wday'] == $j): ?>
+                  <?php for ($colpos; $colpos < $cell['wday']; $colpos++) : ?>
+                    <?php
+                    $colclass = "calendar-agenda-items multi-day";
+                    if ($colpos == 0) {
+                      $colclass .= " first";
+                    }
+                    if ($colpos == 6) {
+                      $colclass .= " last";
+                    }
+                    ?>
+                    <td class="<?php print $colclass ?>"><div class="inner">&nbsp;</div></td>
+                  <?php endfor; ?>
+                  <?php
+                  $colclass = "calendar-agenda-items multi-day";
+                  if ($colpos == 0) {
+                    $colclass .= " first";
+                  }
+                  if ($colpos == 6) {
+                    $colclass .= " last";
+                  }
+                  ?>
+                  <td colspan="<?php print $cell['colspan'] ?>" class="<?php print $colclass ?>">
+                    <div class="inner">
+                      <?php print $cell['entry'] ?>
+                    </div>
+                  </td>
+                  <?php $colpos += $cell['colspan']; ?>
+                <?php endif; ?>
+              <?php endfor; ?>
+              <?php while ($colpos < 7) : ?>
+                <?php
+                $colclass = "calendar-agenda-items multi-day no-entry";
+                if ($colpos == 0) {
+                  $colclass .= " first";
+                }
+                if ($colpos == 6) {
+                  $colclass .= " last";
                 }
-                elseif ($time_cnt == count($start_times) - 1) {
-                  $class = 'last ';
+                ?>
+                <td class="<?php print $colclass ?>"><div class="inner">&nbsp;</div></td>
+                <?php $colpos++; ?>
+              <?php endwhile; ?>
+            </tr>
+          <?php endfor; ?>
+          <?php if ($multiday_rows == 0) : ?>
+            <tr>
+              <td class="<?php print $agenda_hour_class ?>">
+                <span class="calendar-hour"><?php print t('All day', array(), array('context' => 'datetime')) ?></span>
+              </td>
+              <?php for ($j = 0; $j < 7; $j++): ?>
+                <?php
+                $colclass = "calendar-agenda-items multi-day no-entry";
+                if ($j == 0) {
+                  $colclass .= " first";
                 }
-                else {
-                  $class = '';
-                } ?>
-              <?php if( $index == 0 ): ?>
-              <?php $time = $items[$start_time];?>
-              <div class="<?php print $class?>calendar-agenda-hour">
-                <span class="calendar-hour"><?php print $time['hour']; ?></span>
-                <span class="calendar-ampm"><?php print $time['ampm']; ?></span>
-              </div>
-              <?php else: ?>
-              <div class="<?php print $class?>calendar-agenda-items single-day">
-                <div class="half-hour">&nbsp;</div>
-                <div class="calendar item-wrapper">
-                  <div class="inner">
-                    <?php if(!empty($items[$start_time]['values'][$index - 1])) :?>
-                      <?php foreach($items[$start_time]['values'][$index - 1] as $item) :?>
-                        <?php if (isset($item['is_first']) && $item['is_first']) :?>
-                        <div class="item <?php print $item['class']?> first_item">
-                        <?php else : ?>
-                        <div class="item <?php print $item['class']?>">
-                        <?php endif; ?>
-                        <?php print $item['entry'] ?>
+                if ($j == 6) {
+                  $colclass .= " last";
+                }
+                ?>
+                <td class="<?php print $colclass ?>"><div class="inner">&nbsp;</div></td>
+              <?php endfor; ?>
+            </tr>
+          <?php endif; ?>
+          <tr class="expand">
+            <td class="<?php print $agenda_hour_class ?>">
+              <span class="calendar-hour">&nbsp;</span>
+            </td>
+            <?php for ($j = 0; $j < 7; $j++): ?>
+              <?php
+              $colclass = "calendar-agenda-items multi-day no-entry";
+              if ($j == 0) {
+                $colclass .= " first";
+              }
+              if ($j == 6) {
+                $colclass .= " last";
+              }
+              ?>
+              <td class="<?php print $colclass ?>"><div class="inner">&nbsp;</div></td>
+            <?php endfor; ?>
+          </tr>
+          </thead>
+      </table>
+    </div>
+    <div class="header-body-divider">&nbsp;</div>
+    <div id="single-day-container">
+      <script>
+        try {
+          // Hide container while it renders...  Degrade w/o javascript support
+          jQuery('#single-day-container').css('visibility','hidden');
+        }catch(e){
+          // swallow
+        }
+      </script>
+      <table class="full">
+        <tbody>
+          <tr class="holder"><td class="calendar-time-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td></tr>
+          <tr>
+            <?php for ($index = 0; $index < 8; $index++): ?>
+              <?php if ($index == 0): ?>
+                <td class="first">
+                <?php elseif ($index == 7) : ?>
+                <td class="last">
+                <?php else : ?>
+                <td>
+                <?php endif; ?>
+                <?php foreach ($start_times as $time_cnt => $start_time): ?>
+                  <?php
+                  if ($time_cnt == 0) {
+                    $class = 'first ';
+                  }
+                  elseif ($time_cnt == count($start_times) - 1) {
+                    $class = 'last ';
+                  }
+                  else {
+                    $class = '';
+                  }
+                  ?>
+                  <?php if ($index == 0): ?>
+                    <?php $time = $items[$start_time]; ?>
+                    <div class="<?php print $class ?>calendar-agenda-hour">
+                      <span class="calendar-hour"><?php print $time['hour']; ?></span>
+                      <span class="calendar-ampm"><?php print $time['ampm']; ?></span>
+                    </div>
+                  <?php else: ?>
+                    <div class="<?php print $class ?>calendar-agenda-items single-day">
+                      <div class="half-hour">&nbsp;</div>
+                      <div class="calendar item-wrapper">
+                        <div class="inner">
+                          <?php if (!empty($items[$start_time]['values'][$index - 1])) : ?>
+                            <?php foreach ($items[$start_time]['values'][$index - 1] as $item) : ?>
+                              <?php if (isset($item['is_first']) && $item['is_first']) : ?>
+                                <div class="item <?php print $item['class'] ?> first_item">
+                                <?php else : ?>
+                                  <div class="item <?php print $item['class'] ?>">
+                                  <?php endif; ?>
+                                  <?php print $item['entry'] ?>
+                                </div>
+                              <?php endforeach; ?>
+                            <?php endif; ?>
+                          </div>
                         </div>
-                      <?php endforeach; ?>
+                      </div>
                     <?php endif; ?>
-                  </div>
-                </div>
-              </div>
-              <?php endif; ?>
-            <?php endforeach;?>
-          </td>
-          <?php endfor;?>
-        </tr>
-      </tbody>
-    </table>
-  </div>
-  <div class="single-day-footer">&nbsp;</div>
-</div></div>
+                  <?php endforeach; ?>
+              </td>
+            <?php endfor; ?>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="single-day-footer">&nbsp;</div>
+  </div></div>
 <script>
-try {
-  // Size and position the viewport inline so there are no delays
-  calendar_resizeViewport(jQuery);
-  calendar_scrollToFirst(jQuery);
+  try {
+    // Size and position the viewport inline so there are no delays
+    calendar_resizeViewport(jQuery);
+    calendar_scrollToFirst(jQuery);
 
-  // Show it now that it is complete and positioned
-  jQuery('#single-day-container').css('visibility','visible');
-}catch(e){ 
-  // swallow 
-}
+    // Show it now that it is complete and positioned
+    jQuery('#single-day-container').css('visibility','visible');
+  }catch(e){
+    // swallow
+  }
 </script>
\ No newline at end of file
diff --git a/agres_availability/theme/agres-availability-week.tpl.php b/agres_availability/theme/agres-availability-week.tpl.php
index 5671ff3..9e4d99b 100644
--- a/agres_availability/theme/agres-availability-week.tpl.php
+++ b/agres_availability/theme/agres-availability-week.tpl.php
@@ -27,80 +27,71 @@
 //dsm($rows);
 //dsm($items);//currentunittype calendarname
 ?>
-<div class="agreservations-calendar"><div class="week-view">
-        <table class="agreservations-table">       
-          <thead>
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (!isset($currentcategory)) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedweek);?>"><?php print (t('show all categories')); ?></a>
-                </th>
-                <?php foreach ($categories as $category): ?>
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (isset($currentcategory)&&$currentcategory==$category->nid) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedweek."/".$category->nid);?>"><?php print ($category->title); ?></a>
-                </th>
+<div class="agreservations-calendar">
+  <div class="week-view">
+    <table class="agreservations-table">
+      <thead>
+        <tr class="agreservations-calendar">
+          <th class="agreservations-calendar th categories">
+            <a class="<?php print (!isset($currentcategory)) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedweek); ?>"><?php print (t('show all categories')); ?></a>
+          </th>
+          <?php foreach ($categories as $category): ?>
+            <th class="agreservations-calendar th categories">
+              <a class="<?php print (isset($currentcategory) && $currentcategory == $category->nid) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedweek . "/" . $category->nid); ?>"><?php print ($category->title); ?></a>
+            </th>
+          <?php endforeach; ?>
+        </tr>
+    </table>
+    <table class="agreservations-table">
+      <tr class="agreservations-calendar">
+        <th class="agreservations-calendar th unittypes">
+          <a class="<?php print (!isset($currentunittype)) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedweek . "/" . $currentcategory); ?>"><?php print (t('show all units')); ?></a>
+        </th>
+        <?php foreach ($unittypes as $unittype): ?>
+          <th class="agreservations-calendar th unittypes">
+            <a class="<?php print (isset($currentunittype) && $currentunittype == $unittype->nid) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedweek . "/" . $currentcategory . "/" . $unittype->nid); ?>"><?php print ($unittype->title); ?></a>
+          </th>
+        <?php endforeach; ?>
+      </tr>
+    </table>
+    <table class="agreservations-table">
+      <tr>
+        <th class="agreservations-calendar"><?php print $by_hour_count > 0 ? t('units') : ''; ?></th>
+        <?php foreach ($day_names as $cell): ?>
+          <th class="agreservations-calendar">
+            <?php print $cell['data']; ?>
+          </th>
+        <?php endforeach; ?>
+      </tr>
+      </thead>
+      <tbody>
+        <?php foreach ($units as $unit): ?>
+          <tr>
+            <td class="agreservations-calendar">
+              <a href="<?php print(base_path()); ?>node/<?php print $unit->nid ?>"><?php print $unit->title ?></a>
+              <span class="agreservations-calendar-hour"></span>
+            </td>
+            <?php foreach ($rows as $diw => $day): ?>
+              <?php if (isset($day['night'][$unit->title])) : ?>
+                <?php foreach ($day['night'][$unit->title] as $itemnid => $unitbookings): ?>
+                  <?php if (isset($day['night'][$unit->title][$itemnid])) : ?>
+                    <?php if (($day['night'][$unit->title][$itemnid]) !== '***busy***') : ?>
+                      <td class="agreservations-calendar-agenda-items" <?php print isset($spaninfo[$unit->title][$itemnid]) ? "colspan=" . $spaninfo[$unit->title][$itemnid] : ""; ?> >
+                        <?php print ($day['night'][$unit->title][$itemnid]); ?>
+                      </td>
+                    <?php endif; ?>
+                  <?php endif; ?>
                 <?php endforeach; ?>
-            </tr>
-        </table> 
-        <table class="agreservations-table">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (!isset($currentunittype)) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedweek."/".$currentcategory);?>"><?php print (t('show all units')); ?></a>
-                </th>
-                <?php foreach ($unittypes as $unittype): ?>
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (isset($currentunittype)&&$currentunittype==$unittype->nid) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedweek."/".$currentcategory."/".$unittype->nid);?>"><?php print ($unittype->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>
-       <table class="agreservations-table">
-                <tr>
-                    <th class="agreservations-calendar"><?php print $by_hour_count > 0 ? t('units') : ''; ?></th>
-                    <?php foreach ($day_names as $cell): ?>
-                    <th class="agreservations-calendar">
-                            <?php print $cell['data']; ?>
-                    </th>
-                    <?php endforeach; ?>
-                </tr>
-            </thead> <!--<?php print $cell['class']; ?>-->
-            
-            
-            <tbody>
-                <?php foreach ($units as $unit): ?>
-                <tr>
-                    <td class="agreservations-calendar">
-
-                        <a href="<?php print(base_path());?>node/<?php print $unit->nid ?>"><?php print $unit->title  ?></a>
-                        <span class="agreservations-calendar-hour"></span>
-                    </td>
-                    
-                       <?php foreach ($rows as $diw=>$day): ?>               
-                                            
-                                    <?php if (isset($day['night'][$unit->title])) : ?>
-                                        <?php foreach ($day['night'][$unit->title] as $itemnid => $unitbookings): ?>
-                      
-                                            <?php if (isset($day['night'][$unit->title][$itemnid])) : ?>
-                                                <?php if (($day['night'][$unit->title][$itemnid])!=='***busy***') : ?>
-                                                  <td class="agreservations-calendar-agenda-items" <?php print isset($spaninfo[$unit->title][$itemnid]) ? "colspan=".$spaninfo[$unit->title][$itemnid] : ""; ?> >
-<!--                                                  <div class="agreservations-inner">-->
-                                                  <?php print ($day['night'][$unit->title][$itemnid]);?>
-<!--                                                    </div>-->
-                                                  </td>
-                                                  <?php endif; ?>
-                                            <?php endif; ?>
-                                        <?php endforeach; ?>
-                                    <?php else: ?>
-                                     <td class="agreservations-calendar-agenda-items">
-                                       <?php print ($day['datebox']);?>
-                                       <a href="<?php print(base_path());?>node/add/agreservation?&agres_sel_unit=<?php print $unit->nid ?>&default_agres_title=Reservation&default_agres_date=<?php print$day['date']?> 14:00 ">+</a>
-<!--                                       <a href="<?php print(base_path());?>node/add/agreservation?&agres_sel_unit=<?php print $unit->nid ?>&default_agres_title=Reservation&default_agres_date=<?php print$day['date']?> 14:00 ">+</a>-->
-                          
-                                  </td>
-                                   <?php endif; ?>           
-                        <?php endforeach; ?>
-                </tr>
-                <?php endforeach; ?>
-                            </tbody>
-        </table>
-
-    </div></div>
\ No newline at end of file
+              <?php else: ?>
+                <td class="agreservations-calendar-agenda-items">
+                  <?php print ($day['datebox']); ?>
+                  <a href="<?php print(base_path()); ?>node/add/agreservation?&agres_sel_unit=<?php print $unit->nid ?>&default_agres_title=Reservation&default_agres_date=<?php print$day['date'] ?> 14:00 ">+</a>
+                </td>
+              <?php endif; ?>
+            <?php endforeach; ?>
+          </tr>
+        <?php endforeach; ?>
+      </tbody>
+    </table>
+  </div>
+</div>
\ No newline at end of file
diff --git a/agres_availability/theme/agres-availability-year.tpl.php b/agres_availability/theme/agres-availability-year.tpl.php
index 32d9d17..4a1529d 100644
--- a/agres_availability/theme/agres-availability-year.tpl.php
+++ b/agres_availability/theme/agres-availability-year.tpl.php
@@ -2,25 +2,27 @@
 /**
  * @file
  * Template to display a view as a calendar year.
- * 
+ *
  * @see template_preprocess_calendar_year.
  *
  * $view: The view.
  * $months: An array with a formatted month calendar for each month of the year.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
  * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
- * 
+ *
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
 
-<div class="calendar-calendar"><div class="year-view">
-<table <?php if ($mini): ?> class="mini"<?php endif; ?>>
-  <tbody>
-    <tr><td><?php print $months[1] ?></td><td><?php print $months[2] ?></td><td><?php print $months[3] ?></td></tr>  
-    <tr><td><?php print $months[4] ?></td><td><?php print $months[5] ?></td><td><?php print $months[6] ?></td></tr>  
-    <tr><td><?php print $months[7] ?></td><td><?php print $months[8] ?></td><td><?php print $months[9] ?></td></tr>  
-    <tr><td><?php print $months[10] ?></td><td><?php print $months[11] ?></td><td><?php print $months[12] ?></td></tr>  
-  </tbody>
-</table>
-</div></div>
\ No newline at end of file
+<div class="calendar-calendar">
+  <div class="year-view">
+    <table <?php if ($mini): ?> class="mini"<?php endif; ?>>
+      <tbody>
+        <tr><td><?php print $months[1] ?></td><td><?php print $months[2] ?></td><td><?php print $months[3] ?></td></tr>
+        <tr><td><?php print $months[4] ?></td><td><?php print $months[5] ?></td><td><?php print $months[6] ?></td></tr>
+        <tr><td><?php print $months[7] ?></td><td><?php print $months[8] ?></td><td><?php print $months[9] ?></td></tr>
+        <tr><td><?php print $months[10] ?></td><td><?php print $months[11] ?></td><td><?php print $months[12] ?></td></tr>
+      </tbody>
+    </table>
+  </div>
+</div>
\ No newline at end of file
diff --git a/agres_availability/theme/agres_availability-month-col.tpl.php b/agres_availability/theme/agres_availability-month-col.tpl.php
index 0979460..84c120c 100644
--- a/agres_availability/theme/agres_availability-month-col.tpl.php
+++ b/agres_availability/theme/agres_availability-month-col.tpl.php
@@ -2,13 +2,13 @@
 /**
  * @file
  * Template to display a column
- * 
+ *
  * - $item: The item to render within a td element.
  */
 $id = (isset($item['id'])) ? 'id="' . $item['id'] . '" ' : '';
 $date = (isset($item['date'])) ? 'date="' . $item['date'] . '" ' : '';
 ?>
-<td <?php print $id?>class="<?php print $item['class'] ?>" colspan="<?php print $item['colspan'] ?>" rowspan="<?php print $item['rowspan'] ?>"<?php print $date ?>>
+<td <?php print $id ?>class="<?php print $item['class'] ?>" colspan="<?php print $item['colspan'] ?>" rowspan="<?php print $item['rowspan'] ?>"<?php print $date ?>>
   <div class="inner">
     <?php print $item['entry'] ?>
   </div>
diff --git a/agres_availability/theme/agres_availability-month-row.tpl.php b/agres_availability/theme/agres_availability-month-row.tpl.php
index 28c53b7..8f5e8a3 100644
--- a/agres_availability/theme/agres_availability-month-row.tpl.php
+++ b/agres_availability/theme/agres_availability-month-row.tpl.php
@@ -2,16 +2,16 @@
 /**
  * @file
  * Template to display a row
- * 
+ *
  * - $inner: The rendered string of the row's contents.
  */
-$attrs = ($class) ? 'class="' . $class . '"': '';
+$attrs = ($class) ? 'class="' . $class . '"' : '';
 $attrs .= ($iehint > 0) ? ' iehint="' . $iehint . '"' : '';
 ?>
-<?php if ($attrs != ''):?>
-<tr <?php print $attrs?>>
-<?php else:?>
-<tr>
-<?php endif;?>
+<?php if ($attrs != ''): ?>
+  <tr <?php print $attrs ?>>
+  <?php else: ?>
+  <tr>
+  <?php endif; ?>
   <?php print $inner ?>
 </tr>
diff --git a/agres_availability/theme/theme.inc b/agres_availability/theme/theme.inc
index ceceb5e..2f0bb64 100644
--- a/agres_availability/theme/theme.inc
+++ b/agres_availability/theme/theme.inc
@@ -1,40 +1,9 @@
 <?php
-/**
- * additional themingfunctions for agreservations and booking agres_availability
- */
-
 
 /**
- * Format the time row headings in the week and day view.
+ * @file
+ *  Additional themingfunctions for agreservations and booking agres_availability
  */
-//function theme_agres_availability_time_row_heading($start_time, $next_start_time, $curday_date) {
-//  static $format_hour, $format_ampm;
-//  if (empty($format_hour)) {
-////    $format = //variable_get('date_format_short', 'm/d/Y - H:i');
-//    $format =  'm/d/Y - H:i';
-////    $format_hour = str_replace(array('a', 'A'), '', date_limit_format($format, array('hour', 'minute')));
-//    $format_hour = str_replace(array('a', 'A'), '', date_limit_format($format, array('hour', 'minute')));
-//    $format_ampm = strstr($format, 'a') ? 'a' : (strstr($format, 'A') ? 'A' : '');
-//  }
-//  if ($start_time == '00:00:00' && $next_start_time == '23:59:59') {
-//    $hour = t('All');
-//  }
-//  elseif ($start_time == '00:00:00') {
-//    $date = date_create($curday_date .' '. $next_start_time);
-//    $hour = t('< @time', array('@time' => date_format($date, $format_hour)));
-//  }
-//  else {
-//    $date = date_create($curday_date .' '. $start_time);
-//    $hour = date_format($date, $format_hour);
-//  }
-//  if (!empty($date)) {
-//    $ampm = date_format($date, $format_ampm);
-//  }
-//  else {
-//    $ampm = '';
-//  }
-//  return array('hour' => $hour, 'ampm' => $ampm);
-//}
 
 /**
  * Implements hook_preprocess_date_views_pager().
@@ -51,7 +20,7 @@ function agres_availability_preprocess_date_views_pager(&$vars) {
   }
   $options = $view->style_options;
 
-  // If we're not on a view with a path (a page), no links are needed.
+  // If we are not on a view with a path (a page), no links are needed.
   $current_path = !empty($view->display_handler->options['path']) ? $view->display_handler->options['path'] : '';
   if (empty($current_path)) {
     return;
@@ -70,10 +39,11 @@ function agres_availability_preprocess_date_views_pager(&$vars) {
       $title = $display->display_title;
       $type = !empty($display->display_options['style_options']['agres_availability_type']) ? $display->display_options['style_options']['agres_availability_type'] : 'month';
 
-      // Make sure the links to other agres_availability displays use the right path for that display.
-      // Get rid of pager links when swapping between displays to force the base argument
-      // to be structured correctly for the type of display. This means you can't use
-      // these links in a block or panel.
+      // Make sure the links to other agres_availability displays use the right
+      // path for that display. Get rid of pager links when swapping between
+      // displays to force the base argument to be structured correctly for the
+      // type of display. This means you cannot use these links in a block
+      // or panel.
       $href = str_replace($current_path, $path, date_pager_url($view, $type, NULL, TRUE, FALSE));
       $part_path = str_replace(base_path(), '', $href);
 
@@ -89,7 +59,7 @@ function agres_availability_preprocess_date_views_pager(&$vars) {
 
   // If an 'Add new ... link is provided, add it here.
   if (!empty($view->date_info->agres_availability_date_link) && !empty($view->date_info->url)
-   && (user_access("administer nodes") || user_access('create ' . $view->date_info->agres_availability_date_link . ' content'))) {
+    && (user_access("administer nodes") || user_access('create ' . $view->date_info->agres_availability_date_link . ' content'))) {
     $name = node_type_get_name($view->date_info->agres_availability_date_link);
     $href = 'node/add/' . str_replace('_', '-', $view->date_info->agres_availability_date_link);
     $agres_availability_links[$current_path]['actions'][] = array(
@@ -102,76 +72,14 @@ function agres_availability_preprocess_date_views_pager(&$vars) {
   drupal_alter('agres_availability_links', $agres_availability_links);
   // Add the value to the session so it can be used to create the tabs.
   $_SESSION['agres_availability_links'][$current_path] = $agres_availability_links[$current_path];
-
 }
 
-///**
-// * Add agres_availability links above the pager.
-// */
-//function agres_availability_preprocess_date_views_pager(&$vars) {
-//  $view = $vars['plugin']->view;
-//  if ($view->plugin_name != 'agres_availability_style') {
-//    return;
-//  }
-//  $options = $view->style_options;
-//
-//  // If we're not on a view with a path (a page), no links are needed.
-//  $current_path = !empty($view->display_handler->options['path']) ? $view->display_handler->options['path'] : '';
-//  if (empty($current_path)) {
-//    return;
-//  }
-//
-//  // Find all the displays in this view that use the agres_availability style and have a path and create links to each.
-//  $agres_availability_links = array();
-//  $base = array('attributes' => array('rel' => 'nofollow'));
-//  foreach($view->display as $id => $display) {
-//    if ($display->display_options['style_plugin'] == 'agres_availability_style' && !empty($display->display_options['path'])) {
-//      $path = $display->display_options['path'];
-//      $title = $display->display_title;
-//      // @TODO Why is this sometimes empty for a style that uses the default value?
-//      $type = !empty($display->display_options['style_options']['agres_availability_type']) ? $display->display_options['style_options']['agres_availability_type'] : 'month';
-//
-//      // Make sure the links to other agres_availability displays use the right path for that display.
-//      // Get rid of pager links when swapping between displays to force the base argument
-//      // to be structured correctly for the type of display. This means you can't use
-//      // these links in a block or panel.
-//      $href = str_replace($current_path, $path, date_pager_url($view, $type, NULL, TRUE));
-//
-//      // Once we have a path for the links to other displays, add it to our links array.
-//      $agres_availability_links['agres_availability agres_availability-'. $type] = array('title' => $title, 'href' => $href);
-//    }
-//  }
-//
-//  // If an 'Add new ... link is provided, add it here.
-//  // the query will bring the user back here after adding the node.
-//  if (!empty($view->date_info->agres_availability_date_link)
-//  && (user_access("administer nodes") || user_access('create '. $view->date_info->agres_availability_date_link .' content'))) {
-//    $name = node_type_get_name($view->date_info->agres_availability_date_link);
-//    $href = 'node/add/' . str_replace('_', '-', $view->date_info->agres_availability_date_link);
-//    $query = drupal_get_query_parameters(array('destination' => $view->date_info->url));
-//    $agres_availability_links['agres_availability agres_availability-add'] = $base + array(
-//      'title' => t('Add+'),
-//      'href' => $href,
-//      'query' => $query,
-//      );
-//  }
-//
-//  // Append the agres_availability links above the pager.
-//  $links = array(
-//    'links' => $agres_availability_links,
-//    'attributes' => array('class' => array('agres_availability-links', 'inline')),
-//  );
-//  $vars['pager_prefix'] = theme('links', $links);
-//}
-
 /**
  * Preprocess an RSS feed
  */
 function template_preprocess_agres_availability_style(&$vars) {
-//    drupal_set_message('<pre>monthtemplate_preprocess_agres_availability_style '.print_r( $vars,true).'</pre>');
   global $base_url;
   global $language;
-
 }
 
 /**
@@ -179,7 +87,6 @@ function template_preprocess_agres_availability_style(&$vars) {
  */
 function template_preprocess_agres_availability_month(&$vars) {
 
-
   $view = $vars['view'];
   $rows = $vars['rows'];
 
@@ -192,10 +99,7 @@ function template_preprocess_agres_availability_month(&$vars) {
   }
   $month_rows = $rows;
 
-  /*      * **************setup categories and unittypes:******************************************
-   *
-   */
-//  drupal_set_message('<pre>*or**'. print_r($view, TRUE) .'</pre>');
+  // Setup categories and unittypes
   $vars['unittypes'] = '';
   $countarg = count($view->args);
 
@@ -206,12 +110,10 @@ function template_preprocess_agres_availability_month(&$vars) {
     }
     $vars['currentcategory'] = '';
     if (isset($view->args[1]) && $view->args[1]) {
-//         drupal_set_message('<pre>bis hier' . print_r($vars['unittypes'], true) . '</pre>');
       $unittypes = _agres_categories_get_unittypenodes_of_category($view->args[1]);
       $vars['currentcategory'] = $view->args[1];
       $categories = _agres_categories_get_categories(TRUE);
       if (isset($view->args[2]) && $view->args[2]) {
-//        $units = _agreservations_get_unitnodes($view->args[2]);
         $units = _agres_categories_get_unitnodes_of_category($view->args[2], $view->args[1]);
         $vars['currentunittype'] = $view->args[2];
       }
@@ -223,7 +125,6 @@ function template_preprocess_agres_availability_month(&$vars) {
     else {
 
       $unittypes = _agres_categories_get_unittypenodes_of_category();
-//        drupal_set_message('<pre>bis else'.print_r($unittypes,true).'</pre>');
       $categories = _agres_categories_get_categories(TRUE);
       $units = _agreservations_get_unitnodes();
     }
@@ -233,35 +134,28 @@ function template_preprocess_agres_availability_month(&$vars) {
       $view->args = array_slice($view->args, 0, 2);
     }
     if (isset($view->args[1])) {
-//        drupal_set_message('<pre>*view->args[1]view->args[1]**'. print_r($vars['view']->name, TRUE) .'</pre>');
       $units = _agreservations_get_unitnodes($view->args[1]);
       $vars['currentunittype'] = $view->args[1];
     }
     else {
       $units = _agreservations_get_unitnodes();
-//        drupal_set_message('<pre>*elseelseelse]**'. print_r($units, TRUE) .'</pre>');
     }
     $unittypes = _agreservations_get_unittypenodes();
   }
-  //remove the args from agrescurrentpath:
-
 
+  // Remove the args from agrescurrentpath:
   $toremovefrompath = implode("/", $view->args);
   $agrescurrentpath = get_current_path();
   $agrescurrentpath = str_replace($toremovefrompath, "", $agrescurrentpath);
-  //cut off trailing slash:
-
 
-  if (substr($agrescurrentpath, -1, 1) == "/") {
-    $agrescurrentpath = substr($agrescurrentpath, 0, strlen($agrescurrentpath) - 1);
+  // Cut off trailing slash:
+  if (drupal_substr($agrescurrentpath, -1, 1) == "/") {
+    $agrescurrentpath = drupal_substr($agrescurrentpath, 0, drupal_strlen($agrescurrentpath) - 1);
   }
-//    drupal_set_message('<pre>*orig**'. print_r($agrescurrentpath, TRUE) .'</pre>');
-
 
   $vars['agrescurrentpath'] = $agrescurrentpath;
 
-//    drupal_set_message('<pre>*orig**'. print_r($rows, TRUE) .'</pre>');
-  //step1: all in 1 array:
+  // Step #1: All in one array
   $agdaysresitems = array();
   $agmonth_rows = array();
   foreach ($rows as $weekno => $row) {
@@ -272,8 +166,7 @@ function template_preprocess_agres_availability_month(&$vars) {
   }
 
   $agmonth_rows['rinfo'] = array();
-  //step2 organize in unit arrays:
-//     drupal_set_message('<pre>*orig**'. print_r($agdaysresitems, TRUE) .'</pre>');
+  // Step #2: Organize in unit arrays
   foreach ($units as $unit) {
     $agmonth_rows['rinfo'][$unit->title] = array();
 
@@ -283,47 +176,43 @@ function template_preprocess_agres_availability_month(&$vars) {
       $date = $agdayresitem['data']['date'];
       $agmonth_rows[$unit->title][$day]['datebox'] = $data;
       $agmonth_rows[$unit->title][$day]['date'] = $date;
-//         drupal_set_message('<pre>*$day**'. print_r($date, TRUE) .'</pre>');
 
       foreach ($agdayresitem['data']['items'] as $time => $hour) {
-//             drupal_set_message('<pre>*orig**'. print_r($time, TRUE) .'</pre>');
-        //foreach reservation objet node in the hour DO:
+        // For each reservation object node in the hour
         foreach ($hour as $resob) {
           if (!isset($agmonth_rows[$unit->title][$day]['resitm'][$resob->nid])) {
             $agmonth_rows[$unit->title][$day]['resitm'][$resob->nid] = '0';
           }
 
-
           $continues = 0;
           $continuation = 0;
 
-          $tmpunititems = _agreservations_get_unitn_for_reservation_node($resob->nid); //get units per reservation
-          if (in_array($unit->nid, $tmpunititems)) {
-            $tmpEnd = date_create($resob->row->field_field_agres_rdate[0]['raw']['value2']);
-            $tmpGranularityEnd = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
-            if ($tmpEnd > $tmpGranularityEnd) {
+          // Get units per reservation
+          $temp_unit_items = _agreservations_get_unitn_for_reservation_node($resob->nid);
+          if (in_array($unit->nid, $temp_unit_items)) {
+            $temp_end = date_create($resob->row->field_field_agres_rdate[0]['raw']['value2']);
+            $temp_granularity_end = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
+            if ($temp_end > $temp_granularity_end) {
               $continues = 1;
-
             }
             else {
               $continues = 0;
-//                  drupal_set_message('<pre>*$continues = 0;**'. print_r(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME), TRUE) .'</pre>');
             }
-            $tmpstart = date_create($resob->row->field_field_agres_rdate[0]['raw']['value']);
-            $tmpGranularitystart = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
-            if ($tmpstart < $tmpGranularitystart) {
+            $temp_start = date_create($resob->row->field_field_agres_rdate[0]['raw']['value']);
+            $temp_granularity_start = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
+            if ($temp_start < $temp_granularity_start) {
               $continuation = 1;
             }
             else {
               $continuation = 0;
             }
 
-            $itemclass = 'itemwithoutorder';
+            $item_class = 'itemwithoutorder';
             if (!isset($resob->node->field_agres_orderid[$resob->node->language])) {
-              $itemclass = 'itemwithoutorder'; //treat as receptionist manual reservation defaultcolor orange
+              $item_class = 'itemwithoutorder'; //treat as receptionist manual reservation defaultcolor orange
             }
             else {
-              $itemclass = 'itemwithorder'; //treat as receptionist manual reservation defaultcolor blue
+              $item_class = 'itemwithorder'; //treat as receptionist manual reservation defaultcolor blue
             }
             if ((!isset($agmonth_rows[$unit->title]['spaninfo'][$resob->nid]) || (empty($agmonth_rows[$unit->title]['spaninfo'][$resob->nid])))) {
               $theme = 'calendar_month_node';
@@ -337,60 +226,51 @@ function template_preprocess_agres_availability_month(&$vars) {
                 'item' => $resob,
                 'continues' => $continues,
                 'continuation' => $continuation,
-                'itemclass' => $itemclass,
+                'itemclass' => $item_class,
               );
 
               $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = '';
               $agmonth_rows[$unit->title]['spaninfo'][$resob->nid] = 1;
               $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = theme('agres_availability_item', $themeparams); //theme($theme, $variables); //$resob->rendered['nid'];
               //only the first:
-              $agmonth_rows[$unit->title][$day]['data'] = array_slice($agmonth_rows[$unit->title][$day]['data'], 0, 1, true);
+              $agmonth_rows[$unit->title][$day]['data'] = array_slice($agmonth_rows[$unit->title][$day]['data'], 0, 1, TRUE);
             }
             else {
               $endpos = strpos($resob->row->field_field_agres_rdate[0]['raw']['value2'], $agmonth_rows[$unit->title][$day]['date'], 0); //strpos($resob->raw->field_data_field_agres_rdate_field_agres_rdate_value2, $agmonth_rows[$unit->title][$day]['date'], 0);
               if (empty($agmonth_rows[$unit->title][$day]['data'][$resob->nid])) {
-                if ($endpos === false) {
+                if ($endpos === FALSE) {
                   $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = '***busy***';
                   $agmonth_rows[$unit->title]['spaninfo'][$resob->nid] += 1;
                 }
-                else {
-//                          $agmonth_rows[$unit->title][$day]['data'][$resob->id] = '***busy***';
-//                          $agmonth_rows[$unit->title]['spaninfo'][$resob->id] = +1;
-                }
-              }
-              else {
-
               }
             }
           }
         }
       }
-      /////////////////////////////ALL DAY///////////////////////////////////////////////
+      // All Day!
       if (isset($agdayresitem['data']['all_day'])) {
         foreach ($agdayresitem['data']['all_day'] as $resob) {
-          //foreach reservation objet node in the hour DO:
+          // For each reservation object node in the hour
           if (!isset($agmonth_rows[$unit->title][$day]['resitm'][$resob->nid])) {
             $agmonth_rows[$unit->title][$day]['resitm'][$resob->nid] = '0';
           }
 
-          $tmpunititems = _agreservations_get_unitn_for_reservation_node($resob->nid); //get units per reservation
-          if (in_array($unit->nid, $tmpunititems)) {
-            $itemclass = 'itemwithoutorder';
+          $temp_unit_items = _agreservations_get_unitn_for_reservation_node($resob->nid); //get units per reservation
+          if (in_array($unit->nid, $temp_unit_items)) {
+            $item_class = 'itemwithoutorder';
             $continues = 0;
             $continuation = 1;
-            $tmpEnd = date_create($resob->row->field_field_agres_rdate[0]['raw']['value2']);
-            $tmpGranularityEnd = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
-            if ($tmpEnd > $tmpGranularityEnd) {
+            $temp_end = date_create($resob->row->field_field_agres_rdate[0]['raw']['value2']);
+            $temp_granularity_end = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
+            if ($temp_end > $temp_granularity_end) {
               $continues = 1;
-
             }
             else {
               $continues = 0;
-//                  drupal_set_message('<pre>*$continues = 0;**'. print_r(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME), TRUE) .'</pre>');
             }
-            $tmpstart = date_create($resob->row->field_field_agres_rdate[0]['raw']['value']);
-            $tmpGranularitystart = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
-            if ($tmpstart < $tmpGranularitystart) {
+            $temp_start = date_create($resob->row->field_field_agres_rdate[0]['raw']['value']);
+            $temp_granularity_start = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
+            if ($temp_start < $temp_granularity_start) {
               $continuation = 1;
             }
             else {
@@ -398,10 +278,12 @@ function template_preprocess_agres_availability_month(&$vars) {
             }
 
             if (!isset($resob->node->field_agres_orderid[$resob->node->language])) {
-              $itemclass = 'itemwithoutorder'; //treat as receptionist manual reservation defaultcolor orange
+              // Treat as receptionist manual reservation defaultcolor orange
+              $item_class = 'itemwithoutorder';
             }
             else {
-              $itemclass = 'itemwithorder'; //treat as receptionist manual reservation defaultcolor blue
+              // Treat as receptionist manual reservation defaultcolor blue
+              $item_class = 'itemwithorder';
             }
             if ((!isset($agmonth_rows[$unit->title]['spaninfo'][$resob->nid]) || (empty($agmonth_rows[$unit->title]['spaninfo'][$resob->nid])))) {
               $theme = 'calendar_month_node';
@@ -415,35 +297,24 @@ function template_preprocess_agres_availability_month(&$vars) {
                 'item' => $resob,
                 'continues' => $continues,
                 'continuation' => $continuation,
-                'itemclass' => $itemclass,
+                'itemclass' => $item_class,
               );
               $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = '';
               $agmonth_rows[$unit->title]['spaninfo'][$resob->nid] = 1;
               $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = theme('agres_availability_item', $themeparams); //$resob->rendered['nid'];
             }
             else {
-
-//                     drupal_set_message('<pre>'.print_r($resob,true).'<---->'.print_r(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME),true).'</pre>');
-//                     drupal_set_message('<pre>day:'.$day.'itm:'.$resob->nid.'sonst '.print_r($resob,true).'</pre>');
               $endpos = strpos($resob->row->field_field_agres_rdate[0]['raw']['value2'], $agmonth_rows[$unit->title][$day]['date'], 0);
               if (empty($agmonth_rows[$unit->title][$day]['data'][$resob->nid])) {
-                if ($endpos === false) {
+                if ($endpos === FALSE) {
                   $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = '***busy***';
                   $agmonth_rows[$unit->title]['spaninfo'][$resob->nid] += 1;
                 }
-                else {
-//                          $agmonth_rows[$unit->title][$day]['data'][$resob->id] = '***busy***';
-//                          $agmonth_rows[$unit->title]['spaninfo'][$resob->id] = +1;
-                }
-              }
-              else {
-
               }
             }
           }
         }
       }
-      ///////////////////////////////////////////////////////////////////////////////////
     }
   }
 
@@ -462,7 +333,6 @@ function template_preprocess_agres_availability_month(&$vars) {
   if (module_exists('agres_categories')) {
     $vars['categories'] = $categories;
   }
-//    $vars['template_file'] = 'agres_availability-calendar-month-c';
   $path = drupal_get_path('module', 'agres_availability');
   $vars['directory'] = $path . '/theme';
 }
@@ -471,109 +341,112 @@ function template_preprocess_agres_availability_month(&$vars) {
  * Display a mini month view.
  */
 function template_preprocess_agres_availability_mini(&$vars) {
-     // Add in all the $vars added by the main agres_availability preprocessor.
-     //$data['availability1'] = 2  ---> all free
-     //$data['availability1'] = 1  ---> partly booked/partly free
-     //$data['availability1'] = 99 ---> all booked
-     //$data['availability1'] =    ---> no reservations that day
-     template_preprocess_agres_availability_month($vars);
-
-     $view = $vars['view'];
-     if (empty($view->exposed_input['mini'])) {
-       $vars['yearinfo'] = $view->args[0];
-     } else {
-       $vars['yearinfo'] = $vars['view']->exposed_input['mini'];
-     }
-     $rows = $vars['rows'];
-  
+  // Add in all the $vars added by the main agres_availability preprocessor.
+  // $data['availability1'] = 2  ---> all free
+  // $data['availability1'] = 1  ---> partly booked/partly free
+  // $data['availability1'] = 99 ---> all booked
+  // $data['availability1'] =    ---> no reservations that day
+  template_preprocess_agres_availability_month($vars);
+
+  $view = $vars['view'];
+  if (empty($view->exposed_input['mini'])) {
+    $vars['yearinfo'] = $view->args[0];
+  }
+  else {
+    $vars['yearinfo'] = $vars['view']->exposed_input['mini'];
+  }
+  $rows = $vars['rows'];
+
   $vars['unittypes'] = '';
   $countarg = count($view->args);
-  if (isset($_REQUEST["cat"])){
+  if (isset($_REQUEST["cat"])) {
     $unitnodes = _agres_categories_get_unitnodes_of_category(NULL, $_REQUEST["cat"]);
   }
   else {
     $unitnodes = _agreservations_get_unitnodes();
   }
-  //remove the args from agrescurrentpath:
+  // Remove the args from agrescurrentpath
   $toremovefrompath = implode("/", $view->args);
   $agrescurrentpath = get_current_path();
   $agrescurrentpath = str_replace($toremovefrompath, "", $agrescurrentpath);
-  //cut off trailing slash:
-  if (substr($agrescurrentpath, -1, 1) == "/") {
-    $agrescurrentpath = substr($agrescurrentpath, 0, strlen($agrescurrentpath) - 1);
+  // Cut off trailing slash
+  if (drupal_substr($agrescurrentpath, -1, 1) == "/") {
+    $agrescurrentpath = drupal_substr($agrescurrentpath, 0, drupal_strlen($agrescurrentpath) - 1);
   }
   $vars['agrescurrentpath'] = $agrescurrentpath;
-//     $unitnodes = _agreservations_get_unitnodes();
-     $cntunit = count($unitnodes);
-     $agdaysresitems = array();
-     $agmonth_rows = array();
-
-     foreach ($vars['rows'] as $weekno => $row) {
-       foreach ($row as $day => $data) {
-         if (count($data['data']['items']) == 0) {
-           if ($cntunit > 0) {
-             $data['availability1'] = 2;
-           } else {
-             $data['availability1'] = 99;
-           }
-
-           $agdaysresitems[$weekno][$data['id']] = $data;
-         } else {
-           if ($cntunit > 0) {
-             $unodespday = array();
-             foreach ($data['data']['items'] as $reservationsday) {
-               ////date timezonehandling handling:
-               foreach ($reservationsday as $reservation) {
-                 $notadd = false;
-                 if (isset($reservation->node->field_agres_rdate)) {
-                   foreach ($reservation->node->field_agres_rdate as $country => $resdates) {
-                     foreach ($resdates as $resdate) {
-                       $dateTimezone1 = new DateTimeZone($resdate['timezone']);
-                       $resenddate = new DateTime($resdate['value2'], $dateTimezone1);
-                       $offset = $resenddate->getOffset();
-                       $offset = $offset * 1;
-                       $resenddate->modify($offset . 'seconds');
-                       $datobj = new DateTime($data['data']['date'], $dateTimezone1);
-                       if (strpos($resenddate->format('Y-m-d H:i:s'), $datobj->format('Y-m-d')) !== false) {
-                         $notadd = true;
-                       }
-                     }
-                   }
-                   if ($notadd == false) {
-                     foreach ($reservation->node->field_agres_ref_unit as $country => $unodenodes) {
-                       foreach ($unodenodes as $unode) {
-
-                         $unodespday[] = $unode;
-                       }
-                     }
-                   }
-                 }
-               }
-             }
-             if ($cntunit > count($unodespday)) {
-               $data['availability1'] = 1; //partly free
-             } else {
-               $data['availability1'] = 99; //booked
-             }
-             $agdaysresitems[$weekno][$data['id']] = $data;
-//               drupal_set_message('<pre>ddddddddddddddd'.print_r($unodespday,true).'</pre>');
-           } else {
-             $data['availability1'] = 99;
-             $agdaysresitems[$weekno][$data['id']] = $data;
-           }
-         }
-//         $agdaysresitems[$data['id']] =
-       }
-     }
-
-     // Make sure that the agres_availability title links go to the month view,
-     // not the year view (if this is embedded in a year display).
-     $view->override_path = agres_availability_granularity_path($view, 'month');
-     $vars['agdaysresitems'] = $agdaysresitems;
-     $view->date_info->show_title = !empty($view->date_info->show_title) ? $view->date_info->show_title : FALSE;
-     $vars['show_title'] = $view->date_info->show_title;
-     $vars['view'] = $view;
-   }
+  $cntunit = count($unitnodes);
+  $agdaysresitems = array();
+  $agmonth_rows = array();
+
+  foreach ($vars['rows'] as $weekno => $row) {
+    foreach ($row as $day => $data) {
+      if (count($data['data']['items']) == 0) {
+        if ($cntunit > 0) {
+          $data['availability1'] = 2;
+        }
+        else {
+          $data['availability1'] = 99;
+        }
+
+        $agdaysresitems[$weekno][$data['id']] = $data;
+      }
+      else {
+        if ($cntunit > 0) {
+          $unodespday = array();
+          foreach ($data['data']['items'] as $reservationsday) {
+            // Date and Timezone handling:
+            foreach ($reservationsday as $reservation) {
+              $notadd = FALSE;
+              if (isset($reservation->node->field_agres_rdate)) {
+                foreach ($reservation->node->field_agres_rdate as $country => $resdates) {
+                  foreach ($resdates as $resdate) {
+                    $date_timezone_1 = new DateTimeZone($resdate['timezone']);
+                    $resenddate = new DateTime($resdate['value2'], $date_timezone_1);
+                    $offset = $resenddate->getOffset();
+                    $offset = $offset * 1;
+                    $resenddate->modify($offset . 'seconds');
+                    $datobj = new DateTime($data['data']['date'], $date_timezone_1);
+                    if (strpos($resenddate->format('Y-m-d H:i:s'), $datobj->format('Y-m-d')) !== FALSE) {
+                      $notadd = TRUE;
+                    }
+                  }
+                }
+                if ($notadd == FALSE) {
+                  foreach ($reservation->node->field_agres_ref_unit as $country => $unodenodes) {
+                    foreach ($unodenodes as $unode) {
+                      $unodespday[] = $unode;
+                    }
+                  }
+                }
+              }
+            }
+          }
+          if ($cntunit > count($unodespday)) {
+            // Partly free
+            $data['availability1'] = 1;
+          }
+          else {
+            // Booked
+            $data['availability1'] = 99;
+          }
+          $agdaysresitems[$weekno][$data['id']] = $data;
+        }
+        else {
+          $data['availability1'] = 99;
+          $agdaysresitems[$weekno][$data['id']] = $data;
+        }
+      }
+    }
+  }
+
+  // Make sure that the agres_availability title links go to the month view,
+  // not the year view (if this is embedded in a year display).
+  $view->override_path = agres_availability_granularity_path($view, 'month');
+  $vars['agdaysresitems'] = $agdaysresitems;
+  $view->date_info->show_title = !empty($view->date_info->show_title) ? $view->date_info->show_title : FALSE;
+  $vars['show_title'] = $view->date_info->show_title;
+  $vars['view'] = $view;
+}
 
 /**
  * Display a year view.
@@ -609,7 +482,6 @@ function template_preprocess_agres_availability_year(&$vars) {
   $vars['view']->date_info->hide_nav = FALSE;
   $vars['view']->date_info->granularity = 'year';
   $vars['mini'] = $view->date_info->mini;
-
 }
 
 /**
@@ -623,7 +495,6 @@ function template_preprocess_agres_availability_day_overlap(&$vars) {
 function template_preprocess_agres_availability_day(&$vars) {
   // Get rid of visual duplicates.
   $vars['view']->style_with_weekno = FALSE;
-//       template_preprocess_calendar($vars);
   $view = $vars['view'];
   $rows = $vars['rows'];
   $show_empty_times = $view->date_info->style_show_empty_times;
@@ -639,8 +510,6 @@ function template_preprocess_agres_availability_day(&$vars) {
       $vars['currentcategory'] = $view->args[1];
       $categories = _agres_categories_get_categories(TRUE);
       if (isset($view->args[2]) && $view->args[2]) {
-
-//        $units = _agreservations_get_unitnodes($view->args[2]);
         $units = _agres_categories_get_unitnodes_of_category($view->args[2], $view->args[1]);
         $vars['currentunittype'] = $view->args[2];
       }
@@ -668,13 +537,13 @@ function template_preprocess_agres_availability_day(&$vars) {
     }
     $unittypes = _agreservations_get_unittypenodes();
   }
-  //remove the args from agrescurrentpath:
+  // Remove the args from agrescurrentpath
   $toremovefrompath = implode("/", $view->args);
   $agrescurrentpath = get_current_path();
   $agrescurrentpath = str_replace($toremovefrompath, "", $agrescurrentpath);
-  //cut off trailing slash:
-  if (substr($agrescurrentpath, -1, 1) == "/") {
-    $agrescurrentpath = substr($agrescurrentpath, 0, strlen($agrescurrentpath) - 1);
+  // Cut off trailing slash
+  if (drupal_substr($agrescurrentpath, -1, 1) == "/") {
+    $agrescurrentpath = drupal_substr($agrescurrentpath, 0, drupal_strlen($agrescurrentpath) - 1);
   }
   $vars['agrescurrentpath'] = $agrescurrentpath;
 
@@ -684,24 +553,19 @@ function template_preprocess_agres_availability_day(&$vars) {
   $spanning_items = array(); //test
   $r = 0;
 
-//      drupal_set_message("<pre>gfcjcghgjgchj".print_r($rows,TRUE)."</pre>");
-  foreach ($units as $unit) { //loop through all units
+  // Loop through all units
+  foreach ($units as $unit) {
     foreach ($rows['all_day'] as $itmkey => $item) {
-
-      $tmpunititems = _agreservations_get_unitn_for_reservation_node($item->nid); //get units of reservation
-//           drupal_set_message("<pre>gfcjcghgjgchj".print_r($tmpunititems,TRUE)."</pre>");
-      if (in_array($unit->nid, $tmpunititems)) { //if unit is in reserved units
+      // Get units of reservation
+      $tmpunititems = _agreservations_get_unitn_for_reservation_node($item->nid);
+      // If unit is in reserved units
+      if (in_array($unit->nid, $tmpunititems)) {
         $column = t('Items');
         $theme = isset($item->calendar_node_theme) ? $item->calendar_node_theme : 'calendar_' . $view->date_info->granularity . '_node';
-        //add the rendered items to the unit in the calendarmatrix
-//        if (count($unit->actualitems[$column])==0) {
-//            drupal_set_message("<pre>gfcjcghgjgchj".print_r($item->nid,TRUE)."</pre>");
-//             $unit->actualitems['Items'][] = theme('agres_availability_item', array('view' => $view, 'rendered_fields' => $event[0]->rendered_fields, 'item' => $event[0])); //test// l(t("res:$item->nid"), "node/$item->nid", array('query' => drupal_get_destination()));
+        // Add the rendered items to the unit in the calendarmatrix
         $spanning_items[$column][] = theme($theme, $item, $view); //test
-        //theme($theme, $item, $view);!!!"""§§§
         $item_count++;
       }
-//      }
     }
   }
 
@@ -712,63 +576,45 @@ function template_preprocess_agres_availability_day(&$vars) {
   $end_start_time = '23:59:59';
   $grouped_items = array();
   $timeslots = $view->date_info->style_groupby_times;
-//       drupal_set_message('<pre>'.print_r($timeslots,TRUE).'</pre>');
   array_push($timeslots, $end_start_time);
-//  drupal_set_message('<pre>'.print_r($timeslots,TRUE).'</pre>');
   $timeslots_count = count($timeslots);
-  //drupal_set_message("<pre>***timeslots_count**".print_r($timeslots_count,TRUE)."</pre>");
-  //translate rows into better format
+  // Translate rows into better format
   $events = $rows['items'];
-//       drupal_set_message("<pre>gfcjcghgjgchj".print_r($events,TRUE)."</pre>");
   foreach ($units as $unit) {
     $grouped_items[$unit->title] = array();
     foreach ($events as $elemkey => $event) {
-
-      ////    if ($event->calendar_all_day) continue; // skip all day events.
-      $group_key = isset($event->raw->{$grouping_field}) ? $event->raw->{$grouping_field} : t('Items'); // get initial value as formatted one already blanked
-//
+      // Get initial value as formatted one already blanked
+      $group_key = isset($event->raw->{$grouping_field}) ? $event->raw->{$grouping_field} : t('Items');
       $key = $group_key . '-' . 0;
       $columns["$group_key"] = array();
-      if (!($columns["$group_key"])) { // init group on first encounter
+      // Init group on first encounter
+      if (!($columns["$group_key"])) {
         $columns["$group_key"][] = $group_key . '-0';
       }
-//            settype($event->date_end,"DateTime");
-//             drupal_set_message('<pre>$event  '.print_r($event,TRUE).'</pre>');
-//             drupal_set_message('<pre>event g '.print_r($event,TRUE).'</pre>');
-      //IF EVENTDATE < DAYCALENDARDATESTART:
-      $tmpGranularityEnd = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
-      if ($event[0]->date_start < $tmpGranularityEnd) {
+
+      // If EVENTDATE < DAYCALENDARDATESTART:
+      $temp_granularity_end = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
+      if ($event[0]->date_start < $temp_granularity_end) {
         $event_start = '00:00:00';
       }
       else {
         $event_start = $event[0]->date_start->format('H:i:s');
       }
-      $tmpGranularityEnd = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
-      if ($event[0]->date_end > $tmpGranularityEnd) {
+      $temp_granularity_end = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
+      if ($event[0]->date_end > $temp_granularity_end) {
         $event_end = '23:59:59';
       }
       else {
         $event_end = $event[0]->date_end->format('H:i:s');
       }
-//                       $tmpEnd = date_create($resob->row->field_field_agres_rdate[0]['raw']['value2']);
-//                       $tmpGranularityEnd = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
-//                       if($tmpEnd > $tmpGranularityEnd){
-//                           $continues = 1;
-//                       }else{
-//                          $continues = 0;
-//                       }
-//
-//           drupal_set_message("<pre>calendar_start_date  ".print_r($event_start,TRUE)."</pre>");
-//           $event_end = $event[0]->date_end->format('H:i:s');
-//            drupal_set_message('<pre>event g '.print_r($event_end,TRUE).'</pre>');
       $i = 0;
-      $tmpunititems = _agreservations_get_unitn_for_reservation_node($event[0]->nid); //get units of reservation
+      // Get units of reservation
+      $tmpunititems = _agreservations_get_unitn_for_reservation_node($event[0]->nid);
       if (in_array($unit->nid, $tmpunititems)) {
         for ($slot = 0; $slot < $timeslots_count; $slot++) {
-          if ($event_start >= $timeslots[$slot] &&
-                       $event_end <= $timeslots[$slot + 1]) { // one slot event
-//                 $theme = isset($event->calendar_node_theme) ? $event->calendar_node_theme : 'calendar_' . $view->date_info->granularity . '_node';
-            // find free column to use
+          // One slot event
+          if ($event_start >= $timeslots[$slot] && $event_end <= $timeslots[$slot + 1]) {
+            // Find free column to use
             $found = FALSE;
             foreach ($columns["$group_key"] as $ckey => $column) {
               $key = $group_key . '-' . $ckey;
@@ -779,17 +625,17 @@ function template_preprocess_agres_availability_day(&$vars) {
             }
             if (!$found) {
               $key = $group_key . '-' . (count($columns[$group_key]));
-              $columns["$group_key"][] = $key; // add new column
+              // Add new column
+              $columns["$group_key"][] = $key;
             }
 
             $grouped_items[$unit->title][$timeslots[$slot]]['values']["$key"] = theme('agres_availability_item', array('view' => $view, 'rendered_fields' => $event[0]->rendered_fields, 'item' => $event[0])); // theme($theme, $event, $view);
-
           }
-          elseif ($event_start >= $timeslots[$slot] &&
-                       $event_start < $timeslots[$slot + 1] &&
-                       $event_end > $timeslots[$i + 1]) { // first slot of multi slot event
+          // First slot of multi slot event
+          elseif ($event_start >= $timeslots[$slot] && $event_start < $timeslots[$slot + 1] && $event_end > $timeslots[$i + 1]) {
+
             $theme = isset($event->calendar_node_theme) ? $event->calendar_node_theme : 'calendar_' . $view->date_info->granularity . '_node';
-            // find free column to use
+            // Find free column to use
             $found = FALSE;
             foreach ($columns["$group_key"] as $ckey => $column) {
               $key = $group_key . '-' . $ckey;
@@ -800,20 +646,23 @@ function template_preprocess_agres_availability_day(&$vars) {
             }
             if (!$found) {
               $key = $group_key . '-' . (count($columns["$group_key"]));
-              $columns["$group_key"][] = $key; // add new column
+              // Add new column
+              $columns["$group_key"][] = $key;
             }
 
             $span = $timeslots[$slot];
             $grouped_items[$unit->title][$timeslots[$slot]]['values']["$key"] = theme('agres_availability_item', array('view' => $view, 'rendered_fields' => $event[0]->rendered_fields, 'item' => $event[0])); // theme($theme, $event, $view);
             $grouped_items[$unit->title][$timeslots[$slot]]['span']["$key"] = 1;
           }
+          // Middle of end slot of event
           elseif ($event_start < $timeslots[$slot] &&
-                  $event_end > $timeslots[$slot]) { // middle of end slot of event
+            $event_end > $timeslots[$slot]) {
             $grouped_items[$unit->title][$span]['span']["$key"]++;
             $grouped_items[$unit->title][$timeslots[$slot]]['values']["$key"] = '***busy***';
           }
-          else { // empty slot
-            //$grouped_items[$timeslots[$slot]]['values']["$key"] = '';
+          // Empty slot
+          else {
+
           }
         }
       }
@@ -832,7 +681,6 @@ function template_preprocess_agres_availability_day(&$vars) {
         'curday_date' => $rows['date'],
       );
       $heading = theme('agres_availability_time_row_heading', $variables);
-//            drupal_set_message('<pre>dsfg'.print_r($heading,TRUE).'</pre>');
       $grouped_items[$unit->title][$start_time]['hour'] = $heading['hour'];
       $grouped_items[$unit->title][$start_time]['ampm'] = $heading['ampm'];
       $i++;
@@ -841,7 +689,7 @@ function template_preprocess_agres_availability_day(&$vars) {
     ksort($grouped_items[$unit->title]);
     ksort($grouped_items);
   }
-//  drupal_set_message('<pre>dsfg'.print_r($grouped_items,TRUE).'</pre>');
+
   $vars['rows']['items'] = $grouped_items;
   if (empty($columns)) {
     $header_columns[t('Items')]['title'] = t('Items');
@@ -852,7 +700,7 @@ function template_preprocess_agres_availability_day(&$vars) {
     foreach ($columns as $group_key => $group_column) {
       $header_columns[$group_key]['title'] = $group_key;
       $header_columns[$group_key]['span'] = count($group_column);
-      // also span all days events
+      // Also span all days events
       $vars['rows']['all_day'][$group_key]['span'] = count($group_column);
       foreach ($group_column as $column) {
         $flat_columns[] = $column;
@@ -872,17 +720,16 @@ function template_preprocess_agres_availability_day(&$vars) {
   $vars['units'] = $units;
   $vars['unittypes'] = $unittypes;
   $vars['calendarname'] = $view->name;
-//  $vars['first_column_width'] = 22;
-  // add small javascript to extend datebox to whole td height
+
+  // Add small javascript to extend datebox to whole td height
   drupal_add_js(
-               "Drupal.behaviors.myEventBehavior = function(context){
+    "Drupal.behaviors.myEventBehavior = function(context){
       $('.agreservations-calendar td.agreservations-agenda-items div.agreservations div.view-item').each( function(){
         // Just a dirty fix. I have no idea how to properly calculate weight for this element
         var width = Math.max(($(this).parents('td').width())-5, $(this).width());
         $(this).width(width);
         });
-    };",
-               "inline");
+    };", "inline");
   $modulepath = drupal_get_path('module', 'agreservations');
   $vars['template_file'] = 'agreservations-calendar-day-2';
   if (module_exists('agres_categories')) {
@@ -890,15 +737,13 @@ function template_preprocess_agres_availability_day(&$vars) {
     $vars['categories'] = $categories;
   }
   return;
-
 }
 
-
 /**
  * Display a day view.
  */
 function template_preprocess_agres_availability_day_old(&$vars) {
-  //drupal_set_message('<pre>dayday '.print_r( $vars['rows'],true).'</pre>');
+
   $vars['view']->style_with_weekno = FALSE;
   $view = $vars['view'];
   $rows = $vars['rows'];
@@ -911,7 +756,7 @@ function template_preprocess_agres_availability_day_old(&$vars) {
   // Add optional css
   if ($display_overlap) {
     $overlapped_items = array();
-    drupal_add_css(drupal_get_path('module', 'agres_availability')  . '/css/agres_availability-overlap.css');
+    drupal_add_css(drupal_get_path('module', 'agres_availability') . '/css/agres_availability-overlap.css');
     if (empty($view->live_preview)) {
       drupal_add_js(drupal_get_path('module', 'agres_availability') . '/js/agres_availability_overlap.js');
     }
@@ -930,22 +775,6 @@ function template_preprocess_agres_availability_day_old(&$vars) {
 
   $columns = array();
 
-  // Move all_day items into the right columns and render them.
-//  $grouped_items = array();
-//  foreach ($rows['all_day'] as $item) {
-//    if (isset($item->{$grouping_field})) {
-//      $column = $item->{$grouping_field};
-//      $item->{$grouping_field} = ''; // Remove the grouping field from the results.
-//      if (!in_array($column, $columns)) {
-//        $columns[] = $column;
-//      }
-//    }
-//    else {
-//      $column = t('Items');
-//    }
-//    $grouped_items[$column][] = theme('agres_availability_item', array('view' => $view, 'rendered_fields' => $item->rendered_fields, 'item' => $item));
-//    $item_count++;
-//  }
   $vars['rows']['all_day'] = $grouped_items;
 
   // Moved timed items into the right columns and render them.
@@ -961,7 +790,8 @@ function template_preprocess_agres_availability_day_old(&$vars) {
       $time = date_format($item->agres_availability_start_date, 'H:i:s');
       if (isset($item->{$grouping_field})) {
         $column = $item->{$grouping_field};
-        $item->{$grouping_field} = ''; // Remove the grouping field from the results.
+        // Remove the grouping field from the results.
+        $item->{$grouping_field} = '';
         if (!in_array($column, $columns)) {
           $columns[] = $column;
         }
@@ -1064,20 +894,12 @@ function template_preprocess_agres_availability_day_old(&$vars) {
 }
 
 /**
- * Display a week overlap view.
- */
-//function template_preprocess_agres_availability_week_overlap(&$vars) {
-//  template_preprocess_agres_availability_week($vars);
-//}
-
-/**
  * Display a week view.
  */
 function template_preprocess_agres_availability_week(&$vars) {
-//   Add in all the $vars added by the main calendar preprocessor.
-  if ($vars['view']->name == 'agres_view' ) {
+  // Add in all the $vars added by the main calendar preprocessor.
+  if ($vars['view']->name == 'agres_view') {
     $vars['view']->style_with_weekno = FALSE;
-//       template_preprocess_calendar($vars);
     $view = $vars['view'];
     $rows = $vars['rows'];
     $agrrows = $vars['rows'];
@@ -1103,8 +925,6 @@ function template_preprocess_agres_availability_week(&$vars) {
         $vars['currentcategory'] = $view->args[1];
 
         if (isset($view->args[2]) && $view->args[2]) {
-
-//        $units = _agreservations_get_unitnodes($view->args[2]);
           $units = _agres_categories_get_unitnodes_of_category($view->args[2], $view->args[1]);
           $vars['currentunittype'] = $view->args[2];
         }
@@ -1137,16 +957,16 @@ function template_preprocess_agres_availability_week(&$vars) {
       }
       $unittypes = _agreservations_get_unittypenodes();
     }
-    //remove the args from agrescurrentpath:
+    // Remove the args from agrescurrentpath
     $toremovefrompath = implode("/", $view->args);
     $agrescurrentpath = get_current_path();
-//       drupal_set_message('<pre>$agrescurrentpath'.print_r($agrescurrentpath,true).'</pre>');
     $agrescurrentpath = str_replace($toremovefrompath, "", $agrescurrentpath);
-    //cut off trailing slash:
-    if (substr($agrescurrentpath, -1, 1) == "/") {
-      $agrescurrentpath = substr($agrescurrentpath, 0, strlen($agrescurrentpath) - 1);
+    // Cut off trailing slash
+    if (drupal_substr($agrescurrentpath, -1, 1) == "/") {
+      $agrescurrentpath = drupal_substr($agrescurrentpath, 0, drupal_strlen($agrescurrentpath) - 1);
     }
     $vars['agrescurrentpath'] = $agrescurrentpath;
+
     // Moved timed items into the right columns and render them.
     $show_empty_times = $view->date_info->style_show_empty_times;
     $end_start_time = '23:59:59';
@@ -1155,27 +975,22 @@ function template_preprocess_agres_availability_week(&$vars) {
     $lastweekno = '';
     $icount = 1;
     $ff = 0;
-    //initialize vars teststringggg:
-//       drupal_set_message('<pre>***'. print_r($rows[0], TRUE) .'</pre>');
+    //initialize vars teststring:
     $vars['rinfo'] = array();
     foreach ($rows[0] as $weekno => $row) {
-//          drupal_set_message('<pre>weeeeek '.print_r(  $row,true).'</pre>');
       $vars['rows'][$weekno] = $row['data'];
       foreach ($row['data']['items'] as $ikey => $item) {
-//            drupal_set_message('<pre>weeeeek '.print_r(  $item,true).'</pre>');
         ksort($item);
         foreach ($item as $skey => $singlereservation) {
-//               $date = new DateObject($value, date_default_timezone(), DATE_ISO_FORMAT);
-//               new DateOb
           $date = new DateObject($singlereservation->field['value'], $singlereservation->field['timezone_db'], NULL);
-//               $date->setTimezone($singlereservation->field['timezone']);
           $date->setTimezone(timezone_open(date_default_timezone()));
 
           $tmpunititems = array();
-          $tmpunititems = _agreservations_get_unitn_for_reservation_node($singlereservation->nid); //A.Gill: Räume je reservierung holen
+          // Rooms per reservation pick
+          $tmpunititems = _agreservations_get_unitn_for_reservation_node($singlereservation->nid);
           foreach ($units as $unit) {
-
-            if (in_array($unit->nid, $tmpunititems)) { //A.Gill checks if unit is a booked item:
+            // Checks if unit is a booked item
+            if (in_array($unit->nid, $tmpunititems)) {
               $itemdate1 = new DateObject($singlereservation->field['value'], $singlereservation->field['timezone_db'], NULL);
               $itemdate1->setTimezone(timezone_open(date_default_timezone()));
               $itemdate2 = new DateObject($singlereservation->field['value2'], $singlereservation->field['timezone_db'], NULL);
@@ -1192,9 +1007,7 @@ function template_preprocess_agres_availability_week(&$vars) {
 
               if (( ($pos2 === FALSE)) || (($pos !== FALSE) && ($pos2 !== FALSE))) {
                 $row['data']['all_day'][$unit->title] = $singlereservation;
-//                   $row['data']['all_day'][$unit->title] = $singlereservation;
               }
-
             }
           }
         }
@@ -1206,41 +1019,35 @@ function template_preprocess_agres_availability_week(&$vars) {
       $rowcopy = $row['data']['all_day'];
       $row['data']['all_day'] = array();
       foreach ($rowcopy as $ikey => $singlereservation) {
-//             drupal_set_message('<pre>***unit:dddd'. print_r($singlereservation, TRUE) .'</pre>');
         $tmpunititems = array();
-        $tmpunititems = _agreservations_get_unitn_for_reservation_node($singlereservation->nid); //A.Gill: Räume je reservierung holen
-
+        // Rooms per reservation pick
+        $tmpunititems = _agreservations_get_unitn_for_reservation_node($singlereservation->nid);
         foreach ($units as $unit) {
-          if (in_array($unit->nid, $tmpunititems)) { //
+          if (in_array($unit->nid, $tmpunititems)) {
             $row['data']['all_day'][$unit->title] = $singlereservation;
           }
         }
       }
-//        drupal_set_message('<pre>gdgdg***'. print_r($row['data']['all_day'], TRUE) .'</pre>');
       $columns[] = $weekno;
       foreach ($units as $unit) {
-        //initialize $grouped_items:
+        // Initialize $grouped_items
         $grouped_items[$unit->title] = array();
         $start_times = $view->date_info->style_groupby_times;
         $start_time = array_shift($start_times);
         $next_start_time = count($start_times) ? array_shift($start_times) : $end_start_time;
         ksort($row['data']['all_day']);
-        foreach ($row['data']['all_day'] as   $key => $item) { //
-//             $test = node_load($item->nid);
-//             drupal_set_message('<pre>gdgdg***'. print_r($test, TRUE) .'</pre>');
-          $tmpEnd = date_create($item->row->field_field_agres_rdate[0]['raw']['value2']);
-          $tmpGranularityEnd = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
-          if ($tmpEnd > $tmpGranularityEnd) {
+        foreach ($row['data']['all_day'] as $key => $item) {
+          $temp_end = date_create($item->row->field_field_agres_rdate[0]['raw']['value2']);
+          $temp_granularity_end = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
+          if ($temp_end > $temp_granularity_end) {
             $continues = 1;
-
           }
           else {
             $continues = 0;
           }
-//                drupal_set_message('<pre>*$continues = 0;**'. print_r($item->row, TRUE) .'</pre>');
-          $tmpstart = date_create($item->row->field_field_agres_rdate[0]['raw']['value']);
-          $tmpGranularitystart = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
-          if ($tmpstart < $tmpGranularitystart) {
+          $temp_start = date_create($item->row->field_field_agres_rdate[0]['raw']['value']);
+          $temp_granularity_start = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
+          if ($temp_start < $temp_granularity_start) {
             $continuation = 1;
           }
           else {
@@ -1248,10 +1055,12 @@ function template_preprocess_agres_availability_week(&$vars) {
           }
           $itemclass = 'itemwithoutorder';
           if (!isset($item->node->field_agres_orderid[$item->node->language])) {
-            $itemclass = 'itemwithoutorder'; //treat as receptionist manual reservation defaultcolor orange
+            // Treat as receptionist manual reservation defaultcolor orange
+            $itemclass = 'itemwithoutorder';
           }
           else {
-            $itemclass = 'itemwithorder'; //treat as receptionist manual reservation defaultcolor blue
+            // Treat as receptionist manual reservation defaultcolor blue
+            $itemclass = 'itemwithorder';
           }
 
           $themeparams = array(
@@ -1262,10 +1071,12 @@ function template_preprocess_agres_availability_week(&$vars) {
             'continuation' => $continuation,
             'itemclass' => $itemclass,
           );
-          $tmpunititems = _agreservations_get_unitn_for_reservation_node($item->nid); //get units per reservation
-          if ($unit->title === $key) { //A.Gill unit is in booked item:    if (in_array($unit->nid, $tmpunititems)){//
-            if ((!isset($vars['rinfo'][$unit->title][$item->nid]))) { //(!isset($vars['rows'][$weekno]['night'][$unit->title][$item->vid])){
-              $vars['rows'][$weekno]['night'][$unit->title][$item->nid] = theme('agres_availability_item', $themeparams); // theme($theme, $variables);
+          // Get units per reservation
+          $tmpunititems = _agreservations_get_unitn_for_reservation_node($item->nid);
+          // Unit is in booked item
+          if ($unit->title === $key) {
+            if ((!isset($vars['rinfo'][$unit->title][$item->nid]))) {
+              $vars['rows'][$weekno]['night'][$unit->title][$item->nid] = theme('agres_availability_item', $themeparams);
               $vars['rinfo'][$unit->title][$item->nid] = '1';
               $vars['spaninfo'][$unit->title][$item->nid] = 1;
             }
@@ -1281,7 +1092,7 @@ function template_preprocess_agres_availability_week(&$vars) {
           foreach ($items as $item) {
 
             // Find the next time slot and fill it. Populate the skipped
-            // slots if the option to show empty times was chosen.($show_empty_times) &&
+            // slots if the option to show empty times was chosen.
             while ($time >= $next_start_time && $time < $end_start_time) {
               if (is_array($grouped_items[$unit->title])) {
                 if (!array_key_exists($start_time, $grouped_items[$unit->title])) {
@@ -1294,13 +1105,9 @@ function template_preprocess_agres_availability_week(&$vars) {
               $start_time = $next_start_time;
               $next_start_time = count($start_times) ? array_shift($start_times) : $end_start_time;
             }
-
-//            agag   $theme = isset($item->calendar_node_theme) ? $item->calendar_node_theme : 'calendar_' . $view->date_info->granularity . '_node';
             $tmpunititems = array();
-            $tmpunititems = _agreservations_get_unitn_for_reservation_node($item->nid); //get units per reservation
-            if (in_array($unit->nid, $tmpunititems)) {
-//             agag    $grouped_items[$unit->title][$start_time]['values'][$weekno][$item->nid] = theme($theme, $item, $view);
-            }
+            // Get units per reservation
+            $tmpunititems = _agreservations_get_unitn_for_reservation_node($item->nid);
             $item_count++;
             $by_hour_count++;
           }
@@ -1323,7 +1130,6 @@ function template_preprocess_agres_availability_week(&$vars) {
           }
         }
       }
-      // end foreach ($units as $unit) {
     }
     ksort($grouped_items);
     $i = 0;
@@ -1353,10 +1159,9 @@ function template_preprocess_agres_availability_week(&$vars) {
     }
     return;
   }
-  else { //normal calendar
+  // Normal calendar
+  else {
     $vars['template_file'] = 'agreservations-calendar-week-1';
-//       template_preprocess_calendar($vars);
-//       template_preprocess_calendar_week($vars);
     return;
   }
 }
@@ -1367,13 +1172,13 @@ function template_preprocess_agres_availability_week(&$vars) {
 function template_preprocess_agres_availability_datebox(&$vars) {
   $date = $vars['date'];
   $view = $vars['view'];
-  $vars['day'] = intval(substr($date, 8, 2));
+  $vars['day'] = intval(drupal_substr($date, 8, 2));
   $force_view_url = !empty($view->date_info->block) ? TRUE : FALSE;
   $month_path = agres_availability_granularity_path($view, 'month');
   $year_path = agres_availability_granularity_path($view, 'year');
   $day_path = agres_availability_granularity_path($view, 'day');
   $vars['url'] = str_replace(array($month_path, $year_path), $day_path, date_pager_url($view, NULL, $date, $force_view_url));
-  $vars['link'] = $vars['day'];//!empty($day_path) ? l($vars['day'], $vars['url']) : $vars['day'];
+  $vars['link'] = $vars['day'];
   $vars['granularity'] = $view->date_info->granularity;
   $vars['mini'] = !empty($view->date_info->mini);
   if ($vars['mini']) {
@@ -1387,24 +1192,22 @@ function template_preprocess_agres_availability_datebox(&$vars) {
   else {
     $vars['class'] = 'day';
   }
-//  drupal_set_message('<pre>ifrekt. spaninfo '.print_r( $vars['day'],true).'</pre>');
 }
 
 /**
  * Format an agres_availability month node for display.
  */
 function template_preprocess_agres_availability_month_multiple_node(&$vars) {
-//    drupal_set_message('<pre>template_preprocess_agres_availability_month_multiple_node '.print_r( $vars['rows'],true).'</pre>');
   $view = $vars['view'];
   $curday = $vars['curday'];
 
-  // get the year month and date
-  $parts = explode('-', substr($curday, 0, 10));
+  // Get the year month and date
+  $parts = explode('-', drupal_substr($curday, 0, 10));
   $year = $parts[0];
   $month = intval($parts[1]);
   $day = intval($parts[2]);
 
-  // create the link to the day
+  // Create the link to the day
   $vars['link'] = date_pager_url($view, NULL, date_pad($year, 4) . '-' . date_pad($month) . '-' . date_pad($day));
 }
 
@@ -1415,13 +1218,13 @@ function template_preprocess_agres_availability_week_multiple_node(&$vars) {
   $view = $vars['view'];
   $curday = $vars['curday'];
 
-  // get the year month and date
-  $parts = explode('-', substr($curday, 0, 10));
+  // Get the year month and date
+  $parts = explode('-', drupal_substr($curday, 0, 10));
   $year = $parts[0];
   $month = intval($parts[1]);
   $day = intval($parts[2]);
 
-  // create the link to the day
+  // Create the link to the day
   $vars['link'] = date_pager_url($view, NULL, date_pad($year, 4) . '-' . date_pad($month) . '-' . date_pad($day));
 }
 
@@ -1432,12 +1235,11 @@ function template_preprocess_agres_availability_week_multiple_node(&$vars) {
  * $vars['item'] = The source data for this item.
  * $vars['view'] = The view that this item is displayed on.
  *
- * @TODO We need some options about how to combine rendered fields.
+ * @todo We need some options about how to combine rendered fields.
  * Fields rendered in multiday containers need to be inline.
  */
 function template_preprocess_agres_availability_item(&$vars) {
-//    $item->
-  //drupal_set_message('<pre>template_preprocess_agres_availability_item '.print_r( $vars,true).'</pre>');
+
 }
 
 /**
@@ -1449,9 +1251,7 @@ function theme_agres_availability_time_row_heading($vars) {
   $curday_date = $vars['curday_date'];
   static $format_hour, $format_ampm;
   if (empty($format_hour)) {
-//    $format = //variable_get('date_format_short', 'm/d/Y - H:i');
-    $format =  'm/d/Y - H:i';
-//    $format_hour = str_replace(array('a', 'A'), '', date_limit_format($format, array('hour', 'minute')));
+    $format = 'm/d/Y - H:i';
     $format_hour = str_replace(array('a', 'A'), '', date_limit_format($format, array('hour', 'minute')));
     $format_ampm = strstr($format, 'a') ? 'a' : (strstr($format, 'A') ? 'A' : '');
   }
@@ -1473,7 +1273,6 @@ function theme_agres_availability_time_row_heading($vars) {
     $ampm = '';
   }
   return array('hour' => $hour, 'ampm' => $ampm);
-
 }
 
 /**
@@ -1532,11 +1331,13 @@ function theme_agres_availability_stripe_stripe($vars) {
   return $output;
 }
 
+/**
+ * @todo Documentation
+ */
 function template_preprocess_agres_availability_month_col(&$vars) {
-//    $vars['agresss'][]=$vars['item'];
-//        drupal_set_message('<pre>template_preprocess_agres_availability_month_col '.print_r( $vars,true).'</pre>');
-//         $vars['item2']=$vars['item'];
+
 }
+
 /**
  * Format an empty day on a agres_availability
  *
@@ -1544,16 +1345,10 @@ function template_preprocess_agres_availability_month_col(&$vars) {
  *   The day to display.
  */
 function theme_agres_availability_empty_day(&$vars) {
-//    drupal_set_message('<pre>weeeeek '.print_r($vars['view'],true).'</pre>');
   $curday = $vars['curday'];
-//   $vars['agrcurdays'][]=$curday;
-//  $vars['agrdays'][]=$curday;
   $view = $vars['view'];
-//  drupal_set_message('<pre>weeeeek '.print_r($view->style_plugin->date_info->agres_availability_type,true).'</pre>');
   if ($view->style_plugin->date_info->agres_availability_type != 'day') {
     return '<div class="agres_availability-empty">&nbsp;</div>' . "\n";
   }
-  else {
-    return '<div class="agres_availability-dayview-empty">' . t('Empty day') . '</div>';
-  }
-}
+  return '<div class="agres_availability-dayview-empty">' . t('Empty day') . '</div>';
+}
\ No newline at end of file
diff --git a/agres_bookings/agres_bookings-uc-order--customer.tpl.php b/agres_bookings/agres_bookings-uc-order--customer.tpl.php
index c39549e..8cbed6a 100644
--- a/agres_bookings/agres_bookings-uc-order--customer.tpl.php
+++ b/agres_bookings/agres_bookings-uc-order--customer.tpl.php
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * This file is the default customer invoice template for Ubercart.
@@ -44,43 +43,43 @@
     <td>
       <table width="100%" border="0" cellspacing="0" cellpadding="5" align="center" bgcolor="#FFFFFF" style="font-family: verdana, arial, helvetica; font-size: small;">
         <?php if ($business_header): ?>
-        <tr valign="top">
-          <td>
-            <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
-              <tr>
-                <td>
-                  <?php print $site_logo; ?>
-                </td>
-                <td width="98%">
-                  <div style="padding-left: 1em;">
-                  <span style="font-size: large;"><?php print $store_name; ?></span><br />
-                  <?php print $site_slogan; ?>
-                  </div>
-                </td>
-                <td nowrap="nowrap">
-                  <?php print $store_address; ?><br /><?php print $store_phone; ?>
-                </td>
-              </tr>
-            </table>
-          </td>
-        </tr>
+          <tr valign="top">
+            <td>
+              <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
+                <tr>
+                  <td>
+                    <?php print $site_logo; ?>
+                  </td>
+                  <td width="98%">
+                    <div style="padding-left: 1em;">
+                      <span style="font-size: large;"><?php print $store_name; ?></span><br />
+                      <?php print $site_slogan; ?>
+                    </div>
+                  </td>
+                  <td nowrap="nowrap">
+                    <?php print $store_address; ?><br /><?php print $store_phone; ?>
+                  </td>
+                </tr>
+              </table>
+            </td>
+          </tr>
         <?php endif; ?>
 
         <tr valign="top">
           <td>
 
             <?php if ($thank_you_message): ?>
-            <p><b><?php print t('Thanks for your order, !order_first_name!', array('!order_first_name' => $order_first_name)); ?></b></p>
+              <p><b><?php print t('Thanks for your order, !order_first_name!', array('!order_first_name' => $order_first_name)); ?></b></p>
 
-            <?php if (isset($order->data['new_user'])): ?>
-            <p><b><?php print t('An account has been created for you with the following details:'); ?></b></p>
-            <p><b><?php print t('Username:'); ?></b> <?php print $order_new_username; ?><br />
-            <b><?php print t('Password:'); ?></b> <?php print $order_new_password; ?></p>
-            <?php endif; ?>
+              <?php if (isset($order->data['new_user'])): ?>
+                <p><b><?php print t('An account has been created for you with the following details:'); ?></b></p>
+                <p><b><?php print t('Username:'); ?></b> <?php print $order_new_username; ?><br />
+                  <b><?php print t('Password:'); ?></b> <?php print $order_new_password; ?></p>
+              <?php endif; ?>
 
-            <p><b><?php print t('Want to manage your order online?'); ?></b><br />
-            <?php print t('If you need to check the status of your order, please visit our home page at !store_link and click on "My account" in the menu or login with the following link:', array('!store_link' => $store_link)); ?>
-            <br /><br /><?php print $site_login_link; ?></p>
+              <p><b><?php print t('Want to manage your order online?'); ?></b><br />
+                <?php print t('If you need to check the status of your order, please visit our home page at !store_link and click on "My account" in the menu or login with the following link:', array('!store_link' => $store_link)); ?>
+                <br /><br /><?php print $site_login_link; ?></p>
             <?php endif; ?>
 
             <table cellpadding="4" cellspacing="0" border="0" width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
@@ -130,13 +129,13 @@
                         <?php print $order_billing_phone; ?><br />
                       </td>
                       <?php if ($shippable): ?>
-                      <td valign="top" width="50%">
-                        <b><?php print t('Shipping Address:'); ?></b><br />
-                        <?php print $order_shipping_address; ?><br />
-                        <br />
-                        <b><?php print t('Shipping Phone:'); ?></b><br />
-                        <?php print $order_shipping_phone; ?><br />
-                      </td>
+                        <td valign="top" width="50%">
+                          <b><?php print t('Shipping Address:'); ?></b><br />
+                          <?php print $order_shipping_address; ?><br />
+                          <br />
+                          <b><?php print t('Shipping Phone:'); ?></b><br />
+                          <?php print $order_shipping_phone; ?><br />
+                        </td>
                       <?php endif; ?>
                     </tr>
                   </table>
@@ -167,11 +166,11 @@
               </tr>
 
               <?php if ($shippable): ?>
-              <tr>
-                <td colspan="2" bgcolor="#EEEEEE">
-                  <font color="#CC6600"><b><?php print t('Shipping Details:'); ?></b></font>
-                </td>
-              </tr>
+                <tr>
+                  <td colspan="2" bgcolor="#EEEEEE">
+                    <font color="#CC6600"><b><?php print t('Shipping Details:'); ?></b></font>
+                  </td>
+                </tr>
               <?php endif; ?>
 
               <tr>
@@ -197,14 +196,14 @@
                     </tr>
 
                     <?php if ($shipping_method && $shippable): ?>
-                    <tr>
-                      <td nowrap="nowrap">
-                        <b><?php print t('Shipping Method:'); ?></b>
-                      </td>
-                      <td width="98%">
-                        <?php print $order_shipping_method; ?>
-                      </td>
-                    </tr>
+                      <tr>
+                        <td nowrap="nowrap">
+                          <b><?php print t('Shipping Method:'); ?></b>
+                        </td>
+                        <td width="98%">
+                          <?php print $order_shipping_method; ?>
+                        </td>
+                      </tr>
                     <?php endif; ?>
 
                     <tr>
@@ -217,16 +216,16 @@
                     </tr>
 
                     <?php foreach ($line_items as $item): ?>
-                    <?php if ($item['type'] == 'subtotal' || $item['type'] == 'total')  continue; ?>
+                      <?php if ($item['type'] == 'subtotal' || $item['type'] == 'total') continue; ?>
 
-                    <tr>
-                      <td nowrap="nowrap">
-                        <?php print $item['title']; ?>:
-                      </td>
-                      <td>
-                        <?php print $item['formatted_amount']; ?>
-                      </td>
-                    </tr>
+                      <tr>
+                        <td nowrap="nowrap">
+                          <?php print $item['title']; ?>:
+                        </td>
+                        <td>
+                          <?php print $item['formatted_amount']; ?>
+                        </td>
+                      </tr>
 
                     <?php endforeach; ?>
 
@@ -250,56 +249,53 @@
 
                         <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
                           <?php foreach ($products as $product): ?>
-                          <tr>
-                          
-                            <td valign="top" nowrap="nowrap">
-                              <?php
-                                 $timeinfo = '';
-                                 if (isset($product->data['agres_singletimes'])) { 
-                                   
-                                   if (count($product->data['agres_singletimes']) > 1) {
-                                     if(($product->qty/count($product->data['agres_singletimes']))>1){
-                                       $timeinfo = $product->qty/count($product->data['agres_singletimes']).' '.$product->title;
-                                     }
-                                     else {
-                                       $timeinfo = $product->qty/count($product->data['agres_singletimes']).' '.$product->title;
-                                     }
-                                   
-                                 if ($product->qty > 1) {
-                                $price_info['qty'] = 1;
-//                                $product->individual_price = t('(!price each)', array('!price' => uc_currency_format($product->price)));
-                                 $timeinfo .=' '.$product->individual_price;
-                                 $price_info['qty'] = $product->qty;
-                                } 
-                                     if (strpos($timeinfo, $product->data['agres_singletimes'][0] . '<br>'.t('Until:') . end($product->data['agres_singletimes']) .' ('.t('included').')'. ' X ' . count($product->data['agres_singletimes']).' '.$product->agrmesunit,0)==false) {
-                                       $timeinfo .= '<br>'.t('From:'). $product->data['agres_singletimes'][0] . '<br>'.t('Until:') . end($product->data['agres_singletimes']) .' ('.t('included').')'. ' X ' . count($product->data['agres_singletimes']).' '.$product->agrmesunit;
-                                     }
-                                   }
-                                   else {
-                                    // if (strpos($title, $item->data['agres_singletimes'][0].', '.end($item->data['agres_singletimes']).' = '.$tmeasuringunit.' count: '.count($item->data['agres_singletimes']),0)==false){
-                                      if (strpos($timeinfo, $product->data['agres_singletimes'][0],0)==false){
-                                       $timeinfo .=  '<br>'.$product->data['agres_singletimes'][0];
-                                     }
-                                   }
-                                 }
-                                 else {                                  
-                                   $timeinfo .= ( $product->data['times'] > 1) ? ''.' ' . $product->data['times'] .' <-> '. $product->agrmesunit .' count' : ' ' . $product->data['times'].$product->agrmesunit . ' countss';
-                                 }
-//                                 $title .= 'kkk'.$product->agrmesunit;
-                                 echo $timeinfo;
-                              ?>                                
-                             
-                            </td>
-                            <td width="98%">
-                               <b><?php print $product->qty; ?> x </b>
-                              <b><?php print $product->title; ?> - <?php print $product->total_price; ?></b>
-                              <?php print $product->individual_price; ?><br />
-                              <?php print t('SKU'); ?>: <?php print $product->model; ?><br />
-                              <?php print $product->details; ?>
-                            </td>
-                          </tr>
+                            <tr>
+
+                              <td valign="top" nowrap="nowrap">
+                                <?php
+                                $timeinfo = '';
+                                if (isset($product->data['agres_singletimes'])) {
+
+                                  if (count($product->data['agres_singletimes']) > 1) {
+                                    if (($product->qty / count($product->data['agres_singletimes'])) > 1) {
+                                      $timeinfo = $product->qty / count($product->data['agres_singletimes']) . ' ' . $product->title;
+                                    }
+                                    else {
+                                      $timeinfo = $product->qty / count($product->data['agres_singletimes']) . ' ' . $product->title;
+                                    }
+
+                                    if ($product->qty > 1) {
+                                      $price_info['qty'] = 1;
+                                      $timeinfo .=' ' . $product->individual_price;
+                                      $price_info['qty'] = $product->qty;
+                                    }
+                                    if (strpos($timeinfo, $product->data['agres_singletimes'][0] . '<br>' . t('Until:') . end($product->data['agres_singletimes']) . ' (' . t('included') . ')' . ' X ' . count($product->data['agres_singletimes']) . ' ' . $product->agrmesunit, 0) == false) {
+                                      $timeinfo .= '<br>' . t('From:') . $product->data['agres_singletimes'][0] . '<br>' . t('Until:') . end($product->data['agres_singletimes']) . ' (' . t('included') . ')' . ' X ' . count($product->data['agres_singletimes']) . ' ' . $product->agrmesunit;
+                                    }
+                                  }
+                                  else {
+                                    if (strpos($timeinfo, $product->data['agres_singletimes'][0], 0) == false) {
+                                      $timeinfo .= '<br>' . $product->data['agres_singletimes'][0];
+                                    }
+                                  }
+                                }
+                                else {
+                                  $timeinfo .= ( $product->data['times'] > 1) ? '' . ' ' . $product->data['times'] . ' <-> ' . $product->agrmesunit . ' count' : ' ' . $product->data['times'] . $product->agrmesunit . ' countss';
+                                }
+                                echo $timeinfo;
+                                ?>                                
+
+                              </td>
+                              <td width="98%">
+                                <b><?php print $product->qty; ?> x </b>
+                                <b><?php print $product->title; ?> - <?php print $product->total_price; ?></b>
+                                <?php print $product->individual_price; ?><br />
+                                <?php print t('SKU'); ?>: <?php print $product->model; ?><br />
+                                <?php print $product->details; ?>
+                              </td>
+                            </tr>
                           <?php endforeach; ?>
-                          
+
 
                         </table>
 
@@ -311,27 +307,27 @@
               </tr>
 
               <?php if ($help_text || $email_text || $store_footer): ?>
-              <tr>
-                <td colspan="2">
-                  <hr noshade="noshade" size="1" /><br />
+                <tr>
+                  <td colspan="2">
+                    <hr noshade="noshade" size="1" /><br />
 
-                  <?php if ($help_text): ?>
-                  <p><b><?php print t('Where can I get help with reviewing my order?'); ?></b><br />
-                  <?php print t('To learn more about managing your orders on !store_link, please visit our <a href="!store_help_url">help page</a>.', array('!store_link' => $store_link, '!store_help_url' => $store_help_url)); ?>
-                  <br /></p>
-                  <?php endif; ?>
+                    <?php if ($help_text): ?>
+                      <p><b><?php print t('Where can I get help with reviewing my order?'); ?></b><br />
+                        <?php print t('To learn more about managing your orders on !store_link, please visit our <a href="!store_help_url">help page</a>.', array('!store_link' => $store_link, '!store_help_url' => $store_help_url)); ?>
+                        <br /></p>
+                    <?php endif; ?>
 
-                  <?php if ($email_text): ?>
-                  <p><?php print t('Please note: This e-mail message is an automated notification. Please do not reply to this message.'); ?></p>
+                    <?php if ($email_text): ?>
+                      <p><?php print t('Please note: This e-mail message is an automated notification. Please do not reply to this message.'); ?></p>
 
-                  <p><?php print t('Thanks again for shopping with us.'); ?></p>
-                  <?php endif; ?>
+                      <p><?php print t('Thanks again for shopping with us.'); ?></p>
+                    <?php endif; ?>
 
-                  <?php if ($store_footer): ?>
-                  <p><b><?php print $store_link; ?></b><br /><b><?php print $site_slogan; ?></b></p>
-                  <?php endif; ?>
-                </td>
-              </tr>
+                    <?php if ($store_footer): ?>
+                      <p><b><?php print $store_link; ?></b><br /><b><?php print $site_slogan; ?></b></p>
+                    <?php endif; ?>
+                  </td>
+                </tr>
               <?php endif; ?>
 
             </table>
diff --git a/agres_bookings/agres_bookings.css b/agres_bookings/agres_bookings.css
index 9db5cae..22bd25b 100644
--- a/agres_bookings/agres_bookings.css
+++ b/agres_bookings/agres_bookings.css
@@ -1,12 +1,9 @@
 /*  calendar calendar table styles  */
 
 .subtotal {
-    text-align: right;
-/*    color:#008000;*/
-/*    width:600px;
-    overflow:scroll;*/
+  text-align: right;
 }
 
 .rateunittype{
-    width:auto;
+  width:auto;
 }
\ No newline at end of file
diff --git a/agres_bookings/agres_bookings.info b/agres_bookings/agres_bookings.info
index b9e7ed3..4821bab 100644
--- a/agres_bookings/agres_bookings.info
+++ b/agres_bookings/agres_bookings.info
@@ -1,16 +1,11 @@
-; $Id: agres_bookings.info,v 1.1.1.1.6.3.2.1 2010/11/13 02:26:16 agill Exp $
-name = agres_bookings
+name = Agreservations Bookings
 description = Hook in to ubercart.
-dependencies[] = agreservations
-;dependencies[] = uc_addresses
-dependencies[] = uc_cart
-dependencies[] = uc_product
-
-package = agreservations - online bookings
+package = Agreservations - Online Bookings
 core = 7.x
 
-project = "agreservations"
-
-
 files[] = agres_bookings.install
 files[] = agres_bookings.module
+
+dependencies[] = agreservations
+dependencies[] = uc_cart
+dependencies[] = uc_product
\ No newline at end of file
diff --git a/agres_bookings/agres_bookings.install b/agres_bookings/agres_bookings.install
index 08ed6b1..f3df7b3 100644
--- a/agres_bookings/agres_bookings.install
+++ b/agres_bookings/agres_bookings.install
@@ -1,45 +1,41 @@
 <?php
-// $Id: agres_bookings.install,v 1.1.2.2 2010/11/23 19:54:03 agill Exp $
-
-
-/**
- * @file
- * Install, update and uninstall functions for the agres_bookings module.
- *
- */
-
-/**
- * @file
- * agres_bookings.install
- * currently only 1 function:agres_bookings_enable when this moduel is enabled,
- * it will activate itself as a ubercart product
- */
-function agres_bookings_enable() {
-  $result = db_query("SELECT* from {uc_product_classes} where pcid = 'agreservations_unittype'");
-  if (!$result->fetchField()) {
-    // TODO Please review the conversion of this statement to the D7 database API syntax.
-    /* db_query("INSERT INTO {uc_product_classes} (pcid, name, description) VALUES ('%s', '%s', '%s')", 'agreservations_unittype', 'agreservations_unittype', 'agreservations_unittype') */
+
+/**
+ * @file
+ * Install, update and uninstall functions for the agres_bookings module.
+ * 
+ * currently only 1 function:agres_bookings_enable when this module is enabled,
+ * it will activate itself as a ubercart product
+ *
+ */
+
+/**
+ * Implements hook_enable(). 
+ */
+function agres_bookings_enable() {
+  $result = db_query("SELECT* from {uc_product_classes} where pcid = 'agreservations_unittype'");
+  if (!$result->fetchField()) {
     $id = db_insert('uc_product_classes')
-  ->fields(array(
-      'pcid' => 'agreservations_unittype',
-      'name' => 'agreservations_unittype',
-      'description' => 'agreservations_unittype',
-    ))
-  ->execute();
-    uc_product_node_info(TRUE);
-    variable_set('node_options_' . 'agreservations_unittype', variable_get('node_options_product', array('status', 'promote')));
-
-    if (module_exists('comment')) {
-      variable_set('comment_' . 'agreservations_unittype', variable_get('comment_product', 2));
-    }
-
-    module_invoke_all('product_class', 'agreservations_unittype', 'insert');
-    node_types_rebuild();
-    uc_product_node_info(true);
-    node_types_rebuild();
-    if (module_exists('imagefield')) {
-      uc_product_add_default_image_field('agreservations_unittype');
-    }
-    menu_rebuild();
-  }
-}
+      ->fields(array(
+        'pcid' => 'agreservations_unittype',
+        'name' => 'agreservations_unittype',
+        'description' => 'agreservations_unittype',
+      ))
+      ->execute();
+    uc_product_node_info(TRUE);
+    variable_set('node_options_' . 'agreservations_unittype', variable_get('node_options_product', array('status', 'promote')));
+
+    if (module_exists('comment')) {
+      variable_set('comment_' . 'agreservations_unittype', variable_get('comment_product', 2));
+    }
+
+    module_invoke_all('product_class', 'agreservations_unittype', 'insert');
+    node_types_rebuild();
+    uc_product_node_info(true);
+    node_types_rebuild();
+    if (module_exists('imagefield')) {
+      uc_product_add_default_image_field('agreservations_unittype');
+    }
+    menu_rebuild();
+  }
+}
\ No newline at end of file
diff --git a/agres_bookings/agres_bookings.module b/agres_bookings/agres_bookings.module
index a61cbd2..dee972d 100644
--- a/agres_bookings/agres_bookings.module
+++ b/agres_bookings/agres_bookings.module
@@ -1,70 +1,59 @@
 <?php
-// $Id: agres_bookings.module,v 1.1.1.1.2.6.2.11.2.19.2.9 2010/12/23 02:25:46 agill Exp $
-
-
 
 /**
  * @file
  * agres_bookings.module
  * Contains the ubercarthooks...needs research and work
  */
-/* to allow emptying the cart:
- * this code was taken (and extended by me)from http://www.ubercart.org/forum/module_support/5725/add_empty_cart_button
- * the ubercart user dinorastoder wrote it.
+
+/**
+ * To allow for emptying the cart
+ *
+ * This code was written by 'dinorastoder' and extended by me see:
+ *  http://www.ubercart.org/forum/module_support/5725/add_empty_cart_button
  */
 function agres_bookings_views_api($module, $api) {
   if ($module == 'views' && $api == 'views_default') {
     return array('version' => 2);
   }
 }
-/**o
- * @todo Please document this function.
- * @see http://drupal.org/node/1354
+
+/**
+ * @todo Documentation
  */
 function agres_bookings_cart_view_form_submit($form, &$form_state) {
-//       drupal_set_message('<pre>auch noch da'.print_r($form_state,true).'</pre>');
   if (isset($form_state['values']['op'])) {
     switch ($form_state['values']['op']) {
       case t('Empty Cart'):
-        //first read the Agreservation ID:
+        // First read the Agreservation ID:
         $items = uc_cart_get_contents(uc_cart_get_id());
-        //now delete the reservations:
-        //in case where not allowed to delete follow the
-        //suggestion posted here:http://drupal.org/node/218104 :
+        // Now delete the reservations. In case where not allowed to delete,
+        // follow the suggestion posted here:http://drupal.org/node/218104
         foreach ($items as $productunit) {
           if (isset($productunit->data['agreservations_resid'])) {
             if (intval($productunit->data['agreservations_resid']) > 0) {
               global $user;
               $original_user = $user;
-              drupal_save_session(FALSE); // D7: use drupal_save_session(FALSE);
+              drupal_save_session(FALSE);
               $user = user_load(1);
               node_delete(intval($productunit->data['agreservations_resid']));
-              //restore original user:
+              // Restore original user
               $user = $original_user;
-              drupal_save_session(TRUE); // // D7: use drupal_save_session(TRUE);
+              drupal_save_session(TRUE);
             }
           }
         }
         uc_cart_empty(uc_cart_get_id());
-//          $form_state['redirect'] = 'cart';
         drupal_set_message(t('Cart is now empty...'));
-        // set redirect
-
         break;
-//      case t('Checkout'):
-//         drupal_set_message('<pre>auch noch da'.print_r($form_state,true).'</pre>');
     }
   }
 }
 
-//
-///**
-// * @todo Please document this function.
-// * @see http://drupal.org/node/1354
-// */
+/**
+ * @todo Documentation
+ */
 function agres_bookings_uc_checkout_pane() {
-//    drupal_set_message('<pre>agres_bookings_checkout_pane'.print_r('agres_bookings_checkout_pane',false).'</pre>');
-
   $panes['agres_cart_contents'] = array(
     'callback' => 'agres_bookings_agres_cart_contents',
     'title' => t('AGreservations cart contents'),
@@ -84,7 +73,6 @@ function agres_bookings_agres_cart_contents($op, $order, $form = NULL, &$form_st
 
   switch ($op) {
     case 'view':
-//         drupal_set_message('<pre>agres_bookings_checkout_pane'.print_r($op,true).'</pre>');
       $contents['agres_bookings_cart_review_table'] = array(
         '#theme' => 'agres_bookings_cart_review_table',
         '#items' => $order->products,
@@ -93,7 +81,6 @@ function agres_bookings_agres_cart_contents($op, $order, $form = NULL, &$form_st
       return array('contents' => $contents, 'next-button' => FALSE);
 
     case 'review':
-
       $review[] = theme('agres_bookings_pane_cart_review', array('order' => $order));
       return $review;
   }
@@ -111,12 +98,12 @@ function agres_bookings_agres_cart_contents($op, $order, $form = NULL, &$form_st
 function theme_agres_bookings_pane_cart_review($porder) {
   $order = $porder['order'];
   $items = $order->products;
-//      $items = uc_cart_get_contents();
+
   $output = '<table>';
   reset($items);
   $firstitem = current($items);
   $output = $output . '<td>' . t("From: ") . $firstitem->data['agres']['agreservations_request'][1][0] .
-                 t(" To: ") . $firstitem->data['agres']['agreservations_request'][1][1] . '</td>';
+    t(" To: ") . $firstitem->data['agres']['agreservations_request'][1][1] . '</td>';
   $context = array(
     'revision' => 'themed',
     'type' => 'cart_item',
@@ -144,18 +131,18 @@ function theme_agres_bookings_pane_cart_review($porder) {
     }
 
     if (module_exists('agres_categories') && $item->data['module'] == 'agres_categories') {
-      $tmeasuringunit =  $item->data['measuringunit'];
+      $tmeasuringunit = $item->data['measuringunit'];
 
       $timesdesc = $tmeasuringunit;
       $tmptimesqty = $item->data['times'];
       $output .= '<tr valign="top"><td nowrap="nowrap">' . count($item->data['agres_singletimes']) . ' ' . $tmeasuringunit . ' x ' . $item->data['agres_diffproducts'] . ' ' . $desc . ' </td>' .
-                     '</td><td nowrap="nowrap">' . theme('uc_price', array('price' => $item->price * $item->qty)) . '</td></tr>';
+        '</td><td nowrap="nowrap">' . theme('uc_price', array('price' => $item->price * $item->qty)) . '</td></tr>';
     }
     else {
       $timesdesc = t('nights');
       $tmptimesqty = $item->data['times'];
       $output .= '<tr valign="top"><td nowrap="nowrap">' . $item->data['times'] . $tmeasuringunit . ' x ' . $item->qty / $item->data['times'] . ' ' . $desc . ' </td>' .
-                     '</td><td nowrap="nowrap">' . theme('uc_price', array('price' => $item->price * $item->qty)) . '</td></tr>';
+        '</td><td nowrap="nowrap">' . theme('uc_price', array('price' => $item->price * $item->qty)) . '</td></tr>';
     }
   }
   //
@@ -170,18 +157,14 @@ function theme_agres_bookings_pane_cart_review($porder) {
       $output .= '<tr valign="top"><td nowrap="nowrap">' . $agres_info . '</tr>';
     }
   }
-
-
   $output .= '</table>';
-//      $review[] = $output;
+
   return $output;
 }
 
-//
-///**
-// * @todo Please document this function.
-// * @see http://drupal.org/node/1354
-// */
+/**
+ * @todo Documentation
+ */
 function agres_bookings_theme() {
   return array(
     'agres_bookings_cart_review_table' => array(
@@ -193,31 +176,17 @@ function agres_bookings_theme() {
     'agres_bookings_uc_catalog_products' => array(
       'variables' => array('products' => NULL),
     ),
-//    'agres_bookings_uc_order_products' => array(
-//      'variables' => array('products' => NULL),
-//    ),      
   );
 }
 
-///**
-// * List the products in the cart in a TAPIr table adapted for agreservations.
-// */
+/**
+ * List the products in the cart in a TAPIr table adapted for agreservations.
+ */
 function agres_bookings_cart_view_table($table) {
-//    drupal_set_message('<pre>agres_bookings_cart_view_table'.print_r($table,true).'</pre>');
-
-
   $table['#attributes'] = array('width' => '100%');
   $table['#columns'] = array(
-    //    'remove' => array(
-    //      'cell' => t('Remove'),
-    //      'weight' => 0,
-    //    ),
-    //    'remove' => array(
-    //      'cell' => t(' '),
-    //      'weight' => 0,
-    //    ),
     'image' => array(
-      'cell' => '', //t('Image'),
+      'cell' => '',
       'weight' => 1,
     ),
     'desc' => array(
@@ -241,11 +210,6 @@ function agres_bookings_cart_view_table($table) {
   foreach (element_children($table) as $i) {
     $subtotal += $table[$i]['#total'];
 
-//    $table[$i]['remove']['#cell_attributes'] = array('align' => 'center', 'class' => 'remove');
-
-
-//       $table[$i]['image']['#cell_attributes'] = array('class' => 'image');
-
 
     $table[$i]['image']['#cell_attributes'] = array('class' => 'image');
     $table[$i]['desc']['#cell_attributes'] = array('class' => 'desc');
@@ -277,12 +241,11 @@ function agres_bookings_cart_view_table($table) {
   return $table;
 }
 
+/**
+ * Implements hook_init().
+ */
 function agres_bookings_init() {
-//     if (substr($_GET['q'], 0, 24) == 'admin/build/modules/list') {
-//       return;
-//     }
   drupal_add_css(drupal_get_path('module', 'agres_bookings') . '/agres_bookings.css');
-
 }
 
 /**
@@ -297,7 +260,7 @@ function agres_bookings_init() {
  * @ingroup themeable
  */
 function theme_agres_bookings_cart_review_table($variables) {
-//    drupal_set_message('<pre>theme_agres_bookings_cart_review_table'.print_r($variables,true).'</pre>');
+
   $items = $variables['items'];
   $show_subtotal = $variables['show_subtotal'];
 
@@ -317,10 +280,6 @@ function theme_agres_bookings_cart_review_table($variables) {
       'data' => t('Time info'),
       'class' => 'products',
     ),
-    //    array(
- //      'data' => t('Products'),
- //      'class' => 'products',
- //    ),
     array(
       'data' => t('Price'),
       'class' => 'price',
@@ -340,16 +299,14 @@ function theme_agres_bookings_cart_review_table($variables) {
     }
     else {
       $bookingmode = $item->data['bookingmode'];
-      $tmpcheckin = new DateObject($item->data['checkintime'], null, 'Y-m-d H:i:s'); //date_create($userrequest['checkintime']);
-      $tmpcheckout = new DateObject($item->data['checkouttime'], null, 'Y-m-d H:i:s'); //date_create($userrequest['checkouttime']);    
-//      drupal_set_message('<pre>agres_bookings_cart_info_form dfdf '.print_r($items[0]->data['checkintime'],true).'</pre>');
+      $tmpcheckin = new DateObject($item->data['checkintime'], null, 'Y-m-d H:i:s');
+      $tmpcheckout = new DateObject($item->data['checkouttime'], null, 'Y-m-d H:i:s');
+
       if ($bookingmode == BOOKING_MODE_BY_DAYS) {
         $times = $tmpcheckin->difference($tmpcheckout, 'days');
       }
       elseif ($bookingmode == BOOKING_MODE_BY_HOURS) {
-        $times = $tmpcheckin->difference($tmpcheckout, 'hours');
-        //round up:
-        $times = ceil($times);
+        $times = ceil($tmpcheckin->difference($tmpcheckout, 'hours'));
       }
 
       $tmeasuringunit = $item->data['measuringunit'];
@@ -409,22 +366,17 @@ function theme_agres_bookings_cart_review_table($variables) {
   return theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => array('cart-review'))));
 }
 
-
-///**
-// * @todo Please document this function.
-// * @see http://drupal.org/node/1354
-// */
+/**
+ * @todo Documentation
+ */
 function agres_bookings_uc_cart_pane($items) {
-  //drupal_set_message('<pre>agres_bookings_uc_cart_pane  '.print_r($items,true).'</pre>');
   $panes['agres_time_info'] = array(
-    //    'id' => 'agres_booking_cart_info',
     'title' => t('AGreservations Dates Info Pane'),
     'enabled' => TRUE,
     'weight' => -4,
     'body' => !is_null($items) ? drupal_get_form('agres_bookings_cart_info_form', $items) : '',
   );
   $panes['agres_booking_cart'] = array(
-    //    'id' => 'agres_booking_cart',
     'title' => t('Agreservations cart contents'),
     'enabled' => TRUE,
     'weight' => -3,
@@ -432,41 +384,37 @@ function agres_bookings_uc_cart_pane($items) {
   );
   return $panes;
 }
-//
+
 /**
  * Displaying info of booking like chekin and chekoutdate
  */
 function agres_bookings_cart_info_form($form, &$form_state, $items = NULL) {
 
   $items = uc_cart_get_contents();
- reset($items);
- $firstitem = current($items);
+  reset($items);
+  $firstitem = current($items);
   if (isset($firstitem->data['agreservations_resid'])) {
     if ($firstitem->data['module'] == 'agres_categories') {
 
-      $tmeasuringunit =  $firstitem->data['measuringunit'];
+      $tmeasuringunit = $firstitem->data['measuringunit'];
       $bookingmode = $firstitem->data['bookingmode'];
-      $tmpcheckin = new DateObject($firstitem->data['checkintime']); //date_create($userrequest['checkintime']);
-      $tmpcheckout = new DateObject($firstitem->data['checkouttime']); //date_create($userrequest['checkouttime']);    
+      $tmpcheckin = new DateObject($firstitem->data['checkintime']);
+      $tmpcheckout = new DateObject($firstitem->data['checkouttime']);
       $times = 0;
       if ($bookingmode == BOOKING_MODE_BY_DAYS) {
         $times = $tmpcheckin->difference($tmpcheckout, 'days');
-
       }
       elseif ($bookingmode == BOOKING_MODE_BY_HOURS) {
-        $times = $tmpcheckin->difference($tmpcheckout, 'hours');
-        //round up:
-        $times = ceil($times);
+        $times = ceil($tmpcheckin->difference($tmpcheckout, 'hours'));
       }
       $form['agres_info'] = array(
-        '#markup' => '<div><b>' . t('Booking from: %checkin to %checkout = %measuringunit : %times',   
-                     array(
+        '#markup' => '<div><b>' . t('Booking from: %checkin to %checkout = %measuringunit : %times', array(
           '%checkin' => $tmpcheckin->format(variable_get('date_format_short', 'Y-m-d H:i')),
           '%measuringunit' => $tmeasuringunit,
           '%checkout' => $tmpcheckout->format(variable_get('date_format_short', 'Y-m-d H:i')),
           '%times' => $times,
         ))
-             . '</b></div>',
+        . '</b></div>',
         '#weight' => -15,
       );
 
@@ -568,6 +516,7 @@ function agres_bookings_cart_view_form($form, &$form_state, $items = NULL) {
 
   return $form;
 }
+
 /**
  * Display a page allowing the customer to view the contents of his or her cart.
  *
@@ -575,8 +524,6 @@ function agres_bookings_cart_view_form($form, &$form_state, $items = NULL) {
  * i don´t know if this is the best way to change the display of the cart...
  */
 function agres_bookings_cart_view_form_old($form, $form_state, $items = NULL) {
-//    drupal_set_message('<pre>agres_bookings_cart_view_form:'.print_r($items,true).'</pre>');
-
 
   $form['items'] = array(
     '#type' => 'tapir_table',
@@ -621,17 +568,12 @@ function agres_bookings_cart_view_form_old($form, $form_state, $items = NULL) {
   $form['items'] = tapir_get_table('agres_bookings_cart_view_table', $form['items']);
 
   // If the continue shopping element is enabled...
-
-
   if (($cs_type = variable_get('uc_continue_shopping_type', 'link')) !== 'none') {
-    // Setup the text used for the element.
-
 
+    // Setup the text used for the element.
     $cs_text = variable_get('uc_continue_shopping_text', '') ? variable_get('uc_continue_shopping_text', '') : t('Continue shopping');
 
     // Add the element to the form based on the element type.
-
-
     if (variable_get('uc_continue_shopping_type', 'link') == 'link') {
       $form['continue_shopping'] = array(
         '#value' => l($cs_text, uc_cart_continue_shopping_url()),
@@ -649,9 +591,8 @@ function agres_bookings_cart_view_form_old($form, $form_state, $items = NULL) {
       );
     }
   }
-  // Add the control buttons for updating and proceeding to checkout.
-
 
+  // Add the control buttons for updating and proceeding to checkout.
   $form['update'] = array(
     '#type' => 'submit',
     '#value' => t('Update cart'),
@@ -666,36 +607,33 @@ function agres_bookings_cart_view_form_old($form, $form_state, $items = NULL) {
   }
   return $form;
 }
-//
-///**
-// * create an order automatically given a agreservation, and a user
-// */
-//function _agres_create_order($resnode, $user) {
-//
-//}
-//
-
 
+/**
+ * Implements hook_node_view().
+ */
 function agres_bookings_node_view($node, $view_mode, $langcode) {
   if ($node->type == 'agreservation') {
     if (user_access('access agres_bookings')) {
-//               drupal_set_message('<pre>$node'.print_r($node,true).'</pre>');
       $node->content['agres_createorder'] = array(
-        '#markup' => '<a class="Button" href="' . base_path() . 'agres_bookings/' . $node->nid . '"><span class="btn">' . '&nbsp;&nbsp;' . t('CREATE ORDER') . '&nbsp;&nbsp;' . '</span></a><br><br>', //l(' CREATE ORDER', 'agres_bookings/' . $node->nid),
+        '#markup' => '<a class="Button" href="' . base_path() . 'agres_bookings/' . $node->nid . '"><span class="btn">' . '&nbsp;&nbsp;' . t('CREATE ORDER') . '&nbsp;&nbsp;' . '</span></a><br><br>',
         '#weight' => -50,
       );
     }
   }
 }
 
-/*  simulate the pane contents for processing.
- this would change a lot depending on how your data is
- structured. here we're pulling info out of various storage
- arrays. the important things are that the pane values get
- populated and $_POST gets the payment info it needs.
- if you're using modules that create their own panes, they'll
- have to be added; this is a pretty vanilla UC install. */
-
+/**
+ * Simulate the pane contents for processing.
+ *
+ * This would change a lot depending on how your data is structured. Here we are
+ * pulling info out of various storage arrays. The important things are that the
+ * pane values get populated and $_POST gets the payment info it needs. If you
+ * are using modules that create their own panes, they will have to be added;
+ * this is a pretty vanilla UC install.
+ *
+ * @param type $account
+ * @return string
+ */
 function _agres_bookings_fill_checkout_pane_values($account) {
   $pane_values['customer'] = array(
     'primary_email' => $account->mail,
@@ -730,29 +668,30 @@ function _agres_bookings_fill_checkout_pane_values($account) {
 
 function _agres_bookings_create_order($account) {
   $error = FALSE;
-  // a cart id (cid) is just the uid for existing accounts.
-  // you could add any number of items to a cart
-//  uc_cart_add_item(ITEM_NID, 1, NULL, $account->uid, FALSE, FALSE, TRUE);
+  // A cart id (cid) is just the uid for existing accounts. You could add any
+  // number of items to a cart
+  // uc_cart_add_item(ITEM_NID, 1, NULL, $account->uid, FALSE, FALSE, TRUE);
 
   $cart_form_state['values']['op'] = t('Pending');
-  /*  uc_cart_update_item_object is the important part of
-   uc_cart_view_form_submit(), the rest is redirection and
-   sessions. user would then go off to  cart/checkout where
-   they'd enter payment info via uc_cart_checkout_form().
-
-   we don't even have to do this because all the modifications
-   would do is change cart quantities and we're beyond that.
-
-   uc_cart_checkout_form() handily checks the referer so it is
-   impossible to call it programmatically. there is a lot of
-   display stuff going on in there, but CC info is also being
-   gathered. in our case, we already have the CC info in
-   storage. */
+  /*
+   * uc_cart_update_item_object is the important part of
+   * uc_cart_view_form_submit(), the rest is redirection and sessions.
+   * A user would then go off to cart/checkout where they could enter payment
+   * info via uc_cart_checkout_form().
+   *
+   * We don't even have to do this because all the modifications would do is
+   * change cart quantities and we're beyond that.
+   *
+   * uc_cart_checkout_form() handily checks the referer so it is impossible to
+   * call it programmatically. there is a lot of display stuff going on in there,
+   * but CC info is also being gathered. In our case, we already have the CC info
+   * in storage.
+   */
 
   $order = uc_order_new($account->uid);
   $order->products = uc_cart_get_contents($account->uid);
 
-  // this bit is clipped from uc_cart_checkout_form_validate()
+  // This bit is clipped from uc_cart_checkout_form_validate()
   $context = array(
     'revision' => 'original',
     'type' => 'order_product',
@@ -783,13 +722,14 @@ function _agres_bookings_create_order($account) {
   $order->line_items = uc_order_load_line_items($order, TRUE);
   uc_order_save($order);
 
-  /*next onto /cart/checkout/review which is mostly about
-   displaying review info. uc_cart_checkout_review_form_submit()
-   is the finalize button on this page. it does some invocations
-   for UC 'submit', then redirects the user to
-   cart/checkout/complete */
+  /*
+   * Next onto /cart/checkout/review which is mostly about displaying review
+   * info. uc_cart_checkout_review_form_submit() is the finalize button on this
+   * page. It does some invocations for UC 'submit', then redirects the user to
+   * cart/checkout/complete
+   */
 
-  // clipped from uc_cart_checkout_review_form_submit()
+  // Clipped from uc_cart_checkout_review_form_submit()
   // Invoke it on a per-module basis instead of all at once.
   foreach (module_list() as $module) {
     $function = $module . '_order';
@@ -809,65 +749,29 @@ function _agres_bookings_create_order($account) {
 
   return $order;
 }
+
 function agres_bookings_uc_order($op, $arg1, $arg2) {
   switch ($op) {
-//    case 'new':
-//      if (isset($_SESSION['agres_bookings_checkintime']) && isset($_SESSION['agres_bookings_checkouttime'])) {
-//        unset($_SESSION['agres_bookings_checkintime']);
-//        unset($_SESSION['agres_bookings_checkouttime']);
-//        $_SESSION['agres_bookings_bookedunits'] = 0;
-//        $_SESSION['agres_bookings_step'] = 1;
-//      }
-//      if (isset($arg1->products[0]->data['agreservations_resid'])) {
-//        $arg1->data['agres'] = 'dies ist ein Test!!';
-//      }
-//      break;
     case 'submit':
       $pass = TRUE;
-      //  drupal_set_message('<pre>orderrr'.print_r($arg1,true).'</pre>');
-    //
-    //
       if (module_exists('uc_credit') && $arg1->payment_method == 'credit') {
         $ordertotaldepositmultiplikator = variable_get('agres_uc_credit_deposit', '1');
         $arg1->order_total = $arg1->order_total * floatval($ordertotaldepositmultiplikator);
       }
       break;
-    //
-//      //Abort-condition 1.:the agreservation failed, $arg1->products[0]->data['agreservations_resid'] not set:
-    //
-    //
-//      if (isset($arg1->products[0]->data['agreservations_resid'])) {
-//        if (node_load($arg1->products[0]->data['agreservations_resid'], NULL, TRUE) != FALSE) {
-//          // @todo -- The Reservation is there, now further testing:
-    //
-    //
-//        }
-//        else {
-//          $pass = FALSE;
-//        }
-//      }
-//      else {
-//        $pass = FALSE;
-//      }
-//      if (!$pass) {
-//        return array(array('pass' => FALSE, 'message' => t('the room could not be booked. Maybe its already reserved by someone else.')));
-//      }
-//      break;
     case 'save':
       foreach ($arg1->products as $product) {
         if (isset($product->data['agreservations_resid'])) {
 
           db_update('field_data_field_agres_orderid')
-      ->condition('entity_id', $product->data['agreservations_resid'])
-      ->fields(array('field_agres_orderid_value' => $arg1->order_id))
-      ->execute();
+            ->condition('entity_id', $product->data['agreservations_resid'])
+            ->fields(array('field_agres_orderid_value' => $arg1->order_id))
+            ->execute();
 
           db_update('field_data_field_agres_status')
-      ->condition('entity_id', $product->data['agreservations_resid'])
-      ->fields(array('field_agres_status_value' => AGRES_STATUS_ONLINE_ORDER_CREATED))
-      ->execute();
-
-//          drupal_set_message('<pre>orderrr--'.$product->data['agreservations_resid'].'-->'.print_r($arg1,true).'</pre>');
+            ->condition('entity_id', $product->data['agreservations_resid'])
+            ->fields(array('field_agres_status_value' => AGRES_STATUS_ONLINE_ORDER_CREATED))
+            ->execute();
         }
       }
       break;
@@ -888,9 +792,6 @@ function agres_bookings_uc_order($op, $arg1, $arg2) {
         $resnode = node_load($arg1->products[0]->data['agreservations_resid'], NULL, TRUE);
         if (isset($resnode)) {
           node_delete($resnode);
-//                  
-
-
         }
       }
 
@@ -898,44 +799,17 @@ function agres_bookings_uc_order($op, $arg1, $arg2) {
   }
 }
 
-///**
-// * @todo Please document this function.
-// * @see http://drupal.org/node/1354
-// */
-//function agres_bookings_delete_agreservation($order) {
-//  //not ready ergo not working!
-//
-//
-//  switch ($order->order_status) {
-//    case 'canceled':
-//      $message = t("Processing canceled booking(s)");
-//      $sign = "+";
-//      break;
-//    default:
-//      $message = t("Processing booking(s)");
-//      $sign = "-";
-//  }
-//  watchdog('agres bookings', $message);
-//  if (is_array($order->products)) {
-//
-//  }
-//}
-//
-///**
-
-
-//
-///**
-// * Implements hook_order_pane().
-// * this will introduce the callbackfunction
-// * agres_bookings_pane_reservation which lets the admin/receptionist
-// * make a unitreservation/add the unittypes as products to the order by
-// * using a similar multistepform like in the anonymous onlinebooking
-// */
+/**
+ * Implements hook_order_pane().
+ *
+ * This will introduce the callbackfunction agres_bookings_pane_reservation
+ * which lets the admin/receptionist make a unitreservation/add the unittypes as
+ * products to the order by using a similar multistepform like in the anonymous
+ * onlinebooking
+ */
 function agres_bookings_uc_order_pane() {
 
   $panes['agres_bookingsunitsearch'] = array(
-    //    'id' => 'agres_bookingsunitsearch',
     'callback' => 'agres_bookings_pane_reservation',
     'title' => t('Unit reservation'),
     'desc' => t('Define Checkin and Checkout Dates and Unit types'),
@@ -947,9 +821,9 @@ function agres_bookings_uc_order_pane() {
   return $panes;
 }
 
-///**
-// * Handle the "agres_bookings" order pane.
-// */$op, $order, &$form = NULL, &$form_state = NULL
+/**
+ * Handle the "agres_bookings" order pane.
+ */
 function _agres_bookings_show_dates($res) {
   $dateTimezone1 = new DateTimeZone(date_default_timezone());
   $dateTime1 = new DateTime($res->field_agres_rdate[$res->language][0]['value'], $dateTimezone1);
@@ -962,13 +836,15 @@ function _agres_bookings_show_dates($res) {
   return $displayreservation;
 }
 
+/**
+ * @todo Documentation
+ */
 function agres_bookings_pane_reservation($op, $order, &$form = NULL, &$form_state = NULL) { //($op, $arg1) {
   switch ($op) {
     case 'view':
       $reservations = _agres_bookings_get_reservation_by_orderid($order->order_id);
       $res = node_load($reservations[0]->nid);
       $displayreservation = _agres_bookings_show_dates($res);
-//      $displayreservation = l(t('checkin:') . $res->field_agres_rdate[$res->language][0]['value'] . '  ' . t('checkout:') . $res->field_agres_rdate[$res->language][0]['value2'],'node/'.$res->nid);
       $form['view_reservation'] = array(
         '#markup' => $displayreservation,
       );
@@ -991,52 +867,16 @@ function agres_bookings_pane_reservation($op, $order, &$form = NULL, &$form_stat
       return $form;
 
     case 'edit-title':
-      //have to returnb something if this case exists:
+      // Has to return something.
       return '';
     case 'edit-theme':
       return drupal_render($form['view_reservation']);
-
-
-    case 'edit-process': //submit changes button:
-
-//      if ($order['order_uid'] > 0) {
-      ////        $address = new stdClass();
-      ////        // Add the billing address first. If the user has no addresses,
-      ////
-      ////
-      ////        // this is the one that will become the default address
-      ////
-      ////
-      ////        $address->address_name = '';
-      ////        $address->uid = $arg1['order_uid'];
-      ////        $address->first_name = $arg1['billing_first_name'];
-      ////        $address->last_name = $arg1['billing_last_name'];
-      ////        $address->company = $arg1['billing_company'];
-      ////        $address->street1 = $arg1['billing_street1'];
-      ////        $address->street2 = $arg1['billing_street2'];
-      ////        $address->city = $arg1['billing_city'];
-      ////        $address->zone = $arg1['billing_zone'];
-      ////        $address->postal_code = $arg1['billing_postal_code'];
-      ////        $address->country = $arg1['billing_country'];
-      ////        $address->phone = $arg1['billing_phone'];
-      ////        $address->is_default = 1;
-      ////        _uc_addresses_db_add_address($address, TRUE);
-      ////        unset($address);
-//      }
-//      else {
-//        //                drupal_set_message($op .'<pre>*UID ist 0!**'. print_r($arg1, TRUE) .'</pre>');
-      //
-      //
-//      }
-//     //   drupal_set_message($op .'<pre>*$changes**'. print_r($arg1, TRUE) .'</pre>');
-
-//      return $changes;
   }
 }
-//
-///**
-// * get agreservations by orderid
-// */
+
+/**
+ * Get agreservations by orderid
+ */
 function _agres_bookings_get_reservation_by_orderid($orderid) {
   $query = db_select('node', 'n');
   $query->fields('n', array('nid', 'title'));
@@ -1049,44 +889,39 @@ function _agres_bookings_get_reservation_by_orderid($orderid) {
   $reservations = array();
 
   while ($reservation = $res->fetchObject()) {
-//  $reservations[$reservation->nid] = node_load($reservation->nid);
     $reservations[] = node_load($reservation->nid);
   }
   return $reservations;
 }
 
-///**
-// * @todo Please document this function.
-// * @see http://drupal.org/node/1354
-// */
+/**
+ * @todo Documentation
+ */
 function agres_bookings_multi_form_submit($form, &$form_state) {
-//      drupal_set_message($op .'<pre>agres_bookings_multi_form_submit:'. print_r($form, TRUE) .'</pre>');
+
   if (empty($_SESSION['agres_bookings_step'])) {
-    // we are coming in without a step, so default to step 1
+    // We are coming in without a step, so default to step 1
     $_SESSION['agres_bookings_step'] = 1;
   }
   $form_state['storage']['values'][$form_state['storage']['step']] = $form_state['values'];
-  // check the button that was clicked and action the step change
+
+  // Check the button that was clicked and action the step change
   $form_state['rebuild'] = TRUE;
   if ($form_state['clicked_button']['#id'] == 'edit-search') {
-//      drupal_set_message($op .'edit-search'. print_r($form_state, TRUE) .'</pre>');
     _agres_bookings_search_action($form, $form_state);
     $_SESSION['agres_bookings_step']++;
   }
   elseif ($form_state['clicked_button']['#id'] == 'edit-previous') {
-//       drupal_set_message($op .'edit-previous'. print_r($form_state, TRUE) .'</pre>');
     $_SESSION['agres_bookings_step']--;
   }
   elseif ($form_state['clicked_button']['#id'] == 'edit-reservation') {
-//   _agres_bookings_reserve_action($form, $form_state);
     _agres_bookings_reserve_action($form_state);
   }
 }
 
-///**
-// * @todo Please document this function.
-// * @see http://drupal.org/node/1354
-// */
+/**
+ * @todo Documentation
+ */
 function agres_bookings_menu() {
   $access = array('create_order_for_other');
   $items['agres_bookings/%'] = array(
@@ -1101,6 +936,7 @@ function agres_bookings_menu() {
 
   return $items;
 }
+
 /**
  * ...in future use this in place of the now different functions to fill a cart with
  * unit type and rate products...
@@ -1110,8 +946,6 @@ function agres_bookings_menu() {
 function _agres_bookings_fillcart($resnid, $uid = null) {
   $uid = $uid ? $uid : uc_cart_get_id();
   $resnode = node_load($resnid);
-//     $tmpcheckin = new DateObject($resnode->field_agres_rdate[$resnode->language][0]['value']);//date_create($userrequest['checkintime']);
-//     $tmpcheckout = new DateObject($resnode->field_agres_rdate[$resnode->language][0]['value2']);//date_create($userrequest['checkouttime']);
 
   $dateTimezone1 = new DateTimeZone(date_default_timezone());
   $tmpcheckindt = new DateTime($resnode->field_agres_rdate[$resnode->language][0]['value'], $dateTimezone1);
@@ -1132,7 +966,7 @@ function _agres_bookings_fillcart($resnid, $uid = null) {
   }
   foreach ($unitsToBookAll as $kutba => $unitsToBook) {
     $tmpunittype2 = node_load($kutba);
-    //should be 1 only:         
+    // Should be only one
     $tmpunittype2->field_agres_ref_category;
     if (module_exists('agres_categories')) {
       $tmpcat = node_load($tmpunittype2->field_agres_ref_category[$tmpunittype2->language][0]['nid']);
@@ -1145,15 +979,12 @@ function _agres_bookings_fillcart($resnid, $uid = null) {
     }
     if ($bookmode == BOOKING_MODE_BY_DAYS) {
 
-      // $times = date_difference(date_make_date(date_format($tmpcheckin, 'd.m.Y H:i')), date_make_date(date_format($tmpcheckout, 'd.m.Y H:i')), 'days');
-      $times =  $tmpcheckin->difference($tmpcheckout, 'days'); //date_difference(date_make_date($userrequest['checkintime']), date_make_date($userrequest['checkouttime']), 'days');         
+      $times = $tmpcheckin->difference($tmpcheckout, 'days');
     }
     elseif ($bookmode == BOOKING_MODE_BY_HOURS) {
-      $times =  $tmpcheckin->difference($tmpcheckout, 'hours');
-      //round up:
-      $times = ceil($times);
+      $times = ceil($tmpcheckin->difference($tmpcheckout, 'hours'));
     }
-    $agres_singletimes = createDateRangeArray($tmpcheckin->format('Y-m-d H:i:s'), $tmpcheckout->format('Y-m-d H:i:s'));
+    $agres_singletimes = _agreservations_create_date_range($tmpcheckin->format('Y-m-d H:i:s'), $tmpcheckout->format('Y-m-d H:i:s'));
 
     array_pop($agres_singletimes); //!!!
     $data = array(
@@ -1179,29 +1010,24 @@ function _agres_bookings_fillcart($resnid, $uid = null) {
       $unittyporrateesums[$key] = count($unittyporrateesum);
     }
     foreach ($unitsToBook as $unittobook) {
-      //only if rates are activated:
+      // Rates are activated
       if (module_exists('agres_rate')) {
         $ratesntypes = _agres_get_products_for_reservation($unittobook->field_agreservations_unittype[$unittobook->language][0]['nid'], $data);
         $ratesntypessums = array_count_values($ratesntypes);
         foreach ($ratesntypessums as $rot => $rateortypesum) {
-//               foreach ($ratesntypes as $rot => $rateortype) {
-          $data['times'] = $rateortypesum; //$ratesntypessums[$rateortype] * $unittyporrateesums[$unittobook->field_agreservations_unittype[0]['nid']];
+
+          $data['times'] = $rateortypesum;
           $data['agres_singletimes'] = array_keys($ratesntypes, $rot);
           $data['agres_diffproducts'] = $data['times'] / (count($data['agres_singletimes']));
-//               $data['times'] = $ratesntypessums[$rateortype];
-//               $data['agres_singletimes'] = array_keys ($ratesntypes ,$rateortype);
-          ////             drupal_set_message('<pre>enzelne zeiten von'.$rateortype.'->'.print_r($data['agres_singletimes'],true).' </pre>');
-          ////             module_invoke_all('add_to_cart_data', $form_state['values']);
+
           uc_cart_add_item($rot, $rateortypesum, $data, $uid);
         }
       }
       else {
         $data['times'] = $times * $unittyporrateesums[$unittobook->field_agreservations_unittype[$unittobook->language][0]['nid']];
-//             module_invoke_all('add_to_cart_data',$form_state['values']);
         uc_cart_add_item($unittobook->field_agreservations_unittype[0]['nid'], 1 * $times, $data, $uid); //*$nights
       }
     }
-
   }
   drupal_set_message(t('items added to cart of user.'));
   return;
@@ -1214,8 +1040,6 @@ function _agres_bookings_fillcart($resnid, $uid = null) {
  * @see uc_catalog_buy_it_now_form_validate()
  */
 function agres_bookings_buy_it_now_form_submit($form, &$form_state) {
-//    drupal_set_message('<pre>agres_bookings_buy_it_now_form_submit 123' . print_r($form_state, true) . '</pre>');
-//    module_invoke_all('uc_add_to_cart_data', $form_state['values']);
   $categorynid = $_SESSION['agreservationcategory'];
   $category = node_load($categorynid);
 
@@ -1223,7 +1047,6 @@ function agres_bookings_buy_it_now_form_submit($form, &$form_state) {
   if (!isset($category->field_agres_titleresform[$langcode])) {
     $langcode = 'und';
   }
-//      drupal_set_message('<pre>runitdd'.print_r( $form_state['values']['nid'],true).'</pre>'); 
   $userrequest = $_SESSION['agreservationuserrequest'];
   $agreservations_request = array(
     '',
@@ -1233,27 +1056,21 @@ function agres_bookings_buy_it_now_form_submit($form, &$form_state) {
     ),
   );
   $userrequestunit[]['selectunittype'] = $form_state['values']['nid'];
-  $unitsToBook = _agreservations_findunitsForUserRequest($userrequestunit, 
-                     $userrequest['checkintime'], 
-                     $userrequest['checkouttime'], $category);
+  $unitsToBook = _agreservations_find_units_for_user_request($userrequestunit, $userrequest['checkintime'], $userrequest['checkouttime'], $category);
 
   if (isset($category)) {
-//              $categorynid = $_SESSION['agres_category_nid'];
-//              $category = node_load($categorynid);
+
     $bookmode = $category->field_agres_bookingmode[$langcode][0]['value'];
     $measureingunit = $category->field_agres_measuringunit[$langcode][0]['value'];
-//                drupal_set_message('<pre>unitnidunitnidunitniddafgdfg'.print_r( $form_state['storage']['agres_category'],true).'</pre>');
   }
   $tmpcheckin = new DateObject($userrequest['checkintime']);
   $tmpcheckout = new DateObject($userrequest['checkouttime']);
   if ($bookmode == BOOKING_MODE_BY_DAYS) {
-    // $times = date_difference(date_make_date(date_format($tmpcheckin, 'd.m.Y H:i')), date_make_date(date_format($tmpcheckout, 'd.m.Y H:i')), 'days');
-    $times =  $tmpcheckin->difference($tmpcheckout, 'days'); //date_difference(date_make_date($userrequest['checkintime']), date_make_date($userrequest['checkouttime']), 'days');         
+
+    $times = $tmpcheckin->difference($tmpcheckout, 'days');
   }
   elseif ($bookmode == BOOKING_MODE_BY_HOURS) {
-    $times =  $tmpcheckin->difference($tmpcheckout, 'hours');
-    //round up:
-    $times = ceil($times);
+    $times = ceil($tmpcheckin->difference($tmpcheckout, 'hours'));
   }
   if (!$unitsToBook) {
     form_set_error('unitinfo', t('Booking not possible anymore. Not enough free units, try another selection please.'));
@@ -1265,18 +1082,18 @@ function agres_bookings_buy_it_now_form_submit($form, &$form_state) {
       'measuringunit' => $measureingunit,
     );
     $node = node_load($form_state['values']['nid']);
-    return $data; //array('module' => 'uc_product', 'shippable' => $node->shippable);
+    return $data;
   }
   else {
     unset($_SESSION['agres_res_info']);
-    $_SESSION['agres_res_info'] = ''; //$form_state['storage']['values'][1]['unitinfo'];
+    $_SESSION['agres_res_info'] = '';
     $resnid = NULL;
     $resnid = 0;
-    //CHECK IF ALREADY ARE ITEMS IN THE CART
+    // Check if there are already items in the cart!
     $items = uc_cart_get_contents(uc_cart_get_id());
     if (count($items) > 0) {
-       reset($items);
-      $firstitem = current($items);       
+      reset($items);
+      $firstitem = current($items);
       $resnid = $firstitem->data['agreservations_resid'];
       $resnid = _agreservations_update_Reservation($resnid, $unitsToBook, $userrequest['checkintime'], $userrequest['checkouttime'], NULL, NULL, AGRES_STATUS_ONLINE_NO_ORDER_YET);
     }
@@ -1293,15 +1110,12 @@ function agres_bookings_buy_it_now_form_submit($form, &$form_state) {
         $measureingunit = $category->field_agres_measuringunit[$langcode][0]['value'];
       }
       if ($bookmode == BOOKING_MODE_BY_DAYS) {
-        // $times = date_difference(date_make_date(date_format($tmpcheckin, 'd.m.Y H:i')), date_make_date(date_format($tmpcheckout, 'd.m.Y H:i')), 'days');
-        $times =  $tmpcheckin->difference($tmpcheckout, 'days'); //date_difference(date_make_date($userrequest['checkintime']), date_make_date($userrequest['checkouttime']), 'days');         
+        $times = $tmpcheckin->difference($tmpcheckout, 'days');
       }
       elseif ($bookmode == BOOKING_MODE_BY_HOURS) {
-        $times =  $tmpcheckin->difference($tmpcheckout, 'hours');
-        //round up:
-        $times = ceil($times);
+        $times = ceil($tmpcheckin->difference($tmpcheckout, 'hours'));
       }
-      $agres_singletimes = createDateRangeArray(date_format($tmpcheckin, 'Y-m-d H:i:s'), date_format($tmpcheckout,   'Y-m-d H:i:s'));
+      $agres_singletimes = _agreservations_create_date_range(date_format($tmpcheckin, 'Y-m-d H:i:s'), date_format($tmpcheckout, 'Y-m-d H:i:s'));
       array_pop($agres_singletimes);
       $data = array(
         'agres' => array('agreservations_request' => $agreservations_request),
@@ -1310,32 +1124,28 @@ function agres_bookings_buy_it_now_form_submit($form, &$form_state) {
         'times' => $times,
         'shippable' => false,
         'agres_singletimes' => $agres_singletimes,
-        'measuringunit' => $measureingunit,          
+        'measuringunit' => $measureingunit,
         'bookingmode' => $bookmode,
         'checkintime' => date_format($tmpcheckin, 'Y-m-d H:i:s'),
         'checkouttime' => date_format($tmpcheckout, 'Y-m-d H:i:s'),
-        'agres_category_nid' => $categorynid,  
+        'agres_category_nid' => $categorynid,
       );
 
       foreach ($unitsToBook as $unittobook) {
-        $unittyporrateesums[$unittobook->field_agreservations_unittype[$unittobook->language][0]['nid']][] =  $unittobook->nid;
+        $unittyporrateesums[$unittobook->field_agreservations_unittype[$unittobook->language][0]['nid']][] = $unittobook->nid;
       }
       foreach ($unittyporrateesums as $key => $unittyporrateesum) {
         $unittyporrateesums[$key] = count($unittyporrateesum);
       }
-//          drupal_set_message('<pre>test $unitsToBook'.print_r($unitsToBook,true).' </pre>');
       foreach ($unitsToBook as $unittobook) {
-        //only if rates are activated:
         if (module_exists('agres_rate')) {
           $ratesntypes = _agres_get_products_for_reservation($unittobook->field_agreservations_unittype[$unittobook->language][0]['nid'], $data);
           $ratesntypessums = array_count_values($ratesntypes);
-//           drupal_set_message('<pre>test b4foreach'.print_r($ratesntypes,true).' </pre>');
           foreach ($ratesntypes as $rot => $rateortype) {
             $data['times'] = $ratesntypessums[$rateortype] * $unittyporrateesums[$unittobook->field_agreservations_unittype[$unittobook->language][0]['nid']];
             $data['agres_singletimes'] = array_keys($ratesntypes, $rateortype);
             $data['agres_diffproducts'] = $data['times'] / (count($data['agres_singletimes']));
-//               drupal_set_message('<pre>test 1111'.print_r($ratesntypessums,true).' </pre>');
-            uc_cart_add_item($rateortype, 1, $data); //*$nights
+            uc_cart_add_item($rateortype, 1, $data);
           }
         }
         else {
@@ -1346,9 +1156,11 @@ function agres_bookings_buy_it_now_form_submit($form, &$form_state) {
       }
     }
   }
-//  $form_state['redirect'] = uc_cart_add_item($form_state['values']['nid'], 1,  module_invoke_all('uc_add_to_cart_data', $form_state['values']), NULL, variable_get('uc_cart_add_item_msg', TRUE));
 }
 
+/**
+ * @todo Documentation
+ */
 function agres_bookings_create_res_order($resid) {
   $resnode = null;
   $resnode = node_load($resid);
@@ -1375,32 +1187,26 @@ function agres_bookings_create_res_order($resid) {
   }
 }
 
-
+/**
+ * @todo Documentation
+ */
 function agres_bookings_views_query_alter(&$view, &$query) {
-//     drupal_set_message('<pre>agres_bookings_views_query_alter***->'.print_r($query,true).'</pre>'); 
   if ($view->name == 'agres_uc_catalog') {
-//    if ($view->args[0] == '0-9') {
     $agres_bookings_products_available = $_SESSION['agres_bookings_productsavailable'];
     $query->where[0]['conditions'][1]['field'] = 'node.nid';
     $query->where[0]['conditions'][1]['value'] = array_values($agres_bookings_products_available);
     $query->where[0]['conditions'][1]['operator'] = 'in';
-//    }
-//      drupal_set_message('<pre>agres_bookings_views_query_alter***->'.print_r($agres_bookings_products_available,true).'</pre>'); 
   }
 }
 
+/**
+ * @todo Documentation
+ */
 function agres_bookings_uc_invoice_templates() {
   return array('agradmin', 'agrcustomer');
 }
 
-//  function agres_bookings_theme_registry_alter(&$theme_registry) {
-//    drupal_set_message('<pre>läuft'.print_r(drupal_get_path('module', 'agres_bookings'),true).'</pre>'); 
-//  // so that templates are searched in my_module directory if not found in uc_order
-//   if (!empty($theme_registry['uc_order'])) {
-//        $theme_registry['uc_order']['theme paths'][] = drupal_get_path('module', 'agres_bookings');
-//      }
-//    }
-    /**
+/**
  * Preprocesses a formatted invoice with an order's data.
  *
  * @see uc_order--admin.tpl.php
@@ -1422,38 +1228,37 @@ function agres_bookings_preprocess_uc_order(&$variables) {
       $variables['shipping_method'] = TRUE;
       break;
   }
-  
+
   $reservations = _agres_bookings_get_reservation_by_orderid($order->order_id);
   $res = node_load($reservations[0]->nid);
   $variables['agrdate1'] = $res->field_agres_rdate[$res->language][0]['value'];
   $variables['agrdate2'] = $res->field_agres_rdate[$res->language][0]['value2'];
   $variables['shippable'] = uc_order_is_shippable($order);
-//  $variables[''];
-//  $tmeasuringunit = $order->products[0]->data['measuringunit'];  
-//  $variables['agrmeasuringunit'] = $tmeasuringunit;
-//  $variables['agrmeasuringunits'] = 
   $variables['products'] = $order->products;
   foreach ($variables['products'] as $prdkey => &$product) {
-    if (isset($product->data['agres_category_nid'])) {      
-      $agres_category = node_load($product->data['agres_category_nid']);     
-      if (count($product->data['agres_singletimes'])>1) {
+    if (isset($product->data['agres_category_nid'])) {
+      $agres_category = node_load($product->data['agres_category_nid']);
+      if (count($product->data['agres_singletimes']) > 1) {
         $product->agrmesunit = $agres_category->field_agres_pluralmeasure[$agres_category->language][0]['safe_value'];
         $variables['agrmeasuringunit'] = array($prdkey => t('units'),);
-      } else {
+      }
+      else {
         $variables['agrmeasuringunit'] = array($prdkey => t('unit'),);
         $product->agrmesunit = $agres_category->field_agres_measuringunit[$agres_category->language][0]['safe_value'];
       }
-    } else {
-    //category not set, use standard category:
-      if (count($product->data['agres_singletimes'])>1) {
+    }
+    else {
+      // Category not set, use standard category
+      if (count($product->data['agres_singletimes']) > 1) {
         $product->agrmesunit = t('days');
         $variables['agrmeasuringunit'] = array($prdkey => t('units'),);
-      } else {
+      }
+      else {
         $variables['agrmeasuringunit'] = array($prdkey => t('unit'),);
         $product->agrmesunit = t('day');
-      }       
-    }   
-    
+      }
+    }
+
     $product->total_price = uc_currency_format($product->price * $product->qty);
     if ($product->qty > 1) {
       $product->individual_price = t('(!price each)', array('!price' => uc_currency_format($product->price)));
@@ -1495,83 +1300,61 @@ function agres_bookings_preprocess_uc_order(&$variables) {
   // Add hook suggestions, default to customer template.
   $variables['theme_hook_suggestions'] = array(
     'uc_order__customer',
-    'agres_bookings_uc_order__' . $variables['template'],  
+    'agres_bookings_uc_order__' . $variables['template'],
   );
 }
+
 /**
  * Implements hook_theme_registry_alter()
+ *
  * This is from http://www.metachunk.com/blog/adding-module-path-drupal-7-theme-registry
  * Thanks!
-**/
+ */
 function agres_bookings_theme_registry_alter(&$theme_registry) {
   global $theme;
   $mod_path = drupal_get_path('module', 'agres_bookings');
-  $theme_registry_copy = $theme_registry;       // munge on a copy
+  $theme_registry_copy = $theme_registry;
   _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', $theme, $mod_path);
-//  drupal_set_message('<pre>$theme_registry_copy$theme_registry_copy***->'.print_r($theme_registry_copy,true).'</pre>'); 
   $theme_registry += array_diff_key($theme_registry_copy, $theme_registry);
-//  drupal_set_message('<pre>$theme_registry$theme_registry$theme_registry***->'.print_r($theme_registry,true).'</pre>'); 
-  $hooks = array('uc_order','uc_order__agrcustomer','uc_order__admin');
+  $hooks = array('uc_order', 'uc_order__agrcustomer', 'uc_order__admin');
   foreach ($hooks as $h) {
     if (!isset($theme_registry[$h]['theme paths'])) {
-       _agres_bookings_insert_new_element($theme_registry[$h],'theme paths', $mod_path);
-    } else {
+      _agres_bookings_insert_new_element($theme_registry[$h], 'theme paths', $mod_path);
+    }
+    else {
       _agres_bookings_insert_after_first_element($theme_registry[$h]['theme paths'], $mod_path);
-    }   
+    }
   }
-
 }
 
 /**
  * Helper function for re-ordering arrays (needed by theme_registry_alter)
+ *
  * This is from http://www.metachunk.com/blog/adding-module-path-drupal-7-theme-registry
  * Thanks!
-*/
-function _agres_bookings_insert_after_first_element(&$a,$element) {  
-  if(is_array($a)) {
+ */
+function _agres_bookings_insert_after_first_element(&$a, $element) {
+  if (is_array($a)) {
     $first_element = array_shift($a);
     array_unshift($a, $first_element, $element);
-  } else {
-    
   }
-}    
+}
 
-function _agres_bookings_insert_new_element(&$a,$emlemname,$element) {   
-//  
-  if(is_array($a)) {
-    $newelem = array($emlemname=>array($element));
+/**
+ * @todo Documentation
+ */
+function _agres_bookings_insert_new_element(&$a, $emlemname, $element) {
+  if (is_array($a)) {
+    $newelem = array($emlemname => array($element));
     $a += $newelem;
-  } else {
-    
   }
-//   drupal_set_message('<pre>$a$a$a$a**element*->'.print_r($a,true).'</pre>'); 
-}  
-
+}
 
+/**
+ * @todo Documentation
+ */
 function agres_bookings_form_alter(&$form, &$form_state, $form_id) {
 
-  if (isset($form['type']['#value'])) {
-    if ($form['type']['#value'] == 'agreservation') {
-      $node = node_load($form['nid']['#value']);
-      if (user_access('access agres_bookings')) {
-        if (!empty($form['nid']['#value'])) {
-//             if (empty($node->field_agres_orderid[0]['value'])) {
-          //
-//               $form['agres_linebreak'] = array(
-//                   '#value' => '<br>',
-//                   '#weight' => -100,
-//               );
-//               $form['create_order'] = array(
-//                   '#type' => 'submit',
-//                   '#value' => t('fill cart according to selected units'),
-//                   '#weight' => -100,
-//               );
-//               $form['#submit']['create_order'] = 'agres_bookings_create_order_submit';
-//             }
-        }
-      }
-    }
-  }
   if ($form_id == 'uc_cart_checkout_form') {
     foreach ($form['panes']['payment']['payment_method']['#options'] as $key => $value) {
       if ($key == 'credit') {
@@ -1593,24 +1376,19 @@ function agres_bookings_form_alter(&$form, &$form_state, $form_id) {
   }
 
   if (strpos($form_id, 'uc_catalog_buy_it_now_form') === 0) {
-
-//      drupal_set_message('<pre>1111111111 '.print_r( $form_id,true).'</pre>');
-//        $items = uc_cart_get_contents(uc_cart_get_id());
-//        drupal_set_message('<pre>agres_categories_form_alter ' . print_r($items, true) . '</pre>');
     unset($form['#submit']);
     $form['#submit'][] = 'agres_bookings_buy_it_now_form_submit';
-
   }
 
 
   if (isset($form['type']['#value'])) {
     if ($form['type']['#value'] == 'agreservation') {
       $node = node_load($form['nid']['#value']);
-      //checkbox:create order on submit:
+      // Checkbox: Create order on submit
       $form['createorder'] = array(
         '#type' => 'checkbox',
         '#title' => t('Create Order'),
       );
     }
   }
-}
+}
\ No newline at end of file
diff --git a/agres_bookings/agres_bookings.views_default.inc b/agres_bookings/agres_bookings.views_default.inc
index d432340..5542ba9 100644
--- a/agres_bookings/agres_bookings.views_default.inc
+++ b/agres_bookings/agres_bookings.views_default.inc
@@ -1,210 +1,210 @@
 <?php
-// $Id: agres_categories.views.inc,v 1.1.2.5 2010/12/23 02:25:46 agill Exp $
-
-/**
- * @file
- * Bulk export of views_default objects generated by Bulk export module.
- */
-/**
- * Implements hook_views_default_views().
- */
-function agres_bookings_views_default_views() {
-  $views = array();
-
-  $view = new view;
-  $view->name = 'agres_uc_catalog';
-  $view->description = 'Catalog';
-  $view->tag = '';
-  $view->base_table = 'node';
-  $view->human_name = 'agres_uc_catalog';
-  $view->core = 0;
-  $view->api_version = '3.0';
-  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-
-  /* Display: Defaults */
-  $handler = $view->new_display('default', 'Defaults', 'default');
-  $handler->display->display_options['title'] = 'Catalog';
-  $handler->display->display_options['access']['type'] = 'none';
-  $handler->display->display_options['cache']['type'] = 'none';
-  $handler->display->display_options['query']['type'] = 'views_query';
-  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
-  $handler->display->display_options['exposed_form']['type'] = 'basic';
-  $handler->display->display_options['pager']['type'] = 'full';
-  $handler->display->display_options['style_plugin'] = 'table';
-  $handler->display->display_options['style_options']['columns'] = array(
-    'entity_id' => 'entity_id',
-    'model' => 'model',
-    'timestamp' => 'timestamp',
-    'title' => 'title',
-    'sell_price' => 'sell_price',
-    'buyitnowbutton' => 'buyitnowbutton',
-  );
-  $handler->display->display_options['style_options']['default'] = '-1';
-  $handler->display->display_options['style_options']['info'] = array(
-    'entity_id' => array(
-      'sortable' => 0,
-      'align' => '',
-      'separator' => '',
-    ),
-    'model' => array(
-      'sortable' => 1,
-      'align' => '',
-      'separator' => '',
-    ),
-    'timestamp' => array(
-      'align' => '',
-      'separator' => '',
-    ),
-    'title' => array(
-      'sortable' => 1,
-      'align' => '',
-      'separator' => '',
-    ),
-    'sell_price' => array(
-      'sortable' => 1,
-      'align' => '',
-      'separator' => '',
-    ),
-    'buyitnowbutton' => array(
-      'align' => '',
-      'separator' => '',
-    ),
-  );
-  $handler->display->display_options['style_options']['override'] = 1;
-  $handler->display->display_options['style_options']['sticky'] = 1;
-  /* Field: Content: Image */
-  $handler->display->display_options['fields']['entity_id']['id'] = 'entity_id';
-  $handler->display->display_options['fields']['entity_id']['table'] = 'field_data_uc_product_image';
-  $handler->display->display_options['fields']['entity_id']['field'] = 'uc_product_image';
-  $handler->display->display_options['fields']['entity_id']['label'] = '';
-  $handler->display->display_options['fields']['entity_id']['alter']['alter_text'] = 0;
-  $handler->display->display_options['fields']['entity_id']['alter']['make_link'] = 0;
-  $handler->display->display_options['fields']['entity_id']['alter']['absolute'] = 0;
-  $handler->display->display_options['fields']['entity_id']['alter']['word_boundary'] = 1;
-  $handler->display->display_options['fields']['entity_id']['alter']['ellipsis'] = 1;
-  $handler->display->display_options['fields']['entity_id']['alter']['strip_tags'] = 0;
-  $handler->display->display_options['fields']['entity_id']['alter']['trim'] = 0;
-  $handler->display->display_options['fields']['entity_id']['alter']['html'] = 0;
-  $handler->display->display_options['fields']['entity_id']['hide_empty'] = 1;
-  $handler->display->display_options['fields']['entity_id']['empty_zero'] = 0;
-  $handler->display->display_options['fields']['entity_id']['settings'] = array(
-    'image_style' => 'uc_product_list',
-    'image_link' => 'content',
-  );
-  /* Field: Product: SKU */
-  $handler->display->display_options['fields']['model']['id'] = 'model';
-  $handler->display->display_options['fields']['model']['table'] = 'uc_products';
-  $handler->display->display_options['fields']['model']['field'] = 'model';
-  $handler->display->display_options['fields']['model']['alter']['alter_text'] = 0;
-  $handler->display->display_options['fields']['model']['alter']['make_link'] = 0;
-  $handler->display->display_options['fields']['model']['alter']['absolute'] = 0;
-  $handler->display->display_options['fields']['model']['alter']['word_boundary'] = 1;
-  $handler->display->display_options['fields']['model']['alter']['ellipsis'] = 1;
-  $handler->display->display_options['fields']['model']['alter']['strip_tags'] = 0;
-  $handler->display->display_options['fields']['model']['alter']['trim'] = 0;
-  $handler->display->display_options['fields']['model']['alter']['html'] = 0;
-  $handler->display->display_options['fields']['model']['hide_empty'] = 0;
-  $handler->display->display_options['fields']['model']['empty_zero'] = 0;
-  $handler->display->display_options['fields']['model']['link_to_node'] = 0;
-  /* Field: Content: Has new content */
-  $handler->display->display_options['fields']['timestamp']['id'] = 'timestamp';
-  $handler->display->display_options['fields']['timestamp']['table'] = 'history';
-  $handler->display->display_options['fields']['timestamp']['field'] = 'timestamp';
-  $handler->display->display_options['fields']['timestamp']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['timestamp']['alter']['alter_text'] = 0;
-  $handler->display->display_options['fields']['timestamp']['alter']['make_link'] = 0;
-  $handler->display->display_options['fields']['timestamp']['alter']['absolute'] = 0;
-  $handler->display->display_options['fields']['timestamp']['alter']['word_boundary'] = 1;
-  $handler->display->display_options['fields']['timestamp']['alter']['ellipsis'] = 1;
-  $handler->display->display_options['fields']['timestamp']['alter']['strip_tags'] = 0;
-  $handler->display->display_options['fields']['timestamp']['alter']['trim'] = 0;
-  $handler->display->display_options['fields']['timestamp']['alter']['html'] = 0;
-  $handler->display->display_options['fields']['timestamp']['hide_empty'] = 0;
-  $handler->display->display_options['fields']['timestamp']['empty_zero'] = 0;
-  $handler->display->display_options['fields']['timestamp']['link_to_node'] = 0;
-  $handler->display->display_options['fields']['timestamp']['comments'] = 0;
-  /* Field: Content: Title */
-  $handler->display->display_options['fields']['title']['id'] = 'title';
-  $handler->display->display_options['fields']['title']['table'] = 'node';
-  $handler->display->display_options['fields']['title']['field'] = 'title';
-  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 1;
-  $handler->display->display_options['fields']['title']['alter']['text'] = '[title] [timestamp]';
-  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
-  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
-  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
-  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
-  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
-  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
-  /* Field: Product: Sell price */
-  $handler->display->display_options['fields']['sell_price']['id'] = 'sell_price';
-  $handler->display->display_options['fields']['sell_price']['table'] = 'uc_products';
-  $handler->display->display_options['fields']['sell_price']['field'] = 'sell_price';
-  $handler->display->display_options['fields']['sell_price']['label'] = 'Price';
-  $handler->display->display_options['fields']['sell_price']['alter']['alter_text'] = 0;
-  $handler->display->display_options['fields']['sell_price']['alter']['make_link'] = 0;
-  $handler->display->display_options['fields']['sell_price']['alter']['absolute'] = 0;
-  $handler->display->display_options['fields']['sell_price']['alter']['word_boundary'] = 1;
-  $handler->display->display_options['fields']['sell_price']['alter']['ellipsis'] = 1;
-  $handler->display->display_options['fields']['sell_price']['alter']['strip_tags'] = 0;
-  $handler->display->display_options['fields']['sell_price']['alter']['trim'] = 0;
-  $handler->display->display_options['fields']['sell_price']['alter']['html'] = 0;
-  $handler->display->display_options['fields']['sell_price']['hide_empty'] = 0;
-  $handler->display->display_options['fields']['sell_price']['empty_zero'] = 0;
-  $handler->display->display_options['fields']['sell_price']['set_precision'] = 0;
-  $handler->display->display_options['fields']['sell_price']['precision'] = '0';
-  $handler->display->display_options['fields']['sell_price']['format_plural'] = 0;
-  /* Field: Product: Buy it now button */
-  $handler->display->display_options['fields']['buyitnowbutton']['id'] = 'buyitnowbutton';
-  $handler->display->display_options['fields']['buyitnowbutton']['table'] = 'uc_products';
-  $handler->display->display_options['fields']['buyitnowbutton']['field'] = 'buyitnowbutton';
-  $handler->display->display_options['fields']['buyitnowbutton']['label'] = '';
-  $handler->display->display_options['fields']['buyitnowbutton']['alter']['alter_text'] = 0;
-  $handler->display->display_options['fields']['buyitnowbutton']['alter']['make_link'] = 0;
-  $handler->display->display_options['fields']['buyitnowbutton']['alter']['absolute'] = 0;
-  $handler->display->display_options['fields']['buyitnowbutton']['alter']['word_boundary'] = 1;
-  $handler->display->display_options['fields']['buyitnowbutton']['alter']['ellipsis'] = 1;
-  $handler->display->display_options['fields']['buyitnowbutton']['alter']['strip_tags'] = 0;
-  $handler->display->display_options['fields']['buyitnowbutton']['alter']['trim'] = 0;
-  $handler->display->display_options['fields']['buyitnowbutton']['alter']['html'] = 0;
-  $handler->display->display_options['fields']['buyitnowbutton']['hide_empty'] = 0;
-  $handler->display->display_options['fields']['buyitnowbutton']['empty_zero'] = 0;
-  /* Filter criterion: Content: Type */
-  $handler->display->display_options['filters']['type']['id'] = 'type';
-  $handler->display->display_options['filters']['type']['table'] = 'node';
-  $handler->display->display_options['filters']['type']['field'] = 'type';
-  $handler->display->display_options['filters']['type']['value'] = array(
-    'agreservations_unittype' => 'agreservations_unittype',
-  );
-
-  /* Display: Page */
-  $handler = $view->new_display('page', 'Page', 'catalog');
-  $handler->display->display_options['path'] = '_agrcatalog';
-  $translatables['agres_uc_catalog'] = array(
-    t('Defaults'),
-    t('Catalog'),
-    t('more'),
-    t('Apply'),
-    t('Reset'),
-    t('Sort by'),
-    t('Asc'),
-    t('Desc'),
-    t('Items per page'),
-    t('- All -'),
-    t('Offset'),
-    t('SKU'),
-    t('Has new content'),
-    t('Title'),
-    t('[title] [timestamp]'),
-    t('Price'),
-    t('.'),
-    t(','),
-    t('Page'),
-  );
-  $views['agres_uc_catalog'] = $view;
-
-  return $views;
-}
+
+/**
+ * @file
+ * Bulk export of views_default objects generated by Bulk export module.
+ */
+
+/**
+ * Implements hook_views_default_views().
+ */
+function agres_bookings_views_default_views() {
+  $views = array();
+
+  $view = new view;
+  $view->name = 'agres_uc_catalog';
+  $view->description = 'Catalog';
+  $view->tag = '';
+  $view->base_table = 'node';
+  $view->human_name = 'agres_uc_catalog';
+  $view->core = 0;
+  $view->api_version = '3.0';
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+  /* Display: Defaults */
+  $handler = $view->new_display('default', 'Defaults', 'default');
+  $handler->display->display_options['title'] = 'Catalog';
+  $handler->display->display_options['access']['type'] = 'none';
+  $handler->display->display_options['cache']['type'] = 'none';
+  $handler->display->display_options['query']['type'] = 'views_query';
+  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
+  $handler->display->display_options['exposed_form']['type'] = 'basic';
+  $handler->display->display_options['pager']['type'] = 'full';
+  $handler->display->display_options['style_plugin'] = 'table';
+  $handler->display->display_options['style_options']['columns'] = array(
+    'entity_id' => 'entity_id',
+    'model' => 'model',
+    'timestamp' => 'timestamp',
+    'title' => 'title',
+    'sell_price' => 'sell_price',
+    'buyitnowbutton' => 'buyitnowbutton',
+  );
+  $handler->display->display_options['style_options']['default'] = '-1';
+  $handler->display->display_options['style_options']['info'] = array(
+    'entity_id' => array(
+      'sortable' => 0,
+      'align' => '',
+      'separator' => '',
+    ),
+    'model' => array(
+      'sortable' => 1,
+      'align' => '',
+      'separator' => '',
+    ),
+    'timestamp' => array(
+      'align' => '',
+      'separator' => '',
+    ),
+    'title' => array(
+      'sortable' => 1,
+      'align' => '',
+      'separator' => '',
+    ),
+    'sell_price' => array(
+      'sortable' => 1,
+      'align' => '',
+      'separator' => '',
+    ),
+    'buyitnowbutton' => array(
+      'align' => '',
+      'separator' => '',
+    ),
+  );
+  $handler->display->display_options['style_options']['override'] = 1;
+  $handler->display->display_options['style_options']['sticky'] = 1;
+  /* Field: Content: Image */
+  $handler->display->display_options['fields']['entity_id']['id'] = 'entity_id';
+  $handler->display->display_options['fields']['entity_id']['table'] = 'field_data_uc_product_image';
+  $handler->display->display_options['fields']['entity_id']['field'] = 'uc_product_image';
+  $handler->display->display_options['fields']['entity_id']['label'] = '';
+  $handler->display->display_options['fields']['entity_id']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['entity_id']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['entity_id']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['entity_id']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['entity_id']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['entity_id']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['entity_id']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['entity_id']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['entity_id']['hide_empty'] = 1;
+  $handler->display->display_options['fields']['entity_id']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['entity_id']['settings'] = array(
+    'image_style' => 'uc_product_list',
+    'image_link' => 'content',
+  );
+  /* Field: Product: SKU */
+  $handler->display->display_options['fields']['model']['id'] = 'model';
+  $handler->display->display_options['fields']['model']['table'] = 'uc_products';
+  $handler->display->display_options['fields']['model']['field'] = 'model';
+  $handler->display->display_options['fields']['model']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['model']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['model']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['model']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['model']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['model']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['model']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['model']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['model']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['model']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['model']['link_to_node'] = 0;
+  /* Field: Content: Has new content */
+  $handler->display->display_options['fields']['timestamp']['id'] = 'timestamp';
+  $handler->display->display_options['fields']['timestamp']['table'] = 'history';
+  $handler->display->display_options['fields']['timestamp']['field'] = 'timestamp';
+  $handler->display->display_options['fields']['timestamp']['exclude'] = TRUE;
+  $handler->display->display_options['fields']['timestamp']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['timestamp']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['timestamp']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['timestamp']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['timestamp']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['timestamp']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['timestamp']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['timestamp']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['timestamp']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['timestamp']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['timestamp']['link_to_node'] = 0;
+  $handler->display->display_options['fields']['timestamp']['comments'] = 0;
+  /* Field: Content: Title */
+  $handler->display->display_options['fields']['title']['id'] = 'title';
+  $handler->display->display_options['fields']['title']['table'] = 'node';
+  $handler->display->display_options['fields']['title']['field'] = 'title';
+  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 1;
+  $handler->display->display_options['fields']['title']['alter']['text'] = '[title] [timestamp]';
+  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
+  /* Field: Product: Sell price */
+  $handler->display->display_options['fields']['sell_price']['id'] = 'sell_price';
+  $handler->display->display_options['fields']['sell_price']['table'] = 'uc_products';
+  $handler->display->display_options['fields']['sell_price']['field'] = 'sell_price';
+  $handler->display->display_options['fields']['sell_price']['label'] = 'Price';
+  $handler->display->display_options['fields']['sell_price']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['sell_price']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['sell_price']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['sell_price']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['sell_price']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['sell_price']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['sell_price']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['sell_price']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['sell_price']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['sell_price']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['sell_price']['set_precision'] = 0;
+  $handler->display->display_options['fields']['sell_price']['precision'] = '0';
+  $handler->display->display_options['fields']['sell_price']['format_plural'] = 0;
+  /* Field: Product: Buy it now button */
+  $handler->display->display_options['fields']['buyitnowbutton']['id'] = 'buyitnowbutton';
+  $handler->display->display_options['fields']['buyitnowbutton']['table'] = 'uc_products';
+  $handler->display->display_options['fields']['buyitnowbutton']['field'] = 'buyitnowbutton';
+  $handler->display->display_options['fields']['buyitnowbutton']['label'] = '';
+  $handler->display->display_options['fields']['buyitnowbutton']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['buyitnowbutton']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['buyitnowbutton']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['buyitnowbutton']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['buyitnowbutton']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['buyitnowbutton']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['buyitnowbutton']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['buyitnowbutton']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['buyitnowbutton']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['buyitnowbutton']['empty_zero'] = 0;
+  /* Filter criterion: Content: Type */
+  $handler->display->display_options['filters']['type']['id'] = 'type';
+  $handler->display->display_options['filters']['type']['table'] = 'node';
+  $handler->display->display_options['filters']['type']['field'] = 'type';
+  $handler->display->display_options['filters']['type']['value'] = array(
+    'agreservations_unittype' => 'agreservations_unittype',
+  );
+
+  /* Display: Page */
+  $handler = $view->new_display('page', 'Page', 'catalog');
+  $handler->display->display_options['path'] = '_agrcatalog';
+  $translatables['agres_uc_catalog'] = array(
+    t('Defaults'),
+    t('Catalog'),
+    t('more'),
+    t('Apply'),
+    t('Reset'),
+    t('Sort by'),
+    t('Asc'),
+    t('Desc'),
+    t('Items per page'),
+    t('- All -'),
+    t('Offset'),
+    t('SKU'),
+    t('Has new content'),
+    t('Title'),
+    t('[title] [timestamp]'),
+    t('Price'),
+    t('.'),
+    t(','),
+    t('Page'),
+  );
+  $views['agres_uc_catalog'] = $view;
+
+  return $views;
+}
diff --git a/agres_bookings/uc-order--agrcustomer.tpl.php b/agres_bookings/uc-order--agrcustomer.tpl.php
index 75d1cea..61b30e2 100644
--- a/agres_bookings/uc-order--agrcustomer.tpl.php
+++ b/agres_bookings/uc-order--agrcustomer.tpl.php
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * This file is the default customer invoice template for Ubercart.
@@ -44,43 +43,43 @@
     <td>
       <table width="100%" border="0" cellspacing="0" cellpadding="5" align="center" bgcolor="#FFFFFF" style="font-family: verdana, arial, helvetica; font-size: small;">
         <?php if ($business_header): ?>
-        <tr valign="top">
-          <td>
-            <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
-              <tr>
-                <td>
-                  <?php print $site_logo; ?>
-                </td>
-                <td width="98%">
-                  <div style="padding-left: 1em;">
-                  <span style="font-size: large;"><?php print $store_name; ?></span><br />
-                  <?php print $site_slogan; ?>
-                  </div>
-                </td>
-                <td nowrap="nowrap">
-                  <?php print $store_address; ?><br /><?php print $store_phone; ?>
-                </td>
-              </tr>
-            </table>
-          </td>
-        </tr>
+          <tr valign="top">
+            <td>
+              <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
+                <tr>
+                  <td>
+                    <?php print $site_logo; ?>
+                  </td>
+                  <td width="98%">
+                    <div style="padding-left: 1em;">
+                      <span style="font-size: large;"><?php print $store_name; ?></span><br />
+                      <?php print $site_slogan; ?>
+                    </div>
+                  </td>
+                  <td nowrap="nowrap">
+                    <?php print $store_address; ?><br /><?php print $store_phone; ?>
+                  </td>
+                </tr>
+              </table>
+            </td>
+          </tr>
         <?php endif; ?>
 
         <tr valign="top">
           <td>
 
             <?php if ($thank_you_message): ?>
-            <p><b><?php print t('Thanks for your order, !order_first_name!', array('!order_first_name' => $order_first_name)); ?></b></p>
+              <p><b><?php print t('Thanks for your order, !order_first_name!', array('!order_first_name' => $order_first_name)); ?></b></p>
 
-            <?php if (isset($order->data['new_user'])): ?>
-            <p><b><?php print t('An account has been created for you with the following details:'); ?></b></p>
-            <p><b><?php print t('Username:'); ?></b> <?php print $order_new_username; ?><br />
-            <b><?php print t('Password:'); ?></b> <?php print $order_new_password; ?></p>
-            <?php endif; ?>
+              <?php if (isset($order->data['new_user'])): ?>
+                <p><b><?php print t('An account has been created for you with the following details:'); ?></b></p>
+                <p><b><?php print t('Username:'); ?></b> <?php print $order_new_username; ?><br />
+                  <b><?php print t('Password:'); ?></b> <?php print $order_new_password; ?></p>
+              <?php endif; ?>
 
-            <p><b><?php print t('Want to manage your order online?'); ?></b><br />
-            <?php print t('If you need to check the status of your order, please visit our home page at !store_link and click on "My account" in the menu or login with the following link:', array('!store_link' => $store_link)); ?>
-            <br /><br /><?php print $site_login_link; ?></p>
+              <p><b><?php print t('Want to manage your order online?'); ?></b><br />
+                <?php print t('If you need to check the status of your order, please visit our home page at !store_link and click on "My account" in the menu or login with the following link:', array('!store_link' => $store_link)); ?>
+                <br /><br /><?php print $site_login_link; ?></p>
             <?php endif; ?>
 
             <table cellpadding="4" cellspacing="0" border="0" width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
@@ -95,7 +94,7 @@
                 <td width="98%">
                   <?php echo $agrdate1; ?>
                 </td>
-              </tr>    
+              </tr>
               <tr>
                 <td nowrap="nowrap">
                   <b><?php echo t('Departure Date / Check-Out Date :'); ?></b>
@@ -103,7 +102,7 @@
                 <td width="98%">
                   <?php echo $agrdate2; ?>
                 </td>
-              </tr>               
+              </tr>
               <tr>
                 <td colspan="2" bgcolor="#006699" style="color: white;">
                   <b><?php print t('Purchasing Information:'); ?></b>
@@ -130,13 +129,13 @@
                         <?php print $order_billing_phone; ?><br />
                       </td>
                       <?php if ($shippable): ?>
-                      <td valign="top" width="50%">
-                        <b><?php print t('Shipping Address:'); ?></b><br />
-                        <?php print $order_shipping_address; ?><br />
-                        <br />
-                        <b><?php print t('Shipping Phone:'); ?></b><br />
-                        <?php print $order_shipping_phone; ?><br />
-                      </td>
+                        <td valign="top" width="50%">
+                          <b><?php print t('Shipping Address:'); ?></b><br />
+                          <?php print $order_shipping_address; ?><br />
+                          <br />
+                          <b><?php print t('Shipping Phone:'); ?></b><br />
+                          <?php print $order_shipping_phone; ?><br />
+                        </td>
                       <?php endif; ?>
                     </tr>
                   </table>
@@ -167,11 +166,11 @@
               </tr>
 
               <?php if ($shippable): ?>
-              <tr>
-                <td colspan="2" bgcolor="#EEEEEE">
-                  <font color="#CC6600"><b><?php print t('Shipping Details:'); ?></b></font>
-                </td>
-              </tr>
+                <tr>
+                  <td colspan="2" bgcolor="#EEEEEE">
+                    <font color="#CC6600"><b><?php print t('Shipping Details:'); ?></b></font>
+                  </td>
+                </tr>
               <?php endif; ?>
 
               <tr>
@@ -197,14 +196,14 @@
                     </tr>
 
                     <?php if ($shipping_method && $shippable): ?>
-                    <tr>
-                      <td nowrap="nowrap">
-                        <b><?php print t('Shipping Method:'); ?></b>
-                      </td>
-                      <td width="98%">
-                        <?php print $order_shipping_method; ?>
-                      </td>
-                    </tr>
+                      <tr>
+                        <td nowrap="nowrap">
+                          <b><?php print t('Shipping Method:'); ?></b>
+                        </td>
+                        <td width="98%">
+                          <?php print $order_shipping_method; ?>
+                        </td>
+                      </tr>
                     <?php endif; ?>
 
                     <tr>
@@ -217,16 +216,16 @@
                     </tr>
 
                     <?php foreach ($line_items as $item): ?>
-                    <?php if ($item['type'] == 'subtotal' || $item['type'] == 'total')  continue; ?>
+                      <?php if ($item['type'] == 'subtotal' || $item['type'] == 'total') continue; ?>
 
-                    <tr>
-                      <td nowrap="nowrap">
-                        <?php print $item['title']; ?>:
-                      </td>
-                      <td>
-                        <?php print $item['formatted_amount']; ?>
-                      </td>
-                    </tr>
+                      <tr>
+                        <td nowrap="nowrap">
+                          <?php print $item['title']; ?>:
+                        </td>
+                        <td>
+                          <?php print $item['formatted_amount']; ?>
+                        </td>
+                      </tr>
 
                     <?php endforeach; ?>
 
@@ -250,56 +249,53 @@
 
                         <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
                           <?php foreach ($products as $product): ?>
-                          <tr>
-                          
-                            <td valign="top" nowrap="nowrap">
-                              <?php
-                                 $timeinfo = '';
-                                 if (isset($product->data['agres_singletimes'])) { 
-                                   
-                                   if (count($product->data['agres_singletimes']) > 1) {
-                                     if(($product->qty/count($product->data['agres_singletimes']))>1){
-                                       $timeinfo = $product->qty/count($product->data['agres_singletimes']).' '.$product->title;
-                                     }
-                                     else {
-                                       $timeinfo = $product->qty/count($product->data['agres_singletimes']).' '.$product->title;
-                                     }
-                                   
-                                 if ($product->qty > 1) {
-                                $price_info['qty'] = 1;
-//                                $product->individual_price = t('(!price each)', array('!price' => uc_currency_format($product->price)));
-                                 $timeinfo .=' '.$product->individual_price;
-                                 $price_info['qty'] = $product->qty;
-                                } 
-                                     if (strpos($timeinfo, $product->data['agres_singletimes'][0] . '<br>'.t('Until:') . end($product->data['agres_singletimes']) .' ('.t('included').')'. ' X ' . count($product->data['agres_singletimes']).' '.$product->agrmesunit,0)==false) {
-                                       $timeinfo .= '<br>'.t('From:'). $product->data['agres_singletimes'][0] . '<br>'.t('Until:') . end($product->data['agres_singletimes']) .' ('.t('included').')'. ' X ' . count($product->data['agres_singletimes']).' '.$product->agrmesunit;
-                                     }
-                                   }
-                                   else {
-                                    // if (strpos($title, $item->data['agres_singletimes'][0].', '.end($item->data['agres_singletimes']).' = '.$tmeasuringunit.' count: '.count($item->data['agres_singletimes']),0)==false){
-                                      if (strpos($timeinfo, $product->data['agres_singletimes'][0],0)==false){
-                                       $timeinfo .=  '<br>'.$product->data['agres_singletimes'][0];
-                                     }
-                                   }
-                                 }
-                                 else {                                  
-                                   $timeinfo .= ( $product->data['times'] > 1) ? ''.' ' . $product->data['times'] .' <-> '. $product->agrmesunit .' count' : ' ' . $product->data['times'].$product->agrmesunit . ' countss';
-                                 }
-//                                 $title .= 'kkk'.$product->agrmesunit;
-                                 echo $timeinfo;
-                              ?>                                
-                             
-                            </td>
-                            <td width="98%">
-                               <b><?php print $product->qty; ?> x </b>
-                              <b><?php print $product->title; ?> - <?php print $product->total_price; ?></b>
-                              <?php print $product->individual_price; ?><br />
-                              <?php print t('SKU'); ?>: <?php print $product->model; ?><br />
-                              <?php print $product->details; ?>
-                            </td>
-                          </tr>
+                            <tr>
+
+                              <td valign="top" nowrap="nowrap">
+                                <?php
+                                $timeinfo = '';
+                                if (isset($product->data['agres_singletimes'])) {
+
+                                  if (count($product->data['agres_singletimes']) > 1) {
+                                    if (($product->qty / count($product->data['agres_singletimes'])) > 1) {
+                                      $timeinfo = $product->qty / count($product->data['agres_singletimes']) . ' ' . $product->title;
+                                    }
+                                    else {
+                                      $timeinfo = $product->qty / count($product->data['agres_singletimes']) . ' ' . $product->title;
+                                    }
+
+                                    if ($product->qty > 1) {
+                                      $price_info['qty'] = 1;
+                                      $timeinfo .=' ' . $product->individual_price;
+                                      $price_info['qty'] = $product->qty;
+                                    }
+                                    if (strpos($timeinfo, $product->data['agres_singletimes'][0] . '<br>' . t('Until:') . end($product->data['agres_singletimes']) . ' (' . t('included') . ')' . ' X ' . count($product->data['agres_singletimes']) . ' ' . $product->agrmesunit, 0) == false) {
+                                      $timeinfo .= '<br>' . t('From:') . $product->data['agres_singletimes'][0] . '<br>' . t('Until:') . end($product->data['agres_singletimes']) . ' (' . t('included') . ')' . ' X ' . count($product->data['agres_singletimes']) . ' ' . $product->agrmesunit;
+                                    }
+                                  }
+                                  else {
+                                    if (strpos($timeinfo, $product->data['agres_singletimes'][0], 0) == false) {
+                                      $timeinfo .= '<br>' . $product->data['agres_singletimes'][0];
+                                    }
+                                  }
+                                }
+                                else {
+                                  $timeinfo .= ( $product->data['times'] > 1) ? '' . ' ' . $product->data['times'] . ' <-> ' . $product->agrmesunit . ' count' : ' ' . $product->data['times'] . $product->agrmesunit . ' countss';
+                                }
+                                echo $timeinfo;
+                                ?>
+
+                              </td>
+                              <td width="98%">
+                                <b><?php print $product->qty; ?> x </b>
+                                <b><?php print $product->title; ?> - <?php print $product->total_price; ?></b>
+                                <?php print $product->individual_price; ?><br />
+                                <?php print t('SKU'); ?>: <?php print $product->model; ?><br />
+                                <?php print $product->details; ?>
+                              </td>
+                            </tr>
                           <?php endforeach; ?>
-                          
+
 
                         </table>
 
@@ -311,27 +307,27 @@
               </tr>
 
               <?php if ($help_text || $email_text || $store_footer): ?>
-              <tr>
-                <td colspan="2">
-                  <hr noshade="noshade" size="1" /><br />
+                <tr>
+                  <td colspan="2">
+                    <hr noshade="noshade" size="1" /><br />
 
-                  <?php if ($help_text): ?>
-                  <p><b><?php print t('Where can I get help with reviewing my order?'); ?></b><br />
-                  <?php print t('To learn more about managing your orders on !store_link, please visit our <a href="!store_help_url">help page</a>.', array('!store_link' => $store_link, '!store_help_url' => $store_help_url)); ?>
-                  <br /></p>
-                  <?php endif; ?>
+                    <?php if ($help_text): ?>
+                      <p><b><?php print t('Where can I get help with reviewing my order?'); ?></b><br />
+                        <?php print t('To learn more about managing your orders on !store_link, please visit our <a href="!store_help_url">help page</a>.', array('!store_link' => $store_link, '!store_help_url' => $store_help_url)); ?>
+                        <br /></p>
+                    <?php endif; ?>
 
-                  <?php if ($email_text): ?>
-                  <p><?php print t('Please note: This e-mail message is an automated notification. Please do not reply to this message.'); ?></p>
+                    <?php if ($email_text): ?>
+                      <p><?php print t('Please note: This e-mail message is an automated notification. Please do not reply to this message.'); ?></p>
 
-                  <p><?php print t('Thanks again for shopping with us.'); ?></p>
-                  <?php endif; ?>
+                      <p><?php print t('Thanks again for shopping with us.'); ?></p>
+                    <?php endif; ?>
 
-                  <?php if ($store_footer): ?>
-                  <p><b><?php print $store_link; ?></b><br /><b><?php print $site_slogan; ?></b></p>
-                  <?php endif; ?>
-                </td>
-              </tr>
+                    <?php if ($store_footer): ?>
+                      <p><b><?php print $store_link; ?></b><br /><b><?php print $site_slogan; ?></b></p>
+                    <?php endif; ?>
+                  </td>
+                </tr>
               <?php endif; ?>
 
             </table>
@@ -340,4 +336,4 @@
       </table>
     </td>
   </tr>
-</table>
+</table>
\ No newline at end of file
diff --git a/agres_categories/agres_categories.field.inc b/agres_categories/agres_categories.field.inc
index 87cedba..95a6c73 100644
--- a/agres_categories/agres_categories.field.inc
+++ b/agres_categories/agres_categories.field.inc
@@ -1,4 +1,13 @@
 <?php
+
+/**
+ * @file
+ * @todo Fill this in. 
+ */
+
+/**
+ * @todo Documentation
+ */
 function _agres_categories_contenttypes() {
   $types = array(
     array(
@@ -15,90 +24,13 @@ function _agres_categories_contenttypes() {
 }
 
 /**
- * return fields array.
+ * Return fields array.
+ * 
+ * @todo Documentation
  */
 function _agres_category_fields() {
   $fields = array();
 
-//  // Exported field: 'node-agres_category-body'
-//  $fields['node-agres_category-body'] = array(
-//    'field_config' => array(
-//      'active' => '1',
-//      'cardinality' => '1',
-//      'deleted' => '0',
-//      'entity_types' => array(
-//        0 => 'node',
-//      ),
-//      'field_name' => 'body',
-//      'foreign keys' => array(
-//        'format' => array(
-//          'columns' => array(
-//            'format' => 'format',
-//          ),
-//          'table' => 'filter_format',
-//        ),
-//      ),
-//      'indexes' => array(
-//        'format' => array(
-//          0 => 'format',
-//        ),
-//      ),
-//      'module' => 'text',
-//      'settings' => array(),
-//      'translatable' => '1',
-//      'type' => 'text_with_summary',
-//    ),
-//    'field_instance' => array(
-//      'bundle' => 'agres_category',
-//      'default_value' => NULL,
-//      'deleted' => '0',
-//      'description' => '',
-//      'display' => array(
-//        'default' => array(
-//          'label' => 'hidden',
-//          'module' => 'text',
-//          'settings' => array(),
-//          'type' => 'text_default',
-//          'weight' => 0,
-//        ),
-//        'teaser' => array(
-//          'label' => 'hidden',
-//          'module' => 'text',
-//          'settings' => array(
-//            'trim_length' => 600,
-//          ),
-//          'type' => 'text_summary_or_trimmed',
-//          'weight' => 0,
-//        ),
-//        'ubercart' => array(
-//          'label' => 'above',
-//          'settings' => array(),
-//          'type' => 'hidden',
-//          'weight' => 0,
-//        ),
-//      ),
-//      'entity_type' => 'node',
-//      'field_name' => 'body',
-//      'label' => 'Body',
-//      'required' => FALSE,
-//      'settings' => array(
-//        'display_summary' => TRUE,
-//        'text_processing' => 1,
-//        'user_register_form' => FALSE,
-//      ),
-//      'widget' => array(
-//        'module' => 'text',
-//        'settings' => array(
-//          'rows' => 20,
-//          'summary_rows' => 5,
-//        ),
-//        'type' => 'text_textarea_with_summary',
-//        'weight' => '1',
-//      ),
-//      'widget_type' => 'text_textarea_with_summary',
-//    ),
-//  );
-
   // Exported field: 'node-agres_category-field_agres_allowovernight'
   $fields['node-agres_category-field_agres_allowovernight'] = array(
     'field_config' => array(
@@ -1570,7 +1502,7 @@ service times. but the unit can be bookend around the clock.',
   t('Default checkin time');
   t('Default number of units to book');
   t('Examples:  "nights", "days","hours"');
-  t('Hours of service ');
+  t('Hours of service');
   t('Label of date1');
   t('Label of date2');
   t('Measuring unit');
@@ -1595,5 +1527,4 @@ service times. but the unit can be bookend around the clock.');
   t('translatable name of Category(Room,Car,House,Boat,...');
 
   return $fields;
-
-}
+}
\ No newline at end of file
diff --git a/agres_categories/agres_categories.info b/agres_categories/agres_categories.info
index 40d11bc..4782d0b 100644
--- a/agres_categories/agres_categories.info
+++ b/agres_categories/agres_categories.info
@@ -1,13 +1,7 @@
-; $Id: agres_categories.info,v 1.1.2.5 2010/10/14 15:52:05 agill Exp $
-name = agres_categories
-description = Adds contenttype Categories, specifies how reservations of Units of Unittypes that have certain Categories are handled.
+name = Agreservations Categories
+description = Adds the Categories content type, specifies how reservations of Units of Unittypes that have certain Categories are handled.
+package = Agreservations - Online Bookings
+core = 7.x
 
 dependencies[] = agreservations
 dependencies[] = i18n
-package = agreservations - online bookings
-core = 7.x
-project = "agreservations"
-
-
-
-
diff --git a/agres_categories/agres_categories.module b/agres_categories/agres_categories.module
index 6c7cd05..a28ab81 100644
--- a/agres_categories/agres_categories.module
+++ b/agres_categories/agres_categories.module
@@ -441,7 +441,7 @@ function _agres_categories_form_standard($object, $form_state) {
 //          }
 //        }
 //        $resnodes = agreservations_get_reservable_items('agreservations_unit', $userrequest['checkintime'], $userrequest['checkouttime']);
-//        $availableunittypes = agreservations_get_reservable_unittypes($resnodes, FALSE);
+//        $availableunittypes = _agreservations_get_reservable_unittypes($resnodes, FALSE);
 //        $tmpcountselectedtypes = array();
 //        foreach ($form_state['values']['unitinfo'] as $key => $unitinfo) {
 //          if (intval($unitinfo['adults']) > intval($availableunittypes[$unitinfo['selectunittype']]['rtnode']->field_agreservations_capacity[0]['value'])) {
@@ -518,7 +518,7 @@ function _agres_categories_form_standard_submit($form, $form_state) {
         $userrequest['checkouttime'],
       ),
     );
-    $unitsToBook = _agreservations_findunitsForUserRequest($form_state['build_info']['values'][1]['unitinfo'], 
+    $unitsToBook = _agreservations_find_units_for_user_request($form_state['build_info']['values'][1]['unitinfo'], 
                        $userrequest['checkintime'], 
                        $userrequest['checkouttime'], $category);
     if (!$unitsToBook) {
@@ -568,7 +568,7 @@ function _agres_categories_form_standard_submit($form, $form_state) {
         $times = ceil($times);
       }
 //         drupal_set_message('<pre>difference is:'.print_r($times,false).'</pre>');
-      $agres_singletimes = createDateRangeArray(date_format($tmpcheckin, 'Y-m-d H:i:s'), date_format($tmpcheckout,   'Y-m-d H:i:s'));
+      $agres_singletimes = _agreservations_create_date_range(date_format($tmpcheckin, 'Y-m-d H:i:s'), date_format($tmpcheckout,   'Y-m-d H:i:s'));
 
       array_pop($agres_singletimes); //!!!
       $data = array(
@@ -995,7 +995,7 @@ function agres_categories_searchwidget_form_submit($form, $form_state) {
       else {
         $resnodes = agreservations_get_reservable_items('agreservations_unit', date_format($tmpDateCheckin, 'Y-m-d H:i:s'), date_format($tmpDateCheckout, 'Y-m-d H:i:s'));
       }
-      $availableunittypes = agreservations_get_reservable_unittypes($resnodes, FALSE);
+      $availableunittypes = _agreservations_get_reservable_unittypes($resnodes, FALSE);
 //    //Filter types:
       $_SESSION['availableunittypes'] = $availableunittypes;
       $foundunits = count($resnodes);
diff --git a/agres_categories/agres_categories.views_default.inc b/agres_categories/agres_categories.views_default.inc
index 0d4d364..c49a76a 100644
--- a/agres_categories/agres_categories.views_default.inc
+++ b/agres_categories/agres_categories.views_default.inc
@@ -1,282 +1,281 @@
 <?php
-// $Id: agres_categories.views.inc,v 1.1.2.5 2010/12/23 02:25:46 agill Exp $
-
-/**
- * @file
- * agreservations.views.inc providing default views /calendarviews..
- *
- */
-function agres_categories_views_default_views() {
-  $views = array();
-
-  $view = new view;
-  $view->name = 'categories';
-  $view->description = '';
-  $view->tag = 'default';
-  $view->base_table = 'node';
-  $view->human_name = 'Categories';
-  $view->core = 7;
-  $view->api_version = '3.0';
-  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-
-  /* Display: Master */
-  $handler = $view->new_display('default', 'Master', 'default');
-  $handler->display->display_options['title'] = 'Resources';
-  $handler->display->display_options['access']['type'] = 'perm';
-  $handler->display->display_options['access']['perm'] = 'view agreservations Resources';
-  $handler->display->display_options['cache']['type'] = 'none';
-  $handler->display->display_options['query']['type'] = 'views_query';
-  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
-  $handler->display->display_options['exposed_form']['type'] = 'basic';
-  $handler->display->display_options['pager']['type'] = 'full';
-  $handler->display->display_options['pager']['options']['items_per_page'] = '10';
-  $handler->display->display_options['style_plugin'] = 'table';
-  /* Field: Content: Title */
-  $handler->display->display_options['fields']['title']['id'] = 'title';
-  $handler->display->display_options['fields']['title']['table'] = 'node';
-  $handler->display->display_options['fields']['title']['field'] = 'title';
-  $handler->display->display_options['fields']['title']['label'] = '';
-  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
-  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
-  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
-  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
-  /* Sort criterion: Content: Post date */
-  $handler->display->display_options['sorts']['created']['id'] = 'created';
-  $handler->display->display_options['sorts']['created']['table'] = 'node';
-  $handler->display->display_options['sorts']['created']['field'] = 'created';
-  $handler->display->display_options['sorts']['created']['order'] = 'DESC';
-  /* Filter criterion: Content: Published */
-  $handler->display->display_options['filters']['status']['id'] = 'status';
-  $handler->display->display_options['filters']['status']['table'] = 'node';
-  $handler->display->display_options['filters']['status']['field'] = 'status';
-  $handler->display->display_options['filters']['status']['value'] = 1;
-  $handler->display->display_options['filters']['status']['group'] = 0;
-  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
-  /* Filter criterion: Content: Type */
-  $handler->display->display_options['filters']['type']['id'] = 'type';
-  $handler->display->display_options['filters']['type']['table'] = 'node';
-  $handler->display->display_options['filters']['type']['field'] = 'type';
-  $handler->display->display_options['filters']['type']['value'] = array(
-    'agres_category' => 'agres_category',
-  );
-
-  /* Display: Page */
-  $handler = $view->new_display('page', 'Page', 'page');
-  $handler->display->display_options['path'] = 'agres_resources/categories';
-  $handler->display->display_options['menu']['type'] = 'default tab';
-  $handler->display->display_options['menu']['title'] = 'Categories';
-  $handler->display->display_options['menu']['weight'] = '0';
-  $handler->display->display_options['menu']['name'] = 'main-menu';
-  $handler->display->display_options['tab_options']['type'] = 'normal';
-  $handler->display->display_options['tab_options']['title'] = 'Resources';
-  $handler->display->display_options['tab_options']['weight'] = '0';
-  $handler->display->display_options['tab_options']['name'] = 'main-menu';
-  $translatables['categories'] = array(
-    t('Master'),
-    t('Resources'),
-    t('more'),
-    t('Apply'),
-    t('Reset'),
-    t('Sort by'),
-    t('Asc'),
-    t('Desc'),
-    t('Items per page'),
-    t('- All -'),
-    t('Offset'),
-    t('Page'),
-  );
-
-  $views['categories'] = $view;
-
-  $view = new view;
-  $view->name = 'units';
-  $view->description = '';
-  $view->tag = 'default';
-  $view->base_table = 'node';
-  $view->human_name = 'Units';
-  $view->core = 7;
-  $view->api_version = '3.0';
-  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-
-  /* Display: Master */
-  $handler = $view->new_display('default', 'Master', 'default');
-  $handler->display->display_options['title'] = 'Units';
-  $handler->display->display_options['access']['type'] = 'perm';
-  $handler->display->display_options['access']['perm'] = 'view agreservations Resources';
-  $handler->display->display_options['cache']['type'] = 'none';
-  $handler->display->display_options['query']['type'] = 'views_query';
-  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
-  $handler->display->display_options['exposed_form']['type'] = 'basic';
-  $handler->display->display_options['pager']['type'] = 'full';
-  $handler->display->display_options['pager']['options']['items_per_page'] = '10';
-  $handler->display->display_options['style_plugin'] = 'table';
-  /* Field: Content: Title */
-  $handler->display->display_options['fields']['title']['id'] = 'title';
-  $handler->display->display_options['fields']['title']['table'] = 'node';
-  $handler->display->display_options['fields']['title']['field'] = 'title';
-  $handler->display->display_options['fields']['title']['label'] = '';
-  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
-  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
-  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
-  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
-  /* Sort criterion: Content: Post date */
-  $handler->display->display_options['sorts']['created']['id'] = 'created';
-  $handler->display->display_options['sorts']['created']['table'] = 'node';
-  $handler->display->display_options['sorts']['created']['field'] = 'created';
-  $handler->display->display_options['sorts']['created']['order'] = 'DESC';
-  /* Filter criterion: Content: Published */
-  $handler->display->display_options['filters']['status']['id'] = 'status';
-  $handler->display->display_options['filters']['status']['table'] = 'node';
-  $handler->display->display_options['filters']['status']['field'] = 'status';
-  $handler->display->display_options['filters']['status']['value'] = 1;
-  $handler->display->display_options['filters']['status']['group'] = 0;
-  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
-  /* Filter criterion: Content: Type */
-  $handler->display->display_options['filters']['type']['id'] = 'type';
-  $handler->display->display_options['filters']['type']['table'] = 'node';
-  $handler->display->display_options['filters']['type']['field'] = 'type';
-  $handler->display->display_options['filters']['type']['value'] = array(
-    'agreservations_unit' => 'agreservations_unit',
-  );
-
-  /* Display: Page */
-  $handler = $view->new_display('page', 'Page', 'page');
-  $handler->display->display_options['path'] = 'agres_resources/units';
-  $handler->display->display_options['menu']['type'] = 'tab';
-  $handler->display->display_options['menu']['title'] = 'Units';
-  $handler->display->display_options['menu']['weight'] = '0';
-  $handler->display->display_options['menu']['name'] = 'main-menu';
-  $translatables['units'] = array(
-    t('Master'),
-    t('Units'),
-    t('more'),
-    t('Apply'),
-    t('Reset'),
-    t('Sort by'),
-    t('Asc'),
-    t('Desc'),
-    t('Items per page'),
-    t('- All -'),
-    t('Offset'),
-    t('Page'),
-  );
-  $views['units'] = $view;
-
-  $view = new view;
-  $view->name = 'unit_types';
-  $view->description = '';
-  $view->tag = 'default';
-  $view->base_table = 'node';
-  $view->human_name = 'Unit Types';
-  $view->core = 7;
-  $view->api_version = '3.0';
-  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-
-  /* Display: Master */
-  $handler = $view->new_display('default', 'Master', 'default');
-  $handler->display->display_options['title'] = 'Unit Types';
-  $handler->display->display_options['access']['type'] = 'perm';
-  $handler->display->display_options['access']['perm'] = 'view agreservations Resources';
-  $handler->display->display_options['cache']['type'] = 'none';
-  $handler->display->display_options['query']['type'] = 'views_query';
-  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
-  $handler->display->display_options['exposed_form']['type'] = 'basic';
-  $handler->display->display_options['pager']['type'] = 'full';
-  $handler->display->display_options['pager']['options']['items_per_page'] = '10';
-  $handler->display->display_options['style_plugin'] = 'table';
-  $handler->display->display_options['style_options']['columns'] = array(
-    'title' => 'title',
-  );
-  $handler->display->display_options['style_options']['default'] = '-1';
-  $handler->display->display_options['style_options']['info'] = array(
-    'title' => array(
-      'sortable' => 0,
-      'default_sort_order' => 'asc',
-      'align' => '',
-      'separator' => '',
-      'empty_column' => 0,
-    ),
-  );
-  $handler->display->display_options['style_options']['override'] = 1;
-  $handler->display->display_options['style_options']['sticky'] = 0;
-  $handler->display->display_options['style_options']['empty_table'] = 0;
-  /* Field: Content: Title */
-  $handler->display->display_options['fields']['title']['id'] = 'title';
-  $handler->display->display_options['fields']['title']['table'] = 'node';
-  $handler->display->display_options['fields']['title']['field'] = 'title';
-  $handler->display->display_options['fields']['title']['label'] = '';
-  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
-  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
-  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
-  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
-  /* Sort criterion: Content: Post date */
-  $handler->display->display_options['sorts']['created']['id'] = 'created';
-  $handler->display->display_options['sorts']['created']['table'] = 'node';
-  $handler->display->display_options['sorts']['created']['field'] = 'created';
-  $handler->display->display_options['sorts']['created']['order'] = 'DESC';
-  /* Filter criterion: Content: Published */
-  $handler->display->display_options['filters']['status']['id'] = 'status';
-  $handler->display->display_options['filters']['status']['table'] = 'node';
-  $handler->display->display_options['filters']['status']['field'] = 'status';
-  $handler->display->display_options['filters']['status']['value'] = 1;
-  $handler->display->display_options['filters']['status']['group'] = 0;
-  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
-  /* Filter criterion: Content: Type */
-  $handler->display->display_options['filters']['type']['id'] = 'type';
-  $handler->display->display_options['filters']['type']['table'] = 'node';
-  $handler->display->display_options['filters']['type']['field'] = 'type';
-  $handler->display->display_options['filters']['type']['value'] = array(
-    'agreservations_unittype' => 'agreservations_unittype',
-  );
-
-  /* Display: Page */
-  $handler = $view->new_display('page', 'Page', 'page');
-  $handler->display->display_options['path'] = 'agres_resources/unit_types';
-  $handler->display->display_options['menu']['type'] = 'tab';
-  $handler->display->display_options['menu']['title'] = 'Unit Types';
-  $handler->display->display_options['menu']['weight'] = '0';
-  $handler->display->display_options['menu']['name'] = 'main-menu';
-  $handler->display->display_options['tab_options']['type'] = 'normal';
-  $handler->display->display_options['tab_options']['title'] = 'AGreservations Resources';
-  $handler->display->display_options['tab_options']['weight'] = '0';
-  $handler->display->display_options['tab_options']['name'] = 'main-menu';
-  $translatables['unit_types'] = array(
-    t('Master'),
-    t('Unit Types'),
-    t('more'),
-    t('Apply'),
-    t('Reset'),
-    t('Sort by'),
-    t('Asc'),
-    t('Desc'),
-    t('Items per page'),
-    t('- All -'),
-    t('Offset'),
-    t('Page'),
-  );
-
-  $views['unit_types'] = $view;
-
-  return $views;
-}
+
+/**
+ * @file
+ * agreservations.views.inc providing default views /calendarviews..
+ *
+ */
+function agres_categories_views_default_views() {
+  $views = array();
+
+  $view = new view;
+  $view->name = 'categories';
+  $view->description = '';
+  $view->tag = 'default';
+  $view->base_table = 'node';
+  $view->human_name = 'Categories';
+  $view->core = 7;
+  $view->api_version = '3.0';
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+  /* Display: Master */
+  $handler = $view->new_display('default', 'Master', 'default');
+  $handler->display->display_options['title'] = 'Resources';
+  $handler->display->display_options['access']['type'] = 'perm';
+  $handler->display->display_options['access']['perm'] = 'view agreservations Resources';
+  $handler->display->display_options['cache']['type'] = 'none';
+  $handler->display->display_options['query']['type'] = 'views_query';
+  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
+  $handler->display->display_options['exposed_form']['type'] = 'basic';
+  $handler->display->display_options['pager']['type'] = 'full';
+  $handler->display->display_options['pager']['options']['items_per_page'] = '10';
+  $handler->display->display_options['style_plugin'] = 'table';
+  /* Field: Content: Title */
+  $handler->display->display_options['fields']['title']['id'] = 'title';
+  $handler->display->display_options['fields']['title']['table'] = 'node';
+  $handler->display->display_options['fields']['title']['field'] = 'title';
+  $handler->display->display_options['fields']['title']['label'] = '';
+  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
+  /* Sort criterion: Content: Post date */
+  $handler->display->display_options['sorts']['created']['id'] = 'created';
+  $handler->display->display_options['sorts']['created']['table'] = 'node';
+  $handler->display->display_options['sorts']['created']['field'] = 'created';
+  $handler->display->display_options['sorts']['created']['order'] = 'DESC';
+  /* Filter criterion: Content: Published */
+  $handler->display->display_options['filters']['status']['id'] = 'status';
+  $handler->display->display_options['filters']['status']['table'] = 'node';
+  $handler->display->display_options['filters']['status']['field'] = 'status';
+  $handler->display->display_options['filters']['status']['value'] = 1;
+  $handler->display->display_options['filters']['status']['group'] = 0;
+  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
+  /* Filter criterion: Content: Type */
+  $handler->display->display_options['filters']['type']['id'] = 'type';
+  $handler->display->display_options['filters']['type']['table'] = 'node';
+  $handler->display->display_options['filters']['type']['field'] = 'type';
+  $handler->display->display_options['filters']['type']['value'] = array(
+    'agres_category' => 'agres_category',
+  );
+
+  /* Display: Page */
+  $handler = $view->new_display('page', 'Page', 'page');
+  $handler->display->display_options['path'] = 'agres_resources/categories';
+  $handler->display->display_options['menu']['type'] = 'default tab';
+  $handler->display->display_options['menu']['title'] = 'Categories';
+  $handler->display->display_options['menu']['weight'] = '0';
+  $handler->display->display_options['menu']['name'] = 'main-menu';
+  $handler->display->display_options['tab_options']['type'] = 'normal';
+  $handler->display->display_options['tab_options']['title'] = 'Resources';
+  $handler->display->display_options['tab_options']['weight'] = '0';
+  $handler->display->display_options['tab_options']['name'] = 'main-menu';
+  $translatables['categories'] = array(
+    t('Master'),
+    t('Resources'),
+    t('more'),
+    t('Apply'),
+    t('Reset'),
+    t('Sort by'),
+    t('Asc'),
+    t('Desc'),
+    t('Items per page'),
+    t('- All -'),
+    t('Offset'),
+    t('Page'),
+  );
+
+  $views['categories'] = $view;
+
+  $view = new view;
+  $view->name = 'units';
+  $view->description = '';
+  $view->tag = 'default';
+  $view->base_table = 'node';
+  $view->human_name = 'Units';
+  $view->core = 7;
+  $view->api_version = '3.0';
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+  /* Display: Master */
+  $handler = $view->new_display('default', 'Master', 'default');
+  $handler->display->display_options['title'] = 'Units';
+  $handler->display->display_options['access']['type'] = 'perm';
+  $handler->display->display_options['access']['perm'] = 'view agreservations Resources';
+  $handler->display->display_options['cache']['type'] = 'none';
+  $handler->display->display_options['query']['type'] = 'views_query';
+  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
+  $handler->display->display_options['exposed_form']['type'] = 'basic';
+  $handler->display->display_options['pager']['type'] = 'full';
+  $handler->display->display_options['pager']['options']['items_per_page'] = '10';
+  $handler->display->display_options['style_plugin'] = 'table';
+  /* Field: Content: Title */
+  $handler->display->display_options['fields']['title']['id'] = 'title';
+  $handler->display->display_options['fields']['title']['table'] = 'node';
+  $handler->display->display_options['fields']['title']['field'] = 'title';
+  $handler->display->display_options['fields']['title']['label'] = '';
+  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
+  /* Sort criterion: Content: Post date */
+  $handler->display->display_options['sorts']['created']['id'] = 'created';
+  $handler->display->display_options['sorts']['created']['table'] = 'node';
+  $handler->display->display_options['sorts']['created']['field'] = 'created';
+  $handler->display->display_options['sorts']['created']['order'] = 'DESC';
+  /* Filter criterion: Content: Published */
+  $handler->display->display_options['filters']['status']['id'] = 'status';
+  $handler->display->display_options['filters']['status']['table'] = 'node';
+  $handler->display->display_options['filters']['status']['field'] = 'status';
+  $handler->display->display_options['filters']['status']['value'] = 1;
+  $handler->display->display_options['filters']['status']['group'] = 0;
+  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
+  /* Filter criterion: Content: Type */
+  $handler->display->display_options['filters']['type']['id'] = 'type';
+  $handler->display->display_options['filters']['type']['table'] = 'node';
+  $handler->display->display_options['filters']['type']['field'] = 'type';
+  $handler->display->display_options['filters']['type']['value'] = array(
+    'agreservations_unit' => 'agreservations_unit',
+  );
+
+  /* Display: Page */
+  $handler = $view->new_display('page', 'Page', 'page');
+  $handler->display->display_options['path'] = 'agres_resources/units';
+  $handler->display->display_options['menu']['type'] = 'tab';
+  $handler->display->display_options['menu']['title'] = 'Units';
+  $handler->display->display_options['menu']['weight'] = '0';
+  $handler->display->display_options['menu']['name'] = 'main-menu';
+  $translatables['units'] = array(
+    t('Master'),
+    t('Units'),
+    t('more'),
+    t('Apply'),
+    t('Reset'),
+    t('Sort by'),
+    t('Asc'),
+    t('Desc'),
+    t('Items per page'),
+    t('- All -'),
+    t('Offset'),
+    t('Page'),
+  );
+  $views['units'] = $view;
+
+  $view = new view;
+  $view->name = 'unit_types';
+  $view->description = '';
+  $view->tag = 'default';
+  $view->base_table = 'node';
+  $view->human_name = 'Unit Types';
+  $view->core = 7;
+  $view->api_version = '3.0';
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+  /* Display: Master */
+  $handler = $view->new_display('default', 'Master', 'default');
+  $handler->display->display_options['title'] = 'Unit Types';
+  $handler->display->display_options['access']['type'] = 'perm';
+  $handler->display->display_options['access']['perm'] = 'view agreservations Resources';
+  $handler->display->display_options['cache']['type'] = 'none';
+  $handler->display->display_options['query']['type'] = 'views_query';
+  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
+  $handler->display->display_options['exposed_form']['type'] = 'basic';
+  $handler->display->display_options['pager']['type'] = 'full';
+  $handler->display->display_options['pager']['options']['items_per_page'] = '10';
+  $handler->display->display_options['style_plugin'] = 'table';
+  $handler->display->display_options['style_options']['columns'] = array(
+    'title' => 'title',
+  );
+  $handler->display->display_options['style_options']['default'] = '-1';
+  $handler->display->display_options['style_options']['info'] = array(
+    'title' => array(
+      'sortable' => 0,
+      'default_sort_order' => 'asc',
+      'align' => '',
+      'separator' => '',
+      'empty_column' => 0,
+    ),
+  );
+  $handler->display->display_options['style_options']['override'] = 1;
+  $handler->display->display_options['style_options']['sticky'] = 0;
+  $handler->display->display_options['style_options']['empty_table'] = 0;
+  /* Field: Content: Title */
+  $handler->display->display_options['fields']['title']['id'] = 'title';
+  $handler->display->display_options['fields']['title']['table'] = 'node';
+  $handler->display->display_options['fields']['title']['field'] = 'title';
+  $handler->display->display_options['fields']['title']['label'] = '';
+  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
+  /* Sort criterion: Content: Post date */
+  $handler->display->display_options['sorts']['created']['id'] = 'created';
+  $handler->display->display_options['sorts']['created']['table'] = 'node';
+  $handler->display->display_options['sorts']['created']['field'] = 'created';
+  $handler->display->display_options['sorts']['created']['order'] = 'DESC';
+  /* Filter criterion: Content: Published */
+  $handler->display->display_options['filters']['status']['id'] = 'status';
+  $handler->display->display_options['filters']['status']['table'] = 'node';
+  $handler->display->display_options['filters']['status']['field'] = 'status';
+  $handler->display->display_options['filters']['status']['value'] = 1;
+  $handler->display->display_options['filters']['status']['group'] = 0;
+  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
+  /* Filter criterion: Content: Type */
+  $handler->display->display_options['filters']['type']['id'] = 'type';
+  $handler->display->display_options['filters']['type']['table'] = 'node';
+  $handler->display->display_options['filters']['type']['field'] = 'type';
+  $handler->display->display_options['filters']['type']['value'] = array(
+    'agreservations_unittype' => 'agreservations_unittype',
+  );
+
+  /* Display: Page */
+  $handler = $view->new_display('page', 'Page', 'page');
+  $handler->display->display_options['path'] = 'agres_resources/unit_types';
+  $handler->display->display_options['menu']['type'] = 'tab';
+  $handler->display->display_options['menu']['title'] = 'Unit Types';
+  $handler->display->display_options['menu']['weight'] = '0';
+  $handler->display->display_options['menu']['name'] = 'main-menu';
+  $handler->display->display_options['tab_options']['type'] = 'normal';
+  $handler->display->display_options['tab_options']['title'] = 'AGreservations Resources';
+  $handler->display->display_options['tab_options']['weight'] = '0';
+  $handler->display->display_options['tab_options']['name'] = 'main-menu';
+  $translatables['unit_types'] = array(
+    t('Master'),
+    t('Unit Types'),
+    t('more'),
+    t('Apply'),
+    t('Reset'),
+    t('Sort by'),
+    t('Asc'),
+    t('Desc'),
+    t('Items per page'),
+    t('- All -'),
+    t('Offset'),
+    t('Page'),
+  );
+
+  $views['unit_types'] = $view;
+
+  return $views;
+}
diff --git a/agres_rate/agres_rate.field.inc b/agres_rate/agres_rate.field.inc
index 4757f2d..e1f5c9a 100644
--- a/agres_rate/agres_rate.field.inc
+++ b/agres_rate/agres_rate.field.inc
@@ -1,259 +1,211 @@
 <?php
-function _agres_rate_contenttypes() {
-  $types = array(
-    array(
-      'type' => 'agres_rate',
-      'name' => t('Rate'),
-      'base' => 'node_content',
-      'description' => t("A Rate overriding a Unit Types Product Price if the attached Timeframe applies."),
-      'custom' => 1,
-      'modified' => 1,
-      'locked' => 0,
-    ),
-  );
-  return $types;
-}
-/**
- * return fields array.
- */
-function _agres_rate_fields() {
-  $fields = array();
-//  // Exported field: 'node-agres_rate-field_agres_rate_percent'
-//  $fields['node-agres_rate-field_agres_rate_percent'] = array(
-//    'field_config' => array(
-//      'active' => '1',
-//      'cardinality' => '1',
-//      'deleted' => '0',
-//      'entity_types' => array(),
-//      'field_name' => 'field_agres_rate_percent',
-//      'foreign keys' => array(),
-//      'indexes' => array(),
-//      'module' => 'number',
-//      'settings' => array(),
-//      'translatable' => '0',
-//      'type' => 'number_integer',
-//    ),
-//    'field_instance' => array(
-//      'bundle' => 'agres_rate',
-//      'default_value' => NULL,
-//      'deleted' => '0',
-//      'description' => 'If this field is filled, not this products price will be used, but the base unit types price modified by the percent rate entered here.
-  //Use - and + to indicate if the baseprice is increased or decreased by the entered percent number.',
-//      'display' => array(
-//        'default' => array(
-//          'label' => 'above',
-//          'module' => 'number',
-//          'settings' => array(
-//            'decimal_separator' => '.',
-//            'prefix_suffix' => TRUE,
-//            'scale' => 0,
-//            'thousand_separator' => ' ',
-//          ),
-//          'type' => 'number_integer',
-//          'weight' => 3,
-//        ),
-//        'teaser' => array(
-//          'label' => 'above',
-//          'settings' => array(),
-//          'type' => 'hidden',
-//          'weight' => 0,
-//        ),
-//      ),
-//      'entity_type' => 'node',
-//      'field_name' => 'field_agres_rate_percent',
-//      'label' => 'Percent Price Modifier',
-//      'required' => 0,
-//      'settings' => array(
-//        'max' => '',
-//        'min' => '-100',
-//        'prefix' => '',
-//        'suffix' => '%',
-//        'user_register_form' => FALSE,
-//      ),
-//      'widget' => array(
-//        'active' => 0,
-//        'module' => 'number',
-//        'settings' => array(),
-//        'type' => 'number',
-//        'weight' => '-1',
-//      ),
-//    ),
-//  );
-//    ///reference rate for unit type
+
+/**
+ * Helper function
+ *
+ * @todo Documentation.
+ *
+ * @return array
+ */
+function _agres_rate_contenttypes() {
+  $types = array(
+    array(
+      'type' => 'agres_rate',
+      'name' => t('Rate'),
+      'base' => 'node_content',
+      'description' => t("A Rate overriding a Unit Types Product Price if the attached Timeframe applies."),
+      'custom' => 1,
+      'modified' => 1,
+      'locked' => 0,
+    ),
+  );
+  return $types;
+}
+
+/**
+ * return fields array.
+ */
+
+/**
+ * Helper function that returns the fields array.
+ *
+ * @return array The fields array.
+ */
+function _agres_rate_fields() {
+  $fields = array();
   // Exported field: 'node-agreservation-field_agres_ref_unit'
-  $fields['node-agreservation_unittype-field_agres_ref_rate'] = array(
-    'field_config' => array(
-      'active' => '1',
-      'cardinality' => '-1',
-      'deleted' => '0',
-      'entity_types' => array(),
-      'field_name' => 'field_agres_ref_rate',
-      'foreign keys' => array(
-        'nid' => array(
-          'columns' => array(
-            'nid' => 'nid',
-          ),
-          'table' => 'node',
-        ),
-      ),
-      'indexes' => array(
-        'nid' => array(
-          '0' => 'nid',
-        ),
-      ),
-      'module' => 'node_reference',
-      'settings' => array(
-        'field_permissions' => array(
-          'create' => 0,
-          'edit' => 0,
-          'edit own' => 0,
-          'view' => 0,
-          'view own' => 0,
-        ),
-        'referenceable_types' => array(
-          'agres_rate' => 'agres_rate',
-          'agres_category' => 0,
-          'agres_timeframe' => 0,
-          'agreservation' => 0,
-          'agreservations_unit' => 0,
-          'agreservations_unittype' => 0,
-          'article' => 0,
-          'page' => 0,
-        ),
-      ),
-      'translatable' => '1',
-      'type' => 'node_reference',
-    ),
-    'field_instance' => array(
-      'bundle' => 'agreservations_unittype',
-      'default_value' => NULL,
-      'deleted' => '0',
-      'description' => '',
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'module' => 'node_reference',
-          'settings' => array(),
-          'type' => 'node_reference_default',
-          'weight' => 2,
-        ),
-        'teaser' => array(
-          'label' => 'above',
-          'settings' => array(),
-          'type' => 'hidden',
-          'weight' => 0,
-        ),
-      ),
-      'entity_type' => 'node',
-      'field_name' => 'field_agres_ref_rate',
-      'label' => 'Reference Rate',
-      'required' => 0,
-      'settings' => array(
-        'user_register_form' => FALSE,
-      ),
-      'widget' => array(
-        'active' => 1,
-        'module' => 'options',
-        'settings' => array(),
-        'type' => 'options_select',
-        'weight' => '-2',
-      ),
-    ),
-  );
-
+  $fields['node-agreservation_unittype-field_agres_ref_rate'] = array(
+    'field_config' => array(
+      'active' => '1',
+      'cardinality' => '-1',
+      'deleted' => '0',
+      'entity_types' => array(),
+      'field_name' => 'field_agres_ref_rate',
+      'foreign keys' => array(
+        'nid' => array(
+          'columns' => array(
+            'nid' => 'nid',
+          ),
+          'table' => 'node',
+        ),
+      ),
+      'indexes' => array(
+        'nid' => array(
+          '0' => 'nid',
+        ),
+      ),
+      'module' => 'node_reference',
+      'settings' => array(
+        'field_permissions' => array(
+          'create' => 0,
+          'edit' => 0,
+          'edit own' => 0,
+          'view' => 0,
+          'view own' => 0,
+        ),
+        'referenceable_types' => array(
+          'agres_rate' => 'agres_rate',
+          'agres_category' => 0,
+          'agres_timeframe' => 0,
+          'agreservation' => 0,
+          'agreservations_unit' => 0,
+          'agreservations_unittype' => 0,
+          'article' => 0,
+          'page' => 0,
+        ),
+      ),
+      'translatable' => '1',
+      'type' => 'node_reference',
+    ),
+    'field_instance' => array(
+      'bundle' => 'agreservations_unittype',
+      'default_value' => NULL,
+      'deleted' => '0',
+      'description' => '',
+      'display' => array(
+        'default' => array(
+          'label' => 'above',
+          'module' => 'node_reference',
+          'settings' => array(),
+          'type' => 'node_reference_default',
+          'weight' => 2,
+        ),
+        'teaser' => array(
+          'label' => 'above',
+          'settings' => array(),
+          'type' => 'hidden',
+          'weight' => 0,
+        ),
+      ),
+      'entity_type' => 'node',
+      'field_name' => 'field_agres_ref_rate',
+      'label' => 'Reference Rate',
+      'required' => 0,
+      'settings' => array(
+        'user_register_form' => FALSE,
+      ),
+      'widget' => array(
+        'active' => 1,
+        'module' => 'options',
+        'settings' => array(),
+        'type' => 'options_select',
+        'weight' => '-2',
+      ),
+    ),
+  );
+
   // Exported field: 'node-agres_rate-field_agres_ref_timeframe'
-  $fields['node-agres_rate-field_agres_ref_timeframe'] = array(
-    'field_config' => array(
-      'active' => '1',
-      'cardinality' => '-1',
-      'deleted' => '0',
-      'entity_types' => array(),
-      'field_name' => 'field_agres_ref_timeframe',
-      'foreign keys' => array(
-        'nid' => array(
-          'columns' => array(
-            'nid' => 'nid',
-          ),
-          'table' => 'node',
-        ),
-      ),
-      'indexes' => array(
-        'nid' => array(
-          0 => 'nid',
-        ),
-      ),
-      'module' => 'node_reference',
-      'settings' => array(
-        'field_permissions' => array(
-          'create' => 0,
-          'edit' => 0,
-          'edit own' => 0,
-          'view' => 0,
-          'view own' => 0,
-        ),
-        'referenceable_types' => array(
-          'agres_category' => 0,
-          'agres_timeframe' => 'agres_timeframe',
-          'agreservation' => 0,
-          'agreservations_unit' => 0,
-          'agreservations_unittype' => 0,
-          'article' => 0,
-          'page' => 0,
-        ),
-        'view' => array(
-          'args' => array(),
-          'display_name' => '',
-          'view_name' => '',
-        ),
-      ),
-      'translatable' => '1',
-      'type' => 'node_reference',
-    ),
-    'field_instance' => array(
-      'bundle' => 'agres_rate',
-      'default_value' => NULL,
-      'deleted' => '0',
-      'description' => '',
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'module' => 'node_reference',
-          'settings' => array(),
-          'type' => 'node_reference_default',
-          'weight' => 2,
-        ),
-        'teaser' => array(
-          'label' => 'above',
-          'settings' => array(),
-          'type' => 'hidden',
-          'weight' => 0,
-        ),
-      ),
-      'entity_type' => 'node',
-      'field_name' => 'field_agres_ref_timeframe',
-      'label' => 'Reference Timeframe',
-      'required' => 1,
-      'settings' => array(
-        'user_register_form' => FALSE,
-      ),
-      'widget' => array(
-        'active' => 1,
-        'module' => 'options',
-        'settings' => array(),
-        'type' => 'options_select',
-        'weight' => '-2',
-      ),
-    ),
-  );
-
+  $fields['node-agres_rate-field_agres_ref_timeframe'] = array(
+    'field_config' => array(
+      'active' => '1',
+      'cardinality' => '-1',
+      'deleted' => '0',
+      'entity_types' => array(),
+      'field_name' => 'field_agres_ref_timeframe',
+      'foreign keys' => array(
+        'nid' => array(
+          'columns' => array(
+            'nid' => 'nid',
+          ),
+          'table' => 'node',
+        ),
+      ),
+      'indexes' => array(
+        'nid' => array(
+          0 => 'nid',
+        ),
+      ),
+      'module' => 'node_reference',
+      'settings' => array(
+        'field_permissions' => array(
+          'create' => 0,
+          'edit' => 0,
+          'edit own' => 0,
+          'view' => 0,
+          'view own' => 0,
+        ),
+        'referenceable_types' => array(
+          'agres_category' => 0,
+          'agres_timeframe' => 'agres_timeframe',
+          'agreservation' => 0,
+          'agreservations_unit' => 0,
+          'agreservations_unittype' => 0,
+          'article' => 0,
+          'page' => 0,
+        ),
+        'view' => array(
+          'args' => array(),
+          'display_name' => '',
+          'view_name' => '',
+        ),
+      ),
+      'translatable' => '1',
+      'type' => 'node_reference',
+    ),
+    'field_instance' => array(
+      'bundle' => 'agres_rate',
+      'default_value' => NULL,
+      'deleted' => '0',
+      'description' => '',
+      'display' => array(
+        'default' => array(
+          'label' => 'above',
+          'module' => 'node_reference',
+          'settings' => array(),
+          'type' => 'node_reference_default',
+          'weight' => 2,
+        ),
+        'teaser' => array(
+          'label' => 'above',
+          'settings' => array(),
+          'type' => 'hidden',
+          'weight' => 0,
+        ),
+      ),
+      'entity_type' => 'node',
+      'field_name' => 'field_agres_ref_timeframe',
+      'label' => 'Reference Timeframe',
+      'required' => 1,
+      'settings' => array(
+        'user_register_form' => FALSE,
+      ),
+      'widget' => array(
+        'active' => 1,
+        'module' => 'options',
+        'settings' => array(),
+        'type' => 'options_select',
+        'weight' => '-2',
+      ),
+    ),
+  );
+
   // Translatables
   // Included for use with string extractors like potx.
-  t('Body');
+  t('Body');
   t('If this field is filled, not this products price will be used, but the base unit types price modified by the percent rate entered here.
-Use - and + to indicate if the baseprice is increased or decreased by the entered percent number.');
-  t('Percent Price Modifier');
-  t('Reference Timeframe');
-
-  //////////////////////////////////////
-  return $fields;
-}
+Use - and + to indicate if the baseprice is increased or decreased by the entered percent number.');
+  t('Percent Price Modifier');
+  t('Reference Timeframe');
+
+  return $fields;
+}
\ No newline at end of file
diff --git a/agres_rate/agres_rate.info b/agres_rate/agres_rate.info
index 5b390d9..6d8b6df 100644
--- a/agres_rate/agres_rate.info
+++ b/agres_rate/agres_rate.info
@@ -1,13 +1,14 @@
-; $Id: agres_rate.info,v 1.1.2.1 2010/12/23 02:25:46 agill Exp $
 name = Agreservations Rate
 description = Restricts the reservation of a resource to a minimum number of days, a starting day and and end day of the week.
-dependencies[] = agreservations
-dependencies[] = agres_timeframe
-dependencies[] = agres_bookings
-dependencies[] = agres_categories
-package = agreservations - Custom
+package = Agreservations - Custom
 core = 7.x
+
 files[] = agres_rate.cck.inc
 files[] = agres_rate.install
 files[] = agres_rate.module
 files[] = agres_rate.views.inc
+
+dependencies[] = agreservations
+dependencies[] = agres_timeframe
+dependencies[] = agres_bookings
+dependencies[] = agres_categories
\ No newline at end of file
diff --git a/agres_rate/agres_rate.install b/agres_rate/agres_rate.install
index 2b4f394..09fb9a5 100644
--- a/agres_rate/agres_rate.install
+++ b/agres_rate/agres_rate.install
@@ -1,150 +1,95 @@
 <?php
-// $Id: agres_rate.install,v 1.1.2.2 2010/12/24 01:38:01 agill Exp $
-
-
-/**
- * @file
- * Implements the agres_timeframe content type. This module was created by Amazeelabs and
- * given to me as a contribution. Thanks amazee labs!
- */
-//Copied from agreservations.install
-
-
-// inspired by the features module:
-function _agres_rate_install_bundle_fields($fields) {
-  if (isset($fields)) {
-    field_info_cache_clear();
-    foreach ($fields as $field) {
+
+/**
+ * @file
+ * Implements the agres_timeframe content type. This module was created by Amazeelabs and
+ * given to me as a contribution. Thanks amazee labs!
+ */
+
+/**
+ * Copied from agreservations.install
+ * inspired by the features module.
+ *
+ * @todo Documentation
+ * @param type $fields
+ */
+function _agres_rate_install_bundle_fields($fields) {
+  if (isset($fields)) {
+    field_info_cache_clear();
+    foreach ($fields as $field) {
       // Create or update field.
-      $field_config = $field['field_config'];
-      if ($existing_field = field_info_field($field_config['field_name'])) {
-        field_update_field($field_config);
-      }
-      else {
-        field_create_field($field_config);
-      }
-
+      $field_config = $field['field_config'];
+      if ($existing_field = field_info_field($field_config['field_name'])) {
+        field_update_field($field_config);
+      }
+      else {
+        field_create_field($field_config);
+      }
+
       // Create or update field instance.
-      $field_instance = $field['field_instance'];
-//      drupal_set_message('<pre>'.print_r($field_instance,true).'</pre>');
-      $existing_instance = field_info_instance($field_instance['entity_type'], $field_instance['field_name'], $field_instance['bundle']);
-      if ($existing_instance) {
-        field_update_instance($field_instance);
-      }
-      else {
-        field_create_instance($field_instance);
-      }
-      variable_set('menu_rebuild_needed', TRUE);
-    }
-  }
-}
-
-/**
- * Implements hook_install().
- *
- */
-/**
- * @todo Please document this function.
- * @see http://drupal.org/node/1354
- */
-function agres_rate_install() {
-  module_load_include('inc', 'agres_rate', 'agres_rate.field');
-  $types = _agres_rate_contenttypes();
-  foreach ($types as $type) {
-    $type = node_type_set_defaults($type);
-    node_type_save($type);
-    node_add_body_field($type);
-  }
-  $fields = _agres_rate_fields();
-  _agres_rate_install_bundle_fields($fields);
-}
-
-/**
- * Implements hook_enabled().
- *
- */
-function agres_rate_enable() {
-//  module_load_include('inc', 'agres_rate', 'agres_rate.cck');
-//  $export = agres_rate_get_agres_rate_content_type();
-//  $ctinfo = content_types('agres_rate');
-//  if (count($ctinfo['tables']) > 0) {
-//    _agres_rate_install_ccktype('agres_rate', $export);
-//  }
-//  else {
-//    _agres_rate_install_ccktype('<create>', $export);
-//  }
-//  //no enable rates as product:
-  //
-//  
-  /////////////////////////////////
-  //function agres_bookings_enable() {
-//  $result = db_query("SELECT* from {uc_product_classes} where pcid = 'agreservations_unittype'");
-//  if (!$result->fetchField()) {
-//    // TODO Please review the conversion of this statement to the D7 database API syntax.
-//    /* db_query("INSERT INTO {uc_product_classes} (pcid, name, description) VALUES ('%s', '%s', '%s')", 'agreservations_unittype', 'agreservations_unittype', 'agreservations_unittype') */
-//    $id = db_insert('uc_product_classes')
-//  ->fields(array(
-//      'pcid' => 'agres_rate',
-//      'name' => 'Rate',
-//      'description' => 'agres_rate',
-//    ))
-//  ->execute();
-//    uc_product_node_info(TRUE);
-//    variable_set('node_options_' . 'agres_rate', variable_get('node_options_product', array('status', 'promote')));
-  //
-//    if (module_exists('comment')) {
-//      variable_set('comment_' . 'agres_rate', variable_get('comment_product', 2));
-//    }
-  //
-//    module_invoke_all('product_class', 'agres_rate', 'insert');
-//    node_types_rebuild();
-//    uc_product_node_info(true);
-//    node_types_rebuild();
-//    if (module_exists('imagefield')) {
-//      uc_product_add_default_image_field('agres_rate');
-//    }
-//    menu_rebuild();
-//  }
-}
-//////////////////////////////////
-
-
-function agres_rate_uninstall() {
-  module_load_include('inc', 'agres_rate', 'agres_rate.field');
+      $field_instance = $field['field_instance'];
+      $existing_instance = field_info_instance($field_instance['entity_type'], $field_instance['field_name'], $field_instance['bundle']);
+      if ($existing_instance) {
+        field_update_instance($field_instance);
+      }
+      else {
+        field_create_instance($field_instance);
+      }
+      variable_set('menu_rebuild_needed', TRUE);
+    }
+  }
+}
+
+/**
+ * Implements hook_install().
+ */
+function agres_rate_install() {
+  module_load_include('inc', 'agres_rate', 'agres_rate.field');
+  $types = _agres_rate_contenttypes();
+  foreach ($types as $type) {
+    $type = node_type_set_defaults($type);
+    node_type_save($type);
+    node_add_body_field($type);
+  }
+  $fields = _agres_rate_fields();
+  _agres_rate_install_bundle_fields($fields);
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function agres_rate_uninstall() {
+
+  module_load_include('inc', 'agres_rate', 'agres_rate.field');
+
   // Gather all the example content that might have been created while this
   // module was enabled.  Simple selects still use db_query().
-  // http://api.drupal.org/api/function/db_query/7
-  $sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
-  $result = db_query($sql, array(':type' => 'agres_rate'));
-  $nids = array();
-  foreach ($result as $row) {
-    $nids[] = $row->nid;
-  }
-
+  $sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
+  $result = db_query($sql, array(':type' => 'agres_rate'));
+  $nids = array();
+  foreach ($result as $row) {
+    $nids[] = $row->nid;
+  }
+
   // Delete all the nodes at once
-  // http://api.drupal.org/api/function/node_delete_multiple/7
-  node_delete_multiple($nids);
-
+  node_delete_multiple($nids);
+
   // Loop over each of the fields defined by this module and delete
   // all instances of the field, their data, and the field itself.
-  // http://api.drupal.org/api/function/field_delete_field/7
-
-  foreach (_agres_rate_fields() as $field) {
-    field_delete_field($field['field_config']['field_name']);
-  }
+  foreach (_agres_rate_fields() as $field) {
+    field_delete_field($field['field_config']['field_name']);
+  }
+
   // Loop over any remaining field instances attached to the node_example
   // content type (such as the body field) and delete them individually.
-  // http://api.drupal.org/api/function/field_delete_field/7
-  $instances = field_info_instances('node', 'agres_rate');
-  foreach ($instances as $instance_name => $instance) {
-    field_delete_instance($instance);
-  }
-
+  $instances = field_info_instances('node', 'agres_rate');
+  foreach ($instances as $instance_name => $instance) {
+    field_delete_instance($instance);
+  }
+
   // Delete our content type
-  // http://api.drupal.org/api/function/node_type_delete/7
-  node_type_delete('agres_rate');
-
+  node_type_delete('agres_rate');
+
   // Purge all field infromation
-  // http://api.drupal.org/api/function/field_purge_batch/7
-  field_purge_batch(1000);
-}
+  field_purge_batch(1000);
+}
\ No newline at end of file
diff --git a/agres_rate/agres_rate.module b/agres_rate/agres_rate.module
index 1c56da6..6c2be1b 100644
--- a/agres_rate/agres_rate.module
+++ b/agres_rate/agres_rate.module
@@ -1,8 +1,5 @@
 <?php
 
-// $Id: agres_rate.module,v 1.1.2.1 2010/12/23 02:25:46 agill Exp $
-
-
 /**
  * @file
  *  Implements Rates
@@ -13,6 +10,7 @@ function agres_rate_views_api() {
     'path' => drupal_get_path('module', 'agres_rate'),
   );
 }
+
 /**
  * _agres_get_product_for_reservation
  * This functions checks if the unittype has a rate attached and
@@ -29,7 +27,7 @@ function _agres_get_products_for_reservation($unittypenid, $data) {
   $unitnode = node_load($unittypenid);
   $tmpcheckin = new DateObject($data['checkintime']);
   $tmpcheckout = new DateObject($data['checkouttime']);
-  $resdates = createDateRangeArray(date_format($tmpcheckin, 'Y-m-d H:i:s'), date_format($tmpcheckout, 'Y-m-d H:i:s')); //createDateRangeArray($data['checkintime'], $data['checkouttime']);
+  $resdates = _agreservations_create_date_range(date_format($tmpcheckin, 'Y-m-d H:i:s'), date_format($tmpcheckout, 'Y-m-d H:i:s')); //createDateRangeArray($data['checkintime'], $data['checkouttime']);
   array_pop($resdates);
   $retarray = $resdates;
   $retarray = array_flip($retarray);
@@ -42,22 +40,19 @@ function _agres_get_products_for_reservation($unittypenid, $data) {
 
       $ratenode = node_load($rate['nid']);
       $timeframes = array();
-//      drupal_set_message('<pre>$ratenode: ' . print_r($ratenode, true) . '</pre>');
       foreach ($ratenode->field_agres_ref_timeframe[$ratenode->language] as $tkey => $timeframe) {
 
         $timeframes['timeframes'][] = $timeframe['nid'];
         $rates['rates'][$rate['nid']] = $timeframes;
       }
     }
-//     drupal_set_message('<pre>$rates: ' . print_r($rates, true) . '</pre>');
-//       drupal_set_message('<pre>$rates: ' . print_r($rates, true) . '</pre>');
     if (($data['module'] == 'agres_categories' ) && ($data['bookingmode'] == BOOKING_MODE_BY_DAYS)) {
       foreach ($resdates as $time) {
-        // now for each time night or hour or whatever, check
-        //which price/ which rate applies, if no rate aplies, use the nid of the unittype:
+        // Now for each time night or hour or whatever, check which price/rate
+        // applies, if no rate aplies, use the nid of the unittype
         foreach ($rates['rates'] as $rkey => $rate) {
-          //rates should NOT overlap! the first rate that has a timeframe that
-          //gets hit by a date of this booking is taken:
+          // Rates should NOT overlap! The first rate that has a timeframe that
+          // gets hit by a date of this booking is taken
           foreach ($rate['timeframes'] as $timeframenid) {
             $tframe = node_load($timeframenid);
             if (_is_date_in_range($time, $tframe->field_agres_timeframe_period[$tframe->language][0]['value'], $tframe->field_agres_timeframe_period[$tframe->language][0]['value2']) == true) {
@@ -68,17 +63,14 @@ function _agres_get_products_for_reservation($unittypenid, $data) {
       }
     }
   }
-  else {
-
-  }
   $data['agres_singletimes'] = $retarray;
   return $retarray;
 }
-//
-///**
-// * Implements hook_permission().
-// *
-// */
+
+
+/**
+ * Implements hook_permission().
+ */
 function agres_rate_permission() {
   return array(
     'create agres_rate' => array(
@@ -94,4 +86,4 @@ function agres_rate_permission() {
       'description' => t('TODO Add a description for \'administer agres_rate\''),
     ),
   );
-}
+}
\ No newline at end of file
diff --git a/agres_rate/agres_rate.views.inc b/agres_rate/agres_rate.views.inc
index 1c2629c..6048af5 100644
--- a/agres_rate/agres_rate.views.inc
+++ b/agres_rate/agres_rate.views.inc
@@ -1,93 +1,96 @@
 <?php
-// $Id: agres_rate.views.inc,v 1.1.2.1 2010/12/23 02:25:46 agill Exp $
-
-/**
- * @file
- * agreservations.views.inc providing default views /calendarviews..
- *
- */
-function agres_rate_views_default_views() {
-  $views = array();
-  $view = new view;
-  $view->name = 'agres_rate';
-  $view->description = '';
-  $view->tag = 'default';
-  $view->base_table = 'node';
-  $view->human_name = 'agres_rate';
-  $view->core = 7;
-  $view->api_version = '3.0';
-  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-
-  /* Display: Master */
-  $handler = $view->new_display('default', 'Master', 'default');
-  $handler->display->display_options['title'] = 'agres_rate';
-  $handler->display->display_options['access']['type'] = 'perm';
-  $handler->display->display_options['access']['perm'] = 'view agreservations Resources';
-  $handler->display->display_options['cache']['type'] = 'none';
-  $handler->display->display_options['query']['type'] = 'views_query';
-  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
-  $handler->display->display_options['exposed_form']['type'] = 'basic';
-  $handler->display->display_options['pager']['type'] = 'full';
-  $handler->display->display_options['pager']['options']['items_per_page'] = '10';
-  $handler->display->display_options['style_plugin'] = 'table';
-  /* Field: Content: Title */
-  $handler->display->display_options['fields']['title']['id'] = 'title';
-  $handler->display->display_options['fields']['title']['table'] = 'node';
-  $handler->display->display_options['fields']['title']['field'] = 'title';
-  $handler->display->display_options['fields']['title']['label'] = '';
-  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
-  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
-  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
-  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
-  /* Sort criterion: Content: Post date */
-  $handler->display->display_options['sorts']['created']['id'] = 'created';
-  $handler->display->display_options['sorts']['created']['table'] = 'node';
-  $handler->display->display_options['sorts']['created']['field'] = 'created';
-  $handler->display->display_options['sorts']['created']['order'] = 'DESC';
-  /* Filter criterion: Content: Published */
-  $handler->display->display_options['filters']['status']['id'] = 'status';
-  $handler->display->display_options['filters']['status']['table'] = 'node';
-  $handler->display->display_options['filters']['status']['field'] = 'status';
-  $handler->display->display_options['filters']['status']['value'] = 1;
-  $handler->display->display_options['filters']['status']['group'] = 0;
-  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
-  /* Filter criterion: Content: Type */
-  $handler->display->display_options['filters']['type']['id'] = 'type';
-  $handler->display->display_options['filters']['type']['table'] = 'node';
-  $handler->display->display_options['filters']['type']['field'] = 'type';
-  $handler->display->display_options['filters']['type']['value'] = array(
-    'agres_rate' => 'agres_rate',
-  );
-
-  /* Display: Page */
-  $handler = $view->new_display('page', 'Page', 'page');
-  $handler->display->display_options['path'] = 'agres_resources/agres_rate';
-  $handler->display->display_options['menu']['type'] = 'tab';
-  $handler->display->display_options['menu']['title'] = 'Price Rates';
-  $handler->display->display_options['menu']['description'] = 'Each Pricerate can have multiple Timeframe attached, without Timeframes no rates apply';
-  $handler->display->display_options['menu']['weight'] = '0';
-  $handler->display->display_options['menu']['name'] = 'main-menu';
-  $translatables['agres_rate'] = array(
-    t('Master'),
-    t('agres_rate'),
-    t('more'),
-    t('Apply'),
-    t('Reset'),
-    t('Sort by'),
-    t('Asc'),
-    t('Desc'),
-    t('Items per page'),
-    t('- All -'),
-    t('Offset'),
-    t('Page'),
-  );
-  $views['agres_rate'] = $view;
-  return $views;
-}
+
+/**
+ * @file
+ * agreservations.views.inc providing default views /calendarviews..
+ *
+ */
+
+/**
+ * @todo Documentation
+ */
+function agres_rate_views_default_views() {
+  $views = array();
+  $view = new view;
+  $view->name = 'agres_rate';
+  $view->description = '';
+  $view->tag = 'default';
+  $view->base_table = 'node';
+  $view->human_name = 'agres_rate';
+  $view->core = 7;
+  $view->api_version = '3.0';
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+  /* Display: Master */
+  $handler = $view->new_display('default', 'Master', 'default');
+  $handler->display->display_options['title'] = 'agres_rate';
+  $handler->display->display_options['access']['type'] = 'perm';
+  $handler->display->display_options['access']['perm'] = 'view agreservations Resources';
+  $handler->display->display_options['cache']['type'] = 'none';
+  $handler->display->display_options['query']['type'] = 'views_query';
+  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
+  $handler->display->display_options['exposed_form']['type'] = 'basic';
+  $handler->display->display_options['pager']['type'] = 'full';
+  $handler->display->display_options['pager']['options']['items_per_page'] = '10';
+  $handler->display->display_options['style_plugin'] = 'table';
+  /* Field: Content: Title */
+  $handler->display->display_options['fields']['title']['id'] = 'title';
+  $handler->display->display_options['fields']['title']['table'] = 'node';
+  $handler->display->display_options['fields']['title']['field'] = 'title';
+  $handler->display->display_options['fields']['title']['label'] = '';
+  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
+  /* Sort criterion: Content: Post date */
+  $handler->display->display_options['sorts']['created']['id'] = 'created';
+  $handler->display->display_options['sorts']['created']['table'] = 'node';
+  $handler->display->display_options['sorts']['created']['field'] = 'created';
+  $handler->display->display_options['sorts']['created']['order'] = 'DESC';
+  /* Filter criterion: Content: Published */
+  $handler->display->display_options['filters']['status']['id'] = 'status';
+  $handler->display->display_options['filters']['status']['table'] = 'node';
+  $handler->display->display_options['filters']['status']['field'] = 'status';
+  $handler->display->display_options['filters']['status']['value'] = 1;
+  $handler->display->display_options['filters']['status']['group'] = 0;
+  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
+  /* Filter criterion: Content: Type */
+  $handler->display->display_options['filters']['type']['id'] = 'type';
+  $handler->display->display_options['filters']['type']['table'] = 'node';
+  $handler->display->display_options['filters']['type']['field'] = 'type';
+  $handler->display->display_options['filters']['type']['value'] = array(
+    'agres_rate' => 'agres_rate',
+  );
+
+  /* Display: Page */
+  $handler = $view->new_display('page', 'Page', 'page');
+  $handler->display->display_options['path'] = 'agres_resources/agres_rate';
+  $handler->display->display_options['menu']['type'] = 'tab';
+  $handler->display->display_options['menu']['title'] = 'Price Rates';
+  $handler->display->display_options['menu']['description'] = 'Each Pricerate can have multiple Timeframe attached, without Timeframes no rates apply';
+  $handler->display->display_options['menu']['weight'] = '0';
+  $handler->display->display_options['menu']['name'] = 'main-menu';
+  $translatables['agres_rate'] = array(
+    t('Master'),
+    t('agres_rate'),
+    t('more'),
+    t('Apply'),
+    t('Reset'),
+    t('Sort by'),
+    t('Asc'),
+    t('Desc'),
+    t('Items per page'),
+    t('- All -'),
+    t('Offset'),
+    t('Page'),
+  );
+  $views['agres_rate'] = $view;
+  return $views;
+}
\ No newline at end of file
diff --git a/agres_rconflict/agres_rconflict.info b/agres_rconflict/agres_rconflict.info
index 7f5f28a..c700aa2 100644
--- a/agres_rconflict/agres_rconflict.info
+++ b/agres_rconflict/agres_rconflict.info
@@ -1,6 +1,6 @@
-; $Id: agres_rate.info,v 1.1.2.1 2010/12/23 02:25:46 agill Exp $
-name = agres_rconflict
-description = based on Resource Conflict module by deviantintegral : Checks for Conflicts of booked units, and prevents booking on conflict
-package = agreservations - Core
+name = Agreservations Resource Conflict
+description = Checks for Conflicts of booked units, and prevents booking on conflict. Based on Resource Conflict module by deviantintegral
+package = Agreservations - Core
 core = 7.x
-files[] = agres_rconflict.module
+
+files[] = agres_rconflict.module
\ No newline at end of file
diff --git a/agres_rconflict/agres_rconflict.module b/agres_rconflict/agres_rconflict.module
index 4487af4..c636581 100644
--- a/agres_rconflict/agres_rconflict.module
+++ b/agres_rconflict/agres_rconflict.module
@@ -1,268 +1,263 @@
 <?php
-
-
-/**
- * @file
- * agres_rconflict.module takes over the job of Resource Conflict in the Drupal 7 Version
- * of agreservations, until there is a version of Resource Conflict ready for Drupal 7...
- * This substitute module is basically a stripped version of
- * Resource Conflict(Resource Conflict was written by Drupal.org User deviantintegral)
- */
-
-/**
- * Implements hook_node_validate().
- */
-function agres_rconflict_node_validate($node, $form) {
-  $type = $node->type;
-  if (!($type == 'agreservation')) {
+
+/**
+ * @file
+ * The Agreservations Resource Conflict module takes over the job of Resource 
+ * Conflict in the Drupal 7 Version of agreservations, until there is a version 
+ * of Resource Conflict ready for Drupal 7. This substitute module is basically 
+ * a stripped version of Resource Conflict (Resource Conflict was written by 
+ * Drupal.org User deviantintegral)
+ */
+
+/**
+ * Implements hook_node_validate().
+ */
+function agres_rconflict_node_validate($node, $form) {
+  $type = $node->type;
+  if (!($type == 'agreservation')) {
     // Conflict handling is not enabled for this node.
-    return;
-  }
+    return;
+  }
   // Find the date field to use for time overlapping_node_ids detection.
-  $date_field = 'field_agres_rdate';
-  $overlapping_node_ids = array();
-  if (strpos($date_field, 'field_', 0) === 0) {
-    $tlangs1 = array();
-    $alllangs = array();
-    $tlangs1 = language_list();
-    $alllangs = array_merge($tlangs1, array('und' => ''));
-    $alllangs = array_keys($alllangs);
-    foreach ($alllangs as $lang) {
+  $date_field = 'field_agres_rdate';
+  $overlapping_node_ids = array();
+  if (strpos($date_field, 'field_', 0) === 0) {
+    $tlangs1 = array();
+    $alllangs = array();
+    $tlangs1 = language_list();
+    $alllangs = array_merge($tlangs1, array('und' => ''));
+    $alllangs = array_keys($alllangs);
+    foreach ($alllangs as $lang) {
+      
+      if (!isset($node->{$date_field}[$lang])) {
+        continue;
+      }
+
       // Get the start and end Date of the current node
-      if (isset($node->{$date_field}[$lang])) {
-        $start = $node->{$date_field}[$lang][0]['value'];
-        $end = $node->{$date_field}[$lang][0]['value2'];
-      }
-      else {
-        continue;
-      }
-
+      $start = $node->{$date_field}[$lang][0]['value'];
+      $end = $node->{$date_field}[$lang][0]['value2'];
+
       // Get all conflicting Date nodes
-      if (!empty($start) && !empty($end)) {
-        $overlapping_node_ids = _agres_rconflict_overlaps_from_date($start, $end);
-      }
-      else {
-        // If we got here, someone broke the requirements, so turn off
-        // resource conflict for this type and notify an admin
-//      _agres_rconflict_disable($type);
-      }
-    }
-
-  }
-  if (!empty($node->event_start)) {
+      if (!empty($start) && !empty($end)) {
+        $overlapping_node_ids = _agres_rconflict_overlaps_from_date($start, $end);
+      }
+      else {
+        // If we got here, someone broke the requirements, so turn off resource 
+        // conflict for this type and notify an admin.
+      }
+    }
+  }
+  if (!empty($node->event_start)) {
     // Get all overlapping events
-    $tmp = _agres_rconflict_overlaps_from_event($node->event_start, $node->event_end);
-    $overlapping_node_ids = array_unique(array_merge($overlapping_node_ids, $tmp));
-  }
-
+    $tmp = _agres_rconflict_overlaps_from_event($node->event_start, $node->event_end);
+    $overlapping_node_ids = array_unique(array_merge($overlapping_node_ids, $tmp));
+  }
+
   // Load conflicting nodes
-  $conflicting_nodes = array();
-  foreach ($overlapping_node_ids as $nid) {
+  $conflicting_nodes = array();
+  foreach ($overlapping_node_ids as $nid) {
     // Don't have the node conflict with itself
-    if ($nid != $node->nid) {
-      $conflicting_nodes[$nid] = node_load($nid);
-    }
-  }
+    if ($nid != $node->nid) {
+      $conflicting_nodes[$nid] = node_load($nid);
+    }
+  }
   // Display conflict errors
-  _agres_rconflict_display_conflict_errors($node, $conflicting_nodes);
-}
-
-/**
- * Compare our demand to the demand of overlapping nodes
- * and display errors for the intersections
- *
- * @param $node the currently validating node
- * @param $conflicting_nodes array of nodes that overlap with this node
- */
-function _agres_rconflict_display_conflict_errors($node, $conflicting_nodes) {
-  $our_demands = _agres_rconflict_get_node_resource_demand($node);
-  //enable different language checks:
-
-  foreach ($conflicting_nodes as $conflicting_node) {
-    $other_demands = _agres_rconflict_get_node_resource_demand($conflicting_node);
-
-    // select the resources that both this node and the other node demands
-    $conflicting_resources = array();
-    foreach ($our_demands as $our_demand => $dummy) {
-      if (isset($other_demands[$our_demand])) {
-        $conflicting_resources[$our_demand] = node_load($our_demand);
-      }
-    }
-    $tmplangs = language_list();
-//    drupal_set_message('<pre>trtert___'.print_r($tmplangs,true).'</pre>');
-    // display the error for each conflict
-    foreach ($conflicting_resources as $conflicting_resource) {
-      $date_field = 'field_agres_rdate';
-      $type = DATE_ISO;
-      $tlangs1 = array();
-      $alllangs = array();
-      $tlangs1 = language_list();
-      $alllangs = array_merge($tlangs1, array('und' => ''));
-      $alllangs = array_keys($alllangs);
-      foreach ($alllangs as $lang) {
-        if (isset($conflicting_node->{$date_field}[$lang])) {
-          $startobj = new DateObject($conflicting_node->{$date_field}[$lang][0]['value']);
-          $start = $startobj->format('Y-m-d H:i');
-          $endobj = new DateObject($conflicting_node->{$date_field}[$lang][0]['value2']);
-          $end = $endobj->format('Y-m-d H:i');
-
-          $error = t('There is a resource conflict: <a href="@resource-url">%resource</a> is currently booked for <a href="@booker-url">%booker</a> from %start to %end. Please choose a different time or a different resource.', array(
-            '@booker-url' => url('node/' . $conflicting_node->nid),
-            '%booker' => $conflicting_node->title,
-            '@resource-url' => url('node/' . $conflicting_resource->nid),
-            '%resource' => $conflicting_resource->title,
-            '%start' => $start,
-            '%end' => $end,
-          )
-                    );
-
+  _agres_rconflict_display_conflict_errors($node, $conflicting_nodes);
+}
+
+/**
+ * Compare our demand to the demand of overlapping nodes
+ * and display errors for the intersections
+ *
+ * @param $node the currently validating node
+ * @param $conflicting_nodes array of nodes that overlap with this node
+ */
+function _agres_rconflict_display_conflict_errors($node, $conflicting_nodes) {
+  $our_demands = _agres_rconflict_get_node_resource_demand($node);
+
+  // Enable different language checks
+  foreach ($conflicting_nodes as $conflicting_node) {
+    $other_demands = _agres_rconflict_get_node_resource_demand($conflicting_node);
+
+    // Select the resources that both this node and the other node demands
+    $conflicting_resources = array();
+    foreach ($our_demands as $our_demand => $dummy) {
+      if (isset($other_demands[$our_demand])) {
+        $conflicting_resources[$our_demand] = node_load($our_demand);
+      }
+    }
+    $tmplangs = language_list();
+    // Display the error for each conflict
+    foreach ($conflicting_resources as $conflicting_resource) {
+      $date_field = 'field_agres_rdate';
+      $type = DATE_ISO;
+      $tlangs1 = array();
+      $alllangs = array();
+      $tlangs1 = language_list();
+      $alllangs = array_merge($tlangs1, array('und' => ''));
+      $alllangs = array_keys($alllangs);
+      foreach ($alllangs as $lang) {
+        if (isset($conflicting_node->{$date_field}[$lang])) {
+          $startobj = new DateObject($conflicting_node->{$date_field}[$lang][0]['value']);
+          $start = $startobj->format('Y-m-d H:i');
+          $endobj = new DateObject($conflicting_node->{$date_field}[$lang][0]['value2']);
+          $end = $endobj->format('Y-m-d H:i');
+
+          $error = t('There is a resource conflict: <a href="@resource-url">%resource</a> is currently booked for <a href="@booker-url">%booker</a> from %start to %end. Please choose a different time or a different resource.', array(
+            '@booker-url' => url('node/' . $conflicting_node->nid),
+            '%booker' => $conflicting_node->title,
+            '@resource-url' => url('node/' . $conflicting_resource->nid),
+            '%resource' => $conflicting_resource->title,
+            '%start' => $start,
+            '%end' => $end,
+            )
+          );
+
           // This is a bit of a hack, but there's no way with FAPI to have
           // multiple form errors on the same field.  So, we just pass in
           // a bogus (but unique) ID for each error message, to ensure
           // that all conflicts are reported simultaneously.  We use the
           // nid of the conflicting resource (thing) appended with the nid
           // of the conflicting node (reservation event).
-          $conflict_id = $conflicting_resource->nid . '_' . $conflicting_node->nid;
-          form_set_error($conflict_id, $error);
-        }
-      }
-    }
-  }
-}
-
-/**
- * Get a conflict enabled node's resource demand
- *
- * @param $node
- *   The node which resurce demand will be returned
- * @return
- *   An array with keys of the node ID's, values of true
- */
-function _agres_rconflict_get_node_resource_demand($node) {
-  $type = $node->type;
-  $reference_fields = variable_get('rc_reference_fields_' . $type, array());
-  $demand = array();
-  $reference_field = 'field_agres_ref_unit';
-  $tlangs1 = array();
-  $alllangs = array();
-  $tlangs1 = language_list();
-  $alllangs = array_merge($tlangs1, array('und' => ''));
-  $alllangs = array_keys($alllangs);
-  foreach ($alllangs as $lang) {
-    if (isset($node->{$reference_field}[$lang])) {
-      $references = $node->{$reference_field}[$lang];
-      foreach ($references as $key => $reference) {
-        /**
-         * Check to see if any referencable resources exist. If they don't, file
-         * an error. This only matters when the nodereference field is set to
-         * required, otherwise this code doesn't get called at all. We have to
-         * file the error against the fake 'no_resources' element as CCK files
-         * it's own "Illegal choice" error before we get called.
-         */
-        if (is_numeric($reference['nid'])) {
-          $demand[$reference['nid']] = TRUE;
-        }
-        else {
-          form_set_error('no_resources', t('No bookable resources have been created. Please create resources to book before attempting to create a resource booking.'));
-        }
-      }
-    }
-  }
-  return $demand;
-}
-
-/**
- * Determine if any nodes conflict between the specified dates using Date API.
- *
- * @param $date_start
- *   The start date of the date to check
- * @param $date_end
- *   The end date of the date to check.
- * @return
- *   An array of node ID's
- */
-function _agres_rconflict_overlaps_from_date($date_start, $date_end) {
+          $conflict_id = $conflicting_resource->nid . '_' . $conflicting_node->nid;
+          form_set_error($conflict_id, $error);
+        }
+      }
+    }
+  }
+}
+
+/**
+ * Get a conflict enabled node's resource demand
+ *
+ * @param $node
+ *   The node which resurce demand will be returned
+ * @return
+ *   An array with keys of the node ID's, values of true
+ */
+function _agres_rconflict_get_node_resource_demand($node) {
+  $type = $node->type;
+  $reference_fields = variable_get('rc_reference_fields_' . $type, array());
+  $demand = array();
+  $reference_field = 'field_agres_ref_unit';
+  $tlangs1 = array();
+  $alllangs = array();
+  $tlangs1 = language_list();
+  $alllangs = array_merge($tlangs1, array('und' => ''));
+  $alllangs = array_keys($alllangs);
+  foreach ($alllangs as $lang) {
+    if (isset($node->{$reference_field}[$lang])) {
+      $references = $node->{$reference_field}[$lang];
+      foreach ($references as $key => $reference) {
+        /**
+         * Check to see if any referencable resources exist. If they don't, file
+         * an error. This only matters when the nodereference field is set to
+         * required, otherwise this code doesn't get called at all. We have to
+         * file the error against the fake 'no_resources' element as CCK files
+         * it's own "Illegal choice" error before we get called.
+         */
+        if (is_numeric($reference['nid'])) {
+          $demand[$reference['nid']] = TRUE;
+        }
+        else {
+          form_set_error('no_resources', t('No bookable resources have been created. Please create resources to book before attempting to create a resource booking.'));
+        }
+      }
+    }
+  }
+  return $demand;
+}
+
+/**
+ * Determine if any nodes conflict between the specified dates using Date API.
+ *
+ * @param $date_start
+ *   The start date of the date to check
+ * @param $date_end
+ *   The end date of the date to check.
+ * @return
+ *   An array of node ID's
+ */
+function _agres_rconflict_overlaps_from_date($date_start, $date_end) {
   // Make the default type to DATE_ISO.
-  $type = DATE_ISO;
-  $date_startobj = New DateObject($date_start, 'GMT');
-  $date_endobj   = New DateObject($date_end, 'GMT');
-
-  return _agres_rconflict_get_overlaps($date_startobj, $date_endobj);
-}
-
-/**
- * Determine if any nodes conflict between the specified dates using Event.
- *
- * @param $event_start
- *   The start date of the event to check
- * @param $event_end
- *   The end date of the event to check.
- * @return
- *   An array of node ID's
- */
-function _agres_rconflict_overlaps_from_event($event_start, $event_end) {
-  $start = date_make_date($event_start, 'GMT', DATE_UNIX);
-  $end = date_make_date($event_end, 'GMT', DATE_UNIX);
-  return _agres_rconflict_get_overlaps($start, $end);
-}
-
-/**
- * Determine if any conflict enabled nodes overlap the specified times
- *
- * 1. $start is within the event time
- * 2. $end end is within the event time
- * 3. The event encompasses $start and $end
- * 4. Allow the end of one event to occur at the start of the next
- *
- * @param $start
- *  The start time of events to search as dateAPI object
- * @param $end
- *   The end time of events to search as dateAPI object
- * @return
- *   An array of node ID's
- */
-function _agres_rconflict_get_overlaps($start, $end) {
-  $date_start = $start->format(DATE_FORMAT_DATETIME);
-  $date_end = $end->format(DATE_FORMAT_DATETIME);
-  $rows = array();
-  $type = 'agreservation';
-//  foreach ($conflict_types as $type) {
-  $date_field = 'field_agres_rdate';
-  if (strpos($date_field, 'field_', 0) === 0) {
-    $date_table = '{' . 'field_data_' . $date_field . '}';
-    $start_field_name = $date_field . '_value';
-    $end_field_name = $date_field . '_value2';
+  $type = DATE_ISO;
+  $date_startobj = New DateObject($date_start, 'GMT');
+  $date_endobj = New DateObject($date_end, 'GMT');
+
+  return _agres_rconflict_get_overlaps($date_startobj, $date_endobj);
+}
+
+/**
+ * Determine if any nodes conflict between the specified dates using Event.
+ *
+ * @param $event_start
+ *   The start date of the event to check
+ * @param $event_end
+ *   The end date of the event to check.
+ * @return
+ *   An array of node ID's
+ */
+function _agres_rconflict_overlaps_from_event($event_start, $event_end) {
+  $start = date_make_date($event_start, 'GMT', DATE_UNIX);
+  $end = date_make_date($event_end, 'GMT', DATE_UNIX);
+  return _agres_rconflict_get_overlaps($start, $end);
+}
+
+/**
+ * Determine if any conflict enabled nodes overlap the specified times
+ *
+ * 1. $start is within the event time
+ * 2. $end end is within the event time
+ * 3. The event encompasses $start and $end
+ * 4. Allow the end of one event to occur at the start of the next
+ *
+ * @param $start
+ *  The start time of events to search as dateAPI object
+ * @param $end
+ *   The end time of events to search as dateAPI object
+ * @return
+ *   An array of node ID's
+ */
+function _agres_rconflict_get_overlaps($start, $end) {
+  $date_start = $start->format(DATE_FORMAT_DATETIME);
+  $date_end = $end->format(DATE_FORMAT_DATETIME);
+  $rows = array();
+  $type = 'agreservation';
+  $date_field = 'field_agres_rdate';
+  if (strpos($date_field, 'field_', 0) === 0) {
+    $date_table = '{' . 'field_data_' . $date_field . '}';
+    $start_field_name = $date_field . '_value';
+    $end_field_name = $date_field . '_value2';
     $query = "SELECT DISTINCT {node}.nid FROM {node} INNER JOIN $date_table date_table ON {node}.vid = date_table.revision_id
        WHERE(:date_start >= date_table.$start_field_name AND :date_start < date_table.$end_field_name)
        OR(:date_end > date_table.$start_field_name AND :date_end <= date_table.$end_field_name)
-       OR(:date_start <= date_table.$start_field_name AND :date_end >= date_table.$end_field_name)";
-    $result = db_query($query, array(':date_start' => $date_start, ':date_end' => $date_end));
-
+       OR(:date_start <= date_table.$start_field_name AND :date_end >= date_table.$end_field_name)";
+    $result = db_query($query, array(':date_start' => $date_start, ':date_end' => $date_end));
+
     // Create an array of all of the results
-    while ($row = $result->fetchAssoc()) {
-      $rows[] = $row['nid'];
-    }
-  }
-//  }
-  return array_unique($rows);
-}
-
-
-/**
- *  A function to display the database value for the date object
- *
- *  @param $date - the date object
- *  @param $format - DATE_UNIX or DATE_ISO, the type of value to display
- *  @param $type - 'db' or 'local', the date value to display
- */
-if (!function_exists('date_show_value')) {
-  function date_show_value($date, $type = 'db', $format = DATE_ISO) {
-    if ($format == DATE_UNIX) {
-      return $date->$type->timestamp;
-    }
-    else {
-      return $date->$type->iso;
-    }
-  }
-}
-
+    while ($row = $result->fetchAssoc()) {
+      $rows[] = $row['nid'];
+    }
+  }
+  return array_unique($rows);
+}
+
+if (!function_exists('date_show_value')) {
+
+  /**
+   *  A function to display the database value for the date object
+   *
+   *  @param $date - the date object
+   *  @param $format - DATE_UNIX or DATE_ISO, the type of value to display
+   *  @param $type - 'db' or 'local', the date value to display
+   */
+  function date_show_value($date, $type = 'db', $format = DATE_ISO) {
+    if ($format == DATE_UNIX) {
+      return $date->$type->timestamp;
+    }
+    else {
+      return $date->$type->iso;
+    }
+  }
+
+}
\ No newline at end of file
diff --git a/agres_restriction/agres_restriction.info b/agres_restriction/agres_restriction.info
index 011bacd..0f0ee17 100644
--- a/agres_restriction/agres_restriction.info
+++ b/agres_restriction/agres_restriction.info
@@ -1,8 +1,9 @@
-; $Id: agres_restriction.info,v 1.1.2.1 2010/12/23 02:25:46 agill Exp $
 name = Agreservations Restriction
 description = Restricts the reservation of a resource to a minimum number of days, a starting day and and end day of the week.
-dependencies[] = agreservations
-dependencies[] = agres_timeframe
-package = agreservations - Custom
+package = Agreservations - Custom
 core = 7.x
+
 files[] = agres_restriction.module
+
+dependencies[] = agreservations
+dependencies[] = agres_timeframe
diff --git a/agres_restriction/agres_restriction.module b/agres_restriction/agres_restriction.module
index 2216780..0a4e0f7 100644
--- a/agres_restriction/agres_restriction.module
+++ b/agres_restriction/agres_restriction.module
@@ -1,73 +1,42 @@
 <?php
 
-// $Id: agres_restriction.module,v 1.1.2.1 2010/12/23 02:25:46 agill Exp $
-
-
 /**
  * @file
- *  Implements restrictions for resource reservations. It can be specified the number of minimum days, and the starting day. Also, the period when the restriction is
- *  valid can be specified. This is implemented using a content type.
- *  This module was provided to me by amazeelabs, a suiss company.
+ *  Implements restrictions for resource reservations.
+ *
+ * It can be specified the number of minimum days, and the starting day. Also,
+ * the period when the restriction is valid can be specified. This is
+ * implemented using a content type.
+ *
+ * This module was provided to me by amazeelabs, a suiss company.
  */
 
 /**
- * Implements hook_form_alter().
- *
+ * @todo Documentation
  */
-function agres_restriction_form_alter($form, $form_state, $form_id) {
-//  switch ($form_id) {
-//    case 'agreservations_unit_node_form':
-  ////        drupal_set_message('<pre>agres_restriction_form_alter'.print_r(arg(1),true).'</pre>');
-  ////      if (isset($form['field_agres_restrictions']) && is_numeric(arg(1)) && arg(0) == 'node') {
-  ////
-  //////        //Add a link to add a new restriction (a timefram), if the user has access to do that.
-  //////
-  //////
-  ////        if (node_access('create', 'agres_timeframe')) {
-  //////            drupal_set_message('<pre>agres_restriction_form_alter'.print_r(drupal_get_destination(),true).'</pre>');
-  //////          $form['field_agres_restrictions']['#suffix'] .= t('Or !add_new_link', array('!add_new_link' => l(t('Add a new restriction'), 'node/add/agres_timeframe', array('query' => drupal_get_destination() . '&referenceid=' . arg(1)))));
-  ////        }
-  ////      }
-  ////      break;
-//
-  ////  case 'agres_timeframe_node_form':
-  ////    if (isset($_GET['referenceid'])) {
-  ////      //Check also if the user can edit the unit.
-  ////      $unit_node = node_load($_GET['referenceid']);
-  ////      if (node_access('update', $unit_node)) {
-  ////        $form['agreservation_unit_id'] = array(
-  ////          '#type' => 'value',
-  ////          '#value' => (int) $_GET['referenceid'],
-  ////        );
-  ////      }
-  ////    }
-  ////    break;
-  ////}
-
-}
 function _agres_restriction_node_validate($node) {
   switch ($node->type) {
     case 'agreservation':
       $valid = true;
-//            drupal_set_message('<pre>während node_validate'.print_r($node,true).'</pre>');
-//            //Check the agres_timeframe restriction.
+      // Check the agres_timeframe restriction.
       $langcode = i18n_langcode();
       if (!isset($node->field_agres_ref_unit[$langcode])) {
         $langcode = 'und';
       }
       foreach ($node->field_agres_ref_unit[$langcode] as $ref_unit_id) {
-//            	//If there is no unit selected, the $ref_unit_id is NULL, so skip it.
+        // If there is no unit selected, the $ref_unit_id is NULL, so skip it.
         if (is_null($ref_unit_id['nid'])) {
           continue;
         }
         $unit_node = node_load($ref_unit_id['nid']);
-//              //First, check if the unit has agres_timeframes assigned. These will override the global ones.
+        // First, check if the unit has agres_timeframes assigned.
+        // These will override the global ones.
         if (isset($unit_node->field_agres_restrictions[$unit_node->language]) && !is_null($unit_node->field_agres_restrictions[$unit_node->language][0]['nid'])) {
           $message = agres_timeframe_api('check_restrictions', array(
             'start_date' => $node->field_agres_rdate[$langcode][0]['value'],
             'end_date' => $node->field_agres_rdate[$langcode][0]['value2'],
             'nids' => $unit_node->field_agres_restrictions[$unit_node->language],
-          ));
+            ));
           if ($message !== TRUE) {
             $node->validated = FALSE;
             form_set_error('field_agres_rdate', $message['message']);
@@ -75,11 +44,10 @@ function _agres_restriction_node_validate($node) {
           }
         }
         elseif ($unit_node->field_agres_global_restrictions[$unit_node->language][0]['value'] == 1) {
-//
           $message = agres_timeframe_api('check_restrictions', array(
             'start_date' => $node->field_agres_rdate[$langcode][0]['value'],
             'end_date' => $node->field_agres_rdate[$langcode][0]['value2'],
-          ));
+            ));
           $valid = false;
           if ($message !== TRUE) {
             $node->validated = FALSE;
@@ -87,12 +55,8 @@ function _agres_restriction_node_validate($node) {
             $valid = false;
           }
         }
-        else {
-
-        }
       }
       break;
   }
   return $valid;
-}
-
+}
\ No newline at end of file
diff --git a/agres_timeframe/agres_timeframe.admin.inc b/agres_timeframe/agres_timeframe.admin.inc
index 47f73c5..a558a3d 100644
--- a/agres_timeframe/agres_timeframe.admin.inc
+++ b/agres_timeframe/agres_timeframe.admin.inc
@@ -1,13 +1,14 @@
 <?php
 
-// $Id: agres_timeframe.admin.inc,v 1.1.2.1 2010/12/23 02:25:46 agill Exp $
-
-
 /**
  * @file
  * Implements the agres_timeframe content type. This module was created by Amazeelabs and
  * given to me as a contribution. Thanks amazee labs!
  */
+
+/**
+ * Implements hook_settings_form().
+ */
 function agres_timeframe_settings_form($form, &$form_state) {
   $form['agres_timeframes_global_overlap'] = array(
     '#type' => 'checkbox',
@@ -20,4 +21,4 @@ function agres_timeframe_settings_form($form, &$form_state) {
     '#default_value' => variable_get('agres_timeframes_nodes_overlap', NULL),
   );
   return system_settings_form($form);
-}
+}
\ No newline at end of file
diff --git a/agres_timeframe/agres_timeframe.api.inc b/agres_timeframe/agres_timeframe.api.inc
index 3e76bbe..02ef781 100644
--- a/agres_timeframe/agres_timeframe.api.inc
+++ b/agres_timeframe/agres_timeframe.api.inc
@@ -5,6 +5,7 @@
  * Implements the agres_timeframe content type. This module was created by Amazeelabs and
  * given to me as a contribution. Thanks amazee labs!
  */
+
 /**
  * Checks if a restriction is checked for a start date, end date, and a set of agres_timeframe nodes.
  *
@@ -46,8 +47,6 @@ function agres_timeframe_api_check_restrictions($data) {
 
       $data['nids'][] = $nid->nid;
     }
-
-
   }
 
   if (isset($data['nids'])) {
@@ -106,8 +105,8 @@ function timefram_api_check_restriction($data) {
     $agresdate2 = date_format($tmpagresdate2, 'Y-m-d');
 
     //First, check 1.
-    if ( $agresdate1 >= $strperiod1 &&   $agresdate1 <= $strperiod2 &&
-        $agresdate2 >= $strperiod1 && $agresdate2 <= $strperiod2) {
+    if ($agresdate1 >= $strperiod1 && $agresdate1 <= $strperiod2 &&
+      $agresdate2 >= $strperiod1 && $agresdate2 <= $strperiod2) {
       if ((isset($data['node']->field_agres_timeframe_from_day[$data['node']->language][0]['value'])) && $start_day != $data['node']->field_agres_timeframe_from_day[$data['node']->language][0]['value']) {
 //          drupal_set_message('<pre>$query$query$query41111111111neeuuu1*'.print_r($data['node']->field_agres_timeframe_from_day[$data['node']->language][0]['value'],true).'</pre>');
         return FALSE;
@@ -167,10 +166,10 @@ function timefram_api_check_restriction_old($data) {
     if (!$end_day) {
       $end_day = 7;
     }
-    drupal_set_message('<pre>$query$query$query411111111111*' . print_r($data, true) . '</pre>');
+    //drupal_set_message('<pre>$query$query$query411111111111*' . print_r($data, true) . '</pre>');
     //First, check 1.
     if ($data['start_date'] >= $data['node']->field_agres_timeframe_period[$data['node']->language][0]['value'] && $data['start_date'] <= $data['node']->field_agres_timeframe_period[$data['node']->language][0]['value2'] &&
-        $data['end_date'] >= $data['node']->field_agres_timeframe_period[$data['node']->language][0]['value'] && $data['end_date'] <= $data['node']->field_agres_timeframe_period[$data['node']->language][0]['value2']) {
+      $data['end_date'] >= $data['node']->field_agres_timeframe_period[$data['node']->language][0]['value'] && $data['end_date'] <= $data['node']->field_agres_timeframe_period[$data['node']->language][0]['value2']) {
       //To DO: handle different strtotime strings if needed.
 
       if ($data['node']->field_agres_timeframe_from_day[$data['node']->language][0]['value'] && $start_day != $data['node']->field_agres_timeframe_from_day[$data['node']->language][0]['value']) {
@@ -263,4 +262,4 @@ function agres_timeframe_api_get_restriction_message($agres_timeframe_node) {
     $message['message'] = t($message['message_original'], $message['args']);
   }
   return $message;
-}
+}
\ No newline at end of file
diff --git a/agres_timeframe/agres_timeframe.field.inc b/agres_timeframe/agres_timeframe.field.inc
index 7a91d20..2d23ef1 100644
--- a/agres_timeframe/agres_timeframe.field.inc
+++ b/agres_timeframe/agres_timeframe.field.inc
@@ -14,8 +14,9 @@ function _agres_timeframe_contenttypes() {
   );
   return $types;
 }
+
 function _agres_timeframe_patch7201() {
- $fields = array();
+  $fields = array();
   // Exported field: 'node-agres_timeframe-field_agres_timeframe_max_days'
   $fields['node-agres_timeframe-field_agres_timeframe_max_days'] = array(
     'field_config' => array(
@@ -84,7 +85,7 @@ function _agres_timeframe_patch7201() {
       ),
     ),
   );
-    return $fields;
+  return $fields;
 }
 
 /**
@@ -742,4 +743,4 @@ function _agres_timeframe_fields() {
   );
 
   return $fields;
-}
+}
\ No newline at end of file
diff --git a/agres_timeframe/agres_timeframe.info b/agres_timeframe/agres_timeframe.info
index 553fe7f..d0b2ed0 100644
--- a/agres_timeframe/agres_timeframe.info
+++ b/agres_timeframe/agres_timeframe.info
@@ -1,13 +1,14 @@
-; $Id: agres_timeframe.info,v 1.1.2.1 2010/12/23 02:25:46 agill Exp $
 name = Agreservations Timeframe
 description = Implements the Timeframe content type.
-dependencies[] = date
-dependencies[] = agreservations
-package = agreservations - Custom
+package = Agreservations - Custom
 core = 7.x
+
 files[] = agres_timeframe.admin.inc
 files[] = agres_timeframe.api.inc
 files[] = agres_timeframe.cck.inc
 files[] = agres_timeframe.install
 files[] = agres_timeframe.module
 files[] = agres_timeframe.views.inc
+
+dependencies[] = date
+dependencies[] = agreservations
\ No newline at end of file
diff --git a/agres_timeframe/agres_timeframe.install b/agres_timeframe/agres_timeframe.install
index a261e0d..daec128 100644
--- a/agres_timeframe/agres_timeframe.install
+++ b/agres_timeframe/agres_timeframe.install
@@ -1,18 +1,22 @@
 <?php
-// $Id$
 
+/**
+ * @file
+ *  @todo Fill this in
+ */
 
 /**
  * _agres_timeframe_install_ccktype
  * Install the cck fields and types in $export.
  *
+ * Inspired by the features module
+ *
  * @param $typename
  *   '<create>'    :a new cck type will be installed
  *   'contenttype' :the fields in  $export will be added to the given
  *  contenttype.
  * @param $export _ the export to be imported.
  */
-// inspired by the features module:
 function _agres_timeframe_install_bundle_fields($fields) {
   if (isset($fields)) {
     field_info_cache_clear();
@@ -28,7 +32,6 @@ function _agres_timeframe_install_bundle_fields($fields) {
 
       // Create or update field instance.
       $field_instance = $field['field_instance'];
-//      drupal_set_message('<pre>'.print_r($field_instance,true).'</pre>');
       $existing_instance = field_info_instance($field_instance['entity_type'], $field_instance['field_name'], $field_instance['bundle']);
       if ($existing_instance) {
         field_update_instance($field_instance);
@@ -42,8 +45,9 @@ function _agres_timeframe_install_bundle_fields($fields) {
 }
 
 /**
- * @todo Please document this function.
- * @see http://drupal.org/node/1354
+ * Implements hook_install().
+ *
+ * @todo Documentation
  */
 function agres_timeframe_install() {
   module_load_include('inc', 'agres_timeframe', 'agres_timeframe.field');
@@ -57,32 +61,24 @@ function agres_timeframe_install() {
   _agres_timeframe_install_bundle_fields($fields);
 }
 
-  function agres_timeframe_update_7201() {
-     module_load_include('inc', 'agres_timeframe', 'agres_timeframe.field');   
-     $fields = _agres_timeframe_patch7201();
-     _agres_timeframe_install_bundle_fields($fields);
-  }
-
-
 /**
- * Implements hook_enable().
+ * Update function
+ *
+ * @todo Documentation
  */
-//function agres_timeframe_enable() {
-//  module_load_include('inc', 'agres_timeframe', 'agres_timeframe.field');
-//  $fields = _agres_category_fields();
-//  _agres_timeframe_install_bundle_fields($fields);
-//
-//}
-//agreservation_unit_info
-
-
+function agres_timeframe_update_7201() {
+  module_load_include('inc', 'agres_timeframe', 'agres_timeframe.field');
+  $fields = _agres_timeframe_patch7201();
+  _agres_timeframe_install_bundle_fields($fields);
+}
 
-//thanks to authors of the examples modules collection!
+/**
+ * Implements hook_uninstall().
+ */
 function agres_timeframe_uninstall() {
   module_load_include('inc', 'agres_timeframe', 'agres_timeframe.field');
   // Gather all the example content that might have been created while this
   // module was enabled.  Simple selects still use db_query().
-  // http://api.drupal.org/api/function/db_query/7
   $sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
   $result = db_query($sql, array(':type' => 'agres_timeframe'));
   $nids = array();
@@ -91,29 +87,23 @@ function agres_timeframe_uninstall() {
   }
 
   // Delete all the nodes at once
-  // http://api.drupal.org/api/function/node_delete_multiple/7
   node_delete_multiple($nids);
 
   // Loop over each of the fields defined by this module and delete
   // all instances of the field, their data, and the field itself.
-  // http://api.drupal.org/api/function/field_delete_field/7
-
   foreach (_agres_timeframe_fields() as $field) {
     field_delete_field($field['field_config']['field_name']);
   }
   // Loop over any remaining field instances attached to the node_example
   // content type (such as the body field) and delete them individually.
-  // http://api.drupal.org/api/function/field_delete_field/7
   $instances = field_info_instances('node', 'agres_timeframe');
   foreach ($instances as $instance_name => $instance) {
     field_delete_instance($instance);
   }
 
   // Delete our content type
-  // http://api.drupal.org/api/function/node_type_delete/7
   node_type_delete('agres_timeframe');
 
   // Purge all field infromation
-  // http://api.drupal.org/api/function/field_purge_batch/7
   field_purge_batch(1000);
-}
+}
\ No newline at end of file
diff --git a/agres_timeframe/agres_timeframe.module b/agres_timeframe/agres_timeframe.module
index a3f5920..2b05298 100644
--- a/agres_timeframe/agres_timeframe.module
+++ b/agres_timeframe/agres_timeframe.module
@@ -1,45 +1,25 @@
 <?php
 
-// $Id: agres_timeframe.module,v 1.1.2.1 2010/12/23 02:25:46 agill Exp $
-
-
 /**
  * @file
- * Implements the agres_timeframe content type. This module was created by Amazeelabs and
- * given to me as a contribution. Thanks amazee labs!
- * I changed the module a bit to make it fit in to the module collection
- * of agreservations and make maintaining for me easier.
- */
-/**
- * Implementation of hook_form
+ * Implements the agres_timeframe content type.
+ * This module was created by Amazeelabs and given to me as a contribution.
+ * Thanks amazee labs!
  *
+ * I changed the module a bit to make it fit in to the module collection of
+ * agreservations and make maintaining for me easier.
  */
-//function agres_timeframe_form($node){
-//	$type = node_get_types('type', $node);
-//	$form['title'] = array(
-//		'#type' => 'textfield',
-//		'#title' => check_plain($type->title_label),
-//		'#required' => TRUE,
-//		'#default_value' => $node->title,
-//		'#weight' => -5,
-//		'#maxlength' => 255,
-//	);
-//	//If a referenceid is set into the URL, store this in the form, so that the overlap checking can be made.
-//	if (isset($_GET['referenceid'])){
-//		$form['agres_timeframe_referenceid'] = array(
-//			'#type' => 'value',
-//			'#value' => (int)$_GET['referenceid'],
-//		);
-//	}
-//	return $form;
-//}
 
+/**
+ * @todo Documentation
+ */
 function agres_timeframe_views_api() {
   return array(
     'api' => 3,
     'path' => drupal_get_path('module', 'agres_timeframe'),
   );
 }
+
 /**
  * Entry point for some api functions of the agres_timeframe module.
  *
@@ -48,7 +28,7 @@ function agres_timeframe_views_api() {
  *
  * @param array $data
  * 	An array with arguments data. This depends on the $op parameter.
- *  TO DO: document each of the available $op.
+ *  @todo document each of the available $op.
  */
 function agres_timeframe_api($op, $data) {
   static $loaded_api;
@@ -57,14 +37,14 @@ function agres_timeframe_api($op, $data) {
     module_load_include('inc', 'agres_timeframe', 'agres_timeframe.api');
   }
   if (function_exists('agres_timeframe_api_' . $op)) {
-    $message =  call_user_func_array('agres_timeframe_api_' . $op, array($data));
+    $message = call_user_func_array('agres_timeframe_api_' . $op, array($data));
     return $message;
   }
   return FALSE;
 }
+
 /**
- * @todo Please document this function.
- * @see http://drupal.org/node/1354
+ * @todo Documentation
  */
 function agres_timeframe_node_info() {
   return array(
@@ -82,7 +62,6 @@ function agres_timeframe_node_info() {
 
 /**
  * Implements hook_menu().
- *
  */
 function agres_timeframe_menu() {
   $items['admin/config/agres_timeframe'] = array(
@@ -97,7 +76,6 @@ function agres_timeframe_menu() {
 
 /**
  * Implements hook_permission().
- *
  */
 function agres_timeframe_permission() {
   return array(
@@ -118,7 +96,6 @@ function agres_timeframe_permission() {
 
 /**
  * Implements hook_node_access().
- *
  */
 function agres_timeframe_node_access($node, $op, $account) {
   switch ($op) {
@@ -132,4 +109,4 @@ function agres_timeframe_node_access($node, $op, $account) {
     case 'delete':
       return user_access('administer agres_timeframes');
   }
-}
+}
\ No newline at end of file
diff --git a/agres_timeframe/agres_timeframe.views.inc b/agres_timeframe/agres_timeframe.views.inc
index b3b1e81..b66dab5 100644
--- a/agres_timeframe/agres_timeframe.views.inc
+++ b/agres_timeframe/agres_timeframe.views.inc
@@ -1,111 +1,108 @@
 <?php
-// $Id: agres_timeframe.views.inc,v 1.1.2.2 2010/12/24 01:38:01 agill Exp $
-
-
-
-/**
- * @file
- * agreservations.views.inc providing default views /calendarviews..
- *
- */
-function agres_timeframe_views_default_views() {
-  $views = array();
-  $view = new view;
-  $view->name = 'agres_timeframe';
-  $view->description = '';
-  $view->tag = 'default';
-  $view->base_table = 'node';
-  $view->human_name = 'agres_timeframe';
-  $view->core = 7;
-  $view->api_version = '3.0';
-  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-
-  /* Display: Master */
-  $handler = $view->new_display('default', 'Master', 'default');
-  $handler->display->display_options['title'] = 'agres_timeframe';
-  $handler->display->display_options['access']['type'] = 'perm';
-  $handler->display->display_options['access']['perm'] = 'view agreservations Resources';
-  $handler->display->display_options['cache']['type'] = 'none';
-  $handler->display->display_options['query']['type'] = 'views_query';
-  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
-  $handler->display->display_options['exposed_form']['type'] = 'basic';
-  $handler->display->display_options['pager']['type'] = 'full';
-  $handler->display->display_options['pager']['options']['items_per_page'] = '10';
-  $handler->display->display_options['style_plugin'] = 'table';
-  $handler->display->display_options['style_options']['columns'] = array(
-    'title' => 'title',
-  );
-  $handler->display->display_options['style_options']['default'] = '-1';
-  $handler->display->display_options['style_options']['info'] = array(
-    'title' => array(
-      'sortable' => 0,
-      'default_sort_order' => 'asc',
-      'align' => '',
-      'separator' => '',
-      'empty_column' => 0,
-    ),
-  );
-  $handler->display->display_options['style_options']['override'] = 1;
-  $handler->display->display_options['style_options']['sticky'] = 0;
-  $handler->display->display_options['style_options']['empty_table'] = 0;
-  /* Field: Content: Title */
-  $handler->display->display_options['fields']['title']['id'] = 'title';
-  $handler->display->display_options['fields']['title']['table'] = 'node';
-  $handler->display->display_options['fields']['title']['field'] = 'title';
-  $handler->display->display_options['fields']['title']['label'] = '';
-  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
-  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
-  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
-  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
-  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
-  /* Sort criterion: Content: Post date */
-  $handler->display->display_options['sorts']['created']['id'] = 'created';
-  $handler->display->display_options['sorts']['created']['table'] = 'node';
-  $handler->display->display_options['sorts']['created']['field'] = 'created';
-  $handler->display->display_options['sorts']['created']['order'] = 'DESC';
-  /* Filter criterion: Content: Published */
-  $handler->display->display_options['filters']['status']['id'] = 'status';
-  $handler->display->display_options['filters']['status']['table'] = 'node';
-  $handler->display->display_options['filters']['status']['field'] = 'status';
-  $handler->display->display_options['filters']['status']['value'] = 1;
-  $handler->display->display_options['filters']['status']['group'] = 0;
-  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
-  /* Filter criterion: Content: Type */
-  $handler->display->display_options['filters']['type']['id'] = 'type';
-  $handler->display->display_options['filters']['type']['table'] = 'node';
-  $handler->display->display_options['filters']['type']['field'] = 'type';
-  $handler->display->display_options['filters']['type']['value'] = array(
-    'agres_timeframe' => 'agres_timeframe',
-  );
-
-  /* Display: Page */
-  $handler = $view->new_display('page', 'Page', 'page');
-  $handler->display->display_options['path'] = 'agres_resources/timeframes';
-  $handler->display->display_options['menu']['type'] = 'tab';
-  $handler->display->display_options['menu']['title'] = 'Timeframes';
-  $handler->display->display_options['menu']['weight'] = '0';
-  $handler->display->display_options['menu']['name'] = 'main-menu';
-  $translatables['agres_timeframe'] = array(
-    t('Master'),
-    t('agres_timeframe'),
-    t('more'),
-    t('Apply'),
-    t('Reset'),
-    t('Sort by'),
-    t('Asc'),
-    t('Desc'),
-    t('Items per page'),
-    t('- All -'),
-    t('Offset'),
-    t('Page'),
-  );
-
-  $views['agres_timeframe'] = $view;
-  return $views;
-}
+
+/**
+ * @file
+ * agreservations.views.inc providing default views /calendarviews..
+ *
+ */
+function agres_timeframe_views_default_views() {
+  $views = array();
+  $view = new view;
+  $view->name = 'agres_timeframe';
+  $view->description = '';
+  $view->tag = 'default';
+  $view->base_table = 'node';
+  $view->human_name = 'agres_timeframe';
+  $view->core = 7;
+  $view->api_version = '3.0';
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+  /* Display: Master */
+  $handler = $view->new_display('default', 'Master', 'default');
+  $handler->display->display_options['title'] = 'agres_timeframe';
+  $handler->display->display_options['access']['type'] = 'perm';
+  $handler->display->display_options['access']['perm'] = 'view agreservations Resources';
+  $handler->display->display_options['cache']['type'] = 'none';
+  $handler->display->display_options['query']['type'] = 'views_query';
+  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
+  $handler->display->display_options['exposed_form']['type'] = 'basic';
+  $handler->display->display_options['pager']['type'] = 'full';
+  $handler->display->display_options['pager']['options']['items_per_page'] = '10';
+  $handler->display->display_options['style_plugin'] = 'table';
+  $handler->display->display_options['style_options']['columns'] = array(
+    'title' => 'title',
+  );
+  $handler->display->display_options['style_options']['default'] = '-1';
+  $handler->display->display_options['style_options']['info'] = array(
+    'title' => array(
+      'sortable' => 0,
+      'default_sort_order' => 'asc',
+      'align' => '',
+      'separator' => '',
+      'empty_column' => 0,
+    ),
+  );
+  $handler->display->display_options['style_options']['override'] = 1;
+  $handler->display->display_options['style_options']['sticky'] = 0;
+  $handler->display->display_options['style_options']['empty_table'] = 0;
+  /* Field: Content: Title */
+  $handler->display->display_options['fields']['title']['id'] = 'title';
+  $handler->display->display_options['fields']['title']['table'] = 'node';
+  $handler->display->display_options['fields']['title']['field'] = 'title';
+  $handler->display->display_options['fields']['title']['label'] = '';
+  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
+  /* Sort criterion: Content: Post date */
+  $handler->display->display_options['sorts']['created']['id'] = 'created';
+  $handler->display->display_options['sorts']['created']['table'] = 'node';
+  $handler->display->display_options['sorts']['created']['field'] = 'created';
+  $handler->display->display_options['sorts']['created']['order'] = 'DESC';
+  /* Filter criterion: Content: Published */
+  $handler->display->display_options['filters']['status']['id'] = 'status';
+  $handler->display->display_options['filters']['status']['table'] = 'node';
+  $handler->display->display_options['filters']['status']['field'] = 'status';
+  $handler->display->display_options['filters']['status']['value'] = 1;
+  $handler->display->display_options['filters']['status']['group'] = 0;
+  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
+  /* Filter criterion: Content: Type */
+  $handler->display->display_options['filters']['type']['id'] = 'type';
+  $handler->display->display_options['filters']['type']['table'] = 'node';
+  $handler->display->display_options['filters']['type']['field'] = 'type';
+  $handler->display->display_options['filters']['type']['value'] = array(
+    'agres_timeframe' => 'agres_timeframe',
+  );
+
+  /* Display: Page */
+  $handler = $view->new_display('page', 'Page', 'page');
+  $handler->display->display_options['path'] = 'agres_resources/timeframes';
+  $handler->display->display_options['menu']['type'] = 'tab';
+  $handler->display->display_options['menu']['title'] = 'Timeframes';
+  $handler->display->display_options['menu']['weight'] = '0';
+  $handler->display->display_options['menu']['name'] = 'main-menu';
+  $translatables['agres_timeframe'] = array(
+    t('Master'),
+    t('agres_timeframe'),
+    t('more'),
+    t('Apply'),
+    t('Reset'),
+    t('Sort by'),
+    t('Asc'),
+    t('Desc'),
+    t('Items per page'),
+    t('- All -'),
+    t('Offset'),
+    t('Page'),
+  );
+
+  $views['agres_timeframe'] = $view;
+  return $views;
+}
\ No newline at end of file
diff --git a/agres_views/agres_views.css b/agres_views/agres_views.css
index f1a548b..4855055 100644
--- a/agres_views/agres_views.css
+++ b/agres_views/agres_views.css
@@ -1,26 +1,22 @@
 /*  calendar calendar table styles  */
 
 .agreservations-month-view {
-    float: left;
-/*    width:600px;
-    overflow:scroll;*/
-}/*
-
-.agreservations-calendar {
-     width:600px;
-}*/
+  float: left;
+}
+
 .unitname{
-    width:50px;
+  width:50px;
 }
+
 .agreservations-table{
-    clear: both;
-   empty-cells: show;
-   table-layout: fixed; 
-   left: 55px;
-   
-    border:solid;
-   border-width: 1px;
-   
+  clear: both;
+  empty-cells: show;
+  table-layout: fixed;
+  left: 55px;
+
+  border:solid;
+  border-width: 1px;
+
 }
 .agreservations-calendar tr.odd, .agreservations-calendar tr.even {
   background-color:#fff;
@@ -45,7 +41,7 @@ div.agres_item a{
   width:100%;
 }
 
-  /* IE needs a little help to get the side by side tables to the right size */
+/* IE needs a little help to get the side by side tables to the right size */
 .agreservations-calendar .year-view td {
   width:32%;
   padding:1px;
@@ -63,9 +59,9 @@ div.agres_item a{
   background-color: white;
 }
 .agreservations-calendar th {
-    width: 1px;
-    border:solid;
-   border-width: 1px;
+  width: 1px;
+  border:solid;
+  border-width: 1px;
   color: #fff;
   background-color: #AAA;
   text-align: center;
@@ -73,7 +69,7 @@ div.agres_item a{
   margin: 3em;
   font-size:smaller;
 
-  
+
 }
 
 .agreservations-calendar th.unittypes {
@@ -133,16 +129,16 @@ div.agres_item a{
 /* simplify the mini calendar by removing borders */
 .agreservations-calendar .mini {
   border:none;
- }
+}
 
 /* format for the week number in the first cell */
 .agreservations-calendar td.week {
   width:1%;
   min-width:1%;
-  }
+}
 
-  .agreservations-calendar .unittitle td {
-        font-weight:lighter;
+.agreservations-calendar .unittitle td {
+  font-weight:lighter;
   padding:0em;
   background-color: #f2f;
 }
@@ -195,14 +191,14 @@ div.agres_item a{
   text-align: center;
   padding:1px;
   margin:0;
- }
+}
 .agreservations-calendar th.agreservations-calendar-agenda-hour .agreservations-calendar-hour {
   font-size: 1.1em;
   padding: 1px;
-      margin:0;
+  margin:0;
 }
 .agreservations-month-view agreservations-monthcell{
-    width:2.1em;
+  width:2.1em;
 }
 /*  floating day number div  */
 .agreservations-calendar div.day  {
@@ -211,8 +207,6 @@ div.agres_item a{
   padding: 0 0 0 0;
   margin: 0;
   background-color: #fff;
-/*  border: 1px solid gray;*/
-/*  border-width: 0 0 1px 1px;*/
   clear:both;
   width:auto;
   font-size:xx-small;
@@ -238,7 +232,7 @@ table.agreservations-table tbody tr td div.month  {
   width: 96%;
   float:right; /* needed to keep IE from hiding the floating day number */
   clear:both;
-  
+
 }
 /* No floating of day view content because there is no floating day number */
 .agreservations-calendar .day-view div.calendar {
@@ -252,12 +246,6 @@ table.agreservations-table tbody tr td div.month  {
   text-align:center;
 }
 
-/*.agreservations-calendar div.title a {
-  color: #000;
-}
-.agreservations-calendar div.title a:hover {
-  color: #c00;
-}*/
 .agreservations-calendar .content {
   clear:both;
   padding: 3px;
@@ -272,10 +260,10 @@ table th.mini,
 table.mini td.week {
   padding:0 1px 0 0;
   margin:0;
-  }
+}
 table td.mini a {
   font-weight:normal;
-  }
+}
 .agreservations-calendar .mini-day-off {
   padding:0px;
 }
@@ -284,13 +272,13 @@ table td.mini a {
 }
 table .mini-day-on a {
   text-decoration:underline;
-  }
+}
 .agreservations-calendar .mini .title {
   font-size:.8em;
-  }
+}
 .mini .agreservations-calendar .week {
   font-size:.7em;
-  }
+}
 .mini-row {
   width:100%;
   border:none;
@@ -298,8 +286,7 @@ table .mini-day-on a {
 .mini{
   width:32%;
   vertical-align:top;
-  }
-
+}
 
 /* formatting for the legend stripe and block */
 .agreservations-calendar .stripe {
@@ -335,24 +322,19 @@ table.agreservations-legend tr.even .stripe {
 /* formatting for the full day view */
 .agreservations-calendar td.agreservations-agenda-hour {
   font-family:serif;
- /* text-align:right;*/
   border:activeborder;
   border-top:1px #333 dotted;
-  
- /* padding-top:.25em;*/
   width:1%;
   height:100px;
-
   font-size: 1em;
 }
 .agreservations-calendar td.agreservations-agenda-no-hours {
-   font-size: 1em;
+  font-size: 1em;
   min-width:1%;
   max-height: 1%;
 }
 .agreservations-i td.agreservations-agenda-hour .agreservations-hour {
   font-size: 1em;
-  /*font-weight:bold;*/
   max-height: 1%;
 }
 .agreservations-calendar td.agreservations-agenda-hour .agreservations-ampm {
@@ -366,14 +348,12 @@ table.agreservations-legend tr.even .stripe {
 }
 .agreservations-calendar td.agreservations-agenda-items div.calendar {
   width:auto;
-  /*padding:.25em;*/
   margin:0;
 }
 .agreservations-calendar div.calendar div.inner .agreservations-agenda-empty {
   width:100%;
   text-align:center;
   vertical-align:middle;
- /* padding:1em 0;*/
   background-color:#fff;
 }
 
@@ -442,190 +422,149 @@ table.agreservations-legend tr.even .stripe {
 .agreservations-calendar div.calendar {
   border:none;
   font-size:x-small;
-/*  height:auto;*/
-   
-
 }
+
 .agreservations-calendar td .agreservations-inner div.calendar div,
 .agreservations-calendar td .agreservations-inner div.calendar div a {
-/*  border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:9px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;   
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .agresitemcontinues {
-/*   border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:4px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;      
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .agresitemcutoff {
-/*   border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:4px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;      
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .monthview {
-      width: 100%;
+  width: 100%;
   height: 100%;
-/*      border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
 }
 .agreservations-inner-black{
   background-color:#111;
   text-align: center;
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:7px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;  
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .agreservations-inner-red{
   background-color:#911;
   text-align: center;
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:7px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;  
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .agreservations-inner{
   background-color:#44f;
   text-align: center;
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:7px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;  
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .itemwithorder a{
-  color:#fff; 
+  color:#fff;
 }
 
-.itemwithoutorder a{   
-  color:#fff; 
+.itemwithoutorder a{
+  color:#fff;
 }
 .itemwithorder {
-    background-color:#44f;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px; 
-  color:#fff; 
+  background-color:#44f;
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
+  color:#fff;
 }
 
 .itemwithoutorder {
-    background-color:#E87400;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;     
-  color:#fff; 
+  background-color:#E87400;
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
+  color:#fff;
 }
 .agreservations-inner-green{
   background-color:#191;
   text-align: center;
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:7px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;  
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .agreservations-inner a{
-    text-decoration: none;
-/*  background-color:#44f;*/
-  color:#fff;  
+  text-decoration: none;
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:7px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;  
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 
 .agreservations-calendar-cell{
-/*    border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
-  color:#fff;  
+  color:#fff;
   width: 100%;
   height: 10px;
   font-size:9px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;    
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
   text-align: center;
 }
 
-
-
 .calendar weekview{
-/*    border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:9px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;     
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 
 .agreservations-calendar-agenda-items view-field {
-/*    border-color: red;
-  border-width:1px;
-  border-style:solid;*/
-/*  background-color:#44f;*/
-  color:#fff;  
+  color:#fff;
   margin:auto;
   padding:0px 2px;
   font-size:9px;
-    -moz-border-radius : 5px 5px  5px  5px;
-  border-radius : 5px 5px  5px  5px;     
+  -moz-border-radius : 5px 5px  5px  5px;
+  border-radius : 5px 5px  5px  5px;
 }
 .agreservations-calendar td .inner div.calendar div.agreservations-more,
 .agreservations-calendar td .inner div.calendar div.agreservations-more a {
   color:#444;
   background:#fff;
   text-align:right;
-  
+
 
 }
 .agreservations-calendar td .inner .view-field,
-/*.agreservations-calendar td .inner .view-field a {
-  color:#444;
-  font-weight:normal;
-}
-td.views-field a{
-  color: 
-}*/
-
 .agreservations-calendar td span.date-display-single,
 .agreservations-calendar td span.date-display-start,
 .agreservations-calendar td span.date-display-end,
 .agreservations-calendar td span.date-display-separator {
- /* font-weight:bold;*/
 }
+
 .agreservations-calendar td .inner div.day a {
   color:#4b85ac;
 }
diff --git a/agres_views/agres_views.info b/agres_views/agres_views.info
index 6d752cc..3b8935d 100644
--- a/agres_views/agres_views.info
+++ b/agres_views/agres_views.info
@@ -1,12 +1,8 @@
-name = agres_views
-description = Views plugin to display views containing dates AND Resources as Booking Calendars.- Based on the original Drupal Calendar Module by KarenS
-dependencies[] = agreservations
-;dependencies[] = agres_categories
-dependencies[] = calendar
-package = agreservations - extra
+name = Agreservations Views
+description = Views plugin to display views containing dates and Resources as Booking Calendars. Based on the original Drupal Calendar Module by KarenS
+package = Agreservations - Extra
 core = 7.x
 
-
 files[] = agres_views.module
 files[] = includes/agres_views.views.inc
 files[] = includes/agres_views_plugin_style.inc
@@ -14,3 +10,6 @@ files[] = includes/agres_views_plugin_row_node.inc
 files[] = theme/theme.inc
 files[] = theme/agres_views-style.tpl.php
 files[] = theme/agres_views-row-node.tpl.php
+
+dependencies[] = agreservations
+dependencies[] = calendar
\ No newline at end of file
diff --git a/agres_views/agres_views.module b/agres_views/agres_views.module
index 8503149..9a37588 100644
--- a/agres_views/agres_views.module
+++ b/agres_views/agres_views.module
@@ -1,399 +1,15 @@
 <?php
+
 /**
  * @file
  * agres_views.module additional preprocessors and views for agres_views
- *
+ * Adds agres_views filtering and displays to Views.
  */
 
-
-/** Alter the themeregistry in order to override the preprocessors and
- * templates of the calendar-module to use the ones of agres_views for
- * displaying a matrix of resources and bookings.
- */
-//   function agres_views_theme_registry_alter(&$theme_registry) {
-//     $theme_hook_month = 'agres_views_month'; // my hook name
-//     $path = drupal_get_path('module', 'agres_views');
-//     $modulepath = drupal_get_path('module', 'agres_views');
-//     $theme_registry[$theme_hook_month]['type'] = 'module';
-//     $theme_registry[$theme_hook_month]['theme paths'][0] = $modulepath;
-//     $theme_registry[$theme_hook_month]['theme path'] = $modulepath;
-//     $theme_registry[$theme_hook_month]['path'] = "$path";
-//     $theme_registry[$theme_hook_month]['include files'][0] = "$path/theme/theme.inc";
-//     $theme_registry[$theme_hook_month]['includes'][0] = "$path/theme/theme.inc";
-//     $theme_registry[$theme_hook_month]['preprocess functions'] = array(
-//         'template_preprocess',
-//         'template_preprocess_agres_views_month');
-//     $theme_registry[$theme_hook_month]['template'] = 'agres_views-calendar-month-c';
-//
-//
-//   }
 /**
- * Display a view as a calendar.
- *
- * This preprocessor does all the work needed for all types of calendar
- * views and the template takes care of displaying links to related views.
+ * @todo Documentation 
  */
-/**
- * Display a view as a calendar.
- *
- * This preprocessor does all the work needed for all types of calendar
- * views and the template takes care of displaying links to related views.
- */
-
-//function agres_views_preprocess_calendar(&$vars) {
-//    module_load_include('inc', 'calendar', 'includes/calendar');  
-//
-//  $view     = $vars['view'];
-//
-//  // Make sure we only run through this function one time.
-//  if (!empty($view->date_info->calendar_processed)) {
-//    return;
-//  }
-//
-//  $result   = (array) $view->result;
-//  $view->style_plugin->render_fields($result);
-//  $rendered_items = !empty($view->style_plugin->rendered_fields) ? $view->style_plugin->rendered_fields : array();
-//  $items = array();
-//
-//  $calendar_fields = date_views_fields($view->base_table);
-//  $calendar_fields = array_keys($calendar_fields['alias']);
-//
-//  // Try to figure out the 'id' for this collection of items.
-//  // The id field is often not a field but instead an 'additional field',
-//  // so this is cludgy.
-//  foreach ($result as $num => $row) {
-//    $keys = array_keys((array) $row);
-//    foreach ($keys as $key) {
-//      if (strlen($key) == 3 && substr($key, -2) == 'id' && !empty($row->$key)) {
-//        $id = $key;
-//      }
-//    }
-//  }
-//
-//  foreach ($result as $num => $row) {
-//    $copy = clone($row);
-//    $items[$num]->id = !empty($row->$id) ? $row->$id : NULL;
-//    $items[$num]->rendered = $rendered_items[$num];
-//    $items[$num]->raw = $copy;
-//
-//    $items[$num]->calendar_fields = new stdClass();
-//    foreach ($row as $key => $value) {
-//      if (in_array($key, $calendar_fields)) {
-//        $items[$num]->calendar_fields->$key = $value;
-//      }
-//    }
-//  }
-//  
-//  $vars['display_type'] = $view->date_info->granularity;
-//  $vars['min_date_formatted'] = date_format($view->date_info->min_date, DATE_FORMAT_DATETIME);
-//  $vars['max_date_formatted'] = date_format($view->date_info->max_date, DATE_FORMAT_DATETIME);
-//
-//  // Massage the resulting items into formatted calendar items.
-//  $items = calendar_build_nodes($view, $items);
-//
-//  // Merge in items from other sources.
-//  foreach (module_implements('calendar_add_items') as $module) {
-//    $function = $module . '_calendar_add_items';
-//    if (function_exists($function)) {
-//      if ($feeds = $function($view)) {
-//        foreach ($feeds as $feed) {
-//          $items = $feed;
-//        }
-//      }
-//    }
-//  }
-//  $view->date_info->mini = isset($view->date_info->mini) ? $view->date_info->mini : $view->date_info->granularity == 'year';
-//  // Create the calendar day names and rows.
-//
-//  $orgcaltype = $view->date_info->calendar_type;
-//  $view->date_info->calendar_type = 'week';
-//  $rows = calendar_build_calendar($view, $items);
-//  
-//  $view->date_info->calendar_type = $orgcaltype;
-//  $vars['items'] = $items;
-//  $vars['rows'] = $rows;
-//// drupal_set_message('<pre>*iiiiii**'. print_r($vars['rows'], TRUE) .'</pre>'); 
-//  $view->date_info->calendar_processed = TRUE;
-//  $vars['view'] = $view;  
-//  $vars['mini'] = !empty($view->date_info->mini);
-//  $vars['block'] = !empty($view->date_info->block);
-//
-//}
-
-//function agresneu_views_preprocess_calendar_month(&$vars) {
-//  $view = $vars['view'];
-//  $rows = $vars['rows'];
-//  if (empty($rows)) {
-//    $rows = array();
-//    $day_names = array();
-//  } 
-//  elseif (sizeof($rows) > 1) {
-//    $day_names = array_shift($rows);
-//  }
-//  else {
-//    $day_names = $rows;
-//    $rows = array();
-//  }
-//
-//  $month_rows = $rows;
-//  foreach ($rows as $weekno => $row) {
-//    foreach ($row as $day => $data) {
-//      $cell = $data['data'];
-//
-//      // If this cell is already rendered, like the weekno column,
-//      // move to the next item.
-//      if (!is_array($cell)) {
-//        $month_rows[$weekno][$day]['data'] = $cell;
-//        continue;
-//      }
-//      $data = $cell['datebox'];
-//      if ($cell['empty']) {
-//        $data .= $cell['empty'];
-//      }
-//      else {
-//        $data .= implode($cell['all_day']);
-//        foreach ($cell['items'] as $hour => $item) {
-//          $data .= implode($item);
-//        }
-//        $data .= $cell['link'];
-//      }
-//      if ($view->date_info->mini) {
-//        $month_rows[$weekno][$day]['data'] = $data;
-//      }
-//      else {
-//        $month_rows[$weekno][$day]['data'] = '<div class="inner">' . $data . '</div>';
-//      }
-//    }
-//  }
-//
-//  $vars['rows'] = $month_rows;
-//  $vars['day_names'] = $day_names;
-//
-//  $vars['display_type'] = $view->date_info->granularity;
-//  $vars['min_date_formatted'] = date_format($view->date_info->min_date, DATE_FORMAT_DATETIME);
-//  $vars['max_date_formatted'] = date_format($view->date_info->max_date, DATE_FORMAT_DATETIME);
-//}
-//function agres_views_preprocess_calendar_month(&$vars) {
-//  // Add in all the $vars added by the main calendar preprocessor.  
-//   if ($vars['view']->name == 'bookingcalendar4') {   
-//  $view = $vars['view'];
-//  $rows = $vars['rows'];
-//  if (empty($rows)) {
-//    $rows = array();
-//    $day_names = array();
-//  } 
-//  elseif (sizeof($rows) > 1) {
-//    $day_names = array_shift($rows);
-//  }
-//  else {
-//    $day_names = $rows;
-//    $rows = array();
-//  }
-//
-//  $month_rows = $rows;
-////     foreach ($rows[0] as $weekno => $row) {
-//    
-////   }
-///****************setup categories and unittypes:******************************************
-// * 
-// */    
-//    $vars['unittypes'] = '';
-//      $countarg = count($view->args);
-//      
-//    if (module_exists('agres_categories')) {
-//      $countarg = count($view->args);
-//      if ($countarg > 4) {
-//        $view->args = array_slice($view->args, 0, 3);
-//      }
-//      $vars['currentcategory'] = '';
-//      if (isset($view->args[1])&&$view->args[1]) {
-//        drupal_set_message('<pre>bis hier'.print_r($vars['unittypes'],true).'</pre>');
-//        $unittypes = _agres_categories_get_unittypenodes_of_category($view->args[1]);
-//        $vars['currentcategory'] = $view->args[1];
-//        $categories = _agres_categories_get_categories(TRUE);
-//        if (isset($view->args[2])&&$view->args[2]) {
-//
-//          //        $units = _agreservations_get_unitnodes($view->args[2]);
-//
-//
-//          $units = _agres_categories_get_unitnodes_of_category($view->args[2], $view->args[1]);
-//          $vars['currentunittype'] = $view->args[2];
-//        }
-//        else {
-//          $unittypes = _agres_categories_get_unittypenodes_of_category($view->args[1]);
-//          $units = _agres_categories_get_unitnodes_of_category(NULL, $view->args[1]);
-//        }
-//      }
-//      else {
-//        
-//        $unittypes = _agres_categories_get_unittypenodes_of_category();
-////        drupal_set_message('<pre>bis else'.print_r($unittypes,true).'</pre>');
-//        $categories = _agres_categories_get_categories(TRUE);
-//        $units = _agreservations_get_unitnodes();
-//      }
-//    }
-//    else {
-//      if ($countarg > 3) {
-//        $view->args = array_slice($view->args, 0, 2);
-//      }
-//      if (isset($view->args[1])) {
-////        drupal_set_message('<pre>*view->args[1]view->args[1]**'. print_r($vars['view']->name, TRUE) .'</pre>');
-//        $units = _agreservations_get_unitnodes($view->args[1]);
-//        $vars['currentunittype'] = $view->args[1];
-//      }
-//      else {        
-//        $units = _agreservations_get_unitnodes();
-////        drupal_set_message('<pre>*elseelseelse]**'. print_r($units, TRUE) .'</pre>');
-//      }
-//      $unittypes = _agreservations_get_unittypenodes();
-//      
-//    }
-//    //remove the args from agrescurrentpath:
-//
-//
-//    $toremovefrompath = implode("/", $view->args);
-//    $agrescurrentpath = get_current_path();
-//    $agrescurrentpath = str_replace($toremovefrompath, "", $agrescurrentpath);
-//    //cut off trailing slash:
-//
-//
-//    if (substr($agrescurrentpath, -1, 1) == "/") {
-//      $agrescurrentpath = substr($agrescurrentpath, 0, strlen($agrescurrentpath) - 1);
-//    }
-//    //    drupal_set_message('<pre>*orig**'. print_r($agrescurrentpath, TRUE) .'</pre>');
-//
-//
-//    $vars['agrescurrentpath'] = $agrescurrentpath;
-//  
-////   drupal_set_message('<pre>ifrekt. spaninfo '.print_r( $rows,true).'</pre>');                         
-//    //step1: all in 1 array:
-//    $agdaysresitems = array();
-//    $agmonth_rows = array();
-//     foreach ($rows as $weekno => $row) {
-//        foreach ($row as $day => $data) {
-////            drupal_set_message('<pre>ifrekt.55 spaninfo '.print_r( $data,true).'</pre>');
-//             $agdaysresitems[] = $data;
-//              
-//           }
-//     }     
-////     drupal_set_message('<pre>zzzzzzzzzzzz'.print_r( $agdaysresitems,true).'</pre>'); 
-//     $agmonth_rows['rinfo']=array();     
-//     //step2 organize in unit arrays:
-////     foreach ($units as $unit) {
-////       $agmonth_rows['rinfo'][$unit->title]=array();
-////       foreach ($agdaysresitems as $day => $agdayresitem) {
-////         $data = $agdayresitem['data']['datebox'];
-////         $date = $agdayresitem['data']['date'];
-////         $agmonth_rows[$unit->title][$day]['datebox'] = $data;  
-////         $agmonth_rows[$unit->title][$day]['date'] = $date;  
-////         foreach ($agdayresitem['data']['items'] as $time=>$hour) {
-////           
-////           //foreach reservation objet node in the hour DO:
-////           foreach ($hour as $resob) { 
-////              if (!isset($agmonth_rows[$unit->title][$day]['resitm'][$resob->id])) {
-////              $agmonth_rows[$unit->title][$day]['resitm'][$resob->id] = '0';
-////             }         
-//////             if (!isset($agmonth_rows['rinfo'][$unit->title][$resob->id])) {
-//////               $agmonth_rows[$unit->title]['rinfo'][$resob->id] = '0';
-////////               $agmonth_rows[$unit->title]['spaninfo'][$resob->id] = 1;
-//////             }
-////             $tmpunititems = _agreservations_get_unitn_for_reservation_node($resob->id); //get units per reservation
-////                if (in_array($unit->nid, $tmpunititems)) {
-//////drupal_set_message('<pre>ifrekt..day:'.$day.'itm:'.$resob->id.'unit:'.$unit->title.' spaninfo '.print_r( $agmonth_rows[$unit->title][$day]['data'][$resob->id],true).'</pre>');                                           
-////                   if ((!isset($agmonth_rows[$unit->title]['spaninfo'][$resob->id])||(empty($agmonth_rows[$unit->title]['spaninfo'][$resob->id])))) {
-////              $theme = 'calendar_month_node';
-////              $variables = array(
-////                'node' => $resob,
-////                'view' => $view,
-////              );              
-////                        $agmonth_rows[$unit->title][$day]['data'][$resob->id] = '';
-////                        $agmonth_rows[$unit->title]['spaninfo'][$resob->id] = 1;
-////                        $agmonth_rows[$unit->title][$day]['data'][$resob->id] =  theme($theme, $variables); //$resob->rendered['nid']; 
-//////drupal_set_message('<pre>ifrekt..day:'.$day.'itm:'.$resob->id.'unit:'.$unit->title.' spaninfo '.print_r( $agmonth_rows[$unit->title][$day]['data'][$resob->id],true).'</pre>');                         
-////                   }
-////                   else {                     
-//////                     drupal_set_message('<pre>day:'.$day.'itm:'.$resob->id.'sonst '.print_r($agmonth_rows[$unit->title]['spaninfo'][$resob->id],true).'</pre>'); 
-////                       $endpos = strpos($resob->raw->field_data_field_agres_rdate_field_agres_rdate_value2, $agmonth_rows[$unit->title][$day]['date'], 0);
-////                        if( empty($agmonth_rows[$unit->title][$day]['data'][$resob->id])){
-////                          if ($endpos===false){
-////                          $agmonth_rows[$unit->title][$day]['data'][$resob->id] = '***busy***';
-////                          $agmonth_rows[$unit->title]['spaninfo'][$resob->id] += 1;
-////                          }else{
-//////                          $agmonth_rows[$unit->title][$day]['data'][$resob->id] = '***busy***';
-//////                          $agmonth_rows[$unit->title]['spaninfo'][$resob->id] = +1;                            
-////                          }
-////                        }else{
-////                          
-////                        }                
-////                       
-////                   }
-////                  
-////                
-//////                   drupal_set_message('<pre>day:'.$day.'itm:'.$resob->id.'unit:'.$unit->title.' spaninfo '.print_r($agmonth_rows[$unit->title]['spaninfo'][$resob->id],true).'</pre>'); 
-//////                   drupal_set_message('<pre>day:'.$day.'itm:'.$resob->id.'unit:'.$unit->title.' spaninfo '.print_r( $agmonth_rows[$unit->title][$day]['data'][$resob->id],true).'</pre>');
-////                }
-////           }           
-////         }
-////         
-////       }
-////     }
-//   
-//   
-//    $daymonth=0;
-////   foreach ($units as $unit) {
-////         foreach ($rows as $weekno => $row) {
-////           foreach ($row as $day => $data) {
-////             $daymonth++;
-//////    array_shift($data);
-//////               drupal_set_message('<pre>$data'.print_r($data,true).'</pre>');
-////             if (isset($data['data']['date']) && !empty($data['data']['date'])) {
-////
-////             }
-////             $cell = $data['data'];
-////
-////             if (!is_array($cell)) {
-////               $month_rows[$weekno][$day][$unit->title]['data'] = $cell;
-////               continue;
-////             }
-////
-////           }
-////         }
-////       }
-//  $vars['unittypes']=$unittypes;     
-//  $vars['currentselectedmonth'] = $view->args[0]; // year.'-W'.$week;     
-//  $vars['agmonth_rows'] = $agmonth_rows;    
-//  $vars['units'] = $units;
-//  $vars['rows'] = $month_rows;
-//  $vars['day_names'] = $day_names;
-//  $vars['template_file'] = 'agres_views-calendar-month-c';
-//  $vars['display_type'] = $view->date_info->granularity;
-//  $vars['min_date_formatted'] = date_format($view->date_info->min_date, DATE_FORMAT_DATETIME);
-//  $vars['max_date_formatted'] = date_format($view->date_info->max_date, DATE_FORMAT_DATETIME);
-//  if (module_exists('agres_categories')) {         
-//         $vars['categories'] = $categories;
-//       }
-//    $vars['template_file'] = 'agres_views-calendar-month-c';
-//    $path = drupal_get_path('module', 'agres_views');
-//    $vars['directory'] = $path.'/theme';
-////    drupal_set_message('<pre>*or**'. print_r($vars['directory'], TRUE) .'</pre>');
-////    return;
-//   }
-//  else {
-////  drupal_set_message('<pre>*or**'. print_r($vars['directory'], TRUE) .'</pre>');
-//    $vars['template_file'] = 'agres_views-calendar-month-1';
-//    $path = drupal_get_path('module', 'agres_views');
-//    $vars['directory'] = $path;
-////    template_preprocess_calendar(&$vars);
-//    template_preprocess_calendar_month(&$vars);
-////    return;
-//  }  
-//  
-//}
-
 function agres_views_init() {
-//     if (substr($_GET['q'], 0, 24) == 'admin/build/modules/list') {
-//       return;
-//     }
   drupal_add_css(drupal_get_path('module', 'agres_views') . '/agres_views.css');
   require_once('./' . drupal_get_path('module', 'agres_views') . '/theme/theme.inc');
 }
@@ -407,52 +23,44 @@ function agres_views_theme() {
     'path' => "$path/theme",
   );
   return array(
-    //         'agres_views_time_row_heading' => $base + array(
- //     'arguments' => array('start_time', 'next_start_time', 'curday_date'),
- //         ),
     'agres_views_item' => $base + array(
-      'template' => 'agres-views-item',
-      'variables' => array('view' => NULL, 'rendered_fields' => NULL, 'item' => NULL),
+    'template' => 'agres-views-item',
+    'variables' => array('view' => NULL, 'rendered_fields' => NULL, 'item' => NULL),
     ),
     'agres_views_datebox' => $base + array(
-      'template' => 'agres-views-datebox',
-      'variables' => array(
-        'date' => NULL,
-        'view' => NULL,
-        'items' => NULL,
-        'selected' => NULL,
-      ),
+    'template' => 'agres-views-datebox',
+    'variables' => array(
+      'date' => NULL,
+      'view' => NULL,
+      'items' => NULL,
+      'selected' => NULL,
+    ),
     ),
     'agres_views_empty_day' => $base + array(
-      'variables' => array('curday' => NULL, 'view' => NULL),
+    'variables' => array('curday' => NULL, 'view' => NULL),
     ),
     'agres_views_stripe_legend' => $base + array(
-      'variables' => array('stripe_labels' => NULL),
+    'variables' => array('stripe_labels' => NULL),
     ),
     'agres_views_stripe_stripe' => $base + array(
-      'variables' => array('node' => NULL),
+    'variables' => array('node' => NULL),
     ),
     'agres_views_time_row_heading' => $base + array(
-      'variables' => array('start_time' => NULL, 'next_start_time' => NULL, 'curday_date' => NULL),
+    'variables' => array('start_time' => NULL, 'next_start_time' => NULL, 'curday_date' => NULL),
     ),
     'agres_views_month_col' => $base + array(
-      'template' => 'agres-views-month-col',
-      'variables' => array('item' => NULL),
+    'template' => 'agres-views-month-col',
+    'variables' => array('item' => NULL),
     ),
     'agres_views_month_row' => $base + array(
-      'template' => 'agres-views-month-row',
-      'variables' => array('inner' => NULL, 'class' => NULL, 'iehint' => NULL),
+    'template' => 'agres-views-month-row',
+    'variables' => array('inner' => NULL, 'class' => NULL, 'iehint' => NULL),
     ),
   );
 }
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 define('agres_views_SHOW_ALL', 0);
 define('agres_views_HIDE_ALL', -1);
-/**
- * @file
- * Adds agres_views filtering and displays to Views.
- */
 
 /**
  * Implements hook_views_api().
@@ -465,14 +73,14 @@ function agres_views_views_api() {
 }
 
 /**
- * agres_views display types.
+ * @todo Documentation
  */
 function agres_views_display_types() {
   return array('year' => t('Year'), 'month' => t('Month'), 'day' => t('Day'), 'week' => t('Week'));
 }
 
 /**
- * Implementation of hook_help().
+ * Implements hook_help().
  */
 function agres_views_help($section, $arg) {
   switch ($section) {
@@ -480,54 +88,12 @@ function agres_views_help($section, $arg) {
       return t("<p>View complete documentation at !link.</p>", array('!link' => 'http://drupal.org/node/120710'));
   }
 }
-/**
- * Implements hook_theme().
- */
-//function agres_views_theme() {
-//  $module_path = drupal_get_path('module', 'agres_views');
-//
-//  $base = array(
-//    'file' => 'theme.inc',
-//    'path' => "$module_path/theme",
-//  );
-//  return array(
-//    'agres_views_item' => $base + array(
-//      'template' => 'agres_views-item',
-//      'variables' => array('view' => NULL, 'rendered_fields' => NULL, 'item' => NULL),
-//      ),
-//    'agres_views_datebox' => $base + array(
-//      'template' => 'agres_views-datebox',
-//      'variables' => array(
-//        'date' => NULL, 'view' => NULL, 'items' => NULL, 'selected' => NULL),
-//      ),
-//    'agres_views_empty_day' => $base + array(
-//      'variables' => array('curday' => NULL, 'view' => NULL),
-//      ),
-//    'agres_views_stripe_legend' => $base + array(
-//      'variables' => array('stripe_labels' => NULL),
-//      ),
-//    'agres_views_stripe_stripe' => $base + array(
-//      'variables' => array('node' => NULL),
-//      ),
-//    'agres_views_time_row_heading' => $base + array(
-//      'variables' => array('start_time' => NULL, 'next_start_time' => NULL, 'curday_date' => NULL),
-//      ),
-//    'agres_views_month_col' => $base + array(
-//      'template' => 'agres_views-month-col',
-//      'variables' => array('item' => NULL),
-//      ),  
-//    'agres_views_month_row' => $base + array(
-//      'template' => 'agres_views-month-row',
-//      'variables' => array('inner' => NULL, 'class' => NULL, 'iehint' => NULL),
-//      ),
-//    );
-//}
 
 /**
  * Implements hook_node_view().
  *
- * Add link to agres_views to nodes, formerly hook_link().
- * Controlled by value of 'agres_views_date_link' in the view.
+ * Add link to agres_views to nodes, formerly hook_link(). Controlled by value 
+ * of 'agres_views_date_link' in the view.
  */
 function agres_views_node_view($node, $view_mode, $langcode) {
   $path = variable_get('agres_views_date_link_' . $node->type);
@@ -619,7 +185,7 @@ function agres_views_groupby_times($type = '') {
 }
 
 /**
- *  Implementation of hook_block_info()
+ *  Implements hook_block_info().
  */
 function agres_views_block_info() {
   $blocks['agres_views_legend'] = array(
@@ -630,7 +196,7 @@ function agres_views_block_info() {
 }
 
 /**
- *  Implementation of hook_block_view().
+ *  Implements hook_block_view().
  */
 function agres_views_block_view($delta = '') {
   switch ($delta) {
@@ -649,7 +215,7 @@ function agres_views_block_view($delta = '') {
 function agres_views_granularity_path(&$view, $granularity) {
   foreach ($view->display as $id => $display) {
     if ($display->display_options['style_plugin'] == 'agres_views_style' && !empty($display->display_options['path'])) {
-      // @TODO Why is this sometimes empty for a style that uses the default value?
+      // @todo Why is this sometimes empty for a style that uses the default value?
       $type = !empty($display->display_options['style_options']['agres_views_type']) ? $display->display_options['style_options']['agres_views_type'] : 'month';
       if ($type == $granularity) {
         return $display->display_options['path'];
@@ -675,7 +241,6 @@ function agres_views_remove($view_name) {
   views_invalidate_cache();
 }
 
-
 /**
  *
  * from Calendar Module...
@@ -695,9 +260,8 @@ function agres_views_menu_local_tasks_alter(&$data, $router_item, $root_path) {
       foreach ($agres_views_data['actions'] as $action) {
         $item = menu_get_item($action['path']);
         $item['title'] = $action['title'];
-        // The add new content page would redirect to the new event
-        // if we did not override that here. This way they will
-        // redirect back to the agres_views.
+        // The add new content page would redirect to the new event if we did not
+        // override that here. This way they will redirect back to the agres_views.
         $item['localized_options'] += array('query' => array());
         $item['localized_options']['query'] += drupal_get_destination();
         if ($item['access']) {
@@ -714,9 +278,9 @@ function agres_views_menu_local_tasks_alter(&$data, $router_item, $root_path) {
       foreach ($agres_views_data['tabs'] as $tab) {
         $item = menu_get_item($tab['path']);
         $item['title'] = $tab['title'];
-        // If we have moved off the default page for the agres_views, the
-        // links to the other views will have been adjusted to keep information
-        // about the right year/month/week/day to go to.
+        // If we have moved off the default page for the agres_views, the links 
+        // to the other views will have been adjusted to keep information about 
+        // the right year/month/week/day to go to.
         $item['href'] = $tab['path'];
         if ($item['access']) {
           $data['tabs'][0]['output'][$delta] = array(
diff --git a/agres_views/includes/agres_views.views.inc b/agres_views/includes/agres_views.views.inc
index 4693568..f8b47e6 100644
--- a/agres_views/includes/agres_views.views.inc
+++ b/agres_views/includes/agres_views.views.inc
@@ -5,8 +5,9 @@
  *
  * Creates agres_views displays of Views results.
  */
+
 /**
- * Implementation of hook_views_plugins
+ * Implements hook_views_plugins().
  */
 function agres_views_views_plugins() {
   $views_path = drupal_get_path('module', 'views');
@@ -61,8 +62,8 @@ function agres_views_views_plugins() {
         'uses options' => TRUE,
         'uses fields' => TRUE,
         'type' => 'normal',
-      ),        
+      ),
     ),
   );
   return $data;
-}
+}
\ No newline at end of file
diff --git a/agres_views/includes/agres_views.views_default.inc b/agres_views/includes/agres_views.views_default.inc
index 90bff16..01c7baf 100644
--- a/agres_views/includes/agres_views.views_default.inc
+++ b/agres_views/includes/agres_views.views_default.inc
@@ -109,7 +109,7 @@ function agres_views_views_construct($options = NULL) {
   }
 
   $type = '';
-  if (!empty($types) && is_array($types) && count($types) > 0 ) {
+  if (!empty($types) && is_array($types) && count($types) > 0) {
     $types = array_keys($types);
     $type = $types[0];
   }
@@ -118,7 +118,7 @@ function agres_views_views_construct($options = NULL) {
 
   $aliases = array();
   foreach ($date_fields as $field_name) {
-    if (substr($field_name, 0, 6) == 'field_') {
+    if (drupal_substr($field_name, 0, 6) == 'field_') {
       $table = 'field_data_' . $field_name;
       $alias = $table . '.' . $field_name . '_value';
       $cck_field = TRUE;
@@ -131,667 +131,666 @@ function agres_views_views_construct($options = NULL) {
     $aliases[] = $alias;
   }
 
- $view = new view;
-$view->name = 'agres_view';
-$view->description = 'A bookingcalendar';
-$view->tag = 'agres_view';
-$view->base_table = 'node';
-$view->human_name = 'Booking Calendar';
-$view->core = 7;
-$view->api_version = '3.0';
-$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+  $view = new view;
+  $view->name = 'agres_view';
+  $view->description = 'A bookingcalendar';
+  $view->tag = 'agres_view';
+  $view->base_table = 'node';
+  $view->human_name = 'Booking Calendar';
+  $view->core = 7;
+  $view->api_version = '3.0';
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
 
-/* Display: Master */
-$handler = $view->new_display('default', 'Master', 'default');
-$handler->display->display_options['title'] = 'Booking Calendar';
-$handler->display->display_options['link_display'] = 'page_1';
-$handler->display->display_options['access']['type'] = 'perm';
-$handler->display->display_options['access']['perm'] = 'view agres_views bookingcalendar';
-$handler->display->display_options['cache']['type'] = 'none';
-$handler->display->display_options['query']['type'] = 'views_query';
-$handler->display->display_options['query']['options']['query_comment'] = FALSE;
-$handler->display->display_options['exposed_form']['type'] = 'basic';
-$handler->display->display_options['pager']['type'] = 'date_views_pager';
-$handler->display->display_options['pager']['options']['date_id'] = 'month';
-$handler->display->display_options['style_plugin'] = 'agres_views_style';
-$handler->display->display_options['style_options']['name_size'] = '3';
-$handler->display->display_options['style_options']['with_weekno'] = '0';
-$handler->display->display_options['style_options']['multiday_theme'] = '1';
-$handler->display->display_options['style_options']['theme_style'] = '1';
-$handler->display->display_options['style_options']['max_items'] = '0';
-$handler->display->display_options['row_plugin'] = 'agres_views_node';
-/* Field: Content: Title */
-$handler->display->display_options['fields']['title']['id'] = 'title';
-$handler->display->display_options['fields']['title']['table'] = 'node';
-$handler->display->display_options['fields']['title']['field'] = 'title';
-$handler->display->display_options['fields']['title']['label'] = '';
-$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
-$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['title']['alter']['external'] = 0;
-$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
-$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
-$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['title']['alter']['html'] = 0;
-$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
-$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['title']['hide_empty'] = 0;
-$handler->display->display_options['fields']['title']['empty_zero'] = 0;
-$handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
-$handler->display->display_options['fields']['title']['link_to_node'] = 1;
-/* Field: Content: Booking Date */
-$handler->display->display_options['fields']['field_agres_rdate']['id'] = 'field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['table'] = 'field_data_field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['field'] = 'field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['exclude'] = TRUE;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['alter_text'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['external'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['word_boundary'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['ellipsis'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['html'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['element_label_colon'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['hide_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['empty_zero'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['hide_alter_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['settings'] = array(
-  'format_type' => 'long',
-  'fromto' => 'both',
-  'multiple_number' => '',
-  'multiple_from' => '',
-  'multiple_to' => '',
-  'show_repeat_rule' => 'show',
-);
-$handler->display->display_options['fields']['field_agres_rdate']['field_api_classes'] = 0;
-/* Field: Content: Nid */
-$handler->display->display_options['fields']['nid']['id'] = 'nid';
-$handler->display->display_options['fields']['nid']['table'] = 'node';
-$handler->display->display_options['fields']['nid']['field'] = 'nid';
-/* Sort criterion: Content: Updated date */
-$handler->display->display_options['sorts']['changed']['id'] = 'changed';
-$handler->display->display_options['sorts']['changed']['table'] = 'node';
-$handler->display->display_options['sorts']['changed']['field'] = 'changed';
-/* Filter criterion: Content: Published */
-$handler->display->display_options['filters']['status']['id'] = 'status';
-$handler->display->display_options['filters']['status']['table'] = 'node';
-$handler->display->display_options['filters']['status']['field'] = 'status';
-$handler->display->display_options['filters']['status']['value'] = 1;
-$handler->display->display_options['filters']['status']['group'] = 0;
-$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
+  /* Display: Master */
+  $handler = $view->new_display('default', 'Master', 'default');
+  $handler->display->display_options['title'] = 'Booking Calendar';
+  $handler->display->display_options['link_display'] = 'page_1';
+  $handler->display->display_options['access']['type'] = 'perm';
+  $handler->display->display_options['access']['perm'] = 'view agres_views bookingcalendar';
+  $handler->display->display_options['cache']['type'] = 'none';
+  $handler->display->display_options['query']['type'] = 'views_query';
+  $handler->display->display_options['query']['options']['query_comment'] = FALSE;
+  $handler->display->display_options['exposed_form']['type'] = 'basic';
+  $handler->display->display_options['pager']['type'] = 'date_views_pager';
+  $handler->display->display_options['pager']['options']['date_id'] = 'month';
+  $handler->display->display_options['style_plugin'] = 'agres_views_style';
+  $handler->display->display_options['style_options']['name_size'] = '3';
+  $handler->display->display_options['style_options']['with_weekno'] = '0';
+  $handler->display->display_options['style_options']['multiday_theme'] = '1';
+  $handler->display->display_options['style_options']['theme_style'] = '1';
+  $handler->display->display_options['style_options']['max_items'] = '0';
+  $handler->display->display_options['row_plugin'] = 'agres_views_node';
+  /* Field: Content: Title */
+  $handler->display->display_options['fields']['title']['id'] = 'title';
+  $handler->display->display_options['fields']['title']['table'] = 'node';
+  $handler->display->display_options['fields']['title']['field'] = 'title';
+  $handler->display->display_options['fields']['title']['label'] = '';
+  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['title']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
+  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
+  /* Field: Content: Booking Date */
+  $handler->display->display_options['fields']['field_agres_rdate']['id'] = 'field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['table'] = 'field_data_field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['field'] = 'field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['exclude'] = TRUE;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['element_label_colon'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['hide_alter_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['settings'] = array(
+    'format_type' => 'long',
+    'fromto' => 'both',
+    'multiple_number' => '',
+    'multiple_from' => '',
+    'multiple_to' => '',
+    'show_repeat_rule' => 'show',
+  );
+  $handler->display->display_options['fields']['field_agres_rdate']['field_api_classes'] = 0;
+  /* Field: Content: Nid */
+  $handler->display->display_options['fields']['nid']['id'] = 'nid';
+  $handler->display->display_options['fields']['nid']['table'] = 'node';
+  $handler->display->display_options['fields']['nid']['field'] = 'nid';
+  /* Sort criterion: Content: Updated date */
+  $handler->display->display_options['sorts']['changed']['id'] = 'changed';
+  $handler->display->display_options['sorts']['changed']['table'] = 'node';
+  $handler->display->display_options['sorts']['changed']['field'] = 'changed';
+  /* Filter criterion: Content: Published */
+  $handler->display->display_options['filters']['status']['id'] = 'status';
+  $handler->display->display_options['filters']['status']['table'] = 'node';
+  $handler->display->display_options['filters']['status']['field'] = 'status';
+  $handler->display->display_options['filters']['status']['value'] = 1;
+  $handler->display->display_options['filters']['status']['group'] = 0;
+  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
 
-/* Display: Month */
-$handler = $view->new_display('page', 'Month', 'page_1');
-$handler->display->display_options['defaults']['pager'] = FALSE;
-$handler->display->display_options['pager']['type'] = 'date_views_pager';
-$handler->display->display_options['pager']['options']['date_id'] = 'month';
-$handler->display->display_options['pager']['options']['link_format'] = 'clean';
-$handler->display->display_options['defaults']['style_plugin'] = FALSE;
-$handler->display->display_options['style_plugin'] = 'agres_views_style';
-$handler->display->display_options['style_options']['name_size'] = '3';
-$handler->display->display_options['style_options']['mini'] = '0';
-$handler->display->display_options['style_options']['with_weekno'] = '0';
-$handler->display->display_options['style_options']['multiday_theme'] = '1';
-$handler->display->display_options['style_options']['theme_style'] = '1';
-$handler->display->display_options['style_options']['max_items'] = '0';
-$handler->display->display_options['defaults']['style_options'] = FALSE;
-$handler->display->display_options['defaults']['row_plugin'] = FALSE;
-$handler->display->display_options['row_plugin'] = 'agres_views_node';
-$handler->display->display_options['row_options']['colors']['legend'] = 'type';
-$handler->display->display_options['defaults']['row_options'] = FALSE;
-$handler->display->display_options['defaults']['fields'] = FALSE;
-/* Field: Content: Title */
-$handler->display->display_options['fields']['title']['id'] = 'title';
-$handler->display->display_options['fields']['title']['table'] = 'node';
-$handler->display->display_options['fields']['title']['field'] = 'title';
-$handler->display->display_options['fields']['title']['label'] = '';
-$handler->display->display_options['fields']['title']['exclude'] = TRUE;
-$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
-$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['title']['alter']['external'] = 0;
-$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
-$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
-$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['title']['alter']['html'] = 0;
-$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
-$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['title']['hide_empty'] = 0;
-$handler->display->display_options['fields']['title']['empty_zero'] = 0;
-$handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
-$handler->display->display_options['fields']['title']['link_to_node'] = 1;
-/* Field: Content: Booking Date */
-$handler->display->display_options['fields']['field_agres_rdate']['id'] = 'field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['table'] = 'field_data_field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['field'] = 'field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['exclude'] = TRUE;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['alter_text'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['external'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['word_boundary'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['ellipsis'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['html'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['element_label_colon'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['hide_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['empty_zero'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['hide_alter_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['settings'] = array(
-  'format_type' => 'long',
-  'fromto' => 'both',
-  'multiple_number' => '',
-  'multiple_from' => '',
-  'multiple_to' => '',
-  'show_repeat_rule' => 'show',
-);
-$handler->display->display_options['fields']['field_agres_rdate']['field_api_classes'] = 0;
-/* Field: Content: Nid */
-$handler->display->display_options['fields']['nid']['id'] = 'nid';
-$handler->display->display_options['fields']['nid']['table'] = 'node';
-$handler->display->display_options['fields']['nid']['field'] = 'nid';
-$handler->display->display_options['fields']['nid']['label'] = '';
-$handler->display->display_options['fields']['nid']['alter']['alter_text'] = 1;
-$handler->display->display_options['fields']['nid']['alter']['text'] = 'N:[nid]';
-$handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['external'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
-$handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
-$handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['html'] = 0;
-$handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE;
-$handler->display->display_options['fields']['nid']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['nid']['hide_empty'] = 0;
-$handler->display->display_options['fields']['nid']['empty_zero'] = 0;
-$handler->display->display_options['fields']['nid']['hide_alter_empty'] = 1;
-$handler->display->display_options['fields']['nid']['link_to_node'] = 1;
-/* Field: Content: Order_id */
-$handler->display->display_options['fields']['field_agres_orderid']['id'] = 'field_agres_orderid';
-$handler->display->display_options['fields']['field_agres_orderid']['table'] = 'field_data_field_agres_orderid';
-$handler->display->display_options['fields']['field_agres_orderid']['field'] = 'field_agres_orderid';
-$handler->display->display_options['fields']['field_agres_orderid']['label'] = '';
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['alter_text'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['text'] = 'O:[field_agres_orderid]';
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['external'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['word_boundary'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['ellipsis'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['html'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['element_label_colon'] = FALSE;
-$handler->display->display_options['fields']['field_agres_orderid']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['hide_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['empty_zero'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['hide_alter_empty'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['type'] = 'number_unformatted';
-$handler->display->display_options['fields']['field_agres_orderid']['settings'] = array(
-  'thousand_separator' => ' ',
-  'prefix_suffix' => 1,
-);
-$handler->display->display_options['fields']['field_agres_orderid']['field_api_classes'] = 0;
-$handler->display->display_options['defaults']['arguments'] = FALSE;
-/* Contextual filter: Date: Date (node) */
-$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
-$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
-$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
-$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
-$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
-$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
-  'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
-  'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
-);
-$handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
-$handler->display->display_options['path'] = 'agres_view/month';
-$handler->display->display_options['menu']['type'] = 'normal';
-$handler->display->display_options['menu']['title'] = 'Booking Calendar';
-$handler->display->display_options['menu']['description'] = 'A booking Calendar';
-$handler->display->display_options['menu']['weight'] = '0';
-$handler->display->display_options['menu']['name'] = 'main-menu';
-$handler->display->display_options['tab_options']['type'] = 'normal';
-$handler->display->display_options['tab_options']['title'] = 'Month';
-$handler->display->display_options['tab_options']['weight'] = '0';
+  /* Display: Month */
+  $handler = $view->new_display('page', 'Month', 'page_1');
+  $handler->display->display_options['defaults']['pager'] = FALSE;
+  $handler->display->display_options['pager']['type'] = 'date_views_pager';
+  $handler->display->display_options['pager']['options']['date_id'] = 'month';
+  $handler->display->display_options['pager']['options']['link_format'] = 'clean';
+  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
+  $handler->display->display_options['style_plugin'] = 'agres_views_style';
+  $handler->display->display_options['style_options']['name_size'] = '3';
+  $handler->display->display_options['style_options']['mini'] = '0';
+  $handler->display->display_options['style_options']['with_weekno'] = '0';
+  $handler->display->display_options['style_options']['multiday_theme'] = '1';
+  $handler->display->display_options['style_options']['theme_style'] = '1';
+  $handler->display->display_options['style_options']['max_items'] = '0';
+  $handler->display->display_options['defaults']['style_options'] = FALSE;
+  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
+  $handler->display->display_options['row_plugin'] = 'agres_views_node';
+  $handler->display->display_options['row_options']['colors']['legend'] = 'type';
+  $handler->display->display_options['defaults']['row_options'] = FALSE;
+  $handler->display->display_options['defaults']['fields'] = FALSE;
+  /* Field: Content: Title */
+  $handler->display->display_options['fields']['title']['id'] = 'title';
+  $handler->display->display_options['fields']['title']['table'] = 'node';
+  $handler->display->display_options['fields']['title']['field'] = 'title';
+  $handler->display->display_options['fields']['title']['label'] = '';
+  $handler->display->display_options['fields']['title']['exclude'] = TRUE;
+  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['title']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
+  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
+  /* Field: Content: Booking Date */
+  $handler->display->display_options['fields']['field_agres_rdate']['id'] = 'field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['table'] = 'field_data_field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['field'] = 'field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['exclude'] = TRUE;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['element_label_colon'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['hide_alter_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['settings'] = array(
+    'format_type' => 'long',
+    'fromto' => 'both',
+    'multiple_number' => '',
+    'multiple_from' => '',
+    'multiple_to' => '',
+    'show_repeat_rule' => 'show',
+  );
+  $handler->display->display_options['fields']['field_agres_rdate']['field_api_classes'] = 0;
+  /* Field: Content: Nid */
+  $handler->display->display_options['fields']['nid']['id'] = 'nid';
+  $handler->display->display_options['fields']['nid']['table'] = 'node';
+  $handler->display->display_options['fields']['nid']['field'] = 'nid';
+  $handler->display->display_options['fields']['nid']['label'] = '';
+  $handler->display->display_options['fields']['nid']['alter']['alter_text'] = 1;
+  $handler->display->display_options['fields']['nid']['alter']['text'] = 'N:[nid]';
+  $handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['nid']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['nid']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['nid']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['nid']['hide_alter_empty'] = 1;
+  $handler->display->display_options['fields']['nid']['link_to_node'] = 1;
+  /* Field: Content: Order_id */
+  $handler->display->display_options['fields']['field_agres_orderid']['id'] = 'field_agres_orderid';
+  $handler->display->display_options['fields']['field_agres_orderid']['table'] = 'field_data_field_agres_orderid';
+  $handler->display->display_options['fields']['field_agres_orderid']['field'] = 'field_agres_orderid';
+  $handler->display->display_options['fields']['field_agres_orderid']['label'] = '';
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['alter_text'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['text'] = 'O:[field_agres_orderid]';
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['field_agres_orderid']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['hide_alter_empty'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['type'] = 'number_unformatted';
+  $handler->display->display_options['fields']['field_agres_orderid']['settings'] = array(
+    'thousand_separator' => ' ',
+    'prefix_suffix' => 1,
+  );
+  $handler->display->display_options['fields']['field_agres_orderid']['field_api_classes'] = 0;
+  $handler->display->display_options['defaults']['arguments'] = FALSE;
+  /* Contextual filter: Date: Date (node) */
+  $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['table'] = 'node';
+  $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
+  $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
+  $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
+  $handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
+  $handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
+    'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
+    'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
+  );
+  $handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
+  $handler->display->display_options['path'] = 'agres_view/month';
+  $handler->display->display_options['menu']['type'] = 'normal';
+  $handler->display->display_options['menu']['title'] = 'Booking Calendar';
+  $handler->display->display_options['menu']['description'] = 'A booking Calendar';
+  $handler->display->display_options['menu']['weight'] = '0';
+  $handler->display->display_options['menu']['name'] = 'main-menu';
+  $handler->display->display_options['tab_options']['type'] = 'normal';
+  $handler->display->display_options['tab_options']['title'] = 'Month';
+  $handler->display->display_options['tab_options']['weight'] = '0';
 
-/* Display: Week */
-$handler = $view->new_display('page', 'Week', 'page_2');
-$handler->display->display_options['defaults']['pager'] = FALSE;
-$handler->display->display_options['pager']['type'] = 'date_views_pager';
-$handler->display->display_options['pager']['options']['date_id'] = 'week';
-$handler->display->display_options['pager']['options']['link_format'] = 'clean';
-$handler->display->display_options['defaults']['style_plugin'] = FALSE;
-$handler->display->display_options['style_plugin'] = 'agres_views_style';
-$handler->display->display_options['style_options']['name_size'] = '3';
-$handler->display->display_options['style_options']['mini'] = '0';
-$handler->display->display_options['style_options']['with_weekno'] = '0';
-$handler->display->display_options['style_options']['multiday_theme'] = '1';
-$handler->display->display_options['style_options']['theme_style'] = '0';
-$handler->display->display_options['style_options']['max_items'] = '0';
-$handler->display->display_options['style_options']['agres_views_type'] = 'week';
-$handler->display->display_options['defaults']['style_options'] = FALSE;
-$handler->display->display_options['defaults']['row_plugin'] = FALSE;
-$handler->display->display_options['row_plugin'] = 'agres_views_node';
-$handler->display->display_options['defaults']['row_options'] = FALSE;
-$handler->display->display_options['defaults']['fields'] = FALSE;
-/* Field: Content: Title */
-$handler->display->display_options['fields']['title']['id'] = 'title';
-$handler->display->display_options['fields']['title']['table'] = 'node';
-$handler->display->display_options['fields']['title']['field'] = 'title';
-$handler->display->display_options['fields']['title']['label'] = '';
-$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
-$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['title']['alter']['external'] = 0;
-$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
-$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
-$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['title']['alter']['html'] = 0;
-$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
-$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['title']['hide_empty'] = 0;
-$handler->display->display_options['fields']['title']['empty_zero'] = 0;
-$handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
-$handler->display->display_options['fields']['title']['link_to_node'] = 1;
-/* Field: Content: Booking Date */
-$handler->display->display_options['fields']['field_agres_rdate']['id'] = 'field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['table'] = 'field_data_field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['field'] = 'field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['exclude'] = TRUE;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['alter_text'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['external'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['word_boundary'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['ellipsis'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['html'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['element_label_colon'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['hide_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['empty_zero'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['hide_alter_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['settings'] = array(
-  'format_type' => 'long',
-  'fromto' => 'both',
-  'multiple_number' => '',
-  'multiple_from' => '',
-  'multiple_to' => '',
-  'show_repeat_rule' => 'show',
-);
-$handler->display->display_options['fields']['field_agres_rdate']['field_api_classes'] = 0;
-/* Field: Content: Nid */
-$handler->display->display_options['fields']['nid']['id'] = 'nid';
-$handler->display->display_options['fields']['nid']['table'] = 'node';
-$handler->display->display_options['fields']['nid']['field'] = 'nid';
-$handler->display->display_options['fields']['nid']['label'] = '';
-$handler->display->display_options['fields']['nid']['alter']['alter_text'] = 1;
-$handler->display->display_options['fields']['nid']['alter']['text'] = 'N:[nid]';
-$handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['external'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
-$handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
-$handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['html'] = 0;
-$handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE;
-$handler->display->display_options['fields']['nid']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['nid']['hide_empty'] = 0;
-$handler->display->display_options['fields']['nid']['empty_zero'] = 0;
-$handler->display->display_options['fields']['nid']['hide_alter_empty'] = 1;
-$handler->display->display_options['fields']['nid']['link_to_node'] = 1;
-/* Field: Content: Order_id */
-$handler->display->display_options['fields']['field_agres_orderid']['id'] = 'field_agres_orderid';
-$handler->display->display_options['fields']['field_agres_orderid']['table'] = 'field_data_field_agres_orderid';
-$handler->display->display_options['fields']['field_agres_orderid']['field'] = 'field_agres_orderid';
-$handler->display->display_options['fields']['field_agres_orderid']['label'] = '';
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['alter_text'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['text'] = 'O:[field_agres_orderid] ';
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['external'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['word_boundary'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['ellipsis'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['html'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['element_label_colon'] = FALSE;
-$handler->display->display_options['fields']['field_agres_orderid']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['hide_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['empty_zero'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['hide_alter_empty'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['settings'] = array(
-  'thousand_separator' => ' ',
-  'prefix_suffix' => 0,
-);
-$handler->display->display_options['fields']['field_agres_orderid']['field_api_classes'] = 0;
-$handler->display->display_options['defaults']['arguments'] = FALSE;
-/* Contextual filter: Date: Date (node) */
-$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
-$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
-$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
-$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
-$handler->display->display_options['arguments']['date_argument']['granularity'] = 'week';
-$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
-$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
-  'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
-  'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
-);
-$handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
-$handler->display->display_options['path'] = 'agres_view/week';
-$handler->display->display_options['menu']['title'] = 'Week';
-$handler->display->display_options['menu']['weight'] = '2';
+  /* Display: Week */
+  $handler = $view->new_display('page', 'Week', 'page_2');
+  $handler->display->display_options['defaults']['pager'] = FALSE;
+  $handler->display->display_options['pager']['type'] = 'date_views_pager';
+  $handler->display->display_options['pager']['options']['date_id'] = 'week';
+  $handler->display->display_options['pager']['options']['link_format'] = 'clean';
+  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
+  $handler->display->display_options['style_plugin'] = 'agres_views_style';
+  $handler->display->display_options['style_options']['name_size'] = '3';
+  $handler->display->display_options['style_options']['mini'] = '0';
+  $handler->display->display_options['style_options']['with_weekno'] = '0';
+  $handler->display->display_options['style_options']['multiday_theme'] = '1';
+  $handler->display->display_options['style_options']['theme_style'] = '0';
+  $handler->display->display_options['style_options']['max_items'] = '0';
+  $handler->display->display_options['style_options']['agres_views_type'] = 'week';
+  $handler->display->display_options['defaults']['style_options'] = FALSE;
+  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
+  $handler->display->display_options['row_plugin'] = 'agres_views_node';
+  $handler->display->display_options['defaults']['row_options'] = FALSE;
+  $handler->display->display_options['defaults']['fields'] = FALSE;
+  /* Field: Content: Title */
+  $handler->display->display_options['fields']['title']['id'] = 'title';
+  $handler->display->display_options['fields']['title']['table'] = 'node';
+  $handler->display->display_options['fields']['title']['field'] = 'title';
+  $handler->display->display_options['fields']['title']['label'] = '';
+  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['title']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
+  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
+  /* Field: Content: Booking Date */
+  $handler->display->display_options['fields']['field_agres_rdate']['id'] = 'field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['table'] = 'field_data_field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['field'] = 'field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['exclude'] = TRUE;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['element_label_colon'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['hide_alter_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['settings'] = array(
+    'format_type' => 'long',
+    'fromto' => 'both',
+    'multiple_number' => '',
+    'multiple_from' => '',
+    'multiple_to' => '',
+    'show_repeat_rule' => 'show',
+  );
+  $handler->display->display_options['fields']['field_agres_rdate']['field_api_classes'] = 0;
+  /* Field: Content: Nid */
+  $handler->display->display_options['fields']['nid']['id'] = 'nid';
+  $handler->display->display_options['fields']['nid']['table'] = 'node';
+  $handler->display->display_options['fields']['nid']['field'] = 'nid';
+  $handler->display->display_options['fields']['nid']['label'] = '';
+  $handler->display->display_options['fields']['nid']['alter']['alter_text'] = 1;
+  $handler->display->display_options['fields']['nid']['alter']['text'] = 'N:[nid]';
+  $handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['nid']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['nid']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['nid']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['nid']['hide_alter_empty'] = 1;
+  $handler->display->display_options['fields']['nid']['link_to_node'] = 1;
+  /* Field: Content: Order_id */
+  $handler->display->display_options['fields']['field_agres_orderid']['id'] = 'field_agres_orderid';
+  $handler->display->display_options['fields']['field_agres_orderid']['table'] = 'field_data_field_agres_orderid';
+  $handler->display->display_options['fields']['field_agres_orderid']['field'] = 'field_agres_orderid';
+  $handler->display->display_options['fields']['field_agres_orderid']['label'] = '';
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['alter_text'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['text'] = 'O:[field_agres_orderid] ';
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['field_agres_orderid']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['hide_alter_empty'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['settings'] = array(
+    'thousand_separator' => ' ',
+    'prefix_suffix' => 0,
+  );
+  $handler->display->display_options['fields']['field_agres_orderid']['field_api_classes'] = 0;
+  $handler->display->display_options['defaults']['arguments'] = FALSE;
+  /* Contextual filter: Date: Date (node) */
+  $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['table'] = 'node';
+  $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
+  $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
+  $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
+  $handler->display->display_options['arguments']['date_argument']['granularity'] = 'week';
+  $handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
+  $handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
+    'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
+    'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
+  );
+  $handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
+  $handler->display->display_options['path'] = 'agres_view/week';
+  $handler->display->display_options['menu']['title'] = 'Week';
+  $handler->display->display_options['menu']['weight'] = '2';
 
-/* Display: Day */
-$handler = $view->new_display('page', 'Day', 'page_3');
-$handler->display->display_options['defaults']['pager'] = FALSE;
-$handler->display->display_options['pager']['type'] = 'date_views_pager';
-$handler->display->display_options['pager']['options']['date_id'] = 'day';
-$handler->display->display_options['defaults']['style_plugin'] = FALSE;
-$handler->display->display_options['style_plugin'] = 'agres_views_style';
-$handler->display->display_options['style_options']['name_size'] = '3';
-$handler->display->display_options['style_options']['mini'] = '0';
-$handler->display->display_options['style_options']['with_weekno'] = '0';
-$handler->display->display_options['style_options']['multiday_theme'] = '0';
-$handler->display->display_options['style_options']['theme_style'] = '0';
-$handler->display->display_options['style_options']['max_items'] = '0';
-$handler->display->display_options['style_options']['agres_views_type'] = 'day';
-$handler->display->display_options['defaults']['style_options'] = FALSE;
-$handler->display->display_options['defaults']['row_plugin'] = FALSE;
-$handler->display->display_options['row_plugin'] = 'agres_views_node';
-$handler->display->display_options['defaults']['row_options'] = FALSE;
-$handler->display->display_options['defaults']['fields'] = FALSE;
-/* Field: Content: Title */
-$handler->display->display_options['fields']['title']['id'] = 'title';
-$handler->display->display_options['fields']['title']['table'] = 'node';
-$handler->display->display_options['fields']['title']['field'] = 'title';
-$handler->display->display_options['fields']['title']['label'] = '';
-$handler->display->display_options['fields']['title']['exclude'] = TRUE;
-$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
-$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['title']['alter']['external'] = 0;
-$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
-$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
-$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['title']['alter']['html'] = 0;
-$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
-$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['title']['hide_empty'] = 0;
-$handler->display->display_options['fields']['title']['empty_zero'] = 0;
-$handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
-$handler->display->display_options['fields']['title']['link_to_node'] = 1;
-/* Field: Content: Booking Date */
-$handler->display->display_options['fields']['field_agres_rdate']['id'] = 'field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['table'] = 'field_data_field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['field'] = 'field_agres_rdate';
-$handler->display->display_options['fields']['field_agres_rdate']['exclude'] = TRUE;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['alter_text'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['external'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['word_boundary'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['ellipsis'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['alter']['html'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['element_label_colon'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['field_agres_rdate']['hide_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['empty_zero'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['hide_alter_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_rdate']['settings'] = array(
-  'format_type' => 'long',
-  'fromto' => 'both',
-  'multiple_number' => '',
-  'multiple_from' => '',
-  'multiple_to' => '',
-  'show_repeat_rule' => 'show',
-);
-$handler->display->display_options['fields']['field_agres_rdate']['field_api_classes'] = 0;
-/* Field: Content: Nid */
-$handler->display->display_options['fields']['nid']['id'] = 'nid';
-$handler->display->display_options['fields']['nid']['table'] = 'node';
-$handler->display->display_options['fields']['nid']['field'] = 'nid';
-$handler->display->display_options['fields']['nid']['label'] = '';
-$handler->display->display_options['fields']['nid']['alter']['alter_text'] = 1;
-$handler->display->display_options['fields']['nid']['alter']['text'] = 'N:[nid]';
-$handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['external'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
-$handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
-$handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['nid']['alter']['html'] = 0;
-$handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE;
-$handler->display->display_options['fields']['nid']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['nid']['hide_empty'] = 0;
-$handler->display->display_options['fields']['nid']['empty_zero'] = 0;
-$handler->display->display_options['fields']['nid']['hide_alter_empty'] = 1;
-$handler->display->display_options['fields']['nid']['link_to_node'] = 1;
-/* Field: Content: Order_id */
-$handler->display->display_options['fields']['field_agres_orderid']['id'] = 'field_agres_orderid';
-$handler->display->display_options['fields']['field_agres_orderid']['table'] = 'field_data_field_agres_orderid';
-$handler->display->display_options['fields']['field_agres_orderid']['field'] = 'field_agres_orderid';
-$handler->display->display_options['fields']['field_agres_orderid']['label'] = '';
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['alter_text'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['text'] = 'O:[field_agres_orderid]';
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['make_link'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['absolute'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['external'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['replace_spaces'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['trim_whitespace'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['nl2br'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['word_boundary'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['ellipsis'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['strip_tags'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['trim'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['alter']['html'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['element_label_colon'] = FALSE;
-$handler->display->display_options['fields']['field_agres_orderid']['element_default_classes'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['hide_empty'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['empty_zero'] = 0;
-$handler->display->display_options['fields']['field_agres_orderid']['hide_alter_empty'] = 1;
-$handler->display->display_options['fields']['field_agres_orderid']['settings'] = array(
-  'thousand_separator' => ' ',
-  'prefix_suffix' => 0,
-);
-$handler->display->display_options['fields']['field_agres_orderid']['field_api_classes'] = 0;
-$handler->display->display_options['defaults']['arguments'] = FALSE;
-/* Contextual filter: Date: Date (node) */
-$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
-$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
-$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
-$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
-$handler->display->display_options['arguments']['date_argument']['granularity'] = 'day';
-$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
-  'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
-  'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
-);
-$handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
-$handler->display->display_options['path'] = 'agres_view/day';
-$handler->display->display_options['menu']['title'] = 'Day';
-$handler->display->display_options['menu']['weight'] = '3';
+  /* Display: Day */
+  $handler = $view->new_display('page', 'Day', 'page_3');
+  $handler->display->display_options['defaults']['pager'] = FALSE;
+  $handler->display->display_options['pager']['type'] = 'date_views_pager';
+  $handler->display->display_options['pager']['options']['date_id'] = 'day';
+  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
+  $handler->display->display_options['style_plugin'] = 'agres_views_style';
+  $handler->display->display_options['style_options']['name_size'] = '3';
+  $handler->display->display_options['style_options']['mini'] = '0';
+  $handler->display->display_options['style_options']['with_weekno'] = '0';
+  $handler->display->display_options['style_options']['multiday_theme'] = '0';
+  $handler->display->display_options['style_options']['theme_style'] = '0';
+  $handler->display->display_options['style_options']['max_items'] = '0';
+  $handler->display->display_options['style_options']['agres_views_type'] = 'day';
+  $handler->display->display_options['defaults']['style_options'] = FALSE;
+  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
+  $handler->display->display_options['row_plugin'] = 'agres_views_node';
+  $handler->display->display_options['defaults']['row_options'] = FALSE;
+  $handler->display->display_options['defaults']['fields'] = FALSE;
+  /* Field: Content: Title */
+  $handler->display->display_options['fields']['title']['id'] = 'title';
+  $handler->display->display_options['fields']['title']['table'] = 'node';
+  $handler->display->display_options['fields']['title']['field'] = 'title';
+  $handler->display->display_options['fields']['title']['label'] = '';
+  $handler->display->display_options['fields']['title']['exclude'] = TRUE;
+  $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['title']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['title']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['title']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['title']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['title']['hide_alter_empty'] = 0;
+  $handler->display->display_options['fields']['title']['link_to_node'] = 1;
+  /* Field: Content: Booking Date */
+  $handler->display->display_options['fields']['field_agres_rdate']['id'] = 'field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['table'] = 'field_data_field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['field'] = 'field_agres_rdate';
+  $handler->display->display_options['fields']['field_agres_rdate']['exclude'] = TRUE;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['alter_text'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['element_label_colon'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['field_agres_rdate']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['hide_alter_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_rdate']['settings'] = array(
+    'format_type' => 'long',
+    'fromto' => 'both',
+    'multiple_number' => '',
+    'multiple_from' => '',
+    'multiple_to' => '',
+    'show_repeat_rule' => 'show',
+  );
+  $handler->display->display_options['fields']['field_agres_rdate']['field_api_classes'] = 0;
+  /* Field: Content: Nid */
+  $handler->display->display_options['fields']['nid']['id'] = 'nid';
+  $handler->display->display_options['fields']['nid']['table'] = 'node';
+  $handler->display->display_options['fields']['nid']['field'] = 'nid';
+  $handler->display->display_options['fields']['nid']['label'] = '';
+  $handler->display->display_options['fields']['nid']['alter']['alter_text'] = 1;
+  $handler->display->display_options['fields']['nid']['alter']['text'] = 'N:[nid]';
+  $handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['nid']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['nid']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['nid']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['nid']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['nid']['hide_alter_empty'] = 1;
+  $handler->display->display_options['fields']['nid']['link_to_node'] = 1;
+  /* Field: Content: Order_id */
+  $handler->display->display_options['fields']['field_agres_orderid']['id'] = 'field_agres_orderid';
+  $handler->display->display_options['fields']['field_agres_orderid']['table'] = 'field_data_field_agres_orderid';
+  $handler->display->display_options['fields']['field_agres_orderid']['field'] = 'field_agres_orderid';
+  $handler->display->display_options['fields']['field_agres_orderid']['label'] = '';
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['alter_text'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['text'] = 'O:[field_agres_orderid]';
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['make_link'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['absolute'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['external'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['replace_spaces'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['trim_whitespace'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['nl2br'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['word_boundary'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['ellipsis'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['strip_tags'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['trim'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['alter']['html'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['field_agres_orderid']['element_default_classes'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['hide_empty'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['empty_zero'] = 0;
+  $handler->display->display_options['fields']['field_agres_orderid']['hide_alter_empty'] = 1;
+  $handler->display->display_options['fields']['field_agres_orderid']['settings'] = array(
+    'thousand_separator' => ' ',
+    'prefix_suffix' => 0,
+  );
+  $handler->display->display_options['fields']['field_agres_orderid']['field_api_classes'] = 0;
+  $handler->display->display_options['defaults']['arguments'] = FALSE;
+  /* Contextual filter: Date: Date (node) */
+  $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['table'] = 'node';
+  $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
+  $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
+  $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
+  $handler->display->display_options['arguments']['date_argument']['granularity'] = 'day';
+  $handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
+    'field_data_field_agres_rdate.field_agres_rdate_value' => 'field_data_field_agres_rdate.field_agres_rdate_value',
+    'field_data_field_agres_rdate.field_agres_rdate_value2' => 'field_data_field_agres_rdate.field_agres_rdate_value2',
+  );
+  $handler->display->display_options['arguments']['date_argument']['date_method'] = 'AND';
+  $handler->display->display_options['path'] = 'agres_view/day';
+  $handler->display->display_options['menu']['title'] = 'Day';
+  $handler->display->display_options['menu']['weight'] = '3';
 
-/* Display: Year */
-$handler = $view->new_display('page', 'Year', 'page');
-$handler->display->display_options['defaults']['pager'] = FALSE;
-$handler->display->display_options['pager']['type'] = 'date_views_pager';
-$handler->display->display_options['pager']['options']['date_id'] = 'year';
-$handler->display->display_options['defaults']['style_plugin'] = FALSE;
-$handler->display->display_options['style_plugin'] = 'agres_views_style';
-$handler->display->display_options['style_options']['name_size'] = '1';
-$handler->display->display_options['style_options']['mini'] = '0';
-$handler->display->display_options['style_options']['with_weekno'] = '0';
-$handler->display->display_options['style_options']['multiday_theme'] = '1';
-$handler->display->display_options['style_options']['theme_style'] = '1';
-$handler->display->display_options['style_options']['max_items'] = '0';
-$handler->display->display_options['style_options']['agres_views_type'] = 'year';
-$handler->display->display_options['defaults']['style_options'] = FALSE;
-$handler->display->display_options['defaults']['row_plugin'] = FALSE;
-$handler->display->display_options['row_plugin'] = 'agres_views_node';
-$handler->display->display_options['defaults']['row_options'] = FALSE;
-$handler->display->display_options['defaults']['arguments'] = FALSE;
-/* Contextual filter: Date: Date (node) */
-$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
-$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
-$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
-$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
-$handler->display->display_options['arguments']['date_argument']['granularity'] = 'year';
-$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
-$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
-  'node.changed' => 'node.changed',
-);
-$handler->display->display_options['path'] = 'agres_view/year';
-$handler->display->display_options['menu']['title'] = 'Year';
-$handler->display->display_options['menu']['weight'] = '4';
+  /* Display: Year */
+  $handler = $view->new_display('page', 'Year', 'page');
+  $handler->display->display_options['defaults']['pager'] = FALSE;
+  $handler->display->display_options['pager']['type'] = 'date_views_pager';
+  $handler->display->display_options['pager']['options']['date_id'] = 'year';
+  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
+  $handler->display->display_options['style_plugin'] = 'agres_views_style';
+  $handler->display->display_options['style_options']['name_size'] = '1';
+  $handler->display->display_options['style_options']['mini'] = '0';
+  $handler->display->display_options['style_options']['with_weekno'] = '0';
+  $handler->display->display_options['style_options']['multiday_theme'] = '1';
+  $handler->display->display_options['style_options']['theme_style'] = '1';
+  $handler->display->display_options['style_options']['max_items'] = '0';
+  $handler->display->display_options['style_options']['agres_views_type'] = 'year';
+  $handler->display->display_options['defaults']['style_options'] = FALSE;
+  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
+  $handler->display->display_options['row_plugin'] = 'agres_views_node';
+  $handler->display->display_options['defaults']['row_options'] = FALSE;
+  $handler->display->display_options['defaults']['arguments'] = FALSE;
+  /* Contextual filter: Date: Date (node) */
+  $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['table'] = 'node';
+  $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
+  $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
+  $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
+  $handler->display->display_options['arguments']['date_argument']['granularity'] = 'year';
+  $handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
+  $handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
+    'node.changed' => 'node.changed',
+  );
+  $handler->display->display_options['path'] = 'agres_view/year';
+  $handler->display->display_options['menu']['title'] = 'Year';
+  $handler->display->display_options['menu']['weight'] = '4';
 
-/* Display: Block */
-$handler = $view->new_display('block', 'Block', 'block_1');
-$handler->display->display_options['defaults']['pager'] = FALSE;
-$handler->display->display_options['pager']['type'] = 'date_views_pager';
-$handler->display->display_options['pager']['options']['date_id'] = 'mini';
-$handler->display->display_options['defaults']['style_plugin'] = FALSE;
-$handler->display->display_options['style_plugin'] = 'agres_views_style';
-$handler->display->display_options['style_options']['name_size'] = '1';
-$handler->display->display_options['style_options']['mini'] = '1';
-$handler->display->display_options['style_options']['with_weekno'] = '0';
-$handler->display->display_options['style_options']['multiday_theme'] = '1';
-$handler->display->display_options['style_options']['theme_style'] = '1';
-$handler->display->display_options['style_options']['max_items'] = '0';
-$handler->display->display_options['defaults']['style_options'] = FALSE;
-$handler->display->display_options['defaults']['row_plugin'] = FALSE;
-$handler->display->display_options['row_plugin'] = 'agres_views_node';
-$handler->display->display_options['defaults']['row_options'] = FALSE;
-$handler->display->display_options['defaults']['arguments'] = FALSE;
-/* Contextual filter: Date: Date (node) */
-$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
-$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
-$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
-$handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
-$handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
-$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
-$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
-  'node.changed' => 'node.changed',
-);
+  /* Display: Block */
+  $handler = $view->new_display('block', 'Block', 'block_1');
+  $handler->display->display_options['defaults']['pager'] = FALSE;
+  $handler->display->display_options['pager']['type'] = 'date_views_pager';
+  $handler->display->display_options['pager']['options']['date_id'] = 'mini';
+  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
+  $handler->display->display_options['style_plugin'] = 'agres_views_style';
+  $handler->display->display_options['style_options']['name_size'] = '1';
+  $handler->display->display_options['style_options']['mini'] = '1';
+  $handler->display->display_options['style_options']['with_weekno'] = '0';
+  $handler->display->display_options['style_options']['multiday_theme'] = '1';
+  $handler->display->display_options['style_options']['theme_style'] = '1';
+  $handler->display->display_options['style_options']['max_items'] = '0';
+  $handler->display->display_options['defaults']['style_options'] = FALSE;
+  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
+  $handler->display->display_options['row_plugin'] = 'agres_views_node';
+  $handler->display->display_options['defaults']['row_options'] = FALSE;
+  $handler->display->display_options['defaults']['arguments'] = FALSE;
+  /* Contextual filter: Date: Date (node) */
+  $handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['table'] = 'node';
+  $handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
+  $handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
+  $handler->display->display_options['arguments']['date_argument']['default_argument_skip_url'] = 0;
+  $handler->display->display_options['arguments']['date_argument']['summary']['format'] = 'default_summary';
+  $handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
+  $handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
+    'node.changed' => 'node.changed',
+  );
 
-/* Display: Upcoming */
-$handler = $view->new_display('block', 'Upcoming', 'block_2');
-$handler->display->display_options['display_description'] = 'Upcoming events block';
-$handler->display->display_options['defaults']['pager'] = FALSE;
-$handler->display->display_options['pager']['type'] = 'some';
-$handler->display->display_options['pager']['options']['items_per_page'] = '5';
-$handler->display->display_options['pager']['options']['offset'] = '0';
-$handler->display->display_options['defaults']['style_plugin'] = FALSE;
-$handler->display->display_options['style_plugin'] = 'list';
-$handler->display->display_options['defaults']['style_options'] = FALSE;
-$handler->display->display_options['defaults']['row_plugin'] = FALSE;
-$handler->display->display_options['row_plugin'] = 'fields';
-$handler->display->display_options['defaults']['row_options'] = FALSE;
-$handler->display->display_options['defaults']['filters'] = FALSE;
-/* Filter criterion: Content: Published */
-$handler->display->display_options['filters']['status']['id'] = 'status';
-$handler->display->display_options['filters']['status']['table'] = 'node';
-$handler->display->display_options['filters']['status']['field'] = 'status';
-$handler->display->display_options['filters']['status']['value'] = 1;
-$handler->display->display_options['filters']['status']['group'] = 0;
-$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
-/* Filter criterion: Date: Date (node) */
-$handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
-$handler->display->display_options['filters']['date_filter']['table'] = 'node';
-$handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
-$handler->display->display_options['filters']['date_filter']['operator'] = '>=';
-$handler->display->display_options['filters']['date_filter']['default_date'] = 'now';
-$handler->display->display_options['filters']['date_filter']['add_delta'] = 'yes';
-$handler->display->display_options['filters']['date_filter']['date_fields'] = array(
-  'node.changed' => 'node.changed',
-);
-$translatables['agres_view'] = array(
-  t('Master'),
-  t('Booking Calendar'),
-  t('more'),
-  t('Apply'),
-  t('Reset'),
-  t('Sort by'),
-  t('Asc'),
-  t('Desc'),
-  t('Booking Date'),
-  t('Nid'),
-  t('Month'),
-  t('N:[nid]'),
-  t('O:[field_agres_orderid]'),
-  t('All'),
-  t('Week'),
-  t('O:[field_agres_orderid] '),
-  t('Day'),
-  t('Year'),
-  t('Block'),
-  t('Upcoming'),
-  t('Upcoming events block'),
-);
+  /* Display: Upcoming */
+  $handler = $view->new_display('block', 'Upcoming', 'block_2');
+  $handler->display->display_options['display_description'] = 'Upcoming events block';
+  $handler->display->display_options['defaults']['pager'] = FALSE;
+  $handler->display->display_options['pager']['type'] = 'some';
+  $handler->display->display_options['pager']['options']['items_per_page'] = '5';
+  $handler->display->display_options['pager']['options']['offset'] = '0';
+  $handler->display->display_options['defaults']['style_plugin'] = FALSE;
+  $handler->display->display_options['style_plugin'] = 'list';
+  $handler->display->display_options['defaults']['style_options'] = FALSE;
+  $handler->display->display_options['defaults']['row_plugin'] = FALSE;
+  $handler->display->display_options['row_plugin'] = 'fields';
+  $handler->display->display_options['defaults']['row_options'] = FALSE;
+  $handler->display->display_options['defaults']['filters'] = FALSE;
+  /* Filter criterion: Content: Published */
+  $handler->display->display_options['filters']['status']['id'] = 'status';
+  $handler->display->display_options['filters']['status']['table'] = 'node';
+  $handler->display->display_options['filters']['status']['field'] = 'status';
+  $handler->display->display_options['filters']['status']['value'] = 1;
+  $handler->display->display_options['filters']['status']['group'] = 0;
+  $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
+  /* Filter criterion: Date: Date (node) */
+  $handler->display->display_options['filters']['date_filter']['id'] = 'date_filter';
+  $handler->display->display_options['filters']['date_filter']['table'] = 'node';
+  $handler->display->display_options['filters']['date_filter']['field'] = 'date_filter';
+  $handler->display->display_options['filters']['date_filter']['operator'] = '>=';
+  $handler->display->display_options['filters']['date_filter']['default_date'] = 'now';
+  $handler->display->display_options['filters']['date_filter']['add_delta'] = 'yes';
+  $handler->display->display_options['filters']['date_filter']['date_fields'] = array(
+    'node.changed' => 'node.changed',
+  );
+  $translatables['agres_view'] = array(
+    t('Master'),
+    t('Booking Calendar'),
+    t('more'),
+    t('Apply'),
+    t('Reset'),
+    t('Sort by'),
+    t('Asc'),
+    t('Desc'),
+    t('Booking Date'),
+    t('Nid'),
+    t('Month'),
+    t('N:[nid]'),
+    t('O:[field_agres_orderid]'),
+    t('All'),
+    t('Week'),
+    t('O:[field_agres_orderid]'),
+    t('Day'),
+    t('Year'),
+    t('Block'),
+    t('Upcoming'),
+    t('Upcoming events block'),
+  );
 
 
   return $view;
-
 }
diff --git a/agres_views/includes/agres_views_plugin_row_node.inc b/agres_views/includes/agres_views_plugin_row_node.inc
index 7389d4b..c5a6efe 100644
--- a/agres_views/includes/agres_views_plugin_row_node.inc
+++ b/agres_views/includes/agres_views_plugin_row_node.inc
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * @file
  * Contains the agres_views row style plugin.
@@ -28,7 +29,6 @@ class agres_views_plugin_row_node extends calendar_plugin_row {
     // @TODO When the date is coming in through a relationship, the nid
     // of the view is not the right node to use, then we need the related node.
     // Need to sort out how that should be handled.
-
     // Preload each node used in this view from the cache.
     // Provides all the node values relatively cheaply, and we don't
     // need to do it repeatedly for the same node if there are
@@ -56,13 +56,13 @@ class agres_views_plugin_row_node extends calendar_plugin_row {
         if ($handler->definition['handler'] != 'date_views_argument_handler') {
           $alias = $handler->table_alias . '.' . $handler->field;
           $info = $data[$alias];
-          $field_name  = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
+          $field_name = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
           $date_fields[$field_name] = $info;
         }
         else {
           foreach ($handler->options['date_fields'] as $alias) {
             $info = $data[$alias];
-            $field_name  = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
+            $field_name = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
             $date_fields[$field_name] = $info;
           }
         }
@@ -96,12 +96,12 @@ class agres_views_plugin_row_node extends calendar_plugin_row {
     $rows = array();
     foreach ($this->date_fields as $field_name => $info) {
 
-      $table_name  = $info['table_name'];
+      $table_name = $info['table_name'];
       $delta_field = $info['delta_field'];
       $tz_handling = $info['tz_handling'];
-      $tz_field    = $info['timezone_field'];
+      $tz_field = $info['timezone_field'];
       $rrule_field = $info['rrule_field'];
-      $is_field = substr($info['real_field_name'], 0, 6) == 'field_';
+      $is_field = drupal_substr($info['real_field_name'], 0, 6) == 'field_';
 
       // Retrieve the field value that matched our query from the cached node.
       // Find the date and set it to the right timezone.
@@ -109,9 +109,9 @@ class agres_views_plugin_row_node extends calendar_plugin_row {
       $item = $node->$field_name;
       $node->date_id = array();
       $item_start_date = NULL;
-      $item_end_date   = NULL;
+      $item_end_date = NULL;
 
-      $db_tz   = date_get_timezone_db($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
+      $db_tz = date_get_timezone_db($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
       $to_zone = date_get_timezone($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
       $granularity = 'second';
       $increment = 1;
@@ -129,18 +129,17 @@ class agres_views_plugin_row_node extends calendar_plugin_row {
 
         if (!empty($item['value'])) {
           $item_start_date = new dateObject($item['value'], $db_tz);
-          $item_end_date   = array_key_exists('value2', $item) ? new dateObject($item['value2'], $db_tz) : $item_start_date;
+          $item_end_date = array_key_exists('value2', $item) ? new dateObject($item['value2'], $db_tz) : $item_start_date;
         }
 
         $cck_field = field_info_field($field_name);
         $instance = field_info_instance($this->view->base_table, $field_name, $node->type);
         $granularity = date_granularity_precision($cck_field['settings']['granularity']);
         $increment = $instance['widget']['settings']['increment'];
-
       }
       elseif (!$is_field && !empty($item)) {
         $item_start_date = new dateObject($item, $db_tz);
-        $item_end_date   = $item_start_date;
+        $item_end_date = $item_start_date;
         $node->date_id = array('agres_views.' . $node->nid . '.' . $field_name . '.0');
       }
 
@@ -185,7 +184,6 @@ class agres_views_plugin_row_node extends calendar_plugin_row {
         }
         $rows[] = $node;
       }
-
     }
 //    drupal_set_message('<pre>$rows$rows$rows '.print_r( $rows,true).'</pre>');
     return $rows;
@@ -207,7 +205,7 @@ class agres_views_plugin_row_node extends calendar_plugin_row {
     // and possibly create additional nodes so that we have a 'node'
     // for each day that this item occupies in this view.
     $now = max($date_info->min_zone_string, $item_start_date->format(DATE_FORMAT_DATE));
-    $to  = min($date_info->max_zone_string, $item_end_date->format(DATE_FORMAT_DATE));
+    $to = min($date_info->max_zone_string, $item_end_date->format(DATE_FORMAT_DATE));
     $next = new DateObject($now . ' 00:00:00', $date_info->display_timezone);
     if ($date_info->display_timezone_name != $to_zone) {
       // Make $start and $end (derived from $node) use the timezone $to_zone, just as the original dates do.
@@ -268,7 +266,6 @@ class agres_views_plugin_row_node extends calendar_plugin_row {
       date_modify($next, '+1 second');
       $now = date_format($next, DATE_FORMAT_DATE);
       $pos++;
-
     }
     return $rows;
   }
@@ -313,7 +310,6 @@ class agres_views_plugin_row_node extends calendar_plugin_row {
   /**
    * Create a stripe based on a taxonomy term.
    */
-
   function agres_views_node_taxonomy_stripe(&$event) {
     $term_colors = isset($this->options['colors']['term_colors']) ? $this->options['colors']['term_colors'] : array();
     if (empty($term_colors)) {
@@ -404,5 +400,6 @@ class agres_views_plugin_row_node extends calendar_plugin_row {
     }
     return $stripe;
   }
+
 }
 
diff --git a/agres_views/includes/agres_views_plugin_style.inc b/agres_views/includes/agres_views_plugin_style.inc
index cd52a87..aba0a31 100644
--- a/agres_views/includes/agres_views_plugin_style.inc
+++ b/agres_views/includes/agres_views_plugin_style.inc
@@ -363,22 +363,21 @@ class agres_views_plugin_style extends calendar_plugin_style {
       $this->definition['theme'] .= '_overlap';
     }
 
-    $output = theme($this->theme_functions(),
-      array(
+    $output = theme($this->theme_functions(), array(
       'view' => $this->view,
       'options' => $this->options,
       'rows' => $rows,
-    ));
+      ));
     unset($this->view->row_index);
     return $output;
   }
 
   function agres_views_build_month() {
     $curday = $this->curday;
-    $items  = $this->items;
+    $items = $this->items;
     $view = $this->view;
     $month = date_format($curday, 'n');
-    date_modify($curday, '-' . strval(date_format($curday, 'j') -1) . ' days');
+    date_modify($curday, '-' . strval(date_format($curday, 'j') - 1) . ' days');
 
     $rows = array();
     do {
@@ -394,8 +393,6 @@ class agres_views_plugin_style extends calendar_plugin_style {
     return $rows;
   }
 
-
-
   /**
    * Build one week row.
    */
@@ -418,12 +415,11 @@ class agres_views_plugin_style extends calendar_plugin_style {
 
     for ($i = 0; $i < 7; $i++) {
       $curday_date = date_format($this->curday, DATE_FORMAT_DATE);
-      $class = strtolower($weekdays[$i] .
-         ($this->view->style_plugin->date_info->mini ? ' mini' : ''));
+      $class = drupal_strtolower($weekdays[$i] .
+        ($this->view->style_plugin->date_info->mini ? ' mini' : ''));
 //   if ($check_month && ($curday_date < $view->date_info->min_date_date || $curday_date > $view->date_info->max_date_date || date_format($curday, 'n') != $month)) {
       if ($check_month && ($curday_date < $this->date_info->min_date_date || $curday_date > $this->date_info->max_date_date || date_format($this->curday, 'n') != $month)) {
-
-        $class = strtolower($weekdays[$i]) . ' empty';
+        $class = drupal_strtolower($weekdays[$i]) . ' empty';
         $singleday_buckets[$i][][] = array(
           'entry' => theme('agres_views_empty_day', array(
             'curday' => $curday_date,
@@ -448,9 +444,9 @@ class agres_views_plugin_style extends calendar_plugin_style {
       else {
         $content = $this->agres_views_build_day();
         $class .= ($curday_date == $today ? ' today' : '') .
-        ($curday_date < $today ? ' past' : '') .
-        ($curday_date > $today ? ' future' : '') .
-        (empty($items[$curday_date]) ? ' has-no-events' : ' has-events');
+          ($curday_date < $today ? ' past' : '') .
+          ($curday_date > $today ? ' future' : '') .
+          (empty($items[$curday_date]) ? ' has-no-events' : ' has-events');
       }
       $rows[$week][] = array(
         'data' => $content,
@@ -458,7 +454,6 @@ class agres_views_plugin_style extends calendar_plugin_style {
         'id' => $this->view->name . '-' . $curday_date,
       );
       date_modify($this->curday, '+1 day');
-
     }
     return $rows;
   }
@@ -524,10 +519,9 @@ class agres_views_plugin_style extends calendar_plugin_style {
                   if ($wday == 0 || $start_ydate == $cur_ydate || ($this->date_info->granularity == 'month' && $day_no == 1) || ($all_day && !$is_multi_day)) {
                     $cur_cnt++;
                     // Calculate the colspan for this event
-
                     // If the last day of this event exceeds the end of the current month or week,
                     // truncate the remaining days
-                    $diff =  $this->curday->difference($this->date_info->max_date, 'days');
+                    $diff = $this->curday->difference($this->date_info->max_date, 'days');
                     $remaining_days = ($this->date_info->granularity == 'month') ? min(6 - $wday, $diff) : $diff - 1;
                     // The bucket_cnt defines the colspan.  colspan = bucket_cnt + 1
                     $days = $this->curday->difference($item->date_end, 'days');
@@ -545,7 +539,7 @@ class agres_views_plugin_style extends calendar_plugin_style {
                     }
 
                     // Add continuation attributes
-                    $item->continuation =  ($item->date_start < $this->curday);
+                    $item->continuation = ($item->date_start < $this->curday);
                     $item->continues = ( $days > $bucket_cnt );
 
                     // Assign the item to the available bucket
@@ -568,7 +562,7 @@ class agres_views_plugin_style extends calendar_plugin_style {
 
                       // Fill up the preceding buckets - these are available for future
                       // events
-                      for ( $j = 0; $j < $row_diff; $j++) {
+                      for ($j = 0; $j < $row_diff; $j++) {
                         $bucket[($bucket_row_count + $j)] = array(
                           'entry' => '&nbsp;',
                           'colspan' => 1,
@@ -682,8 +676,7 @@ class agres_views_plugin_style extends calendar_plugin_style {
         'count' => $count,
         'view' => $this->view,
         'types' => $types,
-      ));
-
+        ));
     }
 
     $content = array(
@@ -701,7 +694,6 @@ class agres_views_plugin_style extends calendar_plugin_style {
     );
 //    drupal_set_message('<pre>dayday '.print_r( $content,true).'</pre>');
     return $content;
-
   }
 
   /**
@@ -709,7 +701,7 @@ class agres_views_plugin_style extends calendar_plugin_style {
    */
   function agres_views_build_mini_month() {
     $month = date_format($this->curday, 'n');
-    date_modify($this->curday, '-' . strval(date_format($this->curday, 'j') -1) . ' days');
+    date_modify($this->curday, '-' . strval(date_format($this->curday, 'j') - 1) . ' days');
     $rows = array();
     do {
       $rows = array_merge($rows, $this->agres_views_build_mini_week());
@@ -739,7 +731,7 @@ class agres_views_plugin_style extends calendar_plugin_style {
 //    drupal_set_message('<pre>agres_views_build_mini_week '.print_r($curday_date,true).'</pre>');
     for ($i = 0; $i < 7; $i++) {
       $curday_date = date_format($this->curday, DATE_FORMAT_DATE);
-      $class = strtolower($weekdays[$i] . ' mini');
+      $class = drupal_strtolower($weekdays[$i] . ' mini');
       if ($check_month && ($curday_date < $this->date_info->min_date_date || $curday_date > $this->date_info->max_date_date || date_format($this->curday, 'n') != $month)) {
         $class .= ' empty';
         $variables = array(
diff --git a/agres_views/theme/agres-views-day-overlap.tpl.php b/agres_views/theme/agres-views-day-overlap.tpl.php
index 0e88090..b12837f 100644
--- a/agres_views/theme/agres-views-day-overlap.tpl.php
+++ b/agres_views/theme/agres-views-day-overlap.tpl.php
@@ -2,7 +2,7 @@
 /**
  * @file
  * Template to display a view as a calendar day, grouped by time with overlapping items
- * 
+ *
  * @see template_preprocess_calendar_day.
  *
  * $rows: The rendered data for this day.
@@ -13,122 +13,126 @@
  * $rows['items'] - an array of timed items for the day.
  * $rows['items'][$time_period]['hour'] - the formatted hour for a time period.
  * $rows['items'][$time_period]['ampm'] - the formatted ampm value, if any for a time period.
- * $rows['items'][$time_period][$column]['values'] - An array of formatted 
+ * $rows['items'][$time_period][$column]['values'] - An array of formatted
  *   items for a time period and field column.
- * 
+ *
  * $view: The view.
  * $columns: an array of column names.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
  * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
- * 
- * The width of the columns is dynamically set using <col></col> 
+ *
+ * The width of the columns is dynamically set using <col></col>
  * based on the number of columns presented. The values passed in will
- * work to set the 'hour' column to 10% and split the remaining columns 
+ * work to set the 'hour' column to 10% and split the remaining columns
  * evenly over the remaining 90% of the table.
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
-<div class="calendar-calendar"><div class="day-view">
-<div id="multi-day-container">
-  <table class="full">
-    <tbody>
-      <tr class="holder">
-        <td class="calendar-time-holder"></td>
-        <td class="calendar-day-holder"></td>
-      </tr>
-      <tr>
-        <td class="<?php print $agenda_hour_class ?> first">
-           <span class="calendar-hour"><?php print t('All day', array(), array('context' => 'datetime')) ?></span>
-        </td>
-        <td class="calendar-agenda-items multi-day last">
-          <?php foreach ($columns as $column): ?>
-          <div class="calendar">
-            <div class="inner">
-             <?php print isset($rows['all_day'][$column]) ? implode($rows['all_day'][$column]) : '&nbsp;';?>
-            </div>
-          </div>
-          <?php endforeach; ?>   
-        </td>
-      </tr>
-    </tbody>
-  </table>
-</div>
-<div class="header-body-divider">&nbsp;</div>
-<div id="single-day-container">
-  <script>
-    try {
-  	  // Hide container while it renders...  Degrade w/o javascript support
-      jQuery('#single-day-container').css('visibility','hidden');
-    }catch(e){ 
-      // swallow 
-    }
-  </script>
-  <table class="full">
-    <tbody>
-      <tr class="holder">
-        <td class="calendar-time-holder"></td>
-        <td class="calendar-day-holder"></td>
-      </tr>
-      <tr>
-        <td class="first">
-          <?php $is_first = TRUE; ?>
-          <?php foreach ($rows['items'] as $time_cnt => $hour): ?>
-            <?php 
-              if ($time_cnt == 0) {
-                $class = 'first ';
-              }
-              elseif ($time_cnt == count($start_times) - 1) {
-                $class = 'last ';
-              }
-              else {
-                $class = '';
-              } ?>
-            <div class="<?php print $class?>calendar-agenda-hour">
-              <span class="calendar-hour"><?php print $hour['hour']; ?></span>
-              <span class="calendar-ampm"><?php print $hour['ampm']; ?></span>
-            </div>
-          <?php endforeach; ?>   
-        </td>
-        <td class="last">
-          <?php foreach ($rows['items'] as $time_cnt => $hour): ?>
-            <?php 
-              if ($time_cnt == 0) {
-                $class = 'first ';
-              }
-              elseif ($time_cnt == count($start_times) - 1) {
-                $class = 'last ';
-              }
-              else {
-                $class = '';
-              } ?>
-          <div class="<?php print $class?>calendar-agenda-items single-day">
-            <div class="half-hour">&nbsp;</div>
-            <?php if ($is_first && isset($hour['values'][$column])) :?>
-            <div class="calendar item-wrapper first_item">
-            <?php $is_first = FALSE; ?>
-            <?php else : ?>
-            <div class="calendar item-wrapper">
-            <?php endif; ?>
-              <div class="inner">
-               <?php print isset($hour['values'][$column]) ? implode($hour['values'][$column]) : '&nbsp;'; ?>
-              </div>
-            </div>
-          </div>
-          <?php endforeach; ?>   
-        </td>
-      </tr>
-    </tbody>
-  </table>
+<div class="calendar-calendar">
+  <div class="day-view">
+    <div id="multi-day-container">
+      <table class="full">
+        <tbody>
+          <tr class="holder">
+            <td class="calendar-time-holder"></td>
+            <td class="calendar-day-holder"></td>
+          </tr>
+          <tr>
+            <td class="<?php print $agenda_hour_class ?> first">
+              <span class="calendar-hour"><?php print t('All day', array(), array('context' => 'datetime')) ?></span>
+            </td>
+            <td class="calendar-agenda-items multi-day last">
+              <?php foreach ($columns as $column): ?>
+                <div class="calendar">
+                  <div class="inner">
+                    <?php print isset($rows['all_day'][$column]) ? implode($rows['all_day'][$column]) : '&nbsp;'; ?>
+                  </div>
+                </div>
+              <?php endforeach; ?>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="header-body-divider">&nbsp;</div>
+    <div id="single-day-container">
+      <script>
+        try {
+          // Hide container while it renders...  Degrade w/o javascript support
+          jQuery('#single-day-container').css('visibility','hidden');
+        }catch(e){
+          // swallow
+        }
+      </script>
+      <table class="full">
+        <tbody>
+          <tr class="holder">
+            <td class="calendar-time-holder"></td>
+            <td class="calendar-day-holder"></td>
+          </tr>
+          <tr>
+            <td class="first">
+              <?php $is_first = TRUE; ?>
+              <?php foreach ($rows['items'] as $time_cnt => $hour): ?>
+                <?php
+                if ($time_cnt == 0) {
+                  $class = 'first ';
+                }
+                elseif ($time_cnt == count($start_times) - 1) {
+                  $class = 'last ';
+                }
+                else {
+                  $class = '';
+                }
+                ?>
+                <div class="<?php print $class ?>calendar-agenda-hour">
+                  <span class="calendar-hour"><?php print $hour['hour']; ?></span>
+                  <span class="calendar-ampm"><?php print $hour['ampm']; ?></span>
+                </div>
+              <?php endforeach; ?>
+            </td>
+            <td class="last">
+              <?php foreach ($rows['items'] as $time_cnt => $hour): ?>
+                <?php
+                if ($time_cnt == 0) {
+                  $class = 'first ';
+                }
+                elseif ($time_cnt == count($start_times) - 1) {
+                  $class = 'last ';
+                }
+                else {
+                  $class = '';
+                }
+                ?>
+                <div class="<?php print $class ?>calendar-agenda-items single-day">
+                  <div class="half-hour">&nbsp;</div>
+                  <?php if ($is_first && isset($hour['values'][$column])) : ?>
+                    <div class="calendar item-wrapper first_item">
+                      <?php $is_first = FALSE; ?>
+                    <?php else : ?>
+                      <div class="calendar item-wrapper">
+                      <?php endif; ?>
+                      <div class="inner">
+                        <?php print isset($hour['values'][$column]) ? implode($hour['values'][$column]) : '&nbsp;'; ?>
+                      </div>
+                    </div>
+                  </div>
+                <?php endforeach; ?>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="single-day-footer">&nbsp;</div>
+  </div>
 </div>
-<div class="single-day-footer">&nbsp;</div>
-</div></div>
 <script>
-try {
-  // Size and position the viewport inline so there are no delays
-  calendar_resizeViewport(jQuery);
-  calendar_scrollToFirst(jQuery);
-  jQuery('#single-day-container').css('visibility','visible');
-}catch(e){ 
-  // swallow 
-}
+  try {
+    // Size and position the viewport inline so there are no delays
+    calendar_resizeViewport(jQuery);
+    calendar_scrollToFirst(jQuery);
+    jQuery('#single-day-container').css('visibility','visible');
+  }catch(e){
+    // swallow
+  }
 </script>
\ No newline at end of file
diff --git a/agres_views/theme/agres-views-day.tpl.php b/agres_views/theme/agres-views-day.tpl.php
index 11be955..a92d818 100644
--- a/agres_views/theme/agres-views-day.tpl.php
+++ b/agres_views/theme/agres-views-day.tpl.php
@@ -3,7 +3,7 @@
  * @file
  * Template to display a view as a calendar day, grouped by resources
  * and optionally organized into columns by a field value.
- * 
+ *
  * @see template_preprocess_calendar_day.
  * $resources: An Array of the rooms or resources which can be booked.
  * $resources[$name][$rows] - An array of resourcenames each containing
@@ -18,9 +18,9 @@
  * $rows['items'] - an array of timed items for the day.
  * $rows['items'][$time_period]['hour'] - the formatted hour for a time period.
  * $rows['items'][$time_period]['ampm'] - the formatted ampm value, if any for a time period.
- * $rows['items'][$time_period][$column]['values'] - An array of formatted 
+ * $rows['items'][$time_period][$column]['values'] - An array of formatted
  *   items for a time period and field column.
- * 
+ *
  * $view: The view.
  * $columns: an array of column names.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
@@ -29,103 +29,98 @@
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
-<div  class="agreservations-calendar"><div class="day-view">
-            <table class="agreservations-table">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (!isset($currentcategory)) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedday);?>"><?php print (t('show all categories')); ?></a>
-                </th>
-                <?php foreach ($categories as $category): ?>
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (isset($currentcategory)&&$currentcategory==$category->nid) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedday."/".$category->nid);?>"><?php print ($category->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>
-        <table class="agreservations-table">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (!isset($currentunittype)) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedday);?>"><?php print (t('show all units')); ?></a>
-                </th>
-                <?php foreach ($unittypes as $unittype): ?>
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (isset($currentunittype)&&$currentunittype==$unittype->nid) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedday."/".$unittype->nid);?>"><?php print ($unittype->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>
-        <table class="agreservations-table">
-              <colgroup>
-            <col width=70>
-            <col width="20">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-            <col width="15">
-             <col width="15">
-             
-          </colgroup>
-
-            <tbody>
-                <?php foreach ($units as $unit): ?>
-                <tr>
-                    <th class="agreservations-calendar-agenda-hour">
-                    </th>
-                        <?php foreach ($rows['items'][$unit->title] as $hour): ?>
-                    <th class="agreservations-calendar-agenda-hour">
-                        <span class="agreservations-calendar-hour"><?php print $hour['hour']; ?></span>
-                        <span <?php print $hour['ampm']; ?></span>
-                    </th>
-                        <?php endforeach; ?>
-                <tr>
-                    <td class="agreservations-calendar unitname"><a href="<?php print(base_path());?>node/<?php print $unit->nid ?>"><?php print $unit->title  ?></a>
+<div  class="agreservations-calendar">
+  <div class="day-view">
+    <table class="agreservations-table">
+      <tr class="agreservations-calendar">
+        <th class="agreservations-calendar th categories">
+          <a class="<?php print (!isset($currentcategory)) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedday); ?>"><?php print (t('show all categories')); ?></a>
+        </th>
+        <?php foreach ($categories as $category): ?>
+          <th class="agreservations-calendar th categories">
+            <a class="<?php print (isset($currentcategory) && $currentcategory == $category->nid) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedday . "/" . $category->nid); ?>"><?php print ($category->title); ?></a>
+          </th>
+        <?php endforeach; ?>
+      </tr>
+    </table>
+    <table class="agreservations-table">
+      <tr class="agreservations-calendar">
+        <th class="agreservations-calendar th unittypes">
+          <a class="<?php print (!isset($currentunittype)) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedday); ?>"><?php print (t('show all units')); ?></a>
+        </th>
+        <?php foreach ($unittypes as $unittype): ?>
+          <th class="agreservations-calendar th unittypes">
+            <a class="<?php print (isset($currentunittype) && $currentunittype == $unittype->nid) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedday . "/" . $unittype->nid); ?>"><?php print ($unittype->title); ?></a>
+          </th>
+        <?php endforeach; ?>
+      </tr>
+    </table>
+    <table class="agreservations-table">
+      <colgroup>
+        <col width=70>
+        <col width="20">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+        <col width="15">
+      </colgroup>
+      <tbody>
+        <?php foreach ($units as $unit): ?>
+          <tr>
+            <th class="agreservations-calendar-agenda-hour">
+            </th>
+            <?php foreach ($rows['items'][$unit->title] as $hour): ?>
+              <th class="agreservations-calendar-agenda-hour">
+                <span class="agreservations-calendar-hour"><?php print $hour['hour']; ?></span>
+                <span <?php print $hour['ampm']; ?></span>
+              </th>
+            <?php endforeach; ?>
+          <tr>
+            <td class="agreservations-calendar unitname"><a href="<?php print(base_path()); ?>node/<?php print $unit->nid ?>"><?php print $unit->title ?></a>
+            </td>
+            <?php foreach ($rows['items'][$unit->title] as $hour): ?>
+              <?php foreach ($columns as $column): ?>
+                <?php if (isset($hour['values'])) : ?>
+                  <?php if (($hour['values'][$column] != '***busy***')) : ?>
+                    <td class="agreservations-agenda-items <?php print ($hour['values'][$column]) ? 'calendar-has-item' : ''; ?>" <?php print isset($hour['span'][$column]) ? "colspan=" . $hour['span'][$column] : ""; ?> >
+                      <div class="agreservations-calendar">
+                        <?php if (isset($hour['values'][$column])) : ?>
+                          <?php print isset($hour['values'][$column]) ? $hour['values'][$column] : '&nbsp;'; ?>
+                        <?php endif; ?>
+                        <?php if (!isset($hour['values'][$column])) : ?>
+                          <a href="<?php print(base_path()); ?>node/add/agreservation?&agres_sel_unit=<?php print $unit->nid ?>&default_agres_title=Reservation&default_agres_date=<?php print $currentselectedday ?> <?php print $hour['hour']; ?>">+</a>
+                        <?php endif; ?>
+                      </div>
                     </td>
-
-                        <?php foreach ($rows['items'][$unit->title] as $hour): ?>
-                            <?php foreach ($columns as $column): ?>
-                     <?php if(isset($hour['values'])) : ?>
-                                <?php if(($hour['values'][$column] != '***busy***')) : ?>
-                    <td class="agreservations-agenda-items <?php print ($hour['values'][$column])?'calendar-has-item':'';  ?>" <?php print isset($hour['span'][$column]) ? "colspan=".$hour['span'][$column] : ""; ?> >
-                        <div class="agreservations-calendar">
-<!--                            <div class="agreservations-inner">-->
-                                                <?php if(isset($hour['values'][$column])) : ?>
-                                                    <?php print isset($hour['values'][$column]) ? $hour['values'][$column] : '&nbsp;'; ?>
-                                                <?php endif; ?>
-                                                <?php if(!isset($hour['values'][$column])) : ?>
-                              <a href="<?php print(base_path());?>node/add/agreservation?&agres_sel_unit=<?php print $unit->nid ?>&default_agres_title=Reservation&default_agres_date=<?php print $currentselectedday?> <?php print $hour['hour']; ?>">+</a>
-                                
-                                                <?php endif; ?>
-<!--                            </div>-->
-                        </div>
-                    </td>
-                                <?php endif ?>
-                    <?php else: ?>
-                     <td class="agreservations-agenda-items">
-                     </td>                    
-                    <?php endif ?>
-                            <?php endforeach; ?>
-                        <?php endforeach; ?>
-                    <?php endforeach; ?>
-
-                </tr>
-            </tbody>
-        </table>
-    </div></div>
\ No newline at end of file
+                  <?php endif ?>
+                <?php else: ?>
+                  <td class="agreservations-agenda-items">
+                  </td>
+                <?php endif ?>
+              <?php endforeach; ?>
+            <?php endforeach; ?>
+          <?php endforeach; ?>
+        </tr>
+      </tbody>
+    </table>
+  </div>
+</div>
\ No newline at end of file
diff --git a/agres_views/theme/agres-views-item.tpl.php b/agres_views/theme/agres-views-item.tpl.php
index 156051a..aa3dcea 100644
--- a/agres_views/theme/agres-views-item.tpl.php
+++ b/agres_views/theme/agres-views-item.tpl.php
@@ -1,7 +1,7 @@
 <?php
 /**
  * @file
- *originally the calendar-item.tpl.php rewritten to display
+ * originally the calendar-item.tpl.php rewritten to display
  * agreservations in a booking calendar showing a matrix of rooms/resources
  * and days / times.
  */
@@ -9,23 +9,21 @@ $index = 0;
 ?>
 <div class="<?php print !empty($item->class) ? $item->class : 'item'; ?>">
   <div class="view-item view-item-<?php print $view->name ?>">
-  <div class="<?php print !empty($itemclass) ? $itemclass : 'agreservations-inner'; ?> <?php print $item->granularity; ?>view">
-    <?php print theme('agres_views_stripe_stripe', array('item' => $item)); ?>
-    <div class="agres_item contents">
-               <?php if (isset($continuation) && $continuation == 1) : ?>
-             <span style="text-align:left">&laquo;&nbsp;&nbsp;&nbsp;</span>
-        <?php endif;?>
-      <?php foreach ($rendered_fields as $field): ?>
-        <?php print $field; ?>
-      <?php endforeach; ?>
-    <?php if (isset($continues) && $continues == 1) : ?>
-             
-             <span style="text-align:right">&nbsp;&nbsp;&nbsp;&raquo;</span>    
-    <?php else : ?>
-    &nbsp;
-    <?php endif;?>        
-    </div>  
-
-  </div> 
-  </div>   
+    <div class="<?php print !empty($itemclass) ? $itemclass : 'agreservations-inner'; ?> <?php print $item->granularity; ?>view">
+      <?php print theme('agres_views_stripe_stripe', array('item' => $item)); ?>
+      <div class="agres_item contents">
+        <?php if (isset($continuation) && $continuation == 1) : ?>
+          <span style="text-align:left">&laquo;&nbsp;&nbsp;&nbsp;</span>
+        <?php endif; ?>
+        <?php foreach ($rendered_fields as $field): ?>
+          <?php print $field; ?>
+        <?php endforeach; ?>
+        <?php if (isset($continues) && $continues == 1) : ?>
+          <span style="text-align:right">&nbsp;&nbsp;&nbsp;&raquo;</span>
+        <?php else : ?>
+          &nbsp;
+        <?php endif; ?>
+      </div>
+    </div>
+  </div>
 </div>
\ No newline at end of file
diff --git a/agres_views/theme/agres-views-mini.tpl.php b/agres_views/theme/agres-views-mini.tpl.php
index f95f665..9bef69b 100644
--- a/agres_views/theme/agres-views-mini.tpl.php
+++ b/agres_views/theme/agres-views-mini.tpl.php
@@ -2,7 +2,7 @@
 /**
  * @file
  * Template to display a view as a mini calendar month.
- * 
+ *
  * @see template_preprocess_calendar_mini.
  *
  * $day_names: An array of the day of week names for the table header.
@@ -10,10 +10,10 @@
  * $view: The view.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
  * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
- * 
+ *
  * $show_title: If the title should be displayed. Normally false since the title is incorporated
  *   into the navigation, but sometimes needed, like in the year view of mini calendars.
- * 
+ *
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);dsm($day_names);
 $params = array(
@@ -22,38 +22,38 @@ $params = array(
   'link' => FALSE,
 );
 ?>
-<div class="calendar-calendar"><div class="month-view">
-<?php if ($show_title): ?>
-<div class="date-nav-wrapper clear-block">
-  <div class="date-nav">
-    <div class="date-heading">
-      <?php print theme('date_nav_title', $params) ?>
-    </div>
-  </div>
-</div> 
-<?php endif; ?> 
-<table class="mini">
-  <thead>
-    <tr>
-      <?php foreach ($day_names as $cell): ?>
-        <th class="<?php print $cell['class']; ?>">
-          <?php print $cell['data']; ?>
-        </th>
-      <?php endforeach; ?>
-    </tr>
-  </thead>
-  <tbody>
-    <?php foreach ((array) $rows as $row): ?>
-      
-      <tr>
-        <?php foreach ($row as $cell): ?>
-          <td id="<?php print $cell['id']; ?>" class="<?php print $cell['class']; ?>">
-<!--              <pre> <?php print_r($cell) ?> </pre>-->
-            <?php print $cell['data']['datebox']; ?>
-          </td>
+<div class="calendar-calendar">
+  <div class="month-view">
+    <?php if ($show_title): ?>
+      <div class="date-nav-wrapper clear-block">
+        <div class="date-nav">
+          <div class="date-heading">
+            <?php print theme('date_nav_title', $params) ?>
+          </div>
+        </div>
+      </div>
+    <?php endif; ?>
+    <table class="mini">
+      <thead>
+        <tr>
+          <?php foreach ($day_names as $cell): ?>
+            <th class="<?php print $cell['class']; ?>">
+              <?php print $cell['data']; ?>
+            </th>
+          <?php endforeach; ?>
+        </tr>
+      </thead>
+      <tbody>
+        <?php foreach ((array) $rows as $row): ?>
+          <tr>
+            <?php foreach ($row as $cell): ?>
+              <td id="<?php print $cell['id']; ?>" class="<?php print $cell['class']; ?>">
+                <?php print $cell['data']['datebox']; ?>
+              </td>
+            <?php endforeach; ?>
+          </tr>
         <?php endforeach; ?>
-      </tr>
-    <?php endforeach; ?>
-  </tbody>
-</table>
-</div></div>
\ No newline at end of file
+      </tbody>
+    </table>
+  </div>
+</div>
\ No newline at end of file
diff --git a/agres_views/theme/agres-views-month.tpl.php b/agres_views/theme/agres-views-month.tpl.php
index 6651188..ac2e061 100644
--- a/agres_views/theme/agres-views-month.tpl.php
+++ b/agres_views/theme/agres-views-month.tpl.php
@@ -2,9 +2,9 @@
 /**
  * @file
  * Template to display a view as a calendar month.
- * 
+ *
  * @see template_preprocess_calendar_month.
- * agdaysresitems agreservations 
+ * agdaysresitems agreservations
  * $day_names: An array of the day of week names for the table header.
  * $rows: An array of data for each day of the week.
  * $view: The view.
@@ -13,109 +13,79 @@
  * $block: Whether or not this calendar is in a block.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
  * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
- * $date_id: a css id that is unique for this date, 
+ * $date_id: a css id that is unique for this date,
  *   it is in the form: calendar-nid-field_name-delta
- * 
+ *
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
 <div class="agreservations-calendar"><div class="month-view">
-        <?php if (module_exists('agres_categories')): ?>
-      
-        <table class="agreservations-table" style="float:left; text-align: left;">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (!isset($currentcategory)) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedmonth);?>"><?php print (t('show all categories')); ?></a>
-                </th>
-                <?php foreach ($categories as $category): ?>
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (isset($currentcategory)&&$currentcategory==$category->nid) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedmonth."/".$category->nid);?>"><?php print ($category->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>
-        <?php endif; ?>  
-        <table class="agreservations-table">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (!isset($currentunittype)) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedmonth."/".$currentcategory);?>"><?php print (t('show all units')); ?></a>
-                </th>
-                <?php foreach ($unittypes as $unittype): ?>
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (isset($currentunittype)&&$currentunittype==$unittype->nid) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedmonth."/".$currentcategory."/".$unittype->nid);?>"><?php print ($unittype->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>    
-<table class="agreservations-table"  style="table-layout:fixed">
+    <?php if (module_exists('agres_categories')): ?>
+      <table class="agreservations-table" style="float:left; text-align: left;">
+        <tr class="agreservations-calendar">
+          <th class="agreservations-calendar th categories">
+            <a class="<?php print (!isset($currentcategory)) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedmonth); ?>"><?php print (t('show all categories')); ?></a>
+          </th>
+          <?php foreach ($categories as $category): ?>
+            <th class="agreservations-calendar th categories">
+              <a class="<?php print (isset($currentcategory) && $currentcategory == $category->nid) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedmonth . "/" . $category->nid); ?>"><?php print ($category->title); ?></a>
+            </th>
+          <?php endforeach; ?>
+        </tr>
+      </table>
+    <?php endif; ?>
+    <table class="agreservations-table">
+      <tr class="agreservations-calendar">
+        <th class="agreservations-calendar th unittypes">
+          <a class="<?php print (!isset($currentunittype)) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedmonth . "/" . $currentcategory); ?>"><?php print (t('show all units')); ?></a>
+        </th>
+        <?php foreach ($unittypes as $unittype): ?>
+          <th class="agreservations-calendar th unittypes">
+            <a class="<?php print (isset($currentunittype) && $currentunittype == $unittype->nid) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedmonth . "/" . $currentcategory . "/" . $unittype->nid); ?>"><?php print ($unittype->title); ?></a>
+          </th>
+        <?php endforeach; ?>
+      </tr>
+    </table>
+    <table class="agreservations-table"  style="table-layout:fixed">
       <colgroup>
         <col width="10">
-        <?php for ($i = 1; $i <= $daynumber; $i++): ?> 
-           <col width="4">
-        <?php endfor; ?>    
-    </colgroup>
-<!--  <thead>
-    <tr>
-      <?php foreach ($day_names as $cell): ?>
-        <th class="<?php print $cell['class']; ?>">
-          <?php print $cell['data']; ?>
-        </th>
-      <?php endforeach; ?>
-    </tr>
-  </thead>
-  <tbody>   -->
-   
-  <?php foreach ((array) $units as $unit): ?>
+        <?php for ($i = 1; $i <= $daynumber; $i++): ?>
+          <col width="4">
+        <?php endfor; ?>
+      </colgroup>
+      <?php foreach ((array) $units as $unit): ?>
+        <tr>
+          <td class="agreservations-calendar unitname" rowspan="2" style="width:40px;">
+            <a href="<?php print(base_path()); ?>node/<?php print $unit->nid ?>"><?php print $unit->title ?></a>
+          </td>
+          <?php foreach ((array) $agmonth_rows[$unit->title] as $roomrow): ?>
+            <?php if (!empty($roomrow['datebox'])) : ?>
+              <td>
+                <?php print($roomrow['datebox']); ?>
+              </td>
+            <?php endif; ?>
+          <?php endforeach; ?>
+        <tr>
+          <?php foreach ((array) $agmonth_rows[$unit->title] as $roomrow): ?>
+            <?php if (!empty($roomrow['datebox'])) : ?>
+              <?php if (!empty($roomrow['data'])) : ?>
+                <?php foreach ((array) $roomrow['data'] as $key => $roomrowres): ?>
+                  <?php if ($roomrowres !== '***busy***') : ?>
+                    <td  <?php print isset($agmonth_rows[$unit->title]['spaninfo'][$key]) ? "colspan=" . '"' . $agmonth_rows[$unit->title]['spaninfo'][$key] . '"' : "5"; ?>>
+                      <?php print($roomrowres); ?>
+                    </td>
+                  <?php endif; ?>
+                <?php endforeach; ?>
+              <?php else: ?>
+                <td >
+                  <a href="<?php print(base_path() . rawurldecode('node/add/agreservation?&agres_sel_unit=' . $unit->nid . '&default_agres_title=Reservation&default_agres_date=' . $roomrow['date'] . ' 14:00')); ?>"> +</a>
+                </td>
+              <?php endif; ?>
+            <?php endif; ?>
+          <?php endforeach; ?>
+        </tr>
         <tr>
-                    <td class="agreservations-calendar unitname" rowspan="2" style="width:40px;">
-                        <a href="<?php print(base_path());?>node/<?php print $unit->nid ?>"><?php print $unit->title  ?></a>                  
-                    </td>                      
-      <?php foreach ((array) $agmonth_rows[$unit->title] as $roomrow): ?>
-                     <?php if (!empty($roomrow['datebox'])) : ?>
-                    <td>                     
-                     <?php print($roomrow['datebox']);?>
-                    </td> 
-                     <?php endif; ?>  
-      <?php endforeach; ?>
-        <tr>  
-    <?php foreach ((array) $agmonth_rows[$unit->title] as $roomrow): ?>          
-          <?php if (!empty($roomrow['datebox'])) : ?>         
-                               <?php if (!empty($roomrow['data'])) : ?>
-                                 <?php foreach ((array) $roomrow['data'] as $key => $roomrowres): ?>          
-                                     <?php if ($roomrowres!=='***busy***') : ?>                                
-                                       <td  <?php print isset($agmonth_rows[$unit->title]['spaninfo'][$key]) ? "colspan=".'"'.$agmonth_rows[$unit->title]['spaninfo'][$key].'"' : "5"; ?>>
-<!--                                         <div class="agreservations-inner">-->
-                                            <?php print($roomrowres); ?>
-<!--                                         </div>-->
-                                        </td>
-                                     <?php endif; ?>
-                                 <?php endforeach; ?>                                                     
-                               <?php else: ?>
-                                 <td >
-                                   <a href="<?php print(base_path().rawurldecode('node/add/agreservation?&agres_sel_unit='.$unit->nid.'&default_agres_title=Reservation&default_agres_date='.$roomrow['date'].' 14:00'));?>"> +</a>                                
-                                 </td>
-                               <?php endif; ?>
-          <?php endif; ?> 
-    <?php endforeach; ?>
-            </tr>
-            <tr>
- <?php endforeach; ?>
-<!--  </tbody>-->
-</table>
-</div></div>
-<!--<script>
-try {
-  // ie hack to make the single day row expand to available space
-  if ($.browser.msie ) {
-    var multiday_height = $('tr.multi-day')[0].clientHeight; // Height of a multi-day row
-    $('tr[iehint]').each(function(index) {
-      var iehint = this.getAttribute('iehint');
-      // Add height of the multi day rows to the single day row - seems that 80% height works best
-      var height = this.clientHeight + (multiday_height * .8 * iehint); 
-      this.style.height = height + 'px';
-    });
-  }
-}catch(e){
-  // swallow 
-}
-</script>-->
\ No newline at end of file
+        <?php endforeach; ?>
+    </table>
+  </div>
+</div>
\ No newline at end of file
diff --git a/agres_views/theme/agres-views-row-node.tpl.php b/agres_views/theme/agres-views-row-node.tpl.php
index 0479cf2..255581d 100644
--- a/agres_views/theme/agres-views-row-node.tpl.php
+++ b/agres_views/theme/agres-views-row-node.tpl.php
@@ -2,17 +2,17 @@
 /**
  * @file
  * Template to display a view item as a calendar month node.
- * 
- * $node 
+ *
+ * $node
  *   A node object for this calendar item. Note this is
  *   not a complete node object, but it will have $node->nid
  *   that you can use to load the full object, and
  *   $node->type to tell the content type of the node.
- * 
+ *
  * $fields
  *   An array of information for every field selected in the 'Fields'
  *   section of this view, formatted as requested in the View setup.
- * 
+ *
  * Calendar info for this individual calendar item is in local time --
  * the user timezone where configurable timezones are allowed and set,
  * otherwise the site timezone. If this item has extends over more than
@@ -20,20 +20,20 @@
  * date and calendar_start will be no earlier than the start of
  * the current day and calendar_end will be no later than the end
  * of the current day.
- * 
+ *
  * $calendar_start - A formatted datetime start date for this item.
  *   i.e. '2008-05-12 05:26:15'.
  * $calendar_end - A formatted datetime end date for this item,
  *   the same as the start date except for fields that have from/to
- *   fields defined, like Date module dates. 
+ *   fields defined, like Date module dates.
  * $calendar_start_date - a PHP date object for the start time.
  * $calendar_end_date - a PHP date object for the end time.
- * 
+ *
  * You can use PHP date functions on the date object to display date
  * information in other ways, like:
- * 
+ *
  *   print date_format($calendar_start_date, 'l, j F Y - g:ia');
- * 
+ *
  * @see template_preprocess_calendar_row_node.
  */
 ?>
@@ -41,5 +41,5 @@
   <div class="<?php print $item->class; ?>">
     <?php print theme('calendar_stripe_stripe', array('node' => $item)); ?>
     <?php print $item->body; ?>
-  </div>    
+  </div>
 </div>
\ No newline at end of file
diff --git a/agres_views/theme/agres-views-style.tpl.php b/agres_views/theme/agres-views-style.tpl.php
index bdc4e8f..67c94a5 100644
--- a/agres_views/theme/agres-views-style.tpl.php
+++ b/agres_views/theme/agres-views-style.tpl.php
@@ -1 +1,2 @@
-<?php  ?>
\ No newline at end of file
+<?php
+?>
\ No newline at end of file
diff --git a/agres_views/theme/agres-views-week-overlap.tpl.php b/agres_views/theme/agres-views-week-overlap.tpl.php
index bd00106..a3e1ce0 100644
--- a/agres_views/theme/agres-views-week-overlap.tpl.php
+++ b/agres_views/theme/agres-views-week-overlap.tpl.php
@@ -2,12 +2,12 @@
 /**
  * @file
  * Template to display a view as a calendar week with overlapping items
- * 
+ *
  * @see template_preprocess_calendar_week.
  *
  * $day_names: An array of the day of week names for the table header.
  * $rows: The rendered data for this week.
- * 
+ *
  * For each day of the week, you have:
  * $rows['date'] - the date for this day, formatted as YYYY-MM-DD.
  * $rows['datebox'] - the formatted datebox for this day.
@@ -17,216 +17,219 @@
  * $rows['items'][$time_period]['hour'] - the formatted hour for a time period.
  * $rows['items'][$time_period]['ampm'] - the formatted ampm value, if any for a time period.
  * $rows['items'][$time_period]['values'] - An array of formatted items for a time period.
- * 
+ *
  * $view: The view.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
  * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
- * 
+ *
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
 
-<div class="calendar-calendar"><div class="week-view">
-  <div id="header-container">
-  <table class="full">
-  <tbody>
-    <tr class="holder"><td class="calendar-time-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder margin-right"></td></tr>
-    <tr>
-      <th class="calendar-agenda-hour">&nbsp;</th>
-      <?php foreach ($day_names as $cell): ?>
-        <th class="<?php print $cell['class']; ?>">
-          <?php print $cell['data']; ?>
-        </th>
-      <?php endforeach; ?>
-      <th class="calendar-day-holder margin-right"></th>
-    </tr>
-  </tbody>
-  </table>
-  </div>
-  <div id="multi-day-container">
-  <table class="full">
-  <tbody>
-  <tr class="holder"><td class="calendar-time-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td></tr>
-    <?php for ($i = 0; $i < $multiday_rows; $i++): ?>
-    <?php 
-      $colpos = 0; 
-      $rowclass = "all-day";
-      if ($i == 0) {
-        $rowclass .= " first";
-      }
-      if ($i == $multiday_rows - 1) {
-        $rowclass .= " last";
-      }
-    ?>
-    <tr class="<?php print $rowclass?>">
-      <?php if($i == 0 && ($by_hour_count > 0 || !empty($start_times))) :?>
-      <td class="<?php print $agenda_hour_class ?>" rowspan="<?php print $multiday_rows?>">
-        <span class="calendar-hour"><?php print t('All day', array(), array('context' => 'datetime'))?></span>
-      </td>
-      <?php endif; ?>
-      <?php for($j = 0; $j < 7; $j++): ?>
-        <?php $cell = (empty($all_day[$j][$i])) ? NULL : $all_day[$j][$i]; ?>
-        <?php if($cell != NULL && $cell['filled'] && $cell['wday'] == $j): ?>
-          <?php for($colpos; $colpos < $cell['wday']; $colpos++) : ?>
-          <?php 
-            $colclass = "calendar-agenda-items multi-day";
-            if ($colpos == 0) {
-              $colclass .= " first";
-            }
-            if ($colpos == 6) {
-              $colclass .= " last";
+<div class="calendar-calendar">
+  <div class="week-view">
+    <div id="header-container">
+      <table class="full">
+        <tbody>
+          <tr class="holder"><td class="calendar-time-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder margin-right"></td></tr>
+          <tr>
+            <th class="calendar-agenda-hour">&nbsp;</th>
+            <?php foreach ($day_names as $cell): ?>
+              <th class="<?php print $cell['class']; ?>">
+                <?php print $cell['data']; ?>
+              </th>
+            <?php endforeach; ?>
+            <th class="calendar-day-holder margin-right"></th>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div id="multi-day-container">
+      <table class="full">
+        <tbody>
+          <tr class="holder"><td class="calendar-time-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td></tr>
+          <?php for ($i = 0; $i < $multiday_rows; $i++): ?>
+            <?php
+            $colpos = 0;
+            $rowclass = "all-day";
+            if ($i == 0) {
+              $rowclass .= " first";
             }
-          ?>
-          <td class="<?php print $colclass?>"><div class="inner">&nbsp;</div></td>
-          <?php endfor;?>
-          <?php 
-            $colclass = "calendar-agenda-items multi-day";
-            if ($colpos == 0) {
-              $colclass .= " first";
+            if ($i == $multiday_rows - 1) {
+              $rowclass .= " last";
             }
-            if ($colpos == 6) {
-              $colclass .= " last";
-            }
-          ?>
-          <td colspan="<?php print $cell['colspan']?>" class="<?php print $colclass?>">
-            <div class="inner">
-            <?php print $cell['entry']?>
-            </div>
-          </td>
-          <?php $colpos += $cell['colspan']; ?>
-        <?php endif; ?>
-      <?php endfor; ?>  
-      <?php while($colpos < 7) : ?>
-      <?php 
-        $colclass = "calendar-agenda-items multi-day no-entry";
-        if ($colpos == 0) {
-          $colclass .= " first";
-        }
-        if ($colpos == 6) {
-          $colclass .= " last";
-        }
-      ?>
-      <td class="<?php print $colclass?>"><div class="inner">&nbsp;</div></td>
-      <?php $colpos++; ?>
-      <?php endwhile;?>
-    </tr>
-    <?php endfor; ?>
-    <?php if ($multiday_rows == 0) :?>
-    <tr>
-      <td class="<?php print $agenda_hour_class ?>">
-        <span class="calendar-hour"><?php print t('All day', array(), array('context' => 'datetime'))?></span>
-      </td>
-      <?php for($j = 0; $j < 7; $j++): ?>
-      <?php 
-        $colclass = "calendar-agenda-items multi-day no-entry";
-        if ($j == 0) {
-          $colclass .= " first";
-        }
-        if ($j == 6) {
-          $colclass .= " last";
-        }
-      ?>
-      <td class="<?php print $colclass?>"><div class="inner">&nbsp;</div></td>
-      <?php endfor; ?>
-    </tr>
-    <?php endif; ?>
-    <tr class="expand">
-      <td class="<?php print $agenda_hour_class ?>">
-        <span class="calendar-hour">&nbsp;</span>
-      </td>
-      <?php for($j = 0; $j < 7; $j++): ?>
-      <?php 
-        $colclass = "calendar-agenda-items multi-day no-entry";
-        if ($j == 0) {
-          $colclass .= " first";
-        }
-        if ($j == 6) {
-          $colclass .= " last";
-        }
-      ?>
-      <td class="<?php print $colclass?>"><div class="inner">&nbsp;</div></td>
-      <?php endfor; ?>
-     </tr>
-  </thead> 
-  </table>
-  </div>
-  <div class="header-body-divider">&nbsp;</div>
-  <div id="single-day-container">
-    <script>
-      try {
-        // Hide container while it renders...  Degrade w/o javascript support
-        jQuery('#single-day-container').css('visibility','hidden');
-      }catch(e){ 
-        // swallow 
-      }
-    </script>
-    <table class="full">
-      <tbody>
-        <tr class="holder"><td class="calendar-time-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td></tr>
-        <tr>
-          <?php for ($index = 0; $index < 8; $index++): ?>
-          <?php if ($index == 0 ): ?>
-          <td class="first">
-          <?php elseif ($index == 7 ) : ?>
-          <td class="last">
-          <?php else : ?>
-          <td>
-          <?php endif; ?>
-            <?php foreach ($start_times as $time_cnt => $start_time): ?>
-              <?php 
-                if ($time_cnt == 0) {
-                  $class = 'first ';
+            ?>
+            <tr class="<?php print $rowclass ?>">
+              <?php if ($i == 0 && ($by_hour_count > 0 || !empty($start_times))) : ?>
+                <td class="<?php print $agenda_hour_class ?>" rowspan="<?php print $multiday_rows ?>">
+                  <span class="calendar-hour"><?php print t('All day', array(), array('context' => 'datetime')) ?></span>
+                </td>
+              <?php endif; ?>
+              <?php for ($j = 0; $j < 7; $j++): ?>
+                <?php $cell = (empty($all_day[$j][$i])) ? NULL : $all_day[$j][$i]; ?>
+                <?php if ($cell != NULL && $cell['filled'] && $cell['wday'] == $j): ?>
+                  <?php for ($colpos; $colpos < $cell['wday']; $colpos++) : ?>
+                    <?php
+                    $colclass = "calendar-agenda-items multi-day";
+                    if ($colpos == 0) {
+                      $colclass .= " first";
+                    }
+                    if ($colpos == 6) {
+                      $colclass .= " last";
+                    }
+                    ?>
+                    <td class="<?php print $colclass ?>"><div class="inner">&nbsp;</div></td>
+                  <?php endfor; ?>
+                  <?php
+                  $colclass = "calendar-agenda-items multi-day";
+                  if ($colpos == 0) {
+                    $colclass .= " first";
+                  }
+                  if ($colpos == 6) {
+                    $colclass .= " last";
+                  }
+                  ?>
+                  <td colspan="<?php print $cell['colspan'] ?>" class="<?php print $colclass ?>">
+                    <div class="inner">
+                      <?php print $cell['entry'] ?>
+                    </div>
+                  </td>
+                  <?php $colpos += $cell['colspan']; ?>
+                <?php endif; ?>
+              <?php endfor; ?>
+              <?php while ($colpos < 7) : ?>
+                <?php
+                $colclass = "calendar-agenda-items multi-day no-entry";
+                if ($colpos == 0) {
+                  $colclass .= " first";
                 }
-                elseif ($time_cnt == count($start_times) - 1) {
-                  $class = 'last ';
+                if ($colpos == 6) {
+                  $colclass .= " last";
                 }
-                else {
-                  $class = '';
-                } ?>
-              <?php if( $index == 0 ): ?>
-              <?php $time = $items[$start_time];?>
-              <div class="<?php print $class?>calendar-agenda-hour">
-                <span class="calendar-hour"><?php print $time['hour']; ?></span>
-                <span class="calendar-ampm"><?php print $time['ampm']; ?></span>
-              </div>
-              <?php else: ?>
-              <div class="<?php print $class?>calendar-agenda-items single-day">
-                <div class="half-hour">&nbsp;</div>
-                <div class="calendar item-wrapper">
-                  <div class="inner">
-                    <?php if(!empty($items[$start_time]['values'][$index - 1])) :?>
-                      <?php foreach($items[$start_time]['values'][$index - 1] as $item) :?>
-                        <?php if (isset($item['is_first']) && $item['is_first']) :?>
-                        <div class="item <?php print $item['class']?> first_item">
-                        <?php else : ?>
-                        <div class="item <?php print $item['class']?>">
-                        <?php endif; ?>
-                        <?php print $item['entry'] ?>
+                ?>
+                <td class="<?php print $colclass ?>"><div class="inner">&nbsp;</div></td>
+                <?php $colpos++; ?>
+              <?php endwhile; ?>
+            </tr>
+          <?php endfor; ?>
+          <?php if ($multiday_rows == 0) : ?>
+            <tr>
+              <td class="<?php print $agenda_hour_class ?>">
+                <span class="calendar-hour"><?php print t('All day', array(), array('context' => 'datetime')) ?></span>
+              </td>
+              <?php for ($j = 0; $j < 7; $j++): ?>
+                <?php
+                $colclass = "calendar-agenda-items multi-day no-entry";
+                if ($j == 0) {
+                  $colclass .= " first";
+                }
+                if ($j == 6) {
+                  $colclass .= " last";
+                }
+                ?>
+                <td class="<?php print $colclass ?>"><div class="inner">&nbsp;</div></td>
+              <?php endfor; ?>
+            </tr>
+          <?php endif; ?>
+          <tr class="expand">
+            <td class="<?php print $agenda_hour_class ?>">
+              <span class="calendar-hour">&nbsp;</span>
+            </td>
+            <?php for ($j = 0; $j < 7; $j++): ?>
+              <?php
+              $colclass = "calendar-agenda-items multi-day no-entry";
+              if ($j == 0) {
+                $colclass .= " first";
+              }
+              if ($j == 6) {
+                $colclass .= " last";
+              }
+              ?>
+              <td class="<?php print $colclass ?>"><div class="inner">&nbsp;</div></td>
+            <?php endfor; ?>
+          </tr>
+          </thead>
+      </table>
+    </div>
+    <div class="header-body-divider">&nbsp;</div>
+    <div id="single-day-container">
+      <script>
+        try {
+          // Hide container while it renders...  Degrade w/o javascript support
+          jQuery('#single-day-container').css('visibility','hidden');
+        }catch(e){
+          // swallow
+        }
+      </script>
+      <table class="full">
+        <tbody>
+          <tr class="holder"><td class="calendar-time-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td><td class="calendar-day-holder"></td></tr>
+          <tr>
+            <?php for ($index = 0; $index < 8; $index++): ?>
+              <?php if ($index == 0): ?>
+                <td class="first">
+                <?php elseif ($index == 7) : ?>
+                <td class="last">
+                <?php else : ?>
+                <td>
+                <?php endif; ?>
+                <?php foreach ($start_times as $time_cnt => $start_time): ?>
+                  <?php
+                  if ($time_cnt == 0) {
+                    $class = 'first ';
+                  }
+                  elseif ($time_cnt == count($start_times) - 1) {
+                    $class = 'last ';
+                  }
+                  else {
+                    $class = '';
+                  }
+                  ?>
+                  <?php if ($index == 0): ?>
+                    <?php $time = $items[$start_time]; ?>
+                    <div class="<?php print $class ?>calendar-agenda-hour">
+                      <span class="calendar-hour"><?php print $time['hour']; ?></span>
+                      <span class="calendar-ampm"><?php print $time['ampm']; ?></span>
+                    </div>
+                  <?php else: ?>
+                    <div class="<?php print $class ?>calendar-agenda-items single-day">
+                      <div class="half-hour">&nbsp;</div>
+                      <div class="calendar item-wrapper">
+                        <div class="inner">
+                          <?php if (!empty($items[$start_time]['values'][$index - 1])) : ?>
+                            <?php foreach ($items[$start_time]['values'][$index - 1] as $item) : ?>
+                              <?php if (isset($item['is_first']) && $item['is_first']) : ?>
+                                <div class="item <?php print $item['class'] ?> first_item">
+                                <?php else : ?>
+                                  <div class="item <?php print $item['class'] ?>">
+                                  <?php endif; ?>
+                                  <?php print $item['entry'] ?>
+                                </div>
+                              <?php endforeach; ?>
+                            <?php endif; ?>
+                          </div>
                         </div>
-                      <?php endforeach; ?>
+                      </div>
                     <?php endif; ?>
-                  </div>
-                </div>
-              </div>
-              <?php endif; ?>
-            <?php endforeach;?>
-          </td>
-          <?php endfor;?>
-        </tr>
-      </tbody>
-    </table>
+                  <?php endforeach; ?>
+              </td>
+            <?php endfor; ?>
+          </tr>
+        </tbody>
+      </table>
+    </div>
+    <div class="single-day-footer">&nbsp;</div>
   </div>
-  <div class="single-day-footer">&nbsp;</div>
-</div></div>
+</div>
 <script>
-try {
-  // Size and position the viewport inline so there are no delays
-  calendar_resizeViewport(jQuery);
-  calendar_scrollToFirst(jQuery);
+  try {
+    // Size and position the viewport inline so there are no delays
+    calendar_resizeViewport(jQuery);
+    calendar_scrollToFirst(jQuery);
 
-  // Show it now that it is complete and positioned
-  jQuery('#single-day-container').css('visibility','visible');
-}catch(e){ 
-  // swallow 
-}
+    // Show it now that it is complete and positioned
+    jQuery('#single-day-container').css('visibility','visible');
+  }catch(e){
+    // swallow
+  }
 </script>
\ No newline at end of file
diff --git a/agres_views/theme/agres-views-week.tpl.php b/agres_views/theme/agres-views-week.tpl.php
index 5671ff3..2a61d29 100644
--- a/agres_views/theme/agres-views-week.tpl.php
+++ b/agres_views/theme/agres-views-week.tpl.php
@@ -28,79 +28,70 @@
 //dsm($items);//currentunittype calendarname
 ?>
 <div class="agreservations-calendar"><div class="week-view">
-        <table class="agreservations-table">       
-          <thead>
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (!isset($currentcategory)) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedweek);?>"><?php print (t('show all categories')); ?></a>
-                </th>
-                <?php foreach ($categories as $category): ?>
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (isset($currentcategory)&&$currentcategory==$category->nid) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedweek."/".$category->nid);?>"><?php print ($category->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table> 
-        <table class="agreservations-table">
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (!isset($currentunittype)) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedweek."/".$currentcategory);?>"><?php print (t('show all units')); ?></a>
-                </th>
-                <?php foreach ($unittypes as $unittype): ?>
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (isset($currentunittype)&&$currentunittype==$unittype->nid) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedweek."/".$currentcategory."/".$unittype->nid);?>"><?php print ($unittype->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>
-       <table class="agreservations-table">
-                <tr>
-                    <th class="agreservations-calendar"><?php print $by_hour_count > 0 ? t('units') : ''; ?></th>
-                    <?php foreach ($day_names as $cell): ?>
-                    <th class="agreservations-calendar">
-                            <?php print $cell['data']; ?>
-                    </th>
-                    <?php endforeach; ?>
-                </tr>
-            </thead> <!--<?php print $cell['class']; ?>-->
-            
-            
-            <tbody>
-                <?php foreach ($units as $unit): ?>
-                <tr>
-                    <td class="agreservations-calendar">
+    <table class="agreservations-table">
+      <thead>
+        <tr class="agreservations-calendar">
+          <th class="agreservations-calendar th categories">
+            <a class="<?php print (!isset($currentcategory)) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedweek); ?>"><?php print (t('show all categories')); ?></a>
+          </th>
+          <?php foreach ($categories as $category): ?>
+            <th class="agreservations-calendar th categories">
+              <a class="<?php print (isset($currentcategory) && $currentcategory == $category->nid) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedweek . "/" . $category->nid); ?>"><?php print ($category->title); ?></a>
+            </th>
+          <?php endforeach; ?>
+        </tr>
+    </table>
+    <table class="agreservations-table">
+      <tr class="agreservations-calendar">
+        <th class="agreservations-calendar th unittypes">
+          <a class="<?php print (!isset($currentunittype)) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedweek . "/" . $currentcategory); ?>"><?php print (t('show all units')); ?></a>
+        </th>
+        <?php foreach ($unittypes as $unittype): ?>
+          <th class="agreservations-calendar th unittypes">
+            <a class="<?php print (isset($currentunittype) && $currentunittype == $unittype->nid) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedweek . "/" . $currentcategory . "/" . $unittype->nid); ?>"><?php print ($unittype->title); ?></a>
+          </th>
+        <?php endforeach; ?>
+      </tr>
+    </table>
+    <table class="agreservations-table">
+      <tr>
+        <th class="agreservations-calendar"><?php print $by_hour_count > 0 ? t('units') : ''; ?></th>
+        <?php foreach ($day_names as $cell): ?>
+          <th class="agreservations-calendar">
+            <?php print $cell['data']; ?>
+          </th>
+        <?php endforeach; ?>
+      </tr>
+      </thead>
+      <tbody>
+        <?php foreach ($units as $unit): ?>
+          <tr>
+            <td class="agreservations-calendar">
+              <a href="<?php print(base_path()); ?>node/<?php print $unit->nid ?>"><?php print $unit->title ?></a>
+              <span class="agreservations-calendar-hour"></span>
+            </td>
+            <?php foreach ($rows as $diw => $day): ?>
+              <?php if (isset($day['night'][$unit->title])) : ?>
+                <?php foreach ($day['night'][$unit->title] as $itemnid => $unitbookings): ?>
 
-                        <a href="<?php print(base_path());?>node/<?php print $unit->nid ?>"><?php print $unit->title  ?></a>
-                        <span class="agreservations-calendar-hour"></span>
-                    </td>
-                    
-                       <?php foreach ($rows as $diw=>$day): ?>               
-                                            
-                                    <?php if (isset($day['night'][$unit->title])) : ?>
-                                        <?php foreach ($day['night'][$unit->title] as $itemnid => $unitbookings): ?>
-                      
-                                            <?php if (isset($day['night'][$unit->title][$itemnid])) : ?>
-                                                <?php if (($day['night'][$unit->title][$itemnid])!=='***busy***') : ?>
-                                                  <td class="agreservations-calendar-agenda-items" <?php print isset($spaninfo[$unit->title][$itemnid]) ? "colspan=".$spaninfo[$unit->title][$itemnid] : ""; ?> >
-<!--                                                  <div class="agreservations-inner">-->
-                                                  <?php print ($day['night'][$unit->title][$itemnid]);?>
-<!--                                                    </div>-->
-                                                  </td>
-                                                  <?php endif; ?>
-                                            <?php endif; ?>
-                                        <?php endforeach; ?>
-                                    <?php else: ?>
-                                     <td class="agreservations-calendar-agenda-items">
-                                       <?php print ($day['datebox']);?>
-                                       <a href="<?php print(base_path());?>node/add/agreservation?&agres_sel_unit=<?php print $unit->nid ?>&default_agres_title=Reservation&default_agres_date=<?php print$day['date']?> 14:00 ">+</a>
-<!--                                       <a href="<?php print(base_path());?>node/add/agreservation?&agres_sel_unit=<?php print $unit->nid ?>&default_agres_title=Reservation&default_agres_date=<?php print$day['date']?> 14:00 ">+</a>-->
-                          
-                                  </td>
-                                   <?php endif; ?>           
-                        <?php endforeach; ?>
-                </tr>
+                  <?php if (isset($day['night'][$unit->title][$itemnid])) : ?>
+                    <?php if (($day['night'][$unit->title][$itemnid]) !== '***busy***') : ?>
+                      <td class="agreservations-calendar-agenda-items" <?php print isset($spaninfo[$unit->title][$itemnid]) ? "colspan=" . $spaninfo[$unit->title][$itemnid] : ""; ?> >
+                        <?php print ($day['night'][$unit->title][$itemnid]); ?>
+                      </td>
+                    <?php endif; ?>
+                  <?php endif; ?>
                 <?php endforeach; ?>
-                            </tbody>
-        </table>
-
-    </div></div>
\ No newline at end of file
+              <?php else: ?>
+                <td class="agreservations-calendar-agenda-items">
+                  <?php print ($day['datebox']); ?>
+                  <a href="<?php print(base_path()); ?>node/add/agreservation?&agres_sel_unit=<?php print $unit->nid ?>&default_agres_title=Reservation&default_agres_date=<?php print$day['date'] ?> 14:00 ">+</a>
+                </td>
+              <?php endif; ?>
+            <?php endforeach; ?>
+          </tr>
+        <?php endforeach; ?>
+      </tbody>
+    </table>
+  </div>
+</div>
\ No newline at end of file
diff --git a/agres_views/theme/agres-views-year.tpl.php b/agres_views/theme/agres-views-year.tpl.php
index 32d9d17..4a1529d 100644
--- a/agres_views/theme/agres-views-year.tpl.php
+++ b/agres_views/theme/agres-views-year.tpl.php
@@ -2,25 +2,27 @@
 /**
  * @file
  * Template to display a view as a calendar year.
- * 
+ *
  * @see template_preprocess_calendar_year.
  *
  * $view: The view.
  * $months: An array with a formatted month calendar for each month of the year.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
  * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
- * 
+ *
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
 
-<div class="calendar-calendar"><div class="year-view">
-<table <?php if ($mini): ?> class="mini"<?php endif; ?>>
-  <tbody>
-    <tr><td><?php print $months[1] ?></td><td><?php print $months[2] ?></td><td><?php print $months[3] ?></td></tr>  
-    <tr><td><?php print $months[4] ?></td><td><?php print $months[5] ?></td><td><?php print $months[6] ?></td></tr>  
-    <tr><td><?php print $months[7] ?></td><td><?php print $months[8] ?></td><td><?php print $months[9] ?></td></tr>  
-    <tr><td><?php print $months[10] ?></td><td><?php print $months[11] ?></td><td><?php print $months[12] ?></td></tr>  
-  </tbody>
-</table>
-</div></div>
\ No newline at end of file
+<div class="calendar-calendar">
+  <div class="year-view">
+    <table <?php if ($mini): ?> class="mini"<?php endif; ?>>
+      <tbody>
+        <tr><td><?php print $months[1] ?></td><td><?php print $months[2] ?></td><td><?php print $months[3] ?></td></tr>
+        <tr><td><?php print $months[4] ?></td><td><?php print $months[5] ?></td><td><?php print $months[6] ?></td></tr>
+        <tr><td><?php print $months[7] ?></td><td><?php print $months[8] ?></td><td><?php print $months[9] ?></td></tr>
+        <tr><td><?php print $months[10] ?></td><td><?php print $months[11] ?></td><td><?php print $months[12] ?></td></tr>
+      </tbody>
+    </table>
+  </div>
+</div>
\ No newline at end of file
diff --git a/agres_views/theme/agres_views-month-col.tpl.php b/agres_views/theme/agres_views-month-col.tpl.php
index 0979460..6287339 100644
--- a/agres_views/theme/agres_views-month-col.tpl.php
+++ b/agres_views/theme/agres_views-month-col.tpl.php
@@ -2,14 +2,14 @@
 /**
  * @file
  * Template to display a column
- * 
+ *
  * - $item: The item to render within a td element.
  */
 $id = (isset($item['id'])) ? 'id="' . $item['id'] . '" ' : '';
 $date = (isset($item['date'])) ? 'date="' . $item['date'] . '" ' : '';
 ?>
-<td <?php print $id?>class="<?php print $item['class'] ?>" colspan="<?php print $item['colspan'] ?>" rowspan="<?php print $item['rowspan'] ?>"<?php print $date ?>>
+<td <?php print $id ?>class="<?php print $item['class'] ?>" colspan="<?php print $item['colspan'] ?>" rowspan="<?php print $item['rowspan'] ?>"<?php print $date ?>>
   <div class="inner">
     <?php print $item['entry'] ?>
   </div>
-</td>
+</td>
\ No newline at end of file
diff --git a/agres_views/theme/agres_views-month-row.tpl.php b/agres_views/theme/agres_views-month-row.tpl.php
index 28c53b7..8f5e8a3 100644
--- a/agres_views/theme/agres_views-month-row.tpl.php
+++ b/agres_views/theme/agres_views-month-row.tpl.php
@@ -2,16 +2,16 @@
 /**
  * @file
  * Template to display a row
- * 
+ *
  * - $inner: The rendered string of the row's contents.
  */
-$attrs = ($class) ? 'class="' . $class . '"': '';
+$attrs = ($class) ? 'class="' . $class . '"' : '';
 $attrs .= ($iehint > 0) ? ' iehint="' . $iehint . '"' : '';
 ?>
-<?php if ($attrs != ''):?>
-<tr <?php print $attrs?>>
-<?php else:?>
-<tr>
-<?php endif;?>
+<?php if ($attrs != ''): ?>
+  <tr <?php print $attrs ?>>
+  <?php else: ?>
+  <tr>
+  <?php endif; ?>
   <?php print $inner ?>
 </tr>
diff --git a/agres_views/theme/theme.inc b/agres_views/theme/theme.inc
index 7ade3d9..8b29131 100644
--- a/agres_views/theme/theme.inc
+++ b/agres_views/theme/theme.inc
@@ -1,48 +1,17 @@
 <?php
-/**
- * additional themingfunctions for agreservations and booking agres_views
- */
-
 
 /**
- * Format the time row headings in the week and day view.
+ * @file
+ *  Additional theming functions for agreservations and booking agres_views
  */
-//function theme_agres_views_time_row_heading($start_time, $next_start_time, $curday_date) {
-//  static $format_hour, $format_ampm;
-//  if (empty($format_hour)) {
-////    $format = //variable_get('date_format_short', 'm/d/Y - H:i');
-//    $format =  'm/d/Y - H:i';
-////    $format_hour = str_replace(array('a', 'A'), '', date_limit_format($format, array('hour', 'minute')));
-//    $format_hour = str_replace(array('a', 'A'), '', date_limit_format($format, array('hour', 'minute')));
-//    $format_ampm = strstr($format, 'a') ? 'a' : (strstr($format, 'A') ? 'A' : '');
-//  }
-//  if ($start_time == '00:00:00' && $next_start_time == '23:59:59') {
-//    $hour = t('All');
-//  }
-//  elseif ($start_time == '00:00:00') {
-//    $date = date_create($curday_date .' '. $next_start_time);
-//    $hour = t('< @time', array('@time' => date_format($date, $format_hour)));
-//  }
-//  else {
-//    $date = date_create($curday_date .' '. $start_time);
-//    $hour = date_format($date, $format_hour);
-//  }
-//  if (!empty($date)) {
-//    $ampm = date_format($date, $format_ampm);
-//  }
-//  else {
-//    $ampm = '';
-//  }
-//  return array('hour' => $hour, 'ampm' => $ampm);
-//}
 
 /**
  * Implements hook_preprocess_date_views_pager().
  *
- * Creates a calendar_links array which is stored in the session and used
- * in calendar_menu_local_tasks_alter() to display the links as action items and dynamic tabs.
+ * Creates a calendar_links array which is stored in the session and used in
+ * calendar_menu_local_tasks_alter() to display the links as action items and
+ * dynamic tabs.
  * The links can be altered or deleted using hook_calendar_links_alter().
- *
  */
 function agres_views_preprocess_date_views_pager(&$vars) {
   $view = $vars['plugin']->view;
@@ -70,14 +39,15 @@ function agres_views_preprocess_date_views_pager(&$vars) {
       $title = $display->display_title;
       $type = !empty($display->display_options['style_options']['agres_views_type']) ? $display->display_options['style_options']['agres_views_type'] : 'month';
 
-      // Make sure the links to other agres_views displays use the right path for that display.
-      // Get rid of pager links when swapping between displays to force the base argument
-      // to be structured correctly for the type of display. This means you can't use
-      // these links in a block or panel.
+      // Make sure the links to other agres_views displays use the right path
+      // for that display. Get rid of pager links when swapping between displays
+      // to force the base argument to be structured correctly for the type of
+      // display. This means you cannot use these links in a block or panel.
       $href = str_replace($current_path, $path, date_pager_url($view, $type, NULL, TRUE, FALSE));
-      $part_path = substr($href, strlen(base_path()));
+      $part_path = drupal_substr($href, drupal_strlen(base_path()));
 
-      // Once we have a path for the links to other displays, add it to our links array.
+      // Once we have a path for the links to other displays, add it to our
+      // links array.
       $agres_views_links[$current_path]['tabs'][$type] = array(
         'title' => $title,
         'path' => $part_path,
@@ -88,7 +58,8 @@ function agres_views_preprocess_date_views_pager(&$vars) {
 
   // If an 'Add new ... link is provided, add it here.
   if (!empty($view->date_info->agres_views_date_link) && !empty($view->date_info->url)
-   && (user_access("administer nodes") || user_access('create ' . $view->date_info->agres_views_date_link . ' content'))) {
+    && (user_access("administer nodes") || user_access('create ' . $view->date_info->agres_views_date_link . ' content'))) {
+
     $name = node_type_get_name($view->date_info->agres_views_date_link);
     $href = 'node/add/' . str_replace('_', '-', $view->date_info->agres_views_date_link);
     $agres_views_links[$current_path]['actions'][] = array(
@@ -102,77 +73,14 @@ function agres_views_preprocess_date_views_pager(&$vars) {
 
   // Add the value to the session so it can be used to create the tabs.
   $_SESSION['agres_views_links'][$current_path] = $agres_views_links[$current_path];
-
 }
 
-
-///**
-// * Add agres_views links above the pager.
-// */
-//function agres_views_preprocess_date_views_pager(&$vars) {
-//  $view = $vars['plugin']->view;
-//  if ($view->plugin_name != 'agres_views_style') {
-//    return;
-//  }
-//  $options = $view->style_options;
-//
-//  // If we're not on a view with a path (a page), no links are needed.
-//  $current_path = !empty($view->display_handler->options['path']) ? $view->display_handler->options['path'] : '';
-//  if (empty($current_path)) {
-//    return;
-//  }
-//
-//  // Find all the displays in this view that use the agres_views style and have a path and create links to each.
-//  $agres_views_links = array();
-//  $base = array('attributes' => array('rel' => 'nofollow'));
-//  foreach($view->display as $id => $display) {
-//    if ($display->display_options['style_plugin'] == 'agres_views_style' && !empty($display->display_options['path'])) {
-//      $path = $display->display_options['path'];
-//      $title = $display->display_title;
-//      // @TODO Why is this sometimes empty for a style that uses the default value?
-//      $type = !empty($display->display_options['style_options']['agres_views_type']) ? $display->display_options['style_options']['agres_views_type'] : 'month';
-//
-//      // Make sure the links to other agres_views displays use the right path for that display.
-//      // Get rid of pager links when swapping between displays to force the base argument
-//      // to be structured correctly for the type of display. This means you can't use
-//      // these links in a block or panel.
-//      $href = str_replace($current_path, $path, date_pager_url($view, $type, NULL, TRUE));
-//
-//      // Once we have a path for the links to other displays, add it to our links array.
-//      $agres_views_links['agres_views agres_views-'. $type] = array('title' => $title, 'href' => $href);
-//    }
-//  }
-//
-//  // If an 'Add new ... link is provided, add it here.
-//  // the query will bring the user back here after adding the node.
-//  if (!empty($view->date_info->agres_views_date_link)
-//  && (user_access("administer nodes") || user_access('create '. $view->date_info->agres_views_date_link .' content'))) {
-//    $name = node_type_get_name($view->date_info->agres_views_date_link);
-//    $href = 'node/add/' . str_replace('_', '-', $view->date_info->agres_views_date_link);
-//    $query = drupal_get_query_parameters(array('destination' => $view->date_info->url));
-//    $agres_views_links['agres_views agres_views-add'] = $base + array(
-//      'title' => t('Add+'),
-//      'href' => $href,
-//      'query' => $query,
-//      );
-//  }
-//
-//  // Append the agres_views links above the pager.
-//  $links = array(
-//    'links' => $agres_views_links,
-//    'attributes' => array('class' => array('agres_views-links', 'inline')),
-//  );
-//  $vars['pager_prefix'] = theme('links', $links);
-//}
-
 /**
  * Preprocess an RSS feed
  */
 function template_preprocess_agres_views_style(&$vars) {
-//    drupal_set_message('<pre>monthtemplate_preprocess_agres_views_style '.print_r( $vars,true).'</pre>');
   global $base_url;
   global $language;
-
 }
 
 /**
@@ -180,12 +88,9 @@ function template_preprocess_agres_views_style(&$vars) {
  */
 function template_preprocess_agres_views_month(&$vars) {
   // Add in all the $vars added by the main calendar preprocessor.
-//   if ($vars['view']->name == 'agres_view') {
-//     drupal_set_message('<pre>*or**'. print_r($vars['view']->name, TRUE) .'</pre>');
-//  agres_views_preprocess_calendar($vars);
   $view = $vars['view'];
   $rows = $vars['rows'];
-  //drupal_set_message('<pre>*or**'. print_r($rows, TRUE) .'</pre>');
+
   if (sizeof($rows) > 1) {
     $day_names = array_shift($rows);
   }
@@ -194,12 +99,8 @@ function template_preprocess_agres_views_month(&$vars) {
     $rows = array();
   }
   $month_rows = $rows;
-//     foreach ($rows[0] as $weekno => $row) {
-//   }
-  /*      * **************setup categories and unittypes:******************************************
-   *
-   */
-//  drupal_set_message('<pre>*or**'. print_r($view, TRUE) .'</pre>');
+
+  // Setup categories and unittypes
   $vars['unittypes'] = '';
   $countarg = count($view->args);
 
@@ -210,12 +111,10 @@ function template_preprocess_agres_views_month(&$vars) {
     }
     $vars['currentcategory'] = '';
     if (isset($view->args[1]) && $view->args[1]) {
-//         drupal_set_message('<pre>bis hier' . print_r($vars['unittypes'], true) . '</pre>');
       $unittypes = _agres_categories_get_unittypenodes_of_category($view->args[1]);
       $vars['currentcategory'] = $view->args[1];
       $categories = _agres_categories_get_categories(TRUE);
       if (isset($view->args[2]) && $view->args[2]) {
-//        $units = _agreservations_get_unitnodes($view->args[2]);
         $units = _agres_categories_get_unitnodes_of_category($view->args[2], $view->args[1]);
         $vars['currentunittype'] = $view->args[2];
       }
@@ -227,7 +126,6 @@ function template_preprocess_agres_views_month(&$vars) {
     else {
 
       $unittypes = _agres_categories_get_unittypenodes_of_category();
-//        drupal_set_message('<pre>bis else'.print_r($unittypes,true).'</pre>');
       $categories = _agres_categories_get_categories(TRUE);
       $units = _agreservations_get_unitnodes();
     }
@@ -237,52 +135,41 @@ function template_preprocess_agres_views_month(&$vars) {
       $view->args = array_slice($view->args, 0, 2);
     }
     if (isset($view->args[1])) {
-//        drupal_set_message('<pre>*view->args[1]view->args[1]**'. print_r($vars['view']->name, TRUE) .'</pre>');
       $units = _agreservations_get_unitnodes($view->args[1]);
       $vars['currentunittype'] = $view->args[1];
     }
     else {
       $units = _agreservations_get_unitnodes();
-//        drupal_set_message('<pre>*elseelseelse]**'. print_r($units, TRUE) .'</pre>');
     }
     $unittypes = _agreservations_get_unittypenodes();
   }
-  //remove the args from agrescurrentpath:
-
 
+  // Remove the args from agrescurrentpath:
   $toremovefrompath = implode("/", $view->args);
   $agrescurrentpath = get_current_path();
   $agrescurrentpath = str_replace($toremovefrompath, "", $agrescurrentpath);
-  //cut off trailing slash:
-
 
-  if (substr($agrescurrentpath, -1, 1) == "/") {
-    $agrescurrentpath = substr($agrescurrentpath, 0, strlen($agrescurrentpath) - 1);
+  // Cut off trailing slash
+  if (drupal_substr($agrescurrentpath, -1, 1) == "/") {
+    $agrescurrentpath = drupal_substr($agrescurrentpath, 0, drupal_strlen($agrescurrentpath) - 1);
   }
-//    drupal_set_message('<pre>*orig**'. print_r($agrescurrentpath, TRUE) .'</pre>');
-
 
   $vars['agrescurrentpath'] = $agrescurrentpath;
 
-//    drupal_set_message('<pre>*orig**'. print_r($rows, TRUE) .'</pre>');
-  //step1: all in 1 array:
+  // Step1: all in a single array
   $agdaysresitems = array();
   $agmonth_rows = array();
-  $days  = 0;
+  $days = 0;
   foreach ($rows as $weekno => $row) {
-    foreach ($row as $day => $data) {       
-      if (isset($data['data']['date'])&(!empty($data['data']['date']))) {
-//        drupal_set_message('<pre>*orig**'. print_r($data, TRUE) .'</pre>');
+    foreach ($row as $day => $data) {
+      if (isset($data['data']['date']) & (!empty($data['data']['date']))) {
         $days += 1;
       }
-      
       $agdaysresitems[] = $data;
     }
   }
-//   drupal_set_message('<pre>$rows$rows$rdfgdfgowstemplate_preprocess_agres_availability_mini'.print_r($agdaysresitems,true).'</pre>');
   $agmonth_rows['rinfo'] = array();
-  //step2 organize in unit arrays:
-//     drupal_set_message('<pre>*orig**'. print_r($agdaysresitems, TRUE) .'</pre>');
+  // Step 2: Organize in unit arrays
   foreach ($units as $unit) {
     $agmonth_rows['rinfo'][$unit->title] = array();
 
@@ -292,11 +179,10 @@ function template_preprocess_agres_views_month(&$vars) {
       $date = $agdayresitem['data']['date'];
       $agmonth_rows[$unit->title][$day]['datebox'] = $data;
       $agmonth_rows[$unit->title][$day]['date'] = $date;
-//         drupal_set_message('<pre>*$day**'. print_r($date, TRUE) .'</pre>');
-       
+
       foreach ($agdayresitem['data']['items'] as $time => $hour) {
-//             drupal_set_message('<pre>*orig**'. print_r($time, TRUE) .'</pre>');
-        //foreach reservation objet node in the hour DO:
+
+        // For each reservation object node in the hour
         foreach ($hour as $resob) {
           if (!isset($agmonth_rows[$unit->title][$day]['resitm'][$resob->nid])) {
             $agmonth_rows[$unit->title][$day]['resitm'][$resob->nid] = '0';
@@ -308,19 +194,17 @@ function template_preprocess_agres_views_month(&$vars) {
 
           $tmpunititems = _agreservations_get_unitn_for_reservation_node($resob->nid); //get units per reservation
           if (in_array($unit->nid, $tmpunititems)) {
-            $tmpEnd = date_create($resob->row->field_field_agres_rdate[0]['raw']['value2']);
-            $tmpGranularityEnd = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
-            if ($tmpEnd > $tmpGranularityEnd) {
+            $temp_end = date_create($resob->row->field_field_agres_rdate[0]['raw']['value2']);
+            $temp_granularity_end = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
+            if ($temp_end > $temp_granularity_end) {
               $continues = 1;
-
             }
             else {
               $continues = 0;
-//                  drupal_set_message('<pre>*$continues = 0;**'. print_r(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME), TRUE) .'</pre>');
             }
-            $tmpstart = date_create($resob->row->field_field_agres_rdate[0]['raw']['value']);
-            $tmpGranularitystart = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
-            if ($tmpstart < $tmpGranularitystart) {
+            $temp_start = date_create($resob->row->field_field_agres_rdate[0]['raw']['value']);
+            $temp_granularity_start = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
+            if ($temp_start < $temp_granularity_start) {
               $continuation = 1;
             }
             else {
@@ -329,10 +213,12 @@ function template_preprocess_agres_views_month(&$vars) {
 
             $itemclass = 'itemwithoutorder';
             if (!isset($resob->node->field_agres_orderid[$resob->node->language])) {
-              $itemclass = 'itemwithoutorder'; //treat as receptionist manual reservation defaultcolor orange
+              // Treat as receptionist manual reservation defaultcolor orange
+              $itemclass = 'itemwithoutorder';
             }
             else {
-              $itemclass = 'itemwithorder'; //treat as receptionist manual reservation defaultcolor blue
+              // Treat as receptionist manual reservation defaultcolor blue
+              $itemclass = 'itemwithorder';
             }
             if ((!isset($agmonth_rows[$unit->title]['spaninfo'][$resob->nid]) || (empty($agmonth_rows[$unit->title]['spaninfo'][$resob->nid])))) {
               $theme = 'calendar_month_node';
@@ -351,33 +237,27 @@ function template_preprocess_agres_views_month(&$vars) {
 
               $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = '';
               $agmonth_rows[$unit->title]['spaninfo'][$resob->nid] = 1;
-              $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = theme('agres_views_item', $themeparams); //theme($theme, $variables); //$resob->rendered['nid'];
+              $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = theme('agres_views_item', $themeparams);
               //only the first:
-              $agmonth_rows[$unit->title][$day]['data'] = array_slice($agmonth_rows[$unit->title][$day]['data'], 0, 1, true);
+              $agmonth_rows[$unit->title][$day]['data'] = array_slice($agmonth_rows[$unit->title][$day]['data'], 0, 1, TRUE);
             }
             else {
-              $endpos = strpos($resob->row->field_field_agres_rdate[0]['raw']['value2'], $agmonth_rows[$unit->title][$day]['date'], 0); //strpos($resob->raw->field_data_field_agres_rdate_field_agres_rdate_value2, $agmonth_rows[$unit->title][$day]['date'], 0);
+              $endpos = strpos($resob->row->field_field_agres_rdate[0]['raw']['value2'], $agmonth_rows[$unit->title][$day]['date'], 0);
               if (empty($agmonth_rows[$unit->title][$day]['data'][$resob->nid])) {
-                if ($endpos === false) {
+                if ($endpos === FALSE) {
                   $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = '***busy***';
                   $agmonth_rows[$unit->title]['spaninfo'][$resob->nid] += 1;
                 }
-                else {
-//                          $agmonth_rows[$unit->title][$day]['data'][$resob->id] = '***busy***';
-//                          $agmonth_rows[$unit->title]['spaninfo'][$resob->id] = +1;
-                }
-              }
-              else {
-
               }
             }
           }
         }
       }
-      /////////////////////////////ALL DAY///////////////////////////////////////////////
+
+      // All Day
       if (isset($agdayresitem['data']['all_day'])) {
         foreach ($agdayresitem['data']['all_day'] as $resob) {
-          //foreach reservation objet node in the hour DO:
+          // For each reservation object node in the hour
           if (!isset($agmonth_rows[$unit->title][$day]['resitm'][$resob->nid])) {
             $agmonth_rows[$unit->title][$day]['resitm'][$resob->nid] = '0';
           }
@@ -387,19 +267,17 @@ function template_preprocess_agres_views_month(&$vars) {
             $itemclass = 'itemwithoutorder';
             $continues = 0;
             $continuation = 1;
-            $tmpEnd = date_create($resob->row->field_field_agres_rdate[0]['raw']['value2']);
-            $tmpGranularityEnd = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
-            if ($tmpEnd > $tmpGranularityEnd) {
+            $temp_end = date_create($resob->row->field_field_agres_rdate[0]['raw']['value2']);
+            $temp_granularity_end = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
+            if ($temp_end > $temp_granularity_end) {
               $continues = 1;
-
             }
             else {
               $continues = 0;
-//                  drupal_set_message('<pre>*$continues = 0;**'. print_r(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME), TRUE) .'</pre>');
             }
-            $tmpstart = date_create($resob->row->field_field_agres_rdate[0]['raw']['value']);
-            $tmpGranularitystart = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
-            if ($tmpstart < $tmpGranularitystart) {
+            $temp_start = date_create($resob->row->field_field_agres_rdate[0]['raw']['value']);
+            $temp_granularity_start = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
+            if ($temp_start < $temp_granularity_start) {
               $continuation = 1;
             }
             else {
@@ -407,10 +285,12 @@ function template_preprocess_agres_views_month(&$vars) {
             }
 
             if (!isset($resob->node->field_agres_orderid[$resob->node->language])) {
-              $itemclass = 'itemwithoutorder'; //treat as receptionist manual reservation defaultcolor orange
+              // Treat as receptionist manual reservation defaultcolor orange
+              $itemclass = 'itemwithoutorder';
             }
             else {
-              $itemclass = 'itemwithorder'; //treat as receptionist manual reservation defaultcolor blue
+              // Treat as receptionist manual reservation defaultcolor blue
+              $itemclass = 'itemwithorder';
             }
             if ((!isset($agmonth_rows[$unit->title]['spaninfo'][$resob->nid]) || (empty($agmonth_rows[$unit->title]['spaninfo'][$resob->nid])))) {
               $theme = 'calendar_month_node';
@@ -428,31 +308,22 @@ function template_preprocess_agres_views_month(&$vars) {
               );
               $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = '';
               $agmonth_rows[$unit->title]['spaninfo'][$resob->nid] = 1;
-              $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = theme('agres_views_item', $themeparams); //$resob->rendered['nid'];
+              $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = theme('agres_views_item', $themeparams);
             }
             else {
 
-//                     drupal_set_message('<pre>'.print_r($resob,true).'<---->'.print_r(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME),true).'</pre>');
-//                     drupal_set_message('<pre>day:'.$day.'itm:'.$resob->nid.'sonst '.print_r($resob,true).'</pre>');
+
               $endpos = strpos($resob->row->field_field_agres_rdate[0]['raw']['value2'], $agmonth_rows[$unit->title][$day]['date'], 0);
               if (empty($agmonth_rows[$unit->title][$day]['data'][$resob->nid])) {
-                if ($endpos === false) {
+                if ($endpos === FALSE) {
                   $agmonth_rows[$unit->title][$day]['data'][$resob->nid] = '***busy***';
                   $agmonth_rows[$unit->title]['spaninfo'][$resob->nid] += 1;
                 }
-                else {
-//                          $agmonth_rows[$unit->title][$day]['data'][$resob->id] = '***busy***';
-//                          $agmonth_rows[$unit->title]['spaninfo'][$resob->id] = +1;
-                }
-              }
-              else {
-
               }
             }
           }
         }
       }
-      ///////////////////////////////////////////////////////////////////////////////////
     }
   }
 
@@ -472,7 +343,6 @@ function template_preprocess_agres_views_month(&$vars) {
   if (module_exists('agres_categories')) {
     $vars['categories'] = $categories;
   }
-//    $vars['template_file'] = 'agres_views-calendar-month-c';
   $path = drupal_get_path('module', 'agres_views');
   $vars['directory'] = $path . '/theme';
 }
@@ -488,7 +358,7 @@ function template_preprocess_agres_views_mini(&$vars) {
 
   // Make sure that the agres_views title links go to the month view,
   // not the year view (if this is embedded in a year display).
-  $view->override_path =  agres_views_granularity_path($view, 'month');
+  $view->override_path = agres_views_granularity_path($view, 'month');
 
   $view->date_info->show_title = !empty($view->date_info->show_title) ? $view->date_info->show_title : FALSE;
   $vars['show_title'] = $view->date_info->show_title;
@@ -529,7 +399,6 @@ function template_preprocess_agres_views_year(&$vars) {
   $vars['view']->date_info->hide_nav = FALSE;
   $vars['view']->date_info->granularity = 'year';
   $vars['mini'] = $view->date_info->mini;
-
 }
 
 /**
@@ -543,7 +412,6 @@ function template_preprocess_agres_views_day_overlap(&$vars) {
 function template_preprocess_agres_views_day(&$vars) {
   // Get rid of visual duplicates.
   $vars['view']->style_with_weekno = FALSE;
-//       template_preprocess_calendar($vars);
   $view = $vars['view'];
   $rows = $vars['rows'];
   $show_empty_times = $view->date_info->style_show_empty_times;
@@ -559,8 +427,6 @@ function template_preprocess_agres_views_day(&$vars) {
       $vars['currentcategory'] = $view->args[1];
       $categories = _agres_categories_get_categories(TRUE);
       if (isset($view->args[2]) && $view->args[2]) {
-
-//        $units = _agreservations_get_unitnodes($view->args[2]);
         $units = _agres_categories_get_unitnodes_of_category($view->args[2], $view->args[1]);
         $vars['currentunittype'] = $view->args[2];
       }
@@ -588,13 +454,13 @@ function template_preprocess_agres_views_day(&$vars) {
     }
     $unittypes = _agreservations_get_unittypenodes();
   }
-  //remove the args from agrescurrentpath:
+  // Remove the args from agrescurrentpath
   $toremovefrompath = implode("/", $view->args);
   $agrescurrentpath = get_current_path();
   $agrescurrentpath = str_replace($toremovefrompath, "", $agrescurrentpath);
-  //cut off trailing slash:
-  if (substr($agrescurrentpath, -1, 1) == "/") {
-    $agrescurrentpath = substr($agrescurrentpath, 0, strlen($agrescurrentpath) - 1);
+  // Cut off trailing slash
+  if (drupal_substr($agrescurrentpath, -1, 1) == "/") {
+    $agrescurrentpath = drupal_substr($agrescurrentpath, 0, drupal_strlen($agrescurrentpath) - 1);
   }
   $vars['agrescurrentpath'] = $agrescurrentpath;
 
@@ -604,24 +470,18 @@ function template_preprocess_agres_views_day(&$vars) {
   $spanning_items = array(); //test
   $r = 0;
 
-//      drupal_set_message("<pre>gfcjcghgjgchj".print_r($rows,TRUE)."</pre>");
   foreach ($units as $unit) { //loop through all units
     foreach ($rows['all_day'] as $itmkey => $item) {
-
-      $tmpunititems = _agreservations_get_unitn_for_reservation_node($item->nid); //get units of reservation
-//           drupal_set_message("<pre>gfcjcghgjgchj".print_r($tmpunititems,TRUE)."</pre>");
-      if (in_array($unit->nid, $tmpunititems)) { //if unit is in reserved units
+      // Get units of reservation
+      $tmpunititems = _agreservations_get_unitn_for_reservation_node($item->nid);
+      // If unit is in reserved units
+      if (in_array($unit->nid, $tmpunititems)) {
         $column = t('Items');
         $theme = isset($item->calendar_node_theme) ? $item->calendar_node_theme : 'calendar_' . $view->date_info->granularity . '_node';
-        //add the rendered items to the unit in the calendarmatrix
-//        if (count($unit->actualitems[$column])==0) {
-//            drupal_set_message("<pre>gfcjcghgjgchj".print_r($item->nid,TRUE)."</pre>");
-//             $unit->actualitems['Items'][] = theme('agres_views_item', array('view' => $view, 'rendered_fields' => $event[0]->rendered_fields, 'item' => $event[0])); //test// l(t("res:$item->nid"), "node/$item->nid", array('query' => drupal_get_destination()));
+        // Add the rendered items to the unit in the calendarmatrix
         $spanning_items[$column][] = theme($theme, $item, $view); //test
-        //theme($theme, $item, $view);!!!"""§§§
         $item_count++;
       }
-//      }
     }
   }
 
@@ -632,68 +492,54 @@ function template_preprocess_agres_views_day(&$vars) {
   $end_start_time = '23:59:59';
   $grouped_items = array();
   $timeslots = $view->date_info->style_groupby_times;
-//       drupal_set_message('<pre>'.print_r($timeslots,TRUE).'</pre>');
   array_push($timeslots, $end_start_time);
-//  drupal_set_message('<pre>'.print_r($timeslots,TRUE).'</pre>');
   $timeslots_count = count($timeslots);
-  //drupal_set_message("<pre>***timeslots_count**".print_r($timeslots_count,TRUE)."</pre>");
-  //translate rows into better format
+
+  // Translate rows into better format
   $events = $rows['items'];
-//       drupal_set_message("<pre>gfcjcghgjgchj".print_r($events,TRUE)."</pre>");
   foreach ($units as $unit) {
     $grouped_items[$unit->title] = array();
     foreach ($events as $elemkey => $event) {
 
-      ////    if ($event->calendar_all_day) continue; // skip all day events.
-      $group_key = isset($event->raw->{$grouping_field}) ? $event->raw->{$grouping_field} : t('Items'); // get initial value as formatted one already blanked
-//
+      // Get initial value as formatted one already blanked
+      $group_key = isset($event->raw->{$grouping_field}) ? $event->raw->{$grouping_field} : t('Items');
+
       $key = $group_key . '-' . 0;
       $columns["$group_key"] = array();
-      if (!($columns["$group_key"])) { // init group on first encounter
+      // Init group on first encounter
+      if (!($columns["$group_key"])) {
         $columns["$group_key"][] = $group_key . '-0';
       }
-//            settype($event->date_end,"DateTime");
-//             drupal_set_message('<pre>$event  '.print_r($event,TRUE).'</pre>');
-//             drupal_set_message('<pre>event g '.print_r($event,TRUE).'</pre>');
-      //IF EVENTDATE < DAYCALENDARDATESTART:
-      $tmpGranularityEnd = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
-      if ($event[0]->date_start < $tmpGranularityEnd) {
+
+      // If EVENTDATE < DAYCALENDARDATESTART:
+      $temp_granularity_end = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
+      if ($event[0]->date_start < $temp_granularity_end) {
         $event_start = '00:00:00';
       }
       else {
         $event_start = $event[0]->date_start->format('H:i:s');
       }
-      $tmpGranularityEnd = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
-      if ($event[0]->date_end > $tmpGranularityEnd) {
+
+      $temp_granularity_end = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
+      if ($event[0]->date_end > $temp_granularity_end) {
         $event_end = '23:59:59';
       }
       else {
         $event_end = $event[0]->date_end->format('H:i:s');
       }
-//                       $tmpEnd = date_create($resob->row->field_field_agres_rdate[0]['raw']['value2']);
-//                       $tmpGranularityEnd = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
-//                       if($tmpEnd > $tmpGranularityEnd){
-//                           $continues = 1;
-//                       }else{
-//                          $continues = 0;
-//                       }
-//
-//           drupal_set_message("<pre>calendar_start_date  ".print_r($event_start,TRUE)."</pre>");
-//           $event_end = $event[0]->date_end->format('H:i:s');
-//            drupal_set_message('<pre>event g '.print_r($event_end,TRUE).'</pre>');
+
       $i = 0;
-      $tmpunititems = _agreservations_get_unitn_for_reservation_node($event[0]->nid); //get units of reservation
+      // Get units of reservation
+      $tmpunititems = _agreservations_get_unitn_for_reservation_node($event[0]->nid);
 
       if (in_array($unit->nid, $tmpunititems)) {
         for ($slot = 0; $slot < $timeslots_count; $slot++) {
-//
+          // One slot event
           if ($event_start >= $timeslots[$slot] &&
-                       $event_end <= $timeslots[$slot + 1]) { // one slot event
+            $event_end <= $timeslots[$slot + 1]) {
             $grouped_items[$unit->title][$timeslots[$slot]]['values'] = array();
-//                 $theme = isset($event->calendar_node_theme) ? $event->calendar_node_theme : 'calendar_' . $view->date_info->granularity . '_node';
-            // find free column to use
+            // Find free column to use
             $found = FALSE;
-
             foreach ($columns["$group_key"] as $ckey => $column) {
               $grouped_items[$unit->title][$timeslots[$slot]]['values']["$key"] = '';
               $key = $group_key . '-' . $ckey;
@@ -704,20 +550,18 @@ function template_preprocess_agres_views_day(&$vars) {
             }
             if (!$found) {
               $key = $group_key . '-' . (count($columns[$group_key]));
-              $columns["$group_key"][] = $key; // add new column
+              // Add new column
+              $columns["$group_key"][] = $key;
             }
 
             $grouped_items[$unit->title][$timeslots[$slot]]['values']["$key"] = theme('agres_views_item', array('view' => $view, 'rendered_fields' => $event[0]->rendered_fields, 'item' => $event[0])); // theme($theme, $event, $view);
-
           }
-          elseif ($event_start >= $timeslots[$slot] &&
-                       $event_start < $timeslots[$slot + 1] &&
-                       $event_end > $timeslots[$i + 1]) { // first slot of multi slot event
+          // First slot of multi slot event
+          elseif ($event_start >= $timeslots[$slot] && $event_start < $timeslots[$slot + 1] && $event_end > $timeslots[$i + 1]) {
             $grouped_items[$unit->title][$timeslots[$slot]]['values'] = array();
             $theme = isset($event->calendar_node_theme) ? $event->calendar_node_theme : 'calendar_' . $view->date_info->granularity . '_node';
-            // find free column to use
+            // Find free column to use
             $found = FALSE;
-
             foreach ($columns["$group_key"] as $ckey => $column) {
               $grouped_items[$unit->title][$timeslots[$slot]]['values']["$key"] = '';
               $key = $group_key . '-' . $ckey;
@@ -728,7 +572,8 @@ function template_preprocess_agres_views_day(&$vars) {
             }
             if (!$found) {
               $key = $group_key . '-' . (count($columns["$group_key"]));
-              $columns["$group_key"][] = $key; // add new column
+              // Add new column
+              $columns["$group_key"][] = $key;
             }
 
             $span = $timeslots[$slot];
@@ -736,12 +581,13 @@ function template_preprocess_agres_views_day(&$vars) {
             $grouped_items[$unit->title][$timeslots[$slot]]['span']["$key"] = 1;
           }
           elseif ($event_start < $timeslots[$slot] &&
-                  $event_end > $timeslots[$slot]) { // middle of end slot of event
+            $event_end > $timeslots[$slot]) { // middle of end slot of event
             $grouped_items[$unit->title][$span]['span']["$key"]++;
             $grouped_items[$unit->title][$timeslots[$slot]]['values']["$key"] = '***busy***';
           }
-          else { // empty slot
-            //$grouped_items[$timeslots[$slot]]['values']["$key"] = '';
+          // Empty slot
+          else {
+
           }
         }
       }
@@ -760,7 +606,6 @@ function template_preprocess_agres_views_day(&$vars) {
         'curday_date' => $rows['date'],
       );
       $heading = theme('agres_views_time_row_heading', $variables);
-//            drupal_set_message('<pre>dsfg'.print_r($heading,TRUE).'</pre>');
       $grouped_items[$unit->title][$start_time]['hour'] = $heading['hour'];
       $grouped_items[$unit->title][$start_time]['ampm'] = $heading['ampm'];
       $i++;
@@ -769,7 +614,6 @@ function template_preprocess_agres_views_day(&$vars) {
     ksort($grouped_items[$unit->title]);
     ksort($grouped_items);
   }
-//  drupal_set_message('<pre>dsfg'.print_r($grouped_items,TRUE).'</pre>');
   $vars['rows']['items'] = $grouped_items;
   if (empty($columns)) {
     $header_columns[t('Items')]['title'] = t('Items');
@@ -780,7 +624,7 @@ function template_preprocess_agres_views_day(&$vars) {
     foreach ($columns as $group_key => $group_column) {
       $header_columns[$group_key]['title'] = $group_key;
       $header_columns[$group_key]['span'] = count($group_column);
-      // also span all days events
+      // Also span all days events
       $vars['rows']['all_day'][$group_key]['span'] = count($group_column);
       foreach ($group_column as $column) {
         $flat_columns[] = $column;
@@ -800,17 +644,17 @@ function template_preprocess_agres_views_day(&$vars) {
   $vars['units'] = $units;
   $vars['unittypes'] = $unittypes;
   $vars['calendarname'] = $view->name;
-//  $vars['first_column_width'] = 22;
-  // add small javascript to extend datebox to whole td height
+
+  // Add small javascript to extend datebox to whole td height
   drupal_add_js(
-               "Drupal.behaviors.myEventBehavior = function(context){
+    "Drupal.behaviors.myEventBehavior = function(context){
       $('.agreservations-calendar td.agreservations-agenda-items div.agreservations div.view-item').each( function(){
         // Just a dirty fix. I have no idea how to properly calculate weight for this element
         var width = Math.max(($(this).parents('td').width())-5, $(this).width());
         $(this).width(width);
         });
-    };",
-               "inline");
+    };", "inline");
+
   $modulepath = drupal_get_path('module', 'agreservations');
   $vars['template_file'] = 'agreservations-calendar-day-2';
   if (module_exists('agres_categories')) {
@@ -818,15 +662,12 @@ function template_preprocess_agres_views_day(&$vars) {
     $vars['categories'] = $categories;
   }
   return;
-
 }
 
-
 /**
  * Display a day view.
  */
 function template_preprocess_agres_views_day_old(&$vars) {
-  //drupal_set_message('<pre>dayday '.print_r( $vars['rows'],true).'</pre>');
   $vars['view']->style_with_weekno = FALSE;
   $view = $vars['view'];
   $rows = $vars['rows'];
@@ -839,13 +680,13 @@ function template_preprocess_agres_views_day_old(&$vars) {
   // Add optional css
   if ($display_overlap) {
     $overlapped_items = array();
-    drupal_add_css(drupal_get_path('module', 'agres_views')  . '/css/agres_views-overlap.css');
+    drupal_add_css(drupal_get_path('module', 'agres_views') . '/css/agres_views-overlap.css');
     if (empty($view->live_preview)) {
       drupal_add_js(drupal_get_path('module', 'agres_views') . '/js/agres_views_overlap.js');
     }
   }
 
-  // If we're not grouping by time, move all items into the 'all day' array.
+  // If we are not grouping by time, move all items into the 'all day' array.
   if (empty($view->date_info->style_groupby_times)) {
     // Items are already grouped into times, so we need to process each time-group.
     foreach ($rows['items'] as $time => $items) {
@@ -858,22 +699,6 @@ function template_preprocess_agres_views_day_old(&$vars) {
 
   $columns = array();
 
-  // Move all_day items into the right columns and render them.
-//  $grouped_items = array();
-//  foreach ($rows['all_day'] as $item) {
-//    if (isset($item->{$grouping_field})) {
-//      $column = $item->{$grouping_field};
-//      $item->{$grouping_field} = ''; // Remove the grouping field from the results.
-//      if (!in_array($column, $columns)) {
-//        $columns[] = $column;
-//      }
-//    }
-//    else {
-//      $column = t('Items');
-//    }
-//    $grouped_items[$column][] = theme('agres_views_item', array('view' => $view, 'rendered_fields' => $item->rendered_fields, 'item' => $item));
-//    $item_count++;
-//  }
   $vars['rows']['all_day'] = $grouped_items;
 
   // Moved timed items into the right columns and render them.
@@ -889,7 +714,8 @@ function template_preprocess_agres_views_day_old(&$vars) {
       $time = date_format($item->agres_views_start_date, 'H:i:s');
       if (isset($item->{$grouping_field})) {
         $column = $item->{$grouping_field};
-        $item->{$grouping_field} = ''; // Remove the grouping field from the results.
+        // Remove the grouping field from the results.
+        $item->{$grouping_field} = '';
         if (!in_array($column, $columns)) {
           $columns[] = $column;
         }
@@ -992,20 +818,12 @@ function template_preprocess_agres_views_day_old(&$vars) {
 }
 
 /**
- * Display a week overlap view.
- */
-//function template_preprocess_agres_views_week_overlap(&$vars) {
-//  template_preprocess_agres_views_week($vars);
-//}
-
-/**
  * Display a week view.
  */
 function template_preprocess_agres_views_week(&$vars) {
-//   Add in all the $vars added by the main calendar preprocessor.
-  if ($vars['view']->name == 'agres_view' ) {
+  // Add in all the $vars added by the main calendar preprocessor.
+  if ($vars['view']->name == 'agres_view') {
     $vars['view']->style_with_weekno = FALSE;
-//       template_preprocess_calendar($vars);
     $view = $vars['view'];
     $rows = $vars['rows'];
     $agrrows = $vars['rows'];
@@ -1031,8 +849,6 @@ function template_preprocess_agres_views_week(&$vars) {
         $vars['currentcategory'] = $view->args[1];
 
         if (isset($view->args[2]) && $view->args[2]) {
-
-//        $units = _agreservations_get_unitnodes($view->args[2]);
           $units = _agres_categories_get_unitnodes_of_category($view->args[2], $view->args[1]);
           $vars['currentunittype'] = $view->args[2];
         }
@@ -1065,14 +881,13 @@ function template_preprocess_agres_views_week(&$vars) {
       }
       $unittypes = _agreservations_get_unittypenodes();
     }
-    //remove the args from agrescurrentpath:
+    // Remove the args from agrescurrentpath:
     $toremovefrompath = implode("/", $view->args);
     $agrescurrentpath = get_current_path();
-//       drupal_set_message('<pre>$agrescurrentpath'.print_r($agrescurrentpath,true).'</pre>');
     $agrescurrentpath = str_replace($toremovefrompath, "", $agrescurrentpath);
-    //cut off trailing slash:
-    if (substr($agrescurrentpath, -1, 1) == "/") {
-      $agrescurrentpath = substr($agrescurrentpath, 0, strlen($agrescurrentpath) - 1);
+    // Cut off trailing slash:
+    if (drupal_substr($agrescurrentpath, -1, 1) == "/") {
+      $agrescurrentpath = drupal_substr($agrescurrentpath, 0, drupal_strlen($agrescurrentpath) - 1);
     }
     $vars['agrescurrentpath'] = $agrescurrentpath;
     // Moved timed items into the right columns and render them.
@@ -1083,27 +898,24 @@ function template_preprocess_agres_views_week(&$vars) {
     $lastweekno = '';
     $icount = 1;
     $ff = 0;
-    //initialize vars teststringggg:
-//       drupal_set_message('<pre>***'. print_r($rows[0], TRUE) .'</pre>');
+    // Initialize vars teststring
     $vars['rinfo'] = array();
     foreach ($rows[0] as $weekno => $row) {
-//          drupal_set_message('<pre>weeeeek '.print_r(  $row,true).'</pre>');
       $vars['rows'][$weekno] = $row['data'];
       foreach ($row['data']['items'] as $ikey => $item) {
-//            drupal_set_message('<pre>weeeeek '.print_r(  $item,true).'</pre>');
         ksort($item);
         foreach ($item as $skey => $singlereservation) {
-//               $date = new DateObject($value, date_default_timezone(), DATE_ISO_FORMAT);
-//               new DateOb
+
           $date = new DateObject($singlereservation->field['value'], $singlereservation->field['timezone_db'], NULL);
-//               $date->setTimezone($singlereservation->field['timezone']);
           $date->setTimezone(timezone_open(date_default_timezone()));
 
           $tmpunititems = array();
-          $tmpunititems = _agreservations_get_unitn_for_reservation_node($singlereservation->nid); //A.Gill: Räume je reservierung holen
+          // Rooms per reservation pick
+          $tmpunititems = _agreservations_get_unitn_for_reservation_node($singlereservation->nid);
           foreach ($units as $unit) {
 
-            if (in_array($unit->nid, $tmpunititems)) { //A.Gill checks if unit is a booked item:
+            // Checks if unit is a booked item:
+            if (in_array($unit->nid, $tmpunititems)) {
               $itemdate1 = new DateObject($singlereservation->field['value'], $singlereservation->field['timezone_db'], NULL);
               $itemdate1->setTimezone(timezone_open(date_default_timezone()));
               $itemdate2 = new DateObject($singlereservation->field['value2'], $singlereservation->field['timezone_db'], NULL);
@@ -1120,9 +932,7 @@ function template_preprocess_agres_views_week(&$vars) {
 
               if (( ($pos2 === FALSE)) || (($pos !== FALSE) && ($pos2 !== FALSE))) {
                 $row['data']['all_day'][$unit->title] = $singlereservation;
-//                   $row['data']['all_day'][$unit->title] = $singlereservation;
               }
-
             }
           }
         }
@@ -1134,41 +944,36 @@ function template_preprocess_agres_views_week(&$vars) {
       $rowcopy = $row['data']['all_day'];
       $row['data']['all_day'] = array();
       foreach ($rowcopy as $ikey => $singlereservation) {
-//             drupal_set_message('<pre>***unit:dddd'. print_r($singlereservation, TRUE) .'</pre>');
         $tmpunititems = array();
-        $tmpunititems = _agreservations_get_unitn_for_reservation_node($singlereservation->nid); //A.Gill: Räume je reservierung holen
+        // Rooms per reservation pick
+        $tmpunititems = _agreservations_get_unitn_for_reservation_node($singlereservation->nid);
 
         foreach ($units as $unit) {
-          if (in_array($unit->nid, $tmpunititems)) { //
+          if (in_array($unit->nid, $tmpunititems)) {
             $row['data']['all_day'][$unit->title] = $singlereservation;
           }
         }
       }
-//        drupal_set_message('<pre>gdgdg***'. print_r($row['data']['all_day'], TRUE) .'</pre>');
       $columns[] = $weekno;
       foreach ($units as $unit) {
-        //initialize $grouped_items:
+        // Initialize $grouped_items
         $grouped_items[$unit->title] = array();
         $start_times = $view->date_info->style_groupby_times;
         $start_time = array_shift($start_times);
         $next_start_time = count($start_times) ? array_shift($start_times) : $end_start_time;
         ksort($row['data']['all_day']);
-        foreach ($row['data']['all_day'] as   $key => $item) { //
-//             $test = node_load($item->nid);
-//             drupal_set_message('<pre>gdgdg***'. print_r($test, TRUE) .'</pre>');
-          $tmpEnd = date_create($item->row->field_field_agres_rdate[0]['raw']['value2']);
-          $tmpGranularityEnd = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
-          if ($tmpEnd > $tmpGranularityEnd) {
+        foreach ($row['data']['all_day'] as $key => $item) {
+          $temp_end = date_create($item->row->field_field_agres_rdate[0]['raw']['value2']);
+          $temp_granularity_end = date_create(date_format($view->date_info->max_date, DATE_FORMAT_DATETIME));
+          if ($temp_end > $temp_granularity_end) {
             $continues = 1;
-
           }
           else {
             $continues = 0;
           }
-//                drupal_set_message('<pre>*$continues = 0;**'. print_r($item->row, TRUE) .'</pre>');
-          $tmpstart = date_create($item->row->field_field_agres_rdate[0]['raw']['value']);
-          $tmpGranularitystart = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
-          if ($tmpstart < $tmpGranularitystart) {
+          $temp_start = date_create($item->row->field_field_agres_rdate[0]['raw']['value']);
+          $temp_granularity_start = date_create(date_format($view->date_info->min_date, DATE_FORMAT_DATETIME));
+          if ($temp_start < $temp_granularity_start) {
             $continuation = 1;
           }
           else {
@@ -1176,10 +981,12 @@ function template_preprocess_agres_views_week(&$vars) {
           }
           $itemclass = 'itemwithoutorder';
           if (!isset($item->node->field_agres_orderid[$item->node->language])) {
-            $itemclass = 'itemwithoutorder'; //treat as receptionist manual reservation defaultcolor orange
+            // Treat as receptionist manual reservation defaultcolor orange
+            $itemclass = 'itemwithoutorder';
           }
           else {
-            $itemclass = 'itemwithorder'; //treat as receptionist manual reservation defaultcolor blue
+            // Treat as receptionist manual reservation defaultcolor blue
+            $itemclass = 'itemwithorder';
           }
 
           $themeparams = array(
@@ -1190,10 +997,12 @@ function template_preprocess_agres_views_week(&$vars) {
             'continuation' => $continuation,
             'itemclass' => $itemclass,
           );
-          $tmpunititems = _agreservations_get_unitn_for_reservation_node($item->nid); //get units per reservation
-          if ($unit->title === $key) { //A.Gill unit is in booked item:    if (in_array($unit->nid, $tmpunititems)){//
-            if ((!isset($vars['rinfo'][$unit->title][$item->nid]))) { //(!isset($vars['rows'][$weekno]['night'][$unit->title][$item->vid])){
-              $vars['rows'][$weekno]['night'][$unit->title][$item->nid] = theme('agres_views_item', $themeparams); // theme($theme, $variables);
+          // Units per reservation
+          $tmpunititems = _agreservations_get_unitn_for_reservation_node($item->nid);
+          // Unit is in booked item
+          if ($unit->title === $key) {
+            if ((!isset($vars['rinfo'][$unit->title][$item->nid]))) {
+              $vars['rows'][$weekno]['night'][$unit->title][$item->nid] = theme('agres_views_item', $themeparams);
               $vars['rinfo'][$unit->title][$item->nid] = '1';
               $vars['spaninfo'][$unit->title][$item->nid] = 1;
             }
@@ -1209,7 +1018,7 @@ function template_preprocess_agres_views_week(&$vars) {
           foreach ($items as $item) {
 
             // Find the next time slot and fill it. Populate the skipped
-            // slots if the option to show empty times was chosen.($show_empty_times) &&
+            // slots if the option to show empty times was chosen.
             while ($time >= $next_start_time && $time < $end_start_time) {
               if (is_array($grouped_items[$unit->title])) {
                 if (!array_key_exists($start_time, $grouped_items[$unit->title])) {
@@ -1223,11 +1032,11 @@ function template_preprocess_agres_views_week(&$vars) {
               $next_start_time = count($start_times) ? array_shift($start_times) : $end_start_time;
             }
 
-//            agag   $theme = isset($item->calendar_node_theme) ? $item->calendar_node_theme : 'calendar_' . $view->date_info->granularity . '_node';
             $tmpunititems = array();
-            $tmpunititems = _agreservations_get_unitn_for_reservation_node($item->nid); //get units per reservation
+            // Units per reservation
+            $tmpunititems = _agreservations_get_unitn_for_reservation_node($item->nid);
             if (in_array($unit->nid, $tmpunititems)) {
-//             agag    $grouped_items[$unit->title][$start_time]['values'][$weekno][$item->nid] = theme($theme, $item, $view);
+
             }
             $item_count++;
             $by_hour_count++;
@@ -1251,7 +1060,6 @@ function template_preprocess_agres_views_week(&$vars) {
           }
         }
       }
-      // end foreach ($units as $unit) {
     }
     ksort($grouped_items);
     $i = 0;
@@ -1281,10 +1089,9 @@ function template_preprocess_agres_views_week(&$vars) {
     }
     return;
   }
-  else { //normal calendar
+  // Normal calendar
+  else {
     $vars['template_file'] = 'agreservations-calendar-week-1';
-//       template_preprocess_calendar($vars);
-//       template_preprocess_calendar_week($vars);
     return;
   }
 }
@@ -1295,7 +1102,7 @@ function template_preprocess_agres_views_week(&$vars) {
 function template_preprocess_agres_views_datebox(&$vars) {
   $date = $vars['date'];
   $view = $vars['view'];
-  $vars['day'] = intval(substr($date, 8, 2));
+  $vars['day'] = intval(drupal_substr($date, 8, 2));
   $force_view_url = !empty($view->date_info->block) ? TRUE : FALSE;
   $month_path = agres_views_granularity_path($view, 'month');
   $year_path = agres_views_granularity_path($view, 'year');
@@ -1315,24 +1122,22 @@ function template_preprocess_agres_views_datebox(&$vars) {
   else {
     $vars['class'] = 'day';
   }
-//  drupal_set_message('<pre>ifrekt. spaninfo '.print_r( $vars['day'],true).'</pre>');
 }
 
 /**
  * Format an agres_views month node for display.
  */
 function template_preprocess_agres_views_month_multiple_node(&$vars) {
-//    drupal_set_message('<pre>template_preprocess_agres_views_month_multiple_node '.print_r( $vars['rows'],true).'</pre>');
   $view = $vars['view'];
   $curday = $vars['curday'];
 
-  // get the year month and date
-  $parts = explode('-', substr($curday, 0, 10));
+  // Get the year month and date
+  $parts = explode('-', drupal_substr($curday, 0, 10));
   $year = $parts[0];
   $month = intval($parts[1]);
   $day = intval($parts[2]);
 
-  // create the link to the day
+  // Create the link to the day
   $vars['link'] = date_pager_url($view, NULL, date_pad($year, 4) . '-' . date_pad($month) . '-' . date_pad($day));
 }
 
@@ -1343,13 +1148,13 @@ function template_preprocess_agres_views_week_multiple_node(&$vars) {
   $view = $vars['view'];
   $curday = $vars['curday'];
 
-  // get the year month and date
-  $parts = explode('-', substr($curday, 0, 10));
+  // Get the year month and date
+  $parts = explode('-', drupal_substr($curday, 0, 10));
   $year = $parts[0];
   $month = intval($parts[1]);
   $day = intval($parts[2]);
 
-  // create the link to the day
+  // Create the link to the day
   $vars['link'] = date_pager_url($view, NULL, date_pad($year, 4) . '-' . date_pad($month) . '-' . date_pad($day));
 }
 
@@ -1360,12 +1165,11 @@ function template_preprocess_agres_views_week_multiple_node(&$vars) {
  * $vars['item'] = The source data for this item.
  * $vars['view'] = The view that this item is displayed on.
  *
- * @TODO We need some options about how to combine rendered fields.
- * Fields rendered in multiday containers need to be inline.
+ * @todo We need some options about how to combine rendered fields. Fields
+ *  rendered in multiday containers need to be inline.
  */
 function template_preprocess_agres_views_item(&$vars) {
-//    $item->
-  //drupal_set_message('<pre>template_preprocess_agres_views_item '.print_r( $vars,true).'</pre>');
+
 }
 
 /**
@@ -1377,9 +1181,7 @@ function theme_agres_views_time_row_heading($vars) {
   $curday_date = $vars['curday_date'];
   static $format_hour, $format_ampm;
   if (empty($format_hour)) {
-//    $format = //variable_get('date_format_short', 'm/d/Y - H:i');
-    $format =  'm/d/Y - H:i';
-//    $format_hour = str_replace(array('a', 'A'), '', date_limit_format($format, array('hour', 'minute')));
+    $format = 'm/d/Y - H:i';
     $format_hour = str_replace(array('a', 'A'), '', date_limit_format($format, array('hour', 'minute')));
     $format_ampm = strstr($format, 'a') ? 'a' : (strstr($format, 'A') ? 'A' : '');
   }
@@ -1401,7 +1203,6 @@ function theme_agres_views_time_row_heading($vars) {
     $ampm = '';
   }
   return array('hour' => $hour, 'ampm' => $ampm);
-
 }
 
 /**
@@ -1459,11 +1260,15 @@ function theme_agres_views_stripe_stripe($vars) {
   }
   return $output;
 }
+
+/**
+ *
+ * @todo Documentation
+ */
 function template_preprocess_agres_views_month_col(&$vars) {
-//    $vars['agresss'][]=$vars['item'];
-//        drupal_set_message('<pre>template_preprocess_agres_views_month_col '.print_r( $vars,true).'</pre>');
-//         $vars['item2']=$vars['item'];
+
 }
+
 /**
  * Format an empty day on a agres_views
  *
@@ -1471,16 +1276,10 @@ function template_preprocess_agres_views_month_col(&$vars) {
  *   The day to display.
  */
 function theme_agres_views_empty_day(&$vars) {
-//    drupal_set_message('<pre>weeeeek '.print_r($vars['view'],true).'</pre>');
   $curday = $vars['curday'];
-//   $vars['agrcurdays'][]=$curday;
-//  $vars['agrdays'][]=$curday;
   $view = $vars['view'];
-//  drupal_set_message('<pre>weeeeek '.print_r($view->style_plugin->date_info->agres_views_type,true).'</pre>');
   if ($view->style_plugin->date_info->agres_views_type != 'day') {
     return '<div class="agres_views-empty">&nbsp;</div>' . "\n";
   }
-  else {
-    return '<div class="agres_views-dayview-empty">' . t('Empty day') . '</div>';
-  }
-}
+  return '<div class="agres_views-dayview-empty">' . t('Empty day') . '</div>';
+}
\ No newline at end of file
diff --git a/agreservations.field.inc b/agreservations.field.inc
index 885bdcb..9272dd0 100644
--- a/agreservations.field.inc
+++ b/agreservations.field.inc
@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * @file
+ *  @todd Fill this in.
+ */
+
+/**
+ * @todo Documentation
+ */
 function _agreservations_contenttypes() {
   $types = array(
     array(
@@ -45,9 +53,6 @@ other example: Unit "Porsche red #434224" is of Unit type "sport cars" which is
   return $types;
 }
 
-
-
-
 function _agreservations_fields() {
   $fields = array();
 
@@ -1357,4 +1362,4 @@ function _agreservations_fields() {
   t('Userreference');
 
   return $fields;
-}
+}
\ No newline at end of file
diff --git a/agreservations.info b/agreservations.info
index 9949b39..f583194 100644
--- a/agreservations.info
+++ b/agreservations.info
@@ -1,24 +1,23 @@
-; $Id: agreservations.info,v 1.1.1.1.6.7.2.1 2010/12/24 01:38:02 agill Exp $
-name = agreservations
-description = Provide you with a Bookingcalendar view for hotels for example
+name = Agreservations
+description = Provide you with a Booking calendar view for rental properties like hotels.
+package = Agreservations - Core
+core = 7.x
+
+files[] = agreservations.install
+files[] = agreservations.module
+files[] = agreservations.views.inc
+
 dependencies[] = date_popup
 dependencies[] = agres_rconflict
-;dependencies[] = date_timezone -not yet portet to D7
-;dependencies[] = cck ;name has changed from content to cck
-;dependencies[] = content_copy not yet portet to D7
-;dependencies[] = number not yet portet to D7
+dependencies[] = number
 dependencies[] = references
 dependencies[] = user_reference
 dependencies[] = node_reference
 dependencies[] = date
 dependencies[] = date_views
-;dependencies[] = taxonomy
 dependencies[] = i18n
-;dependencies[] = cck_referential_integrity not yet portet to D7
-
-package = agreservations - Core
-core = 7.x
-
-files[] = agreservations.install
-files[] = agreservations.module
-files[] = agreservations.views.inc
+;dependencies[] = date_timezone -not yet portet to D7
+;dependencies[] = cck ;name has changed from content to cck
+;dependencies[] = content_copy not yet portet to D7
+;dependencies[] = taxonomy
+;dependencies[] = cck_referential_integrity not yet portet to D7
\ No newline at end of file
diff --git a/agreservations.install b/agreservations.install
index f88f84a..fdd60d7 100644
--- a/agreservations.install
+++ b/agreservations.install
@@ -1,174 +1,152 @@
 <?php
-// $Id: agreservations.install,v 1.1.1.1.6.7.2.1 2010/11/08 23:13:12 agill Exp $
-
-
-
-/**
- * @file
- * agreservations Installer / Uninstaller
- */
-
-/**
- * _agres_categories_install_ccktype
- * Install the cck fields and types in $export.
- *
- * @param $typename
- *   '<create>'    :a new cck type will be installed
- *   'contenttype' :the fields in  $export will be added to the given
- *  contenttype.
- * @param $export _ the export to be imported.
- */
+
+/**
+ * @file
+ * agreservations Installer / Uninstaller
+ */
+
+/**
+ * _agres_categories_install_ccktype
+ * Install the cck fields and types in $export.
+ *
+ * @param $typename
+ *   '<create>'    :a new cck type will be installed
+ *   'contenttype' :the fields in  $export will be added to the given
+ *  contenttype.
+ * @param $export _ the export to be imported.
+ */
 // from the features module:
-function _agreservations_install_bundle_fields($fields) {
-  if (isset($fields)) {
-    field_info_cache_clear();
-    foreach ($fields as $field) {
+function _agreservations_install_bundle_fields($fields) {
+  if (isset($fields)) {
+    field_info_cache_clear();
+    foreach ($fields as $field) {
       // Create or update field.
-      $field_config = $field['field_config'];
-      if ($existing_field = field_info_field($field_config['field_name'])) {
-        field_update_field($field_config);
-      }
-      else {
-        field_create_field($field_config);
-      }
-
+      $field_config = $field['field_config'];
+      if ($existing_field = field_info_field($field_config['field_name'])) {
+        field_update_field($field_config);
+      }
+      else {
+        field_create_field($field_config);
+      }
+
       // Create or update field instance.
-      $field_instance = $field['field_instance'];
-      $existing_instance = field_info_instance($field_instance['entity_type'], $field_instance['field_name'], $field_instance['bundle']);
-      if ($existing_instance) {
-        field_update_instance($field_instance);
-      }
-      else {
-        field_create_instance($field_instance);
-      }
-      variable_set('menu_rebuild_needed', TRUE);
-    }
-  }
-}
-
-/**
- * @todo Please document this function.
- * @see http://drupal.org/node/1354
- */
-function agreservations_install() {
-  module_load_include('inc', 'agreservations', 'agreservations.field');
-  $types = _agreservations_contenttypes();
-  foreach ($types as $type) {
-    $type = node_type_set_defaults($type);
-    node_type_save($type);
-    node_add_body_field($type);
-  }
-  $fields = _agreservations_fields();
-  module_load_include('inc', 'agreservations', '/includes/agres_funcs');
-//  _install_bundle_fields($fields);
-  _install_bundle_fields($fields);
-}
-
-/**
- * Implements hook_enable().
- */
-function agreservations_enable() {
-//  module_load_include('inc', 'agreservations', 'agreservations.field');
-//  $fields = _agreservations_fields();
-  module_load_include('inc', 'agreservations', '/includes/agres_funcs');
-//  _agreservations_install_bundle_fields($fields);
-
-}
-//agreservation_unit_info
-
-
-
-//thanks to authors of the examples modules collection!
-function agreservations_uninstall() {
-  module_load_include('inc', 'agreservations', 'agreservations.field');
+      $field_instance = $field['field_instance'];
+      $existing_instance = field_info_instance($field_instance['entity_type'], $field_instance['field_name'], $field_instance['bundle']);
+      if ($existing_instance) {
+        field_update_instance($field_instance);
+      }
+      else {
+        field_create_instance($field_instance);
+      }
+      variable_set('menu_rebuild_needed', TRUE);
+    }
+  }
+}
+
+/**
+ * Implements hook_install().
+ * 
+ * @todo Documentation
+ */
+function agreservations_install() {
+  module_load_include('inc', 'agreservations', 'agreservations.field');
+  $types = _agreservations_contenttypes();
+  foreach ($types as $type) {
+    $type = node_type_set_defaults($type);
+    node_type_save($type);
+    node_add_body_field($type);
+  }
+  $fields = _agreservations_fields();
+  module_load_include('inc', 'agreservations', '/includes/agres_funcs');
+  _install_bundle_fields($fields);
+}
+
+/**
+ * Implements hook_enable().
+ */
+function agreservations_enable() {
+  module_load_include('inc', 'agreservations', '/includes/agres_funcs');
+}
+
+/**
+ * Implements hook_uninstall().
+ */
+function agreservations_uninstall() {
+  module_load_include('inc', 'agreservations', 'agreservations.field');
   // Gather all the example content that might have been created while this
   // module was enabled.  Simple selects still use db_query().
-  // http://api.drupal.org/api/function/db_query/7
-  $sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
-  $result = db_query($sql, array(':type' => 'agreservation'));
-  $nids = array();
-  foreach ($result as $row) {
-    $nids[] = $row->nid;
-  }
-
+  $result = db_query('SELECT nid FROM {node} n WHERE n.type = :type', array(':type' => 'agreservation'));
+  $nids = array();
+  foreach ($result as $row) {
+    $nids[] = $row->nid;
+  }
+
   // Delete all the nodes at once
-  // http://api.drupal.org/api/function/node_delete_multiple/7
-  node_delete_multiple($nids);
-
-  $sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
-  $result = db_query($sql, array(':type' => 'agreservations_unit'));
-  $nids = array();
-  foreach ($result as $row) {
-    $nids[] = $row->nid;
-  }
-
-  node_delete_multiple($nids);
-
-  $sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
-  $result = db_query($sql, array(':type' => 'agreservation_unit_info'));
-  $nids = array();
-  foreach ($result as $row) {
-    $nids[] = $row->nid;
-  }
-
-  node_delete_multiple($nids);
-
-  $sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
-  $result = db_query($sql, array(':type' => 'agreservations_unittype'));
-  $nids = array();
-  foreach ($result as $row) {
-    $nids[] = $row->nid;
-  }
-
-  node_delete_multiple($nids);
-
+  node_delete_multiple($nids);
+
+  $result = db_query('SELECT nid FROM {node} n WHERE n.type = :type', array(':type' => 'agreservations_unit'));
+  $nids = array();
+  foreach ($result as $row) {
+    $nids[] = $row->nid;
+  }
+
+  node_delete_multiple($nids);
+
+  $result = db_query('SELECT nid FROM {node} n WHERE n.type = :type', array(':type' => 'agreservation_unit_info'));
+  $nids = array();
+  foreach ($result as $row) {
+    $nids[] = $row->nid;
+  }
+
+  node_delete_multiple($nids);
+
+  $result = db_query('SELECT nid FROM {node} n WHERE n.type = :type', array(':type' => 'agreservations_unittype'));
+  $nids = array();
+  foreach ($result as $row) {
+    $nids[] = $row->nid;
+  }
+
+  node_delete_multiple($nids);
+
   // Loop over each of the fields defined by this module and delete
   // all instances of the field, their data, and the field itself.
-  // http://api.drupal.org/api/function/field_delete_field/7
-
-
-
-  foreach (array_keys(_agreservations_fields()) as $field) {
-    field_delete_field($field);
-  }
+  foreach (array_keys(_agreservations_fields()) as $field) {
+    field_delete_field($field);
+  }
+
   // Loop over any remaining field instances attached to the node_example
   // content type (such as the body field) and delete them individually.
-  // http://api.drupal.org/api/function/field_delete_field/7
-  $instances = field_info_instances('node', 'agreservation');
-  foreach ($instances as $instance_name => $instance) {
-    field_delete_instance($instance);
-  }
-
+  $instances = field_info_instances('node', 'agreservation');
+  foreach ($instances as $instance_name => $instance) {
+    field_delete_instance($instance);
+  }
+
   // Delete our content type
-  // http://api.drupal.org/api/function/node_type_delete/7
-  node_type_delete('agreservation');
-
-  $instances = field_info_instances('node', 'agreservations_unittype');
-  foreach ($instances as $instance_name => $instance) {
-    field_delete_instance($instance);
-  }
-
+  node_type_delete('agreservation');
+
+  $instances = field_info_instances('node', 'agreservations_unittype');
+  foreach ($instances as $instance_name => $instance) {
+    field_delete_instance($instance);
+  }
+
   // Delete our content type
-  // http://api.drupal.org/api/function/node_type_delete/7
-  node_type_delete('agreservations_unittype');
-
-  $instances = field_info_instances('node', 'agreservation_unit_info');
-  foreach ($instances as $instance_name => $instance) {
-    field_delete_instance($instance);
-  }
-
-  node_type_delete('agreservation_unit_info');
-
-  $instances = field_info_instances('node', 'agreservations_unit');
-  foreach ($instances as $instance_name => $instance) {
-    field_delete_instance($instance);
-  }
-
+  node_type_delete('agreservations_unittype');
+
+  $instances = field_info_instances('node', 'agreservation_unit_info');
+  foreach ($instances as $instance_name => $instance) {
+    field_delete_instance($instance);
+  }
+
+  node_type_delete('agreservation_unit_info');
+
+  $instances = field_info_instances('node', 'agreservations_unit');
+  foreach ($instances as $instance_name => $instance) {
+    field_delete_instance($instance);
+  }
+
   // Delete our content type
-  // http://api.drupal.org/api/function/node_type_delete/7
-  node_type_delete('agreservations_unit');
-
+  node_type_delete('agreservations_unit');
+
   // Purge all field infromation
-  // http://api.drupal.org/api/function/field_purge_batch/7
-  field_purge_batch(1000);
-}
+  field_purge_batch(1000);
+}
\ No newline at end of file
diff --git a/agreservations.module b/agreservations.module
index 8a66de3..2fdc2d5 100644
--- a/agreservations.module
+++ b/agreservations.module
@@ -8,29 +8,30 @@
  *
  */
 require_once('./' . drupal_get_path('module', 'agreservations') . '/includes/agres_funcs.inc');
+
 // agreservations status options.
 define('AGRES_STATUS_ONLINE_NO_ORDER_YET', 1);
 define('AGRES_STATUS_ONLINE_ORDER_CREATED', 2);
 define('AGRES_STATUS_NO_ORDER', 3);
 define('AGRES_STATUS_ADMIN_ORDER', 4);
+
 /**
  * Implement hook_views_api().
  */
-
-
 function agreservations_views_api($module, $api) {
   if ($module == 'views' && $api == 'views_default') {
     return array('version' => 3);
   }
 }
+
 /**
- * @todo Please document this function.
- * @see http://drupal.org/node/1354
+ * Implements hook_init().
  */
 function agreservations_init() {
   drupal_add_css(drupal_get_path('module', 'agreservations') . '/agreservations.css');
 //   module_load_include('inc', 'node', 'node.pages');
 }
+
 /**
  * Implements hook_permission().
  */
@@ -51,7 +52,6 @@ function agreservations_permission() {
   );
 }
 
-
 /**
  * Return an array of nids of reserved rooms/units from a single reservation:
  */
@@ -74,6 +74,7 @@ function _agreservations_get_unitn_for_reservation_node($paramnid) {
 
   return $bookedunitnids;
 }
+
 /**
  * Return an array of nids of reserved unit types from a single reservation:
  */
@@ -113,7 +114,6 @@ function _agreservations_get_unitnodes($nidunittype = NULL) {
     $query->addField('fau', 'field_agreservations_unitnumber_value');
     $query->orderBy('field_agreservations_unitnumber_value', 'ASC');
     $res = $query->execute();
-
   }
   else {
     // TODO Please convert this statement to the D7 database API syntax.
@@ -129,8 +129,7 @@ function _agreservations_get_unitnodes($nidunittype = NULL) {
 
   while ($unititem = $res->fetchObject()) {
     $units[$unititem->nid] = node_load($unititem->nid); //$unititem;
-
-    //
+  //
   }
 
   return $units;
@@ -170,6 +169,9 @@ function _agreservations_get_unittypenodes() {
   return $unittypes;
 }
 
+/**
+ * Implements hook_views_pre_view().
+ */
 function agreservations_views_pre_view(&$view, &$display_id, &$args) {
   $output = '';
   switch ($view->name) {
@@ -193,6 +195,9 @@ function agreservations_views_pre_view(&$view, &$display_id, &$args) {
   $view->attachment_after = $output;
 }
 
+/**
+ * Implements hook_node_view().
+ */
 function agreservations_node_view($node, $view_mode, $langcode) {
   if ($node->type == 'agreservation') {
     $tmpdatewarg = new DateTime($node->field_agres_rdate[$node->language][0]['value']);
@@ -206,11 +211,12 @@ function agreservations_node_view($node, $view_mode, $langcode) {
       '#suffix' => '</div>',
       '#weight' => -1,
     );
-
-
   }
 }
 
+/**
+ * Implements hook_node_validate().
+ */
 function agreservations_node_validate($node, $form, $form_state) {
   if ($node->type == 'agreservation') {
     $tlangs1 = array();
@@ -228,8 +234,8 @@ function agreservations_node_validate($node, $form, $form_state) {
           $error = t('Date To (%start): has to be after Date From (%end)', array(
             '%start' => $strtmpdat1,
             '%end' => $strtmpdat2,
-          )
-                    );
+            )
+          );
           form_set_error('field_agres_rdate', $error);
         }
       }
@@ -237,7 +243,6 @@ function agreservations_node_validate($node, $form, $form_state) {
   }
 }
 
-
 /**
  * Implements hook_nodeapi().
  */
@@ -399,32 +404,39 @@ function _agreservations_find_agreservationinfo($nid, $unitnid) {
   $fieldname_agres_refsingle_unit = $db_info['columns']['nid']['column'];
   $tablename_agres_refsingle_unit = $db_info['table'];
 //                drupal_set_message('<pre>'.print_r($db_info,TRUE).'</pre>');
-
-
 //                drupal_set_message('<pre>'.print_r(db_rewrite_sql("SELECT n.nid, n.title AS title,ctau.nid ,ctau.$fieldname_field_agreservations_unitnumber, ctaut.$fieldname_field_agreservations_unittype FROM {node} n INNER JOIN {".$tablename_field_agreservations_unitnumber."} ctau ON n.nid = ctau.nid INNER JOIN {".$tablename_field_agreservations_unitnumber."} ctaut ON ctaut.nid =  ctaut.nid WHERE (n.status = 1 and n.type = 'agreservations_unit') order by ctau.$fieldname_field_agreservations_unitnumber"),TRUE).'</pre>');
-
-
-
-
   // TODO Please convert this statement to the D7 database API syntax.
-  $res = db_query("SELECT n.nid, ctauira.$fieldname_agres_ref_agreservation, ctauiru.$fieldname_agres_refsingle_unit FROM {node} n INNER JOIN {" . $tablename_agres_ref_agreservation . "} ctauira ON n.nid = ctauira.nid INNER JOIN {" . $tablename_agres_refsingle_unit . "} ctauiru ON ctauira.nid =  ctauiru.nid WHERE n.status = 1 AND n.type = 'agreservation_unit_info' AND ctauira.$fieldname_agres_ref_agreservation = %d AND ctauiru.$fieldname_agres_refsingle_unit = %d order by ctauiru.$fieldname_agres_refsingle_unit", $nid, $unitnid);
+  $query = db_select('node', 'n')
+    ->fields('n', array('nid'))
+    ->fields('ctauira', array($fieldname_agres_ref_agreservation))
+    ->fields('ctauiru', array($fieldname_agres_refsingle_unit))
+    ->join($tablename_agres_ref_agreservation, 'ctauira', 'n.nid = ctauira.nid')
+    ->join($tablename_agres_refsingle_unit, 'ctauiru', 'ctauira.nid = ctauiru.nid')
+    ->condition('n.status', 1)
+    ->condition('n.type', 'agreservation_unit_info')
+    ->condition('ctauira.' . $fieldname_agres_ref_agreservation, $nid)
+    ->condition('ctauiru.' . $fieldname_agres_refsingle_unit, $unitnid)
+    ->orderBy('ctauiru.' . $fieldname_agres_refsingle_unit, 'asc')
+    ->execute();
+  //$res = db_query("SELECT n.nid, ctauira.$fieldname_agres_ref_agreservation, ctauiru.$fieldname_agres_refsingle_unit FROM {node} n INNER JOIN {" . $tablename_agres_ref_agreservation . "} ctauira ON n.nid = ctauira.nid INNER JOIN {" . $tablename_agres_refsingle_unit . "} ctauiru ON ctauira.nid =  ctauiru.nid WHERE n.status = 1 AND n.type = 'agreservation_unit_info' AND ctauira.$fieldname_agres_ref_agreservation = %d AND ctauiru.$fieldname_agres_refsingle_unit = %d order by ctauiru.$fieldname_agres_refsingle_unit", $nid, $unitnid);
 
   $unitinfos = array();
-  while ($unitinfo = db_fetch_object($res)) {
+  foreach ($query as $unitinfo) {
     $unitinfos[$unitinfo->nid] = $unitinfo;
   }
   return $unitinfos;
 }
 
-/** Implementation of hook_user:
+/**
+ * Implements hook_user().
  *       switch ($op){
- case 'insert':
- $five = time()+300; // 5 minutes in the future.
- setcookie("PopupRefNid", $node->nid, $five, '/');
- //      setcookie("PopupRefTitle", $node->title, $five, '/');
- setrawcookie("PopupRefTitle", rawurlencode($node->title), $five, '/');
+  case 'insert':
+  $five = time()+300; // 5 minutes in the future.
+  setcookie("PopupRefNid", $node->nid, $five, '/');
+  //      setcookie("PopupRefTitle", $node->title, $five, '/');
+  setrawcookie("PopupRefTitle", rawurlencode($node->title), $five, '/');
 
- }
+  }
  */
 
 /**
@@ -535,7 +547,6 @@ function agreservations_get_reservable_items($content_type, $start, $end, $cat =
   if (module_exists('agres_categories') && isset($cat)) {
     while ($unititem = $res->fetchObject()) {
       $availableunits[] = node_load($unititem->nid); //$unititem;
-
     }
 
 //    while ($item = db_fetch_object($items)) {
@@ -563,13 +574,12 @@ function agreservations_get_reservable_items($content_type, $start, $end, $cat =
   return $availableunits;
 }
 
-/*    * This function returns an array of reservable unittypes in the */
+/* * This function returns an array of reservable unittypes in the */
 
 /**
- * @todo Please document this function.
- * @see http://drupal.org/node/1354
+ *
  */
-function agreservations_get_reservable_unittypes($nodesarray, $simple) {
+function _agreservations_get_reservable_unittypes($nodesarray, $simple) {
   $availableunittypes = array();
   $availableunittypesnids = array();
   if ($simple == TRUE) {
@@ -604,14 +614,13 @@ function agreservations_get_reservable_unittypes($nodesarray, $simple) {
   }
 }
 
-/* Finds the concrete units for the userrequest used
- * for filling out a reservationnode programmatically.
+/**
+ * Finds the concrete units for the userrequest used for filling out a 
+ * reservationnode programmatically.
  */
-
-function _agreservations_findunitsForUserRequest($userrequestunits, $checkin, $checkout, $category) {
+function _agreservations_find_units_for_user_request($userrequestunits, $checkin, $checkout, $category) {
   //1.:get all reservable items:
 
-
   $check = FALSE;
   $resarray = array();
   $reservable_units = agreservations_get_reservable_items('agreservations_unit', $checkin, $checkout, $category);
@@ -634,25 +643,24 @@ function _agreservations_findunitsForUserRequest($userrequestunits, $checkin, $c
       }
     }
     //if no fitting room was found anymore, the booking has to be stopped!
-
-
     if ($check === FALSE) {
 //             drupal_set_message('<pre>_agreservations_findunitsForUserRequest errr</pre>');
-
-
       return FALSE;
     }
   }
   return $resarray;
 }
 
-/*    * ************Programmatically creates a Reservationsinfo: reservation/resource/Persons/...**************** */
-
+/**
+ * Programmatically creates a Reservationsinfo
+ * 
+ * reservation/resource/Persons/...
+ */
 function _agreservations_create_ResInfo($agresnid, $unitid, $pers = 0) {
   $node = new stdClass();
   $node->is_new = 1;
   $tmpnodeunit = node_load($unitid, NULL, TRUE);
-  $node->title = t('Info of Reservation: @resid and Unit: @unit ', array('@resid' => $agresnid, '@unit' => $tmpnodeunit->title));
+  $node->title = t('Info of Reservation: @resid and Unit: @unit', array('@resid' => $agresnid, '@unit' => $tmpnodeunit->title));
 //  $node->body = "";
 
 
@@ -675,9 +683,9 @@ function _agreservations_create_ResInfo($agresnid, $unitid, $pers = 0) {
   return $node->nid;
 }
 
-
-/*    * ************Programmatically updates a Reservationnode *** */
-
+/**
+ * Programmatically updates a Reservationnode
+ */
 function _agreservations_update_Reservation($resnid, $units, $checkin, $checkout, $userid = NULL, $orderid = NULL, $agresstatus = NULL) {
   $node = node_load($resnid);
   $langcode_unit = i18n_langcode();
@@ -693,8 +701,10 @@ function _agreservations_update_Reservation($resnid, $units, $checkin, $checkout
   $retval = $node->nid;
   return $retval;
 }
-/*    * ************Programmatically creates a Reservationnode:**************** */
 
+/**
+ * Programmatically creates a Reservationnode
+ */
 function _agreservations_create_Reservation($units, $checkin, $checkout, $userid = NULL, $orderid = NULL, $agresstatus = NULL) {
 //    module_load_include('inc', 'node', 'node.pages');  
   $langcode_unit = i18n_langcode();
@@ -712,7 +722,8 @@ function _agreservations_create_Reservation($units, $checkin, $checkout, $userid
   $node->created = REQUEST_TIME;
   $node->changed = REQUEST_TIME;
   $node->language = $langcode_unit;
-  ////date timezonehandling handling:
+  
+  // Date and timezone handling
   $dateTimezone1 = new DateTimeZone(date_default_timezone());
   $dateTime1 = new DateTime($checkin, $dateTimezone1);
   $dateTime2 = new DateTime($checkout, $dateTimezone1);
@@ -740,21 +751,18 @@ function _agreservations_create_Reservation($units, $checkin, $checkout, $userid
   $node->field_agres_userref[$langcode_unit][0]['uid'] = $userid;
   $form_state = array();
   $form = array();
-  $node->validated = true;
+  $node->validated = TRUE;
   if (module_exists('agres_restriction')) {
-    $node->validated =  _agres_restriction_node_validate($node);
+    $node->validated = _agres_restriction_node_validate($node);
   }
 //  drupal_set_message('<pre>valide'.print_r($node->validated,true).'</pre>');
   $retval = 0;
   if ($node->validated) {
-
-    node_save($node); //Actually save the node
-
-
+    //Actually save the node
+    node_save($node);
     $retval = $node->nid;
   }
   return $retval;
-
 }
 
 ///**
@@ -774,33 +782,23 @@ function _agreservations_create_Reservation($units, $checkin, $checkout, $userid
 function agreservations_menu() {
 
   $admin = array('configure agreservations');
-  // Administration settings.
-
 
+  // Administration settings.
   $items['admin/config/system/agreservations'] = array(
     'title' => 'Agreservations',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('agreservations_admin_settings'),
     'access callback' => 'user_access',
     'access arguments' => $admin,
-    'description' => t('Configure Agreservations.'),
+    'description' => 'Configure Agreservations.',
   );
 
 //    $items['agrescontrol_panel'] = array(
-
-
 //    'title' => t('Control Panel'),
-
-
 //    'page callback' => 'agreservations_build_controlpanel',
-
-
 //    'access arguments' => array('access control panel')
-
-
 //    );
 
-
   return $items;
 }
 
@@ -832,7 +830,7 @@ function agreservations_admin_settings($form, &$form_state) {
       '#title' => t('Form entries for the searchwidget + multisteform for overnightbookings.'),
       '#default_value' => variable_get('agres_onlineformelements', 'standard'),
       '#options' => array(
-        'standard' => t('standard = checkin date,checkout date,number of units '),
+        'standard' => t('standard = checkin date,checkout date,number of units'),
         'hotel1' => t('hotel1 = checkin date,checkout date,Number of Persons'),
       ),
       '#description' => t('select the fields to fill in in the onlinesearchwidget for sitevisitors.'),
@@ -867,7 +865,6 @@ function agreservations_admin_settings($form, &$form_state) {
       ),
       '#description' => t('Decide wether global restrictions should be checked for anonymus unitsearch in the searchwidget'),
     );
-
   }
   //@todo this should be adjusted to consider the categories 
   //measurement unit/ and booking mode: days/hours /in advance:
diff --git a/includes/agres_categories.ccknodedef.inc b/includes/agres_categories.ccknodedef.inc
index 75cfe54..8bb7655 100644
--- a/includes/agres_categories.ccknodedef.inc
+++ b/includes/agres_categories.ccknodedef.inc
@@ -1,543 +1,547 @@
 <?php
-/**
- * @file
- * Install cck types for agreservationsmodule.
- */
-
-function _agres_categories_cck_unittype_category() {
-
-  $content['type']  = array(
-    'name' => 'Unit type category',
-    'type' => 'agres_category',
+
+/**
+ * @file
+ * Install cck types for agreservationsmodule.
+ */
+
+/**
+ * @todo Documentation
+ */
+function _agres_categories_cck_unittype_category() {
+
+  $content['type'] = array(
+    'name' => 'Unit type category',
+    'type' => 'agres_category',
     'description' => 'Create categories like: cars, rooms, tables and asign them to unittypes.
-Additionaly select Properties like, hourly booking, daily booking...',
-    'title_label' => 'Title',
-    'body_label' => 'Body',
-    'min_word_count' => '0',
-    'help' => '',
-    'node_options' => array(
-      'status' => true,
-      'promote' => false,
-      'sticky' => false,
-      'revision' => false,
-    ),
-    'language_content_type' => '0',
-    'old_type' => 'agres_category',
-    'orig_type' => '',
-    'module' => 'node',
-    'custom' => '1',
-    'modified' => '1',
-    'locked' => '0',
-    'i18n_newnode_current' => 0,
-    'i18n_required_node' => 0,
-    'i18n_lock_node' => 0,
-    'i18n_node' => 1,
-  );
-  $content['fields']  = array(
-    0 => array(
-      'label' => 'Booking mode',
-      'field_name' => 'field_agres_bookingmode',
-      'type' => 'text',
-      'widget_type' => 'optionwidgets_select',
-      'change' => 'Change basic information',
-      'weight' => '2',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => NULL,
-      'required' => 1,
-      'multiple' => '0',
-      'text_processing' => '0',
-      'max_length' => '',
+Additionaly select Properties like, hourly booking, daily booking...',
+    'title_label' => 'Title',
+    'body_label' => 'Body',
+    'min_word_count' => '0',
+    'help' => '',
+    'node_options' => array(
+      'status' => TRUE,
+      'promote' => FALSE,
+      'sticky' => FALSE,
+      'revision' => FALSE,
+    ),
+    'language_content_type' => '0',
+    'old_type' => 'agres_category',
+    'orig_type' => '',
+    'module' => 'node',
+    'custom' => '1',
+    'modified' => '1',
+    'locked' => '0',
+    'i18n_newnode_current' => 0,
+    'i18n_required_node' => 0,
+    'i18n_lock_node' => 0,
+    'i18n_node' => 1,
+  );
+  $content['fields'] = array(
+    0 => array(
+      'label' => 'Booking mode',
+      'field_name' => 'field_agres_bookingmode',
+      'type' => 'text',
+      'widget_type' => 'optionwidgets_select',
+      'change' => 'Change basic information',
+      'weight' => '2',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => NULL,
+      'required' => 1,
+      'multiple' => '0',
+      'text_processing' => '0',
+      'max_length' => '',
       'allowed_values' => '1|booking hour
-2|booking days',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'optionwidgets',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    1 => array(
-      'label' => 'Unit selection method',
-      'field_name' => 'field_agres_unitselectionmethod',
-      'type' => 'text',
-      'widget_type' => 'optionwidgets_select',
-      'change' => 'Change basic information',
-      'weight' => '3',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_unitselectionmethod' => array(
-          'value' => '',
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'text_processing' => '0',
-      'max_length' => '',
+2|booking days',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'optionwidgets',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    1 => array(
+      'label' => 'Unit selection method',
+      'field_name' => 'field_agres_unitselectionmethod',
+      'type' => 'text',
+      'widget_type' => 'optionwidgets_select',
+      'change' => 'Change basic information',
+      'weight' => '3',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_unitselectionmethod' => array(
+          'value' => '',
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'text_processing' => '0',
+      'max_length' => '',
       'allowed_values' => '1|standard
-2|ubercart productlist',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'optionwidgets',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    2 => array(
-      'label' => 'Label of date1',
-      'field_name' => 'field_agres_datelabel1',
-      'type' => 'text',
-      'widget_type' => 'text_textfield',
-      'change' => 'Change basic information',
-      'weight' => '4',
-      'rows' => 5,
-      'size' => '60',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          'format' => '1',
-          '_error_element' => 'default_value_widget][field_agres_datelabel1][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_datelabel1' => array(
-          0 => array(
-            'value' => '',
-            'format' => '1',
-            '_error_element' => 'default_value_widget][field_agres_datelabel1][0][value',
-          ),
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'text_processing' => '1',
-      'max_length' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'text',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-        'format' => array(
-          'type' => 'int',
-          'unsigned' => true,
-          'not null' => false,
-          'views' => false,
-        ),
-      ),
-      'display_settings' => array(
-        'weight' => '32',
-        'parent' => '',
-        'label' => array(
-          'format' => 'above',
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    3 => array(
-      'label' => 'Label of date2',
-      'field_name' => 'field_agres_datelabel2',
-      'type' => 'text',
-      'widget_type' => 'text_textfield',
-      'change' => 'Change basic information',
-      'weight' => '5',
-      'rows' => 5,
-      'size' => '60',
-      'description' => 'if you leave empty this entry field the to date will not be displayed.',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          'format' => '1',
-          '_error_element' => 'default_value_widget][field_agres_datelabel2][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_datelabel2' => array(
-          0 => array(
-            'value' => '',
-            'format' => '1',
-            '_error_element' => 'default_value_widget][field_agres_datelabel2][0][value',
-          ),
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'text_processing' => '1',
-      'max_length' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'text',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-        'format' => array(
-          'type' => 'int',
-          'unsigned' => true,
-          'not null' => false,
-          'views' => false,
-        ),
-      ),
-      'display_settings' => array(
-        'weight' => '33',
-        'parent' => '',
-        'label' => array(
-          'format' => 'above',
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    4 => array(
-      'label' => 'Select times too',
-      'field_name' => 'field_agres_showtime',
-      'type' => 'number_integer',
-      'widget_type' => 'optionwidgets_buttons',
-      'change' => 'Change basic information',
-      'weight' => '6',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '1',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_showtime' => array(
-          'value' => '1',
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'min' => '',
-      'max' => '',
-      'prefix' => '',
-      'suffix' => '',
+2|ubercart productlist',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'optionwidgets',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    2 => array(
+      'label' => 'Label of date1',
+      'field_name' => 'field_agres_datelabel1',
+      'type' => 'text',
+      'widget_type' => 'text_textfield',
+      'change' => 'Change basic information',
+      'weight' => '4',
+      'rows' => 5,
+      'size' => '60',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          'format' => '1',
+          '_error_element' => 'default_value_widget][field_agres_datelabel1][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_datelabel1' => array(
+          0 => array(
+            'value' => '',
+            'format' => '1',
+            '_error_element' => 'default_value_widget][field_agres_datelabel1][0][value',
+          ),
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'text_processing' => '1',
+      'max_length' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'text',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+        'format' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => FALSE,
+          'views' => FALSE,
+        ),
+      ),
+      'display_settings' => array(
+        'weight' => '32',
+        'parent' => '',
+        'label' => array(
+          'format' => 'above',
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    3 => array(
+      'label' => 'Label of date2',
+      'field_name' => 'field_agres_datelabel2',
+      'type' => 'text',
+      'widget_type' => 'text_textfield',
+      'change' => 'Change basic information',
+      'weight' => '5',
+      'rows' => 5,
+      'size' => '60',
+      'description' => 'if you leave empty this entry field the to date will not be displayed.',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          'format' => '1',
+          '_error_element' => 'default_value_widget][field_agres_datelabel2][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_datelabel2' => array(
+          0 => array(
+            'value' => '',
+            'format' => '1',
+            '_error_element' => 'default_value_widget][field_agres_datelabel2][0][value',
+          ),
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'text_processing' => '1',
+      'max_length' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'text',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+        'format' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => FALSE,
+          'views' => FALSE,
+        ),
+      ),
+      'display_settings' => array(
+        'weight' => '33',
+        'parent' => '',
+        'label' => array(
+          'format' => 'above',
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    4 => array(
+      'label' => 'Select times too',
+      'field_name' => 'field_agres_showtime',
+      'type' => 'number_integer',
+      'widget_type' => 'optionwidgets_buttons',
+      'change' => 'Change basic information',
+      'weight' => '6',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '1',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_showtime' => array(
+          'value' => '1',
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'min' => '',
+      'max' => '',
+      'prefix' => '',
+      'suffix' => '',
       'allowed_values' => '0|off
 1|on
-',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'number',
-      'widget_module' => 'optionwidgets',
-      'columns' => array(
-        'value' => array(
-          'type' => 'int',
-          'not null' => false,
-          'sortable' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'weight' => '34',
-        'parent' => '',
-        'label' => array(
-          'format' => 'inline',
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    5 => array(
-      'label' => 'Title of reservation form',
-      'field_name' => 'field_agres_titleresform',
-      'type' => 'text',
-      'widget_type' => 'text_textfield',
-      'change' => 'Change basic information',
-      'weight' => '7',
-      'rows' => 5,
-      'size' => '60',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          'format' => '2',
-          '_error_element' => 'default_value_widget][field_agres_titleresform][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_titleresform' => array(
-          0 => array(
-            'value' => '',
-            'format' => '2',
-            '_error_element' => 'default_value_widget][field_agres_titleresform][0][value',
-          ),
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'text_processing' => '1',
-      'max_length' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'text',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-        'format' => array(
-          'type' => 'int',
-          'unsigned' => true,
-          'not null' => false,
-          'views' => false,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    6 => array(
-      'label' => 'Measuringunit',
-      'field_name' => 'field_agres_measuringunit',
-      'type' => 'text',
-      'widget_type' => 'text_textfield',
-      'change' => 'Change basic information',
-      'weight' => '8',
-      'rows' => 5,
-      'size' => '60',
+',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'number',
+      'widget_module' => 'optionwidgets',
+      'columns' => array(
+        'value' => array(
+          'type' => 'int',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'weight' => '34',
+        'parent' => '',
+        'label' => array(
+          'format' => 'inline',
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    5 => array(
+      'label' => 'Title of reservation form',
+      'field_name' => 'field_agres_titleresform',
+      'type' => 'text',
+      'widget_type' => 'text_textfield',
+      'change' => 'Change basic information',
+      'weight' => '7',
+      'rows' => 5,
+      'size' => '60',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          'format' => '2',
+          '_error_element' => 'default_value_widget][field_agres_titleresform][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_titleresform' => array(
+          0 => array(
+            'value' => '',
+            'format' => '2',
+            '_error_element' => 'default_value_widget][field_agres_titleresform][0][value',
+          ),
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'text_processing' => '1',
+      'max_length' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'text',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+        'format' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => FALSE,
+          'views' => FALSE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    6 => array(
+      'label' => 'Measuringunit',
+      'field_name' => 'field_agres_measuringunit',
+      'type' => 'text',
+      'widget_type' => 'text_textfield',
+      'change' => 'Change basic information',
+      'weight' => '8',
+      'rows' => 5,
+      'size' => '60',
       'description' => 'Examples: Hotelrooms -> nights
 cars -> days
-Pooltable -> hours',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          '_error_element' => 'default_value_widget][field_agres_measuringunit][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_measuringunit' => array(
-          0 => array(
-            'value' => '',
-            '_error_element' => 'default_value_widget][field_agres_measuringunit][0][value',
-            'format' => '2',
-          ),
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'text_processing' => '1',
-      'max_length' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'text',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-        'format' => array(
-          'type' => 'int',
-          'unsigned' => true,
-          'not null' => false,
-          'views' => false,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    7 => array(
-      'label' => 'Default checkin time',
-      'field_name' => 'field_agres_defaultcheckintime',
-      'type' => 'text',
-      'widget_type' => 'optionwidgets_select',
-      'change' => 'Change basic information',
-      'weight' => '9',
+Pooltable -> hours',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          '_error_element' => 'default_value_widget][field_agres_measuringunit][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_measuringunit' => array(
+          0 => array(
+            'value' => '',
+            '_error_element' => 'default_value_widget][field_agres_measuringunit][0][value',
+            'format' => '2',
+          ),
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'text_processing' => '1',
+      'max_length' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'text',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+        'format' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => FALSE,
+          'views' => FALSE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    7 => array(
+      'label' => 'Default checkin time',
+      'field_name' => 'field_agres_defaultcheckintime',
+      'type' => 'text',
+      'widget_type' => 'optionwidgets_select',
+      'change' => 'Change basic information',
+      'weight' => '9',
       'description' => 'when the guest is not allowed to choose the time of checkin.
-this is the time that will be set by the system for checkin.',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_defaultcheckintime' => array(
-          'value' => '',
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'text_processing' => '0',
-      'max_length' => '',
+this is the time that will be set by the system for checkin.',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_defaultcheckintime' => array(
+          'value' => '',
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'text_processing' => '0',
+      'max_length' => '',
       'allowed_values' => '+09 hour
 +10 hour
 +11 hour
@@ -548,66 +552,66 @@ this is the time that will be set by the system for checkin.',
 +16 hour
 +17 hour
 +18 hour
-+19 hour',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'optionwidgets',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    8 => array(
-      'label' => 'Default Chekout time',
-      'field_name' => 'field_agres_defaultcheckouttime',
-      'type' => 'text',
-      'widget_type' => 'optionwidgets_select',
-      'change' => 'Change basic information',
-      'weight' => '10',
-      'description' => 'The default time when a guest has to check out.',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_defaultcheckouttime' => array(
-          'value' => '',
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'text_processing' => '0',
-      'max_length' => '',
++19 hour',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'optionwidgets',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    8 => array(
+      'label' => 'Default Chekout time',
+      'field_name' => 'field_agres_defaultcheckouttime',
+      'type' => 'text',
+      'widget_type' => 'optionwidgets_select',
+      'change' => 'Change basic information',
+      'weight' => '10',
+      'description' => 'The default time when a guest has to check out.',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_defaultcheckouttime' => array(
+          'value' => '',
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'text_processing' => '0',
+      'max_length' => '',
       'allowed_values' => '+09 hour
 +10 hour
 +11 hour
@@ -618,713 +622,709 @@ this is the time that will be set by the system for checkin.',
 +16 hour
 +17 hour
 +18 hour
-+19 hour',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'optionwidgets',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    9 => array(
-      'label' => 'Allow over night bookings',
-      'field_name' => 'field_agres_allowovernight',
-      'type' => 'text',
-      'widget_type' => 'optionwidgets_select',
-      'change' => 'Change basic information',
-      'weight' => '11',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_allowovernight' => array(
-          'value' => '',
-        ),
-      ),
-      'required' => 1,
-      'multiple' => '0',
-      'text_processing' => '0',
-      'max_length' => '',
++19 hour',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'optionwidgets',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    9 => array(
+      'label' => 'Allow over night bookings',
+      'field_name' => 'field_agres_allowovernight',
+      'type' => 'text',
+      'widget_type' => 'optionwidgets_select',
+      'change' => 'Change basic information',
+      'weight' => '11',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_allowovernight' => array(
+          'value' => '',
+        ),
+      ),
+      'required' => 1,
+      'multiple' => '0',
+      'text_processing' => '0',
+      'max_length' => '',
       'allowed_values' => '1|yes
-2|no',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'optionwidgets',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    10 => array(
-      'label' => 'Hours of service ',
-      'field_name' => 'field_agres_servicehours',
-      'type' => 'text',
-      'widget_type' => 'text_textfield',
-      'change' => 'Change basic information',
-      'weight' => '12',
-      'rows' => 5,
-      'size' => '40',
+2|no',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'optionwidgets',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    10 => array(
+      'label' => 'Hours of service ',
+      'field_name' => 'field_agres_servicehours',
+      'type' => 'text',
+      'widget_type' => 'text_textfield',
+      'change' => 'Change basic information',
+      'weight' => '12',
+      'rows' => 5,
+      'size' => '40',
       'description' => 'example: 00:00-23:59 for 24hour service
 7 entries 1 for each day, first Monday, last Sunday.
 Mark closed days as: x
 each slot can have multiple values example: 08:00-12-00,13:00-18:00
 ->means hours of service are from 08:00 until 12:00 and from 13:00 to 18:00
 if overnight booking is allowed, this means only the checkin and checkout times have to be within the
-service times. but the unit can be bookend around the clock.',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          '_error_element' => 'default_value_widget][field_agres_servicehours][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_servicehours' => array(
-          0 => array(
-            'value' => '',
-            '_error_element' => 'default_value_widget][field_agres_servicehours][0][value',
-          ),
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '7',
-      'text_processing' => '0',
-      'max_length' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'text',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    11 => array(
-      'label' => 'Duration',
-      'field_name' => 'field_agres_duration',
-      'type' => 'duration',
-      'widget_type' => 'duration_combo',
-      'change' => 'Change basic information',
-      'weight' => '13',
-      'use_weeks' => 0,
-      'largest_metric' => 'days',
-      'smallest_metric' => 'minutes',
+service times. but the unit can be bookend around the clock.',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          '_error_element' => 'default_value_widget][field_agres_servicehours][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_servicehours' => array(
+          0 => array(
+            'value' => '',
+            '_error_element' => 'default_value_widget][field_agres_servicehours][0][value',
+          ),
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '7',
+      'text_processing' => '0',
+      'max_length' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'text',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    11 => array(
+      'label' => 'Duration',
+      'field_name' => 'field_agres_duration',
+      'type' => 'duration',
+      'widget_type' => 'duration_combo',
+      'change' => 'Change basic information',
+      'weight' => '13',
+      'use_weeks' => 0,
+      'largest_metric' => 'days',
+      'smallest_metric' => 'minutes',
       'description' => 'leave empty (on 0) if you don´t want to set a default duration of a booking.
-if you leave empty the \'Label of date2\' entry, the \'to\' date entry will not be displayed in the search form block, making this default duration a fixed duration!',
-      'default_value' => array(
-        0 => array(
-          'duration' => array(
-            'duration' => array(
-              'days' => 0,
-              'hours' => '0',
-              'minutes' => 0,
-            ),
-            'is_negative' => false,
-            'is_valid' => true,
-            'conversion_factors' => array(
-              'seconds/minutes' => 60,
-              'minutes/hours' => 60,
-              'hours/days' => 24,
-              'days/weeks' => 7,
-              'days/months' => 30,
-              'weeks/years' => 52.1428571429,
-              'months/years' => 12,
-            ),
-          ),
-          'iso8601' => 'PT0S',
-          'approx_seconds' => 0,
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_duration' => array(
-          0 => array(
-            'type' => 'months',
-            'years' => 0,
-            'months' => 0,
-            'days' => 0,
-            'hours' => 0,
-            'minutes' => 0,
-            'seconds' => 0,
-          ),
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'op' => 'Save field settings',
-      'module' => 'duration',
-      'widget_module' => 'duration',
-      'columns' => array(
-        'iso8601' => array(
-          'type' => 'varchar',
-          'length' => '64',
-          'not null' => true,
-          'default' => '',
-        ),
-        'approx_seconds' => array(
-          'type' => 'int',
-          'unsigned' => true,
-          'not null' => true,
-          'default' => 0,
-          'sortable' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    12 => array(
-      'label' => 'Show number of units?',
-      'field_name' => 'field_agres_shownumberunits',
-      'type' => 'text',
-      'widget_type' => 'optionwidgets_select',
-      'change' => 'Change basic information',
-      'weight' => '14',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_shownumberunits' => array(
-          'value' => '',
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'text_processing' => '0',
-      'max_length' => '',
+if you leave empty the \'Label of date2\' entry, the \'to\' date entry will not be displayed in the search form block, making this default duration a fixed duration!',
+      'default_value' => array(
+        0 => array(
+          'duration' => array(
+            'duration' => array(
+              'days' => 0,
+              'hours' => '0',
+              'minutes' => 0,
+            ),
+            'is_negative' => FALSE,
+            'is_valid' => TRUE,
+            'conversion_factors' => array(
+              'seconds/minutes' => 60,
+              'minutes/hours' => 60,
+              'hours/days' => 24,
+              'days/weeks' => 7,
+              'days/months' => 30,
+              'weeks/years' => 52.1428571429,
+              'months/years' => 12,
+            ),
+          ),
+          'iso8601' => 'PT0S',
+          'approx_seconds' => 0,
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_duration' => array(
+          0 => array(
+            'type' => 'months',
+            'years' => 0,
+            'months' => 0,
+            'days' => 0,
+            'hours' => 0,
+            'minutes' => 0,
+            'seconds' => 0,
+          ),
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'op' => 'Save field settings',
+      'module' => 'duration',
+      'widget_module' => 'duration',
+      'columns' => array(
+        'iso8601' => array(
+          'type' => 'varchar',
+          'length' => '64',
+          'not null' => TRUE,
+          'default' => '',
+        ),
+        'approx_seconds' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+          'default' => 0,
+          'sortable' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    12 => array(
+      'label' => 'Show number of units?',
+      'field_name' => 'field_agres_shownumberunits',
+      'type' => 'text',
+      'widget_type' => 'optionwidgets_select',
+      'change' => 'Change basic information',
+      'weight' => '14',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_shownumberunits' => array(
+          'value' => '',
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'text_processing' => '0',
+      'max_length' => '',
       'allowed_values' => '1|yes let the guest choose number of units
-2|no, use default unitnumber ',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'optionwidgets',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    13 => array(
-      'label' => 'Ask for Persons',
-      'field_name' => 'field_agres_askpersons',
-      'type' => 'text',
-      'widget_type' => 'optionwidgets_select',
-      'change' => 'Change basic information',
-      'weight' => '15',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_askpersons' => array(
-          'value' => '',
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'text_processing' => '0',
-      'max_length' => '',
+2|no, use default unitnumber ',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'optionwidgets',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    13 => array(
+      'label' => 'Ask for Persons',
+      'field_name' => 'field_agres_askpersons',
+      'type' => 'text',
+      'widget_type' => 'optionwidgets_select',
+      'change' => 'Change basic information',
+      'weight' => '15',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_askpersons' => array(
+          'value' => '',
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'text_processing' => '0',
+      'max_length' => '',
       'allowed_values' => '1|ask for Number of Persons during the online booking
 2|don´t ask for number of Persons
-3|ask for number of Adults and Children seperately',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'optionwidgets',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    14 => array(
-      'label' => 'Default number of units to book',
-      'field_name' => 'field_agres_numberunits',
-      'type' => 'number_integer',
-      'widget_type' => 'number',
-      'change' => 'Change basic information',
-      'weight' => '16',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          '_error_element' => 'default_value_widget][field_agres_numberunits][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_numberunits' => array(
-          0 => array(
-            'value' => '',
-            '_error_element' => 'default_value_widget][field_agres_numberunits][0][value',
-          ),
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'min' => '1',
-      'max' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'number',
-      'widget_module' => 'number',
-      'columns' => array(
-        'value' => array(
-          'type' => 'int',
-          'not null' => false,
-          'sortable' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    15 => array(
-      'label' => 'Remove Add to Cart button if present',
-      'field_name' => 'field_agres_removeaddtocart',
-      'type' => 'text',
-      'widget_type' => 'optionwidgets_select',
-      'change' => 'Change basic information',
-      'weight' => '17',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_removeaddtocart' => array(
-          'value' => '',
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '0',
-      'text_processing' => '0',
-      'max_length' => '',
+3|ask for number of Adults and Children seperately',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'optionwidgets',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    14 => array(
+      'label' => 'Default number of units to book',
+      'field_name' => 'field_agres_numberunits',
+      'type' => 'number_integer',
+      'widget_type' => 'number',
+      'change' => 'Change basic information',
+      'weight' => '16',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          '_error_element' => 'default_value_widget][field_agres_numberunits][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_numberunits' => array(
+          0 => array(
+            'value' => '',
+            '_error_element' => 'default_value_widget][field_agres_numberunits][0][value',
+          ),
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'min' => '1',
+      'max' => '',
+      'prefix' => '',
+      'suffix' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'number',
+      'widget_module' => 'number',
+      'columns' => array(
+        'value' => array(
+          'type' => 'int',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    15 => array(
+      'label' => 'Remove Add to Cart button if present',
+      'field_name' => 'field_agres_removeaddtocart',
+      'type' => 'text',
+      'widget_type' => 'optionwidgets_select',
+      'change' => 'Change basic information',
+      'weight' => '17',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_removeaddtocart' => array(
+          'value' => '',
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '0',
+      'text_processing' => '0',
+      'max_length' => '',
       'allowed_values' => '1|yes: remove add to cart
-2|add to cart button will be displayed',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'text',
-      'widget_module' => 'optionwidgets',
-      'columns' => array(
-        'value' => array(
-          'type' => 'text',
-          'size' => 'big',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-  );
-  $content['extra']  = array(
-    'title' => '-5',
-    'body_field' => '-3',
-    'revision_information' => '-2',
-    'author' => '-1',
-    'options' => '0',
-    'menu' => '-4',
-    'path' => '1',
-  );
-
-
-  // paste code before this line.
-  return $content;
-}
-
-function _agres_categories_cck_export_unittype_categories() {
-  $content['type']  = array(
-    'name' => 'Unit type',
-    'type' => 'agreservations_unittype',
+2|add to cart button will be displayed',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'text',
+      'widget_module' => 'optionwidgets',
+      'columns' => array(
+        'value' => array(
+          'type' => 'text',
+          'size' => 'big',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+  );
+  $content['extra'] = array(
+    'title' => '-5',
+    'body_field' => '-3',
+    'revision_information' => '-2',
+    'author' => '-1',
+    'options' => '0',
+    'menu' => '-4',
+    'path' => '1',
+  );
+
+  return $content;
+}
+
+/**
+ * @todo Documentation
+ */
+function _agres_categories_cck_export_unittype_categories() {
+  $content['type'] = array(
+    'name' => 'Unit type',
+    'type' => 'agreservations_unittype',
     'description' => 'The Type of unit by agreservations module:
-Single unit, Double unit, Suite, Presidents Suite, Guestunit...',
-    'title_label' => 'Title',
-    'body_label' => 'Description',
-    'min_word_count' => '0',
-    'help' => '',
-    'node_options' => array(
-      'status' => true,
-      'promote' => true,
-      'sticky' => false,
-      'revision' => false,
-    ),
-    'language_content_type' => '2',
-    'old_type' => 'agreservations_unittype',
-    'orig_type' => '',
-    'module' => 'uc_product',
-    'custom' => '0',
-    'modified' => '1',
-    'locked' => '0',
-    'reset' => 'Reset to defaults',
-    'uc_product_shippable' => 0,
-    'uc_image' => '',
-    'i18n_newnode_current' => 0,
-    'i18n_required_node' => 0,
-    'i18n_lock_node' => 0,
-    'i18n_node' => 1,
-  );
-  $content['fields']  = array(
-    0 => array(
-      'label' => 'Capacity',
-      'field_name' => 'field_agreservations_capacity',
-      'type' => 'number_integer',
-      'widget_type' => 'number',
-      'change' => 'Change basic information',
-      'weight' => '4',
+Single unit, Double unit, Suite, Presidents Suite, Guestunit...',
+    'title_label' => 'Title',
+    'body_label' => 'Description',
+    'min_word_count' => '0',
+    'help' => '',
+    'node_options' => array(
+      'status' => TRUE,
+      'promote' => TRUE,
+      'sticky' => FALSE,
+      'revision' => FALSE,
+    ),
+    'language_content_type' => '2',
+    'old_type' => 'agreservations_unittype',
+    'orig_type' => '',
+    'module' => 'uc_product',
+    'custom' => '0',
+    'modified' => '1',
+    'locked' => '0',
+    'reset' => 'Reset to defaults',
+    'uc_product_shippable' => 0,
+    'uc_image' => '',
+    'i18n_newnode_current' => 0,
+    'i18n_required_node' => 0,
+    'i18n_lock_node' => 0,
+    'i18n_node' => 1,
+  );
+  $content['fields'] = array(
+    0 => array(
+      'label' => 'Capacity',
+      'field_name' => 'field_agreservations_capacity',
+      'type' => 'number_integer',
+      'widget_type' => 'number',
+      'change' => 'Change basic information',
+      'weight' => '4',
       'description' => 'How many persons are allowed for this unittype?
-     children count only 0.5',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          '_error_element' => 'default_value_widget][field_agreservations_capacity][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => NULL,
-      'required' => 1,
-      'multiple' => '0',
-      'min' => '',
-      'max' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'number',
-      'widget_module' => 'number',
-      'columns' => array(
-        'value' => array(
-          'type' => 'int',
-          'not null' => false,
-          'sortable' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    1 => array(
-      'label' => 'Categories',
-      'field_name' => 'field_agres_ref_category',
-      'type' => 'nodereference',
-      'widget_type' => 'nodereference_select',
-      'change' => 'Change basic information',
-      'weight' => '31',
-      'autocomplete_match' => 'contains',
-      'size' => 60,
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'nid' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_ref_category' => array(
-          0 => array(
-            'nid' => '',
-          ),
-          'nid' => array(
-            'nid' => array(
-              0 => '',
-            ),
-          ),
-        ),
-      ),
-      'required' => 0,
-      'multiple' => '1',
-      'referenceable_types' => array(
-        'agres_category' => 'agres_category',
-        'page' => 0,
-        'product' => 0,
-        'agreservation' => 0,
-        'story' => 0,
-        'agreservations_unit' => 0,
-        'agreservation_unit_info' => 0,
-        'agreservations_unittype' => 0,
-        'webform' => 0,
-        'testproduct' => 0,
-      ),
-      'advanced_view' => '--',
-      'advanced_view_args' => '',
-      'op' => 'Save field settings',
-      'module' => 'nodereference',
-      'widget_module' => 'nodereference',
-      'columns' => array(
-        'nid' => array(
-          'type' => 'int',
-          'unsigned' => true,
-          'not null' => false,
-          'index' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-  );
-  $content['extra']  = array(
-    'title' => '-5',
-    'body_field' => '0',
-    'revision_information' => '20',
-    'menu' => '-2',
-    'taxonomy' => '-3',
-    'path' => '30',
-    'base' => '-1',
-    'body' => '1',
-  );
-
-  return $content;
-}
-
-
-
-
-
+     children count only 0.5',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          '_error_element' => 'default_value_widget][field_agreservations_capacity][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => NULL,
+      'required' => 1,
+      'multiple' => '0',
+      'min' => '',
+      'max' => '',
+      'prefix' => '',
+      'suffix' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'number',
+      'widget_module' => 'number',
+      'columns' => array(
+        'value' => array(
+          'type' => 'int',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    1 => array(
+      'label' => 'Categories',
+      'field_name' => 'field_agres_ref_category',
+      'type' => 'nodereference',
+      'widget_type' => 'nodereference_select',
+      'change' => 'Change basic information',
+      'weight' => '31',
+      'autocomplete_match' => 'contains',
+      'size' => 60,
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'nid' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_ref_category' => array(
+          0 => array(
+            'nid' => '',
+          ),
+          'nid' => array(
+            'nid' => array(
+              0 => '',
+            ),
+          ),
+        ),
+      ),
+      'required' => 0,
+      'multiple' => '1',
+      'referenceable_types' => array(
+        'agres_category' => 'agres_category',
+        'page' => 0,
+        'product' => 0,
+        'agreservation' => 0,
+        'story' => 0,
+        'agreservations_unit' => 0,
+        'agreservation_unit_info' => 0,
+        'agreservations_unittype' => 0,
+        'webform' => 0,
+        'testproduct' => 0,
+      ),
+      'advanced_view' => '--',
+      'advanced_view_args' => '',
+      'op' => 'Save field settings',
+      'module' => 'nodereference',
+      'widget_module' => 'nodereference',
+      'columns' => array(
+        'nid' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => FALSE,
+          'index' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+  );
+  $content['extra'] = array(
+    'title' => '-5',
+    'body_field' => '0',
+    'revision_information' => '20',
+    'menu' => '-2',
+    'taxonomy' => '-3',
+    'path' => '30',
+    'base' => '-1',
+    'body' => '1',
+  );
+
+  return $content;
+}
\ No newline at end of file
diff --git a/includes/agres_funcs.inc b/includes/agres_funcs.inc
index 5fa6354..5dba22b 100644
--- a/includes/agres_funcs.inc
+++ b/includes/agres_funcs.inc
@@ -1,163 +1,153 @@
 <?php
-// $Id: agres_funcs.inc,v 1.1.2.4 2010/12/23 02:25:46 agill Exp $
-/**
- * @file
- * helper functions. not only usefull for agreservations
- */
-
-/**
- * _install_bundle_fields: inspired by features module.
- *
- */
-function _install_bundle_fields($fields) {
-  if (isset($fields)) {
-    field_info_cache_clear();
-    foreach ($fields as $field) {
+
+/**
+ * @file
+ * helper functions. not only usefull for agreservations
+ */
+
+/**
+ * _install_bundle_fields: inspired by features module.
+ *
+ */
+function _install_bundle_fields($fields) {
+  if (isset($fields)) {
+    field_info_cache_clear();
+    foreach ($fields as $field) {
       // Create or update field.
-      $field_config = $field['field_config'];
-      if ($existing_field = field_info_field($field_config['field_name'])) {
-        field_update_field($field_config);
-      }
-      else {
-        field_create_field($field_config);
-      }
-
+      $field_config = $field['field_config'];
+      if ($existing_field = field_info_field($field_config['field_name'])) {
+        field_update_field($field_config);
+      }
+      else {
+        field_create_field($field_config);
+      }
+
       // Create or update field instance.
-      $field_instance = $field['field_instance'];
-      $existing_instance = field_info_instance($field_instance['entity_type'], $field_instance['field_name'], $field_instance['bundle']);
-      if ($existing_instance) {
-        field_update_instance($field_instance);
-      }
-      else {
-        field_create_instance($field_instance);
-      }
-      variable_set('menu_rebuild_needed', TRUE);
-    }
-  }
-}
-
-/**
- * in_multi_assoc_array: returns BOOLEAN.
- *
- * @author     Andreas Gill
- * @param      $needle zu suchender Wert.
- * @param      $array   zu durchsuchendes Array.
- * @return     TRUE oder FALSE
- */
-function in_multi_assoc_array($needle, $array) {
-  foreach ($array as $element) {
-    if ($element == $needle) {
-      return true;
-    }
-    else {
-      if (is_array($element)) {
-        if (in_multi_assoc_array($needle, $element)) {
-          return true;
-        }
-      }
-    }
-  }
-  return false;
-}
-/**
- * _is_time_in_range: returns BOOLEAN.
- *
- * @author     Andreas Gill
- * @param      $timetocheck time to check.timestring'H:i'
- * @param      $rangelow lower end of timerange.timestring'H:i'
- * @param      hrangehigh higher end of timerange.timestring of form 'H:i'
- * @return     TRUE if in range or FALSE if not within range
- */
-function _is_time_in_range($timetocheck, $rangelow, $rangehigh) {
-  $strtimetocheck = date('H:i', strtotime($timetocheck));
-  if ((strtotime($strtimetocheck) >= strtotime($rangelow)) && (strtotime($strtimetocheck) <= strtotime($rangehigh))) {
-    return TRUE;
-  }
-  else {
-    return FALSE;
-  }
-}
-/**
- * _is_date_in_range: returns BOOLEAN.
- *
- * @author     Andreas Gill
- * @param      $datetocheck, date to check. timestring 'Y-m-d'
- * @param      $rangelow lower end of daterange.timestring'Y-m-d'
- * @param      hrangehigh higher end of daterange.timestring of form 'Y-m-d'
- * @return     TRUE if in range or FALSE if not within range
- */
-function _is_date_in_range($datetocheck, $rangelow, $rangehigh) {
-  $strdatetocheck = date_format(new DateObject($datetocheck), 'Y-m-d');
-  $strrangelow = date_format(new DateObject($rangelow), 'Y-m-d');
-  $strrangehigh = date_format(new DateObject($rangehigh), 'Y-m-d');
-  if ((strtotime($strdatetocheck) >= strtotime($strrangelow)) && (strtotime($strdatetocheck) <= strtotime($strrangehigh))) {
-    return TRUE;
-  }
-  else {
-    return FALSE;
-  }
-}
-
-/**
- * get_current_path: current url
- * from drupaluser dhaneshharidas
- * from http://drupal.org/node/46088
- */
-function get_current_path() {
-
-  $tmpdest = '';
-  $tmpdest = drupal_get_destination();
-//    drupal_set_message('<pre>get_current_path'.print_r($tmpdest,true).'</pre>');
-  $current_path = explode('=', $tmpdest['destination']);
-
+      $field_instance = $field['field_instance'];
+      $existing_instance = field_info_instance($field_instance['entity_type'], $field_instance['field_name'], $field_instance['bundle']);
+      if ($existing_instance) {
+        field_update_instance($field_instance);
+      }
+      else {
+        field_create_instance($field_instance);
+      }
+      variable_set('menu_rebuild_needed', TRUE);
+    }
+  }
+}
+
+/**
+ * in_multi_assoc_array: returns BOOLEAN.
+ *
+ * @author     Andreas Gill
+ * @param      $needle zu suchender Wert.
+ * @param      $array   zu durchsuchendes Array.
+ * @return     TRUE oder FALSE
+ */
+function in_multi_assoc_array($needle, $array) {
+  foreach ($array as $element) {
+    if ($element == $needle) {
+      return TRUE;
+    }
+
+    if (is_array($element)) {
+      if (in_multi_assoc_array($needle, $element)) {
+        return TRUE;
+      }
+    }
+  }
+  return FALSE;
+}
+
+/**
+ * _is_time_in_range: returns BOOLEAN.
+ *
+ * @author     Andreas Gill
+ * @param      $timetocheck time to check.timestring'H:i'
+ * @param      $rangelow lower end of timerange.timestring'H:i'
+ * @param      hrangehigh higher end of timerange.timestring of form 'H:i'
+ * @return     TRUE if in range or FALSE if not within range
+ */
+function _is_time_in_range($timetocheck, $rangelow, $rangehigh) {
+  $strtimetocheck = date('H:i', strtotime($timetocheck));
+  if ((strtotime($strtimetocheck) >= strtotime($rangelow)) && (strtotime($strtimetocheck) <= strtotime($rangehigh))) {
+    return TRUE;
+  }
+  return FALSE;
+}
+
+/**
+ * _is_date_in_range: returns BOOLEAN.
+ *
+ * @author     Andreas Gill
+ * @param      $datetocheck, date to check. timestring 'Y-m-d'
+ * @param      $rangelow lower end of daterange.timestring'Y-m-d'
+ * @param      hrangehigh higher end of daterange.timestring of form 'Y-m-d'
+ * @return     TRUE if in range or FALSE if not within range
+ */
+function _is_date_in_range($datetocheck, $rangelow, $rangehigh) {
+  $strdatetocheck = date_format(new DateObject($datetocheck), 'Y-m-d');
+  $strrangelow = date_format(new DateObject($rangelow), 'Y-m-d');
+  $strrangehigh = date_format(new DateObject($rangehigh), 'Y-m-d');
+  if ((strtotime($strdatetocheck) >= strtotime($strrangelow)) && (strtotime($strdatetocheck) <= strtotime($strrangehigh))) {
+    return TRUE;
+  }
+  return FALSE;
+}
+
+/**
+ * get_current_path: current url
+ * from drupaluser dhaneshharidas
+ * from http://drupal.org/node/46088
+ */
+function get_current_path() {
+
+  $tmpdest = '';
+  $tmpdest = drupal_get_destination();
+  //drupal_set_message('<pre>get_current_path'.print_r($tmpdest,true).'</pre>');
+  $current_path = explode('=', $tmpdest['destination']);
+
   // Extracting URL from $current_path
-  if (is_array($current_path) && count($current_path) >= 1) {
-    if (trim($current_path[0]) != '') {
-      $current_url_full = htmlspecialchars(urldecode($current_path[0]));
+  if (is_array($current_path) && count($current_path) >= 1) {
+    if (trim($current_path[0]) != '') {
+      $current_url_full = htmlspecialchars(urldecode($current_path[0]));
       // Removing query string
-      $current_url_elements = explode('?', $current_url_full);
-      if (is_array($current_url_elements)) {
-        return trim($current_url_elements[0]);
-      }
-      else {
-        return trim($current_url_elements);
-      }
-    }
-    else {
-
-      return $_REQUEST['q'];
-    }
-  }
-
-}
-
-/**
- * createDateRangeArray: current url
- * @author   Mike Boone
- * @param    $strDateFrom Y-m-d
- * @param    $strDateTo Y-m-d
- * @return   creates an inclusive array of the dates between the from and to dates.
- * from http://boonedocks.net/mike/archives/137-Creating-a-Date-Range-Array-with-PHP.html
- */
-function createDateRangeArray($strDateFrom, $strDateTo) {
-  // takes two dates formatted as Y-m-d and creates an
-  // inclusive array of the dates between the from and to dates.
-
-  // could test validity of dates here but I'm already doing
-  // that in the main script
-  $aryRange = array();
-//   drupal_set_message('<pre>createDateRangeArray: ' . print_r($strDateFrom.'--'.$strDateTo, true) . '</pre>');
-  $iDateFrom = mktime(1, 0, 0, substr($strDateFrom, 5, 2),      substr($strDateFrom, 8, 2), substr($strDateFrom, 0, 4));
-  $iDateTo = mktime(1, 0, 0, substr($strDateTo, 5, 2),      substr($strDateTo, 8, 2), substr($strDateTo, 0, 4));
-
-  if ($iDateTo >= $iDateFrom) {
-    array_push($aryRange, date('Y-m-d', $iDateFrom)); // first entry
-
-    while ($iDateFrom < $iDateTo) {
-      $iDateFrom = strtotime("+1 day", $iDateFrom); //86400; // add 24 hours
-      array_push($aryRange, date('Y-m-d', $iDateFrom));
-    }
-  }
-//  drupal_set_message('<pre>$aryRange: ' . print_r($aryRange, true) . '</pre>');
-  return $aryRange;
-}
+      $current_url_elements = explode('?', $current_url_full);
+      if (is_array($current_url_elements)) {
+        return trim($current_url_elements[0]);
+      }
+      return trim($current_url_elements);
+    }
+    return $_REQUEST['q'];
+  }
+}
+
+/**
+ * Create an array of dates from two string dates.
+ *
+ * Takes two dates formatted as Y-m-d and creates an inclusive array of the
+ * dates between the from and to dates. Could test validity of dates here but
+ * I'm already doing that in the main script.
+ *
+ * @author   Mike Boone
+ * @param string $date_from Y-m-d
+ * @param string $date_to Y-m-d
+ * @return array An inclusive array of the dates between the from and to dates.
+ * @see http://boonedocks.net/mike/archives/137-Creating-a-Date-Range-Array-with-PHP.html
+ */
+function _agreservations_create_date_range($date_from, $date_to) {
+  $range = array();
+  $temp_date_from = mktime(1, 0, 0, drupal_substr($date_from, 5, 2), drupal_substr($date_from, 8, 2), drupal_substr($date_from, 0, 4));
+  $temp_date_to = mktime(1, 0, 0, drupal_substr($date_to, 5, 2), drupal_substr($date_to, 8, 2), drupal_substr($date_to, 0, 4));
+
+  if ($temp_date_to >= $temp_date_from) {
+    // first entry
+    array_push($range, date('Y-m-d', $temp_date_from));
+
+    while ($temp_date_from < $temp_date_to) {
+      $temp_date_from = strtotime("+1 day", $temp_date_from);
+      array_push($range, date('Y-m-d', $temp_date_from));
+    }
+  }
+  return $range;
+}
\ No newline at end of file
diff --git a/includes/agreservations.ccknodedef.inc b/includes/agreservations.ccknodedef.inc
index 189d2bd..1f7e8df 100644
--- a/includes/agreservations.ccknodedef.inc
+++ b/includes/agreservations.ccknodedef.inc
@@ -1,1248 +1,1248 @@
 <?php
-/**
- * @file
- * Install cck types for agreservationsmodule.
- */
-
-function _agreservations_cck_export_unit() {
-
-  $content['type']  = array(
-    'name' => 'Unit',
-    'type' => 'agreservations_unit',
-    'description' => t('reservable units implemented by agreservations module'),
-    'title_label' => 'Unitname',
-    'body_label' => '',
-    'min_word_count' => '0',
-    'help' => '',
-    'node_options' => array(
-      'status' => true,
-      'promote' => true,
-      'sticky' => false,
-      'revision' => false,
-    ),
-    'language_content_type' => '0',
-    'old_type' => 'agreservations_unit',
-    'orig_type' => '',
-    'module' => 'node',
-    'custom' => '1',
-    'modified' => '1',
-    'locked' => '0',
-    'content_profile_use' => 0,
-    'comment' => '2',
-    'comment_default_mode' => '4',
-    'comment_default_order' => '1',
-    'comment_default_per_page' => '50',
-    'comment_controls' => '3',
-    'comment_anonymous' => 0,
-    'comment_subject_field' => '1',
-    'comment_preview' => '1',
-    'comment_form_location' => '0',
-    'availability_calendars' => '0',
-  );
-  $content['fields']  = array(
-    0 => array(
-      'label' => 'Unitnumber',
-      'field_name' => 'field_agreservations_unitnumber',
-      'type' => 'number_integer',
-      'widget_type' => 'number',
-      'change' => 'Change basic information',
-      'weight' => '1',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          '_error_element' => 'default_value_widget][field_agreservations_unitnumber][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => NULL,
-      'group' => false,
-      'required' => 0,
-      'multiple' => '0',
-      'min' => '',
-      'max' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'number',
-      'widget_module' => 'number',
-      'columns' => array(
-        'value' => array(
-          'type' => 'int',
-          'not null' => false,
-          'sortable' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    1 => array(
-      'label' => 'unittype',
-      'field_name' => 'field_agreservations_unittype',
-      'type' => 'nodereference',
-      'widget_type' => 'nodereference_select',
-      'change' => 'Change basic information',
-      'weight' => '2',
-      'autocomplete_match' => 'contains',
-      'size' => 60,
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'nid' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agreservations_unittype' => array(
-          0 => array(
-            'nid' => '',
-          ),
-          'nid' => array(
-            'nid' => '',
-          ),
-        ),
-      ),
-      'group' => false,
-      'required' => 1,
-      'multiple' => '0',
-      'referenceable_types' => array(
-        'agreservations_unittype' => 'agreservations_unittype',
-        'unit' => 1,
-        'page' => false,
-        'product' => false,
-        'profile' => false,
-        'agreservation' => false,
-        'story' => false,
-        'agreservations_unit' => false,
-        'agreservation_unit_info' => false,
-      ),
-      'advanced_view' => '--',
-      'advanced_view_args' => '',
-      'cck_referential_integrity_behavior' => '',
-      'show_add_link' => true,
-      'op' => 'Save field settings',
-      'module' => 'nodereference',
-      'widget_module' => 'nodereference',
-      'columns' => array(
-        'nid' => array(
-          'type' => 'int',
-          'unsigned' => true,
-          'not null' => false,
-          'index' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-  );
-  $content['extra']  = array(
-    'title' => '-5',
-    'revision_information' => '20',
-    'comment_settings' => '30',
-    'menu' => '-2',
-    'path' => '30',
-  );
-
-
+
+/**
+ * @file
+ * Install cck types for agreservationsmodule.
+ */
+
+/**
+ * @todo Documentation
+ */
+function _agreservations_cck_export_unit() {
+
+  $content['type'] = array(
+    'name' => 'Unit',
+    'type' => 'agreservations_unit',
+    'description' => t('reservable units implemented by agreservations module'),
+    'title_label' => 'Unitname',
+    'body_label' => '',
+    'min_word_count' => '0',
+    'help' => '',
+    'node_options' => array(
+      'status' => TRUE,
+      'promote' => TRUE,
+      'sticky' => FALSE,
+      'revision' => FALSE,
+    ),
+    'language_content_type' => '0',
+    'old_type' => 'agreservations_unit',
+    'orig_type' => '',
+    'module' => 'node',
+    'custom' => '1',
+    'modified' => '1',
+    'locked' => '0',
+    'content_profile_use' => 0,
+    'comment' => '2',
+    'comment_default_mode' => '4',
+    'comment_default_order' => '1',
+    'comment_default_per_page' => '50',
+    'comment_controls' => '3',
+    'comment_anonymous' => 0,
+    'comment_subject_field' => '1',
+    'comment_preview' => '1',
+    'comment_form_location' => '0',
+    'availability_calendars' => '0',
+  );
+  $content['fields'] = array(
+    0 => array(
+      'label' => 'Unitnumber',
+      'field_name' => 'field_agreservations_unitnumber',
+      'type' => 'number_integer',
+      'widget_type' => 'number',
+      'change' => 'Change basic information',
+      'weight' => '1',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          '_error_element' => 'default_value_widget][field_agreservations_unitnumber][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => NULL,
+      'group' => FALSE,
+      'required' => 0,
+      'multiple' => '0',
+      'min' => '',
+      'max' => '',
+      'prefix' => '',
+      'suffix' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'number',
+      'widget_module' => 'number',
+      'columns' => array(
+        'value' => array(
+          'type' => 'int',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    1 => array(
+      'label' => 'unittype',
+      'field_name' => 'field_agreservations_unittype',
+      'type' => 'nodereference',
+      'widget_type' => 'nodereference_select',
+      'change' => 'Change basic information',
+      'weight' => '2',
+      'autocomplete_match' => 'contains',
+      'size' => 60,
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'nid' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agreservations_unittype' => array(
+          0 => array(
+            'nid' => '',
+          ),
+          'nid' => array(
+            'nid' => '',
+          ),
+        ),
+      ),
+      'group' => FALSE,
+      'required' => 1,
+      'multiple' => '0',
+      'referenceable_types' => array(
+        'agreservations_unittype' => 'agreservations_unittype',
+        'unit' => 1,
+        'page' => FALSE,
+        'product' => FALSE,
+        'profile' => FALSE,
+        'agreservation' => FALSE,
+        'story' => FALSE,
+        'agreservations_unit' => FALSE,
+        'agreservation_unit_info' => FALSE,
+      ),
+      'advanced_view' => '--',
+      'advanced_view_args' => '',
+      'cck_referential_integrity_behavior' => '',
+      'show_add_link' => TRUE,
+      'op' => 'Save field settings',
+      'module' => 'nodereference',
+      'widget_module' => 'nodereference',
+      'columns' => array(
+        'nid' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => FALSE,
+          'index' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+  );
+  $content['extra'] = array(
+    'title' => '-5',
+    'revision_information' => '20',
+    'comment_settings' => '30',
+    'menu' => '-2',
+    'path' => '30',
+  );
+
+
   // paste code before this line.
-  return $content;
-}
-
-function _agreservations_cck_export_unittype() {
-  $content['type']  = array(
-    'name' => 'Unit type',
-    'type' => 'agreservations_unittype',
+  return $content;
+}
+
+function _agreservations_cck_export_unittype() {
+  $content['type'] = array(
+    'name' => 'Unit type',
+    'type' => 'agreservations_unittype',
     'description' => 'The Type of unit by agreservations module:
-Single unit, Double unit, Suite, Presidents Suite, Guestunit...',
-    'title_label' => 'Title',
-    'body_label' => '',
-    'min_word_count' => '0',
-    'help' => '',
-    'node_options' => array(
-      'status' => TRUE,
-      'promote' => TRUE,
-      'sticky' => FALSE,
-      'revision' => FALSE,
-    ),
-    'language_content_type' => '0',
-    'old_type' => 'agreservations_unittype',
-    'orig_type' => '',
-    'module' => 'node',
-    'custom' => '1',
-    'modified' => '1',
-    'locked' => '0',
-    'comment' => '2',
-    'comment_default_mode' => '4',
-    'comment_default_order' => '1',
-    'comment_default_per_page' => '50',
-    'comment_controls' => '3',
-    'comment_anonymous' => 0,
-    'comment_subject_field' => '1',
-    'comment_preview' => '1',
-    'comment_form_location' => '0',
-  );
-  $content['fields']  = array(
-    0 => array(
-      'label' => 'Capacity',
-      'field_name' => 'field_agreservations_capacity',
-      'type' => 'number_integer',
-      'widget_type' => 'number',
-      'change' => 'Change basic information',
-      'weight' => '4',
+Single unit, Double unit, Suite, Presidents Suite, Guestunit...',
+    'title_label' => 'Title',
+    'body_label' => '',
+    'min_word_count' => '0',
+    'help' => '',
+    'node_options' => array(
+      'status' => TRUE,
+      'promote' => TRUE,
+      'sticky' => FALSE,
+      'revision' => FALSE,
+    ),
+    'language_content_type' => '0',
+    'old_type' => 'agreservations_unittype',
+    'orig_type' => '',
+    'module' => 'node',
+    'custom' => '1',
+    'modified' => '1',
+    'locked' => '0',
+    'comment' => '2',
+    'comment_default_mode' => '4',
+    'comment_default_order' => '1',
+    'comment_default_per_page' => '50',
+    'comment_controls' => '3',
+    'comment_anonymous' => 0,
+    'comment_subject_field' => '1',
+    'comment_preview' => '1',
+    'comment_form_location' => '0',
+  );
+  $content['fields'] = array(
+    0 => array(
+      'label' => 'Capacity',
+      'field_name' => 'field_agreservations_capacity',
+      'type' => 'number_integer',
+      'widget_type' => 'number',
+      'change' => 'Change basic information',
+      'weight' => '4',
       'description' => 'How many persons are allowed for this unittype?
-     children count only 0.5',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          '_error_element' => 'default_value_widget][field_agreservations_capacity][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agreservations_capacity' => array(
-          0 => array(
-            'value' => '',
-            '_error_element' => 'default_value_widget][field_agreservations_capacity][0][value',
-          ),
-        ),
-      ),
-      'group' => FALSE,
-      'required' => 1,
-      'multiple' => '0',
-      'min' => '',
-      'max' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'number',
-      'widget_module' => 'number',
-      'columns' => array(
-        'value' => array(
-          'type' => 'int',
-          'not null' => FALSE,
-          'sortable' => TRUE,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-  );
-  $content['extra']  = array(
-    'title' => '-5',
-    'body_field' => '0',
-    'menu' => '-2',
-  );
-
-
-
-  // paste code before this line.
-  return $content;
-}
-
-
-
-
-function _agreservations_cck_export_agreservation() {
-
-  $content['type']  = array(
-    'name' => 'Reservation',
-    'type' => 'agreservation',
-    'description' => '',
-    'title_label' => 'Title',
-    'body_label' => '',
-    'min_word_count' => '0',
-    'help' => '',
-    'node_options' => array(
-      'status' => true,
-      'promote' => true,
-      'sticky' => false,
-      'revision' => false,
-    ),
-    'language_content_type' => '0',
-    'old_type' => 'agreservation',
-    'orig_type' => '',
-    'module' => 'node',
-    'custom' => '1',
-    'modified' => '1',
-    'locked' => '0',
-    'widgets_enabled' => 0,
-    'widgets_default' => array(
-    ),
-    'content_profile_use' => 0,
-    'comment' => '2',
-    'comment_default_mode' => '4',
-    'comment_default_order' => '1',
-    'comment_default_per_page' => '50',
-    'comment_controls' => '3',
-    'comment_anonymous' => 0,
-    'comment_subject_field' => '1',
-    'comment_preview' => '1',
-    'comment_form_location' => '0',
-    'availability_calendars' => '0',
-  );
-  $content['fields']  = array(
-    0 => array(
-      'label' => 'Reservationdate',
-      'field_name' => 'field_agres_checkinout',
-      'type' => 'datetime',
-      'widget_type' => 'date_popup',
-      'change' => 'Change basic information',
-      'weight' => '-1',
-      'default_value' => 'blank',
-      'default_value2' => 'same',
-      'default_value_code' => '',
-      'default_value_code2' => '',
-      'input_format' => 'd.m.Y - H:i',
-      'input_format_custom' => '',
-      'year_range' => '-3:+3',
-      'increment' => '1',
-      'advanced' => array(
-        'label_position' => 'above',
-        'text_parts' => array(
-          'year' => 0,
-          'month' => 0,
-          'day' => 0,
-          'hour' => 0,
-          'minute' => 0,
-          'second' => 0,
-        ),
-      ),
-      'label_position' => 'above',
-      'text_parts' => array(
-      ),
-      'description' => '',
-      'group' => false,
-      'required' => 1,
-      'multiple' => '0',
-      'repeat' => 0,
-      'todate' => 'required',
-      'granularity' => array(
-        'year' => 'year',
-        'month' => 'month',
-        'day' => 'day',
-        'hour' => 'hour',
-        'minute' => 'minute',
-      ),
-      'default_format' => 'medium',
-      'tz_handling' => 'none',
-      'timezone_db' => '',
-      'op' => 'Save field settings',
-      'module' => 'date',
-      'widget_module' => 'date',
-      'columns' => array(
-        'value' => array(
-          'type' => 'datetime',
-          'not null' => false,
-          'sortable' => true,
-          'views' => true,
-        ),
-        'value2' => array(
-          'type' => 'datetime',
-          'not null' => false,
-          'sortable' => true,
-          'views' => false,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        2 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        3 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    1 => array(
-      'label' => 'unitreference',
-      'field_name' => 'field_agres_ref_unit',
-      'type' => 'nodereference',
-      'widget_type' => 'nodereference_buttons',
-      'change' => 'Change basic information',
-      'weight' => 0,
-      'autocomplete_match' => 'contains',
-      'size' => 60,
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'nid' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_ref_unit' => array(
-          0 => array(
-            'nid' => '',
-          ),
-          'nid' => array(
-            'nid' => array(
-              '' => 1,
-              517 => false,
-              518 => false,
-              527 => false,
-              528 => false,
-              566 => false,
-            ),
-          ),
-        ),
-      ),
-      'group' => false,
-      'required' => 0,
-      'multiple' => '1',
-      'referenceable_types' => array(
-        'agreservations_unit' => 'agreservations_unit',
-        'page' => 0,
-        'product' => 0,
-        'profile' => 0,
-        'story' => 0,
-        'agreservation' => 0,
-        'agreservation2' => 0,
-        'agreservations_unittype' => 0,
-        'agreservation_unit_info' => false,
-      ),
-      'advanced_view' => '--',
-      'advanced_view_args' => '',
-      'cck_referential_integrity_behavior' => '',
-      'show_add_link' => 1,
-      'op' => 'Save field settings',
-      'module' => 'nodereference',
-      'widget_module' => 'nodereference',
-      'columns' => array(
-        'nid' => array(
-          'type' => 'int',
-          'unsigned' => true,
-          'not null' => false,
-          'index' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        2 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        3 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    2 => array(
-      'label' => 'Order_id',
-      'field_name' => 'field_agres_orderid',
-      'type' => 'number_integer',
-      'widget_type' => 'number',
-      'change' => 'Change basic information',
-      'weight' => '1',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          '_error_element' => 'default_value_widget][field_agres_orderid][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_orderid' => array(
-          0 => array(
-            'value' => '',
-            '_error_element' => 'default_value_widget][field_agres_orderid][0][value',
-          ),
-        ),
-      ),
-      'group' => false,
-      'required' => 0,
-      'multiple' => '0',
-      'min' => '',
-      'max' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'number',
-      'widget_module' => 'number',
-      'columns' => array(
-        'value' => array(
-          'type' => 'int',
-          'not null' => false,
-          'sortable' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    3 => array(
-      'label' => 'agreservations_Status',
-      'field_name' => 'field_agres_status',
-      'type' => 'number_integer',
-      'widget_type' => 'number',
-      'change' => 'Change basic information',
-      'weight' => '2',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          '_error_element' => 'default_value_widget][field_agres_status][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_status' => array(
-          0 => array(
-            'value' => '',
-            '_error_element' => 'default_value_widget][field_agres_status][0][value',
-          ),
-        ),
-      ),
-      'group' => false,
-      'required' => 0,
-      'multiple' => '0',
-      'min' => '',
-      'max' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'number',
-      'widget_module' => 'number',
-      'columns' => array(
-        'value' => array(
-          'type' => 'int',
-          'not null' => false,
-          'sortable' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    4 => array(
-      'label' => 'Userreference',
-      'field_name' => 'field_agres_userref',
-      'type' => 'userreference',
-      'widget_type' => 'userreference_autocomplete',
-      'change' => 'Change basic information',
-      'weight' => '3',
-      'autocomplete_match' => 'contains',
-      'size' => '60',
-      'reverse_link' => 0,
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'uid' => NULL,
-          '_error_element' => 'default_value_widget][field_agres_userref][0][uid][uid',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_userref' => array(
-          0 => array(
-            'uid' => array(
-              'uid' => '',
-              '_error_element' => 'default_value_widget][field_agres_userref][0][uid][uid',
-            ),
-            '_error_element' => 'default_value_widget][field_agres_userref][0][uid][uid',
-          ),
-        ),
-      ),
-      'group' => false,
-      'required' => 0,
-      'multiple' => '0',
-      'referenceable_roles' => array(
-        2 => 0,
-      ),
-      'referenceable_status' => '',
-      'advanced_view' => 'hotelcustomers',
-      'advanced_view_args' => '',
-      'cck_referential_integrity_behavior' => '',
-      'show_add_link' => 1,
-      'op' => 'Save field settings',
-      'module' => 'userreference',
-      'widget_module' => 'userreference',
-      'columns' => array(
-        'uid' => array(
-          'type' => 'int',
-          'unsigned' => true,
-          'not null' => false,
-          'index' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    5 => array(
-      'label' => 'number of adults',
-      'field_name' => 'field_agres_adults',
-      'type' => 'number_integer',
-      'widget_type' => 'number',
-      'change' => 'Change basic information',
-      'weight' => '4',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          '_error_element' => 'default_value_widget][field_agres_adults][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_adults' => array(
-          0 => array(
-            'value' => '',
-            '_error_element' => 'default_value_widget][field_agres_adults][0][value',
-          ),
-        ),
-      ),
-      'group' => false,
-      'required' => 0,
-      'multiple' => '0',
-      'min' => '1',
-      'max' => '10',
-      'prefix' => '',
-      'suffix' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'number',
-      'widget_module' => 'number',
-      'columns' => array(
-        'value' => array(
-          'type' => 'int',
-          'not null' => false,
-          'sortable' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        2 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        3 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    6 => array(
-      'label' => 'number of Children',
-      'field_name' => 'field_agres_children',
-      'type' => 'number_integer',
-      'widget_type' => 'number',
-      'change' => 'Change basic information',
-      'weight' => '5',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          '_error_element' => 'default_value_widget][field_agres_children][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_children' => array(
-          0 => array(
-            'value' => '',
-            '_error_element' => 'default_value_widget][field_agres_children][0][value',
-          ),
-        ),
-      ),
-      'group' => false,
-      'required' => 0,
-      'multiple' => '0',
-      'min' => '0',
-      'max' => '10',
-      'prefix' => '',
-      'suffix' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'number',
-      'widget_module' => 'number',
-      'columns' => array(
-        'value' => array(
-          'type' => 'int',
-          'not null' => false,
-          'sortable' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        2 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        3 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    7 => array(
-      'label' => 'Persons',
-      'field_name' => 'field_agres_persons',
-      'type' => 'number_integer',
-      'widget_type' => 'number',
-      'change' => 'Change basic information',
-      'weight' => '6',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          '_error_element' => 'default_value_widget][field_agres_persons][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_persons' => array(
-          0 => array(
-            'value' => '',
-            '_error_element' => 'default_value_widget][field_agres_persons][0][value',
-          ),
-        ),
-      ),
-      'group' => false,
-      'required' => 0,
-      'multiple' => '0',
-      'min' => '',
-      'max' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'number',
-      'widget_module' => 'number',
-      'columns' => array(
-        'value' => array(
-          'type' => 'int',
-          'not null' => false,
-          'sortable' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'label' => array(
-          'format' => 'above',
-          'exclude' => 0,
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        2 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        3 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-  );
-  $content['extra']  = array(
-    'title' => '-5',
-    'revision_information' => '-3',
-    'comment_settings' => '-2',
-    'menu' => '-4',
-    'path' => '30',
-  );
-
-
-  return $content;
-}
-
-
-function _agreservations_cck_export_unitinfo() {
-  $content['type']  = array(
-    'name' => 'Unit info per reservation',
-    'type' => 'agreservation_unit_info',
-    'description' => 'resourceregarded Info of an agreservation',
-    'title_label' => 'Title',
-    'body_label' => '',
-    'min_word_count' => '0',
-    'help' => '',
-    'node_options' => array(
-      'status' => true,
-      'promote' => true,
-      'sticky' => false,
-      'revision' => false,
-    ),
-    'language_content_type' => '0',
-    'old_type' => 'agreservation_unit_info',
-    'orig_type' => '',
-    'module' => 'node',
-    'custom' => '1',
-    'modified' => '1',
-    'locked' => '0',
-    'widgets_enabled' => 0,
-    'widgets_default' => array(
-    ),
-    'content_profile_use' => 0,
-    'comment' => '2',
-    'comment_default_mode' => '4',
-    'comment_default_order' => '1',
-    'comment_default_per_page' => '50',
-    'comment_controls' => '3',
-    'comment_anonymous' => 0,
-    'comment_subject_field' => '1',
-    'comment_preview' => '1',
-    'comment_form_location' => '0',
-    'availability_calendars' => '0',
-  );
-  $content['fields']  = array(
-    0 => array(
-      'label' => 'Reference Agreservation',
-      'field_name' => 'field_agres_ref_agreservation',
-      'type' => 'nodereference',
-      'widget_type' => 'nodereference_select',
-      'change' => 'Change basic information',
-      'weight' => '31',
-      'autocomplete_match' => 'contains',
-      'size' => '60',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'nid' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => NULL,
-      'group' => false,
-      'required' => 1,
-      'multiple' => '1',
-      'referenceable_types' => array(
-        'agreservation' => 'agreservation',
-        'page' => 0,
-        'product' => 0,
-        'profile' => 0,
-        'story' => 0,
-        'agreservations_unittype' => 0,
-        'agreservation_unit_info' => 0,
-        'agreservations_unit' => 0,
-      ),
-      'advanced_view' => '--',
-      'advanced_view_args' => '',
-      'cck_referential_integrity_behavior' => '',
-      'show_add_link' => 0,
-      'op' => 'Save field settings',
-      'module' => 'nodereference',
-      'widget_module' => 'nodereference',
-      'columns' => array(
-        'nid' => array(
-          'type' => 'int',
-          'unsigned' => true,
-          'not null' => false,
-          'index' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'weight' => '31',
-        'parent' => '',
-        'label' => array(
-          'format' => 'above',
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        2 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        3 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    1 => array(
-      'label' => 'Reserved Room',
-      'field_name' => 'field_agres_refsingle_unit',
-      'type' => 'nodereference',
-      'widget_type' => 'nodereference_select',
-      'change' => 'Change basic information',
-      'weight' => '32',
-      'autocomplete_match' => 'contains',
-      'size' => 60,
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'nid' => '',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_refsingle_unit' => array(
-          0 => array(
-            'nid' => '',
-          ),
-          'nid' => array(
-            'nid' => '',
-          ),
-        ),
-      ),
-      'group' => false,
-      'required' => 1,
-      'multiple' => '0',
-      'referenceable_types' => array(
-        'agreservations_unit' => 'agreservations_unit',
-        'page' => 0,
-        'product' => 0,
-        'profile' => 0,
-        'story' => 0,
-        'agreservation' => 0,
-        'agreservations_unittype' => 0,
-        'agreservation_unit_info' => 0,
-      ),
-      'advanced_view' => '--',
-      'advanced_view_args' => '',
-      'cck_referential_integrity_behavior' => '',
-      'show_add_link' => 1,
-      'op' => 'Save field settings',
-      'module' => 'nodereference',
-      'widget_module' => 'nodereference',
-      'columns' => array(
-        'nid' => array(
-          'type' => 'int',
-          'unsigned' => true,
-          'not null' => false,
-          'index' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'weight' => '32',
-        'parent' => '',
-        'label' => array(
-          'format' => 'above',
-        ),
-        'teaser' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        2 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        3 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-    2 => array(
-      'label' => 'Persons',
-      'field_name' => 'field_agres_unit_persons',
-      'type' => 'number_integer',
-      'widget_type' => 'number',
-      'change' => 'Change basic information',
-      'weight' => '33',
-      'description' => '',
-      'default_value' => array(
-        0 => array(
-          'value' => '',
-          '_error_element' => 'default_value_widget][field_agres_unit_persons][0][value',
-        ),
-      ),
-      'default_value_php' => '',
-      'default_value_widget' => array(
-        'field_agres_unit_persons' => array(
-          0 => array(
-            'value' => '',
-            '_error_element' => 'default_value_widget][field_agres_unit_persons][0][value',
-          ),
-        ),
-      ),
-      'group' => false,
-      'required' => 0,
-      'multiple' => '0',
-      'min' => '',
-      'max' => '',
-      'prefix' => '',
-      'suffix' => '',
-      'allowed_values' => '',
-      'allowed_values_php' => '',
-      'op' => 'Save field settings',
-      'module' => 'number',
-      'widget_module' => 'number',
-      'columns' => array(
-        'value' => array(
-          'type' => 'int',
-          'not null' => false,
-          'sortable' => true,
-        ),
-      ),
-      'display_settings' => array(
-        'weight' => '33',
-        'parent' => '',
-        'label' => array(
-          'format' => 'above',
-        ),
-        'teaser' => array(
-          'format' => 'editable',
-          'exclude' => 0,
-        ),
-        'full' => array(
-          'format' => 'editable',
-          'exclude' => 0,
-        ),
-        4 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        2 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        3 => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-        'token' => array(
-          'format' => 'default',
-          'exclude' => 0,
-        ),
-      ),
-    ),
-  );
-  $content['extra']  = array(
-    'title' => '-5',
-    'revision_information' => '20',
-    'comment_settings' => '30',
-    'menu' => '-2',
-    'path' => '30',
-  );
-
-  return $content;
-}
+     children count only 0.5',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          '_error_element' => 'default_value_widget][field_agreservations_capacity][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agreservations_capacity' => array(
+          0 => array(
+            'value' => '',
+            '_error_element' => 'default_value_widget][field_agreservations_capacity][0][value',
+          ),
+        ),
+      ),
+      'group' => FALSE,
+      'required' => 1,
+      'multiple' => '0',
+      'min' => '',
+      'max' => '',
+      'prefix' => '',
+      'suffix' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'number',
+      'widget_module' => 'number',
+      'columns' => array(
+        'value' => array(
+          'type' => 'int',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+  );
+  $content['extra'] = array(
+    'title' => '-5',
+    'body_field' => '0',
+    'menu' => '-2',
+  );
+
+  return $content;
+}
+
+/**
+ * @todo Documentation
+ */
+function _agreservations_cck_export_agreservation() {
+
+  $content['type'] = array(
+    'name' => 'Reservation',
+    'type' => 'agreservation',
+    'description' => '',
+    'title_label' => 'Title',
+    'body_label' => '',
+    'min_word_count' => '0',
+    'help' => '',
+    'node_options' => array(
+      'status' => TRUE,
+      'promote' => TRUE,
+      'sticky' => FALSE,
+      'revision' => FALSE,
+    ),
+    'language_content_type' => '0',
+    'old_type' => 'agreservation',
+    'orig_type' => '',
+    'module' => 'node',
+    'custom' => '1',
+    'modified' => '1',
+    'locked' => '0',
+    'widgets_enabled' => 0,
+    'widgets_default' => array(
+    ),
+    'content_profile_use' => 0,
+    'comment' => '2',
+    'comment_default_mode' => '4',
+    'comment_default_order' => '1',
+    'comment_default_per_page' => '50',
+    'comment_controls' => '3',
+    'comment_anonymous' => 0,
+    'comment_subject_field' => '1',
+    'comment_preview' => '1',
+    'comment_form_location' => '0',
+    'availability_calendars' => '0',
+  );
+  $content['fields'] = array(
+    0 => array(
+      'label' => 'Reservationdate',
+      'field_name' => 'field_agres_checkinout',
+      'type' => 'datetime',
+      'widget_type' => 'date_popup',
+      'change' => 'Change basic information',
+      'weight' => '-1',
+      'default_value' => 'blank',
+      'default_value2' => 'same',
+      'default_value_code' => '',
+      'default_value_code2' => '',
+      'input_format' => 'd.m.Y - H:i',
+      'input_format_custom' => '',
+      'year_range' => '-3:+3',
+      'increment' => '1',
+      'advanced' => array(
+        'label_position' => 'above',
+        'text_parts' => array(
+          'year' => 0,
+          'month' => 0,
+          'day' => 0,
+          'hour' => 0,
+          'minute' => 0,
+          'second' => 0,
+        ),
+      ),
+      'label_position' => 'above',
+      'text_parts' => array(
+      ),
+      'description' => '',
+      'group' => FALSE,
+      'required' => 1,
+      'multiple' => '0',
+      'repeat' => 0,
+      'todate' => 'required',
+      'granularity' => array(
+        'year' => 'year',
+        'month' => 'month',
+        'day' => 'day',
+        'hour' => 'hour',
+        'minute' => 'minute',
+      ),
+      'default_format' => 'medium',
+      'tz_handling' => 'none',
+      'timezone_db' => '',
+      'op' => 'Save field settings',
+      'module' => 'date',
+      'widget_module' => 'date',
+      'columns' => array(
+        'value' => array(
+          'type' => 'datetime',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => TRUE,
+        ),
+        'value2' => array(
+          'type' => 'datetime',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+          'views' => FALSE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        2 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        3 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    1 => array(
+      'label' => 'unitreference',
+      'field_name' => 'field_agres_ref_unit',
+      'type' => 'nodereference',
+      'widget_type' => 'nodereference_buttons',
+      'change' => 'Change basic information',
+      'weight' => 0,
+      'autocomplete_match' => 'contains',
+      'size' => 60,
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'nid' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_ref_unit' => array(
+          0 => array(
+            'nid' => '',
+          ),
+          'nid' => array(
+            'nid' => array(
+              '' => 1,
+              517 => FALSE,
+              518 => FALSE,
+              527 => FALSE,
+              528 => FALSE,
+              566 => FALSE,
+            ),
+          ),
+        ),
+      ),
+      'group' => FALSE,
+      'required' => 0,
+      'multiple' => '1',
+      'referenceable_types' => array(
+        'agreservations_unit' => 'agreservations_unit',
+        'page' => 0,
+        'product' => 0,
+        'profile' => 0,
+        'story' => 0,
+        'agreservation' => 0,
+        'agreservation2' => 0,
+        'agreservations_unittype' => 0,
+        'agreservation_unit_info' => FALSE,
+      ),
+      'advanced_view' => '--',
+      'advanced_view_args' => '',
+      'cck_referential_integrity_behavior' => '',
+      'show_add_link' => 1,
+      'op' => 'Save field settings',
+      'module' => 'nodereference',
+      'widget_module' => 'nodereference',
+      'columns' => array(
+        'nid' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => FALSE,
+          'index' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        2 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        3 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    2 => array(
+      'label' => 'Order_id',
+      'field_name' => 'field_agres_orderid',
+      'type' => 'number_integer',
+      'widget_type' => 'number',
+      'change' => 'Change basic information',
+      'weight' => '1',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          '_error_element' => 'default_value_widget][field_agres_orderid][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_orderid' => array(
+          0 => array(
+            'value' => '',
+            '_error_element' => 'default_value_widget][field_agres_orderid][0][value',
+          ),
+        ),
+      ),
+      'group' => FALSE,
+      'required' => 0,
+      'multiple' => '0',
+      'min' => '',
+      'max' => '',
+      'prefix' => '',
+      'suffix' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'number',
+      'widget_module' => 'number',
+      'columns' => array(
+        'value' => array(
+          'type' => 'int',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    3 => array(
+      'label' => 'agreservations_Status',
+      'field_name' => 'field_agres_status',
+      'type' => 'number_integer',
+      'widget_type' => 'number',
+      'change' => 'Change basic information',
+      'weight' => '2',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          '_error_element' => 'default_value_widget][field_agres_status][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_status' => array(
+          0 => array(
+            'value' => '',
+            '_error_element' => 'default_value_widget][field_agres_status][0][value',
+          ),
+        ),
+      ),
+      'group' => FALSE,
+      'required' => 0,
+      'multiple' => '0',
+      'min' => '',
+      'max' => '',
+      'prefix' => '',
+      'suffix' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'number',
+      'widget_module' => 'number',
+      'columns' => array(
+        'value' => array(
+          'type' => 'int',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    4 => array(
+      'label' => 'Userreference',
+      'field_name' => 'field_agres_userref',
+      'type' => 'userreference',
+      'widget_type' => 'userreference_autocomplete',
+      'change' => 'Change basic information',
+      'weight' => '3',
+      'autocomplete_match' => 'contains',
+      'size' => '60',
+      'reverse_link' => 0,
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'uid' => NULL,
+          '_error_element' => 'default_value_widget][field_agres_userref][0][uid][uid',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_userref' => array(
+          0 => array(
+            'uid' => array(
+              'uid' => '',
+              '_error_element' => 'default_value_widget][field_agres_userref][0][uid][uid',
+            ),
+            '_error_element' => 'default_value_widget][field_agres_userref][0][uid][uid',
+          ),
+        ),
+      ),
+      'group' => FALSE,
+      'required' => 0,
+      'multiple' => '0',
+      'referenceable_roles' => array(
+        2 => 0,
+      ),
+      'referenceable_status' => '',
+      'advanced_view' => 'hotelcustomers',
+      'advanced_view_args' => '',
+      'cck_referential_integrity_behavior' => '',
+      'show_add_link' => 1,
+      'op' => 'Save field settings',
+      'module' => 'userreference',
+      'widget_module' => 'userreference',
+      'columns' => array(
+        'uid' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => FALSE,
+          'index' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    5 => array(
+      'label' => 'number of adults',
+      'field_name' => 'field_agres_adults',
+      'type' => 'number_integer',
+      'widget_type' => 'number',
+      'change' => 'Change basic information',
+      'weight' => '4',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          '_error_element' => 'default_value_widget][field_agres_adults][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_adults' => array(
+          0 => array(
+            'value' => '',
+            '_error_element' => 'default_value_widget][field_agres_adults][0][value',
+          ),
+        ),
+      ),
+      'group' => FALSE,
+      'required' => 0,
+      'multiple' => '0',
+      'min' => '1',
+      'max' => '10',
+      'prefix' => '',
+      'suffix' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'number',
+      'widget_module' => 'number',
+      'columns' => array(
+        'value' => array(
+          'type' => 'int',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        2 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        3 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    6 => array(
+      'label' => 'number of Children',
+      'field_name' => 'field_agres_children',
+      'type' => 'number_integer',
+      'widget_type' => 'number',
+      'change' => 'Change basic information',
+      'weight' => '5',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          '_error_element' => 'default_value_widget][field_agres_children][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_children' => array(
+          0 => array(
+            'value' => '',
+            '_error_element' => 'default_value_widget][field_agres_children][0][value',
+          ),
+        ),
+      ),
+      'group' => FALSE,
+      'required' => 0,
+      'multiple' => '0',
+      'min' => '0',
+      'max' => '10',
+      'prefix' => '',
+      'suffix' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'number',
+      'widget_module' => 'number',
+      'columns' => array(
+        'value' => array(
+          'type' => 'int',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        2 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        3 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    7 => array(
+      'label' => 'Persons',
+      'field_name' => 'field_agres_persons',
+      'type' => 'number_integer',
+      'widget_type' => 'number',
+      'change' => 'Change basic information',
+      'weight' => '6',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          '_error_element' => 'default_value_widget][field_agres_persons][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_persons' => array(
+          0 => array(
+            'value' => '',
+            '_error_element' => 'default_value_widget][field_agres_persons][0][value',
+          ),
+        ),
+      ),
+      'group' => FALSE,
+      'required' => 0,
+      'multiple' => '0',
+      'min' => '',
+      'max' => '',
+      'prefix' => '',
+      'suffix' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'number',
+      'widget_module' => 'number',
+      'columns' => array(
+        'value' => array(
+          'type' => 'int',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'label' => array(
+          'format' => 'above',
+          'exclude' => 0,
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        2 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        3 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+  );
+  $content['extra'] = array(
+    'title' => '-5',
+    'revision_information' => '-3',
+    'comment_settings' => '-2',
+    'menu' => '-4',
+    'path' => '30',
+  );
+
+
+  return $content;
+}
+
+function _agreservations_cck_export_unitinfo() {
+  $content['type'] = array(
+    'name' => 'Unit info per reservation',
+    'type' => 'agreservation_unit_info',
+    'description' => 'resourceregarded Info of an agreservation',
+    'title_label' => 'Title',
+    'body_label' => '',
+    'min_word_count' => '0',
+    'help' => '',
+    'node_options' => array(
+      'status' => TRUE,
+      'promote' => TRUE,
+      'sticky' => FALSE,
+      'revision' => FALSE,
+    ),
+    'language_content_type' => '0',
+    'old_type' => 'agreservation_unit_info',
+    'orig_type' => '',
+    'module' => 'node',
+    'custom' => '1',
+    'modified' => '1',
+    'locked' => '0',
+    'widgets_enabled' => 0,
+    'widgets_default' => array(
+    ),
+    'content_profile_use' => 0,
+    'comment' => '2',
+    'comment_default_mode' => '4',
+    'comment_default_order' => '1',
+    'comment_default_per_page' => '50',
+    'comment_controls' => '3',
+    'comment_anonymous' => 0,
+    'comment_subject_field' => '1',
+    'comment_preview' => '1',
+    'comment_form_location' => '0',
+    'availability_calendars' => '0',
+  );
+  $content['fields'] = array(
+    0 => array(
+      'label' => 'Reference Agreservation',
+      'field_name' => 'field_agres_ref_agreservation',
+      'type' => 'nodereference',
+      'widget_type' => 'nodereference_select',
+      'change' => 'Change basic information',
+      'weight' => '31',
+      'autocomplete_match' => 'contains',
+      'size' => '60',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'nid' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => NULL,
+      'group' => FALSE,
+      'required' => 1,
+      'multiple' => '1',
+      'referenceable_types' => array(
+        'agreservation' => 'agreservation',
+        'page' => 0,
+        'product' => 0,
+        'profile' => 0,
+        'story' => 0,
+        'agreservations_unittype' => 0,
+        'agreservation_unit_info' => 0,
+        'agreservations_unit' => 0,
+      ),
+      'advanced_view' => '--',
+      'advanced_view_args' => '',
+      'cck_referential_integrity_behavior' => '',
+      'show_add_link' => 0,
+      'op' => 'Save field settings',
+      'module' => 'nodereference',
+      'widget_module' => 'nodereference',
+      'columns' => array(
+        'nid' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => FALSE,
+          'index' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'weight' => '31',
+        'parent' => '',
+        'label' => array(
+          'format' => 'above',
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        2 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        3 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    1 => array(
+      'label' => 'Reserved Room',
+      'field_name' => 'field_agres_refsingle_unit',
+      'type' => 'nodereference',
+      'widget_type' => 'nodereference_select',
+      'change' => 'Change basic information',
+      'weight' => '32',
+      'autocomplete_match' => 'contains',
+      'size' => 60,
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'nid' => '',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_refsingle_unit' => array(
+          0 => array(
+            'nid' => '',
+          ),
+          'nid' => array(
+            'nid' => '',
+          ),
+        ),
+      ),
+      'group' => FALSE,
+      'required' => 1,
+      'multiple' => '0',
+      'referenceable_types' => array(
+        'agreservations_unit' => 'agreservations_unit',
+        'page' => 0,
+        'product' => 0,
+        'profile' => 0,
+        'story' => 0,
+        'agreservation' => 0,
+        'agreservations_unittype' => 0,
+        'agreservation_unit_info' => 0,
+      ),
+      'advanced_view' => '--',
+      'advanced_view_args' => '',
+      'cck_referential_integrity_behavior' => '',
+      'show_add_link' => 1,
+      'op' => 'Save field settings',
+      'module' => 'nodereference',
+      'widget_module' => 'nodereference',
+      'columns' => array(
+        'nid' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => FALSE,
+          'index' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'weight' => '32',
+        'parent' => '',
+        'label' => array(
+          'format' => 'above',
+        ),
+        'teaser' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        2 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        3 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+    2 => array(
+      'label' => 'Persons',
+      'field_name' => 'field_agres_unit_persons',
+      'type' => 'number_integer',
+      'widget_type' => 'number',
+      'change' => 'Change basic information',
+      'weight' => '33',
+      'description' => '',
+      'default_value' => array(
+        0 => array(
+          'value' => '',
+          '_error_element' => 'default_value_widget][field_agres_unit_persons][0][value',
+        ),
+      ),
+      'default_value_php' => '',
+      'default_value_widget' => array(
+        'field_agres_unit_persons' => array(
+          0 => array(
+            'value' => '',
+            '_error_element' => 'default_value_widget][field_agres_unit_persons][0][value',
+          ),
+        ),
+      ),
+      'group' => FALSE,
+      'required' => 0,
+      'multiple' => '0',
+      'min' => '',
+      'max' => '',
+      'prefix' => '',
+      'suffix' => '',
+      'allowed_values' => '',
+      'allowed_values_php' => '',
+      'op' => 'Save field settings',
+      'module' => 'number',
+      'widget_module' => 'number',
+      'columns' => array(
+        'value' => array(
+          'type' => 'int',
+          'not null' => FALSE,
+          'sortable' => TRUE,
+        ),
+      ),
+      'display_settings' => array(
+        'weight' => '33',
+        'parent' => '',
+        'label' => array(
+          'format' => 'above',
+        ),
+        'teaser' => array(
+          'format' => 'editable',
+          'exclude' => 0,
+        ),
+        'full' => array(
+          'format' => 'editable',
+          'exclude' => 0,
+        ),
+        4 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        2 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        3 => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+        'token' => array(
+          'format' => 'default',
+          'exclude' => 0,
+        ),
+      ),
+    ),
+  );
+  $content['extra'] = array(
+    'title' => '-5',
+    'revision_information' => '20',
+    'comment_settings' => '30',
+    'menu' => '-2',
+    'path' => '30',
+  );
+
+  return $content;
+}
\ No newline at end of file
diff --git a/js/agresdatechange.js b/js/agresdatechange.js
index 7e0a4e6..ab6f1af 100644
--- a/js/agresdatechange.js
+++ b/js/agresdatechange.js
@@ -1,36 +1,20 @@
-/* 
- * change the to date when the from date changes:
- */
-//jQuery(document).ready(function () { alert("Hellodgfghf!"); });
-
-//(function ($) {
-//  Drupal.behaviors.exampleModule = {
-//    attach: function(context, settings) {
-//      $('#edit-checkin-datepicker-popup-0',context).change(function () {
-//      $(this).slideUp();
-//});
-//}
-//}
-//})(jQuery);
-
 (function ($) {
   Drupal.behaviors.exampleModule = {
     attach: function(context, settings) {
-      $('#edit-checkin-datepicker-popup-0',context).change(function () {   
-          var strdate = $(this).attr("value");    
-          var dt1  = strdate.substring(0,2); 
-          var mon1 = strdate.substring(3,5); 
-          var yr1  = strdate.substring(6,10); 
-          var tmpstrdate = mon1+"/"+dt1+"/"+yr1;          
-          var msecsdate  = Date.parse(tmpstrdate);
-          var interval = +1;       
-          var dateto = new Date(msecsdate);
-          dateto.setDate(dateto.getDate() -0+interval);    
-          var tdate = document.getElementById("edit-checkout-datepicker-popup-0");          
-          var dtext = dateto.getDate()+'.'+(dateto.getMonth()+1)+'.'+dateto.getFullYear();
-            tdate.value = dtext;
-//           alert(tdate.value);          
+      $('#edit-checkin-datepicker-popup-0',context).change(function () {
+        var strdate = $(this).attr("value");
+        var dt1  = strdate.substring(0,2);
+        var mon1 = strdate.substring(3,5);
+        var yr1  = strdate.substring(6,10);
+        var tmpstrdate = mon1+"/"+dt1+"/"+yr1;
+        var msecsdate  = Date.parse(tmpstrdate);
+        var interval = +1;
+        var dateto = new Date(msecsdate);
+        dateto.setDate(dateto.getDate() -0+interval);
+        var tdate = document.getElementById("edit-checkout-datepicker-popup-0");
+        var dtext = dateto.getDate()+'.'+(dateto.getMonth()+1)+'.'+dateto.getFullYear();
+        tdate.value = dtext;
       });
-}
-}
+    }
+  }
 })(jQuery);
diff --git a/templates/admin_agres.itpl.php b/templates/admin_agres.itpl.php
index b81755a..f9067b1 100644
--- a/templates/admin_agres.itpl.php
+++ b/templates/admin_agres.itpl.php
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * This file is the default admin notification template for Ubercart.
@@ -7,42 +6,44 @@
 ?>
 
 <p>
-<?php echo t('Checkin:'); ?> [reservation-checkin]<br />    [reservation-checkout]
-<?php echo t('Order number:'); ?> [order-admin-link]<br />
-<?php echo t('Customer:'); ?> [order-first-name] [order-last-name] - [order-email]<br />
-<?php echo t('Order total:'); ?> [order-total]<br />
-<?php echo t('Charged:'); ?> [agres_deposit]<br />
-<?php echo t('Shipping method:'); ?> [order-shipping-method]
+  <?php echo t('Checkin:'); ?> [reservation-checkin]<br />    [reservation-checkout]
+  <?php echo t('Order number:'); ?> [order-admin-link]<br />
+  <?php echo t('Customer:'); ?> [order-first-name] [order-last-name] - [order-email]<br />
+  <?php echo t('Order total:'); ?> [order-total]<br />
+  <?php echo t('Charged:'); ?> [agres_deposit]<br />
+  <?php echo t('Shipping method:'); ?> [order-shipping-method]
 </p>
 
 <p>
-<?php echo t('Products:'); ?><br />
-<?php
-$context = array(
-  'revision' => 'themed',
-  'type' => 'order_product',
-);
-foreach ($products as $product) {
-  $price_info = array(
-    'price' => $product->price,
-    'qty' => $product->qty,
-  );
-  $context['subject'] = array(
-    'order_product' => $product,
+  <?php echo t('Products:'); ?><br />
+  <?php
+  $context = array(
+    'revision' => 'themed',
+    'type' => 'order_product',
   );
-?>
-- <?php echo $product->qty; ?> x <?php echo $product->title .' - '. uc_price($price_info, $context); ?><br />
-&nbsp;&nbsp;<?php echo t('SKU: ') . $product->model; ?><br />
-    <?php if (is_array($product->data['attributes']) && count($product->data['attributes']) > 0) {?>
-    <?php foreach ($product->data['attributes'] as $attribute => $option) {
-      echo '&nbsp;&nbsp;'. t('@attribute: @options', array('@attribute' => $attribute, '@options' => implode(', ', (array)$option))) .'<br />';
-    } ?>
+  foreach ($products as $product) {
+    $price_info = array(
+      'price' => $product->price,
+      'qty' => $product->qty,
+    );
+    $context['subject'] = array(
+      'order_product' => $product,
+    );
+    ?>
+    - <?php echo $product->qty; ?> x <?php echo $product->title . ' - ' . uc_price($price_info, $context); ?><br />
+    &nbsp;&nbsp;<?php echo t('SKU: ') . $product->model; ?><br />
+    <?php if (is_array($product->data['attributes']) && count($product->data['attributes']) > 0) { ?>
+      <?php
+      foreach ($product->data['attributes'] as $attribute => $option) {
+        echo '&nbsp;&nbsp;' . t('@attribute: @options', array('@attribute' => $attribute, '@options' => implode(', ', (array) $option))) . '<br />';
+      }
+      ?>
     <?php } ?>
-<br />
+    <br />
 <?php } ?>
 </p>
 
 <p>
 <?php echo t('Order comments:'); ?><br />
-[order-comments]
-</p>
+  [order-comments]
+</p>
\ No newline at end of file
diff --git a/templates/customer_agres.itpl.php b/templates/customer_agres.itpl.php
index 604cc7d..6c0d594 100644
--- a/templates/customer_agres.itpl.php
+++ b/templates/customer_agres.itpl.php
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * This file is the default customer invoice template for Ubercart.
@@ -10,57 +9,55 @@
   <tr>
     <td>
       <table width="100%" border="0" cellspacing="0" cellpadding="5" align="center" bgcolor="#FFFFFF" style="font-family: verdana, arial, helvetica; font-size: small;">
-        <?php if ($business_header) { ?>
+        <?php if ($business_header): ?>
+          <tr valign="top">
+            <td>
+              <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
+                <tr>
+                  <td>
+                    [site-logo]
+                  </td>
+                  <td width="98%">
+                    <div style="padding-left: 1em;">
+                      <span style="font-size: large;">[store-name]</span><br />
+                      [site-slogan]
+                    </div>
+                  </td>
+                  <td nowrap="nowrap">
+                    [store-address]<br />[store-phone]
+                  </td>
+                </tr>
+              </table>
+            </td>
+          </tr>
+        <?php endif; ?>
         <tr valign="top">
           <td>
-            <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
-              <tr>
-                <td>
-                  [site-logo]
-                </td>
-                <td width="98%">
-                  <div style="padding-left: 1em;">
-                  <span style="font-size: large;">[store-name]</span><br />
-                  [site-slogan]
-                  </div>
-                </td>
-                <td nowrap="nowrap">
-                  [store-address]<br />[store-phone]
-                </td>
-              </tr>
-            </table>
-          </td>
-        </tr>
-        <?php } ?>
-
-        <tr valign="top">
-          <td>
-
-            <?php if ($thank_you_message) { ?>
-            <p><b><?php echo t('Thanks for your order, [order-first-name]!'); ?></b></p>
-
-            <?php if (isset($_SESSION['new_user'])) { ?>
-            <p><b><?php echo t('An account has been created for you with the following details:'); ?></b></p>
-            <p><b><?php echo t('Username:'); ?></b> [new-username]<br />
-            <b><?php echo t('Password:'); ?></b> [new-password]</p>
-            <?php } ?>
-
-            <p><b><?php echo t('Want to manage your order online?'); ?></b><br />
-            <?php echo t('If you need to check the status of your order, please visit our home page at [store-link] and click on "My account" in the menu or login with the following link:'); ?>
-            <br /><br />[site-login]</p>
-            <?php } ?>
+            <?php if ($thank_you_message): ?>
+              <p><b><?php echo t('Thanks for your order, [order-first-name]!'); ?></b></p>
+
+              <?php if (isset($_SESSION['new_user'])): ?>
+                <p><b><?php echo t('An account has been created for you with the following details:'); ?></b></p>
+                <p><b><?php echo t('Username:'); ?></b> [new-username]<br />
+                  <b><?php echo t('Password:'); ?></b> [new-password]</p>
+              <?php endif; ?>
+
+              <p><b><?php echo t('Want to manage your order online?'); ?></b><br />
+                <?php echo t('If you need to check the status of your order, please visit our home page at [store-link] and click on "My account" in the menu or login with the following link:'); ?>
+                <br /><br />[site-login]</p>
+            <?php endif; ?>
             <table cellpadding="4" cellspacing="0" border="0" width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
               <tr>
                 <td colspan="2" bgcolor="#006699" style="color: white;">
                   <b><?php echo t('Purchasing Information:'); ?></b>
                 </td>
               </tr>
-               <tr>
+              <tr>
                 <td nowrap="nowrap"><b><?php echo t('Checkin:'); ?></b> [reservation-checkin]
 
                 </td>
                 <td ><b><?php echo t('Checkout:'); ?></b>
-                    [reservation-checkout]
+                  [reservation-checkout]
                 </td>
               </tr>
               <tr>
@@ -73,11 +70,9 @@
               </tr>
               <tr>
                 <td colspan="2">
-
                   <table width="100%" cellspacing="0" cellpadding="0" style="font-family: verdana, arial, helvetica; font-size: small;">
                     <tr>
                       <td valign="top" width="50%">
-
                         <b><?php echo t('Billing Address:'); ?></b><br />
                         [order-billing-address]<br />
                         <br />
@@ -85,17 +80,16 @@
                         [order-billing-phone]<br />
                       </td>
                       <?php if (uc_order_is_shippable($order)) { ?>
-                      <td valign="top" width="50%">
-                        <b><?php echo t('Shipping Address:'); ?></b><br />
-                        [order-shipping-address]<br />
-                        <br />
-                        <b><?php echo t('Shipping Phone:'); ?></b><br />
-                        [order-shipping-phone]<br />
-                      </td>
+                        <td valign="top" width="50%">
+                          <b><?php echo t('Shipping Address:'); ?></b><br />
+                          [order-shipping-address]<br />
+                          <br />
+                          <b><?php echo t('Shipping Phone:'); ?></b><br />
+                          [order-shipping-phone]<br />
+                        </td>
                       <?php } ?>
                     </tr>
                   </table>
-
                 </td>
               </tr>
               <tr>
@@ -122,7 +116,6 @@
                   <b>[agres_deposit]</b>
                 </td>
               </tr>
-
               <tr>
                 <td nowrap="nowrap">
                   <b><?php echo t('Payment Method:'); ?></b>
@@ -131,24 +124,20 @@
                   [order-payment-method]
                 </td>
               </tr>
-
               <tr>
                 <td colspan="2" bgcolor="#006699" style="color: white;">
                   <b><?php echo t('Order Summary:'); ?></b>
                 </td>
               </tr>
-
-              <?php if (uc_order_is_shippable($order)) { ?>
-              <tr>
-                <td colspan="2" bgcolor="#EEEEEE">
-                  <font color="#CC6600"><b><?php echo t('Shipping Details:'); ?></b></font>
-                </td>
-              </tr>
-              <?php } ?>
-
+              <?php if (uc_order_is_shippable($order)): ?>
+                <tr>
+                  <td colspan="2" bgcolor="#EEEEEE">
+                    <font color="#CC6600"><b><?php echo t('Shipping Details:'); ?></b></font>
+                  </td>
+                </tr>
+              <?php endif; ?>
               <tr>
                 <td colspan="2">
-
                   <table border="0" cellpadding="1" cellspacing="0" width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
                     <tr>
                       <td nowrap="nowrap">
@@ -158,18 +147,16 @@
                         [order-link]
                       </td>
                     </tr>
-
-                    <?php if ($shipping_method && uc_order_is_shippable($order)) { ?>
-                    <tr>
-                      <td nowrap="nowrap">
-                        <b><?php echo t('Shipping Method:'); ?></b>
-                      </td>
-                      <td width="98%">
-                        [order-shipping-method]
-                      </td>
-                    </tr>
-                    <?php } ?>
-
+                    <?php if ($shipping_method && uc_order_is_shippable($order)): ?>
+                      <tr>
+                        <td nowrap="nowrap">
+                          <b><?php echo t('Shipping Method:'); ?></b>
+                        </td>
+                        <td width="98%">
+                          [order-shipping-method]
+                        </td>
+                      </tr>
+                    <?php endif; ?>
                     <tr>
                       <td nowrap="nowrap">
                         <?php echo t('Products Subtotal:'); ?>&nbsp;
@@ -178,7 +165,6 @@
                         [order-subtotal]
                       </td>
                     </tr>
-
                     <?php
                     $context = array(
                       'revision' => 'themed',
@@ -187,30 +173,28 @@
                         'order' => $order,
                       ),
                     );
-                    foreach ($line_items as $item) {
-                    if ($item['line_item_id'] == 'subtotal' || $item['line_item_id'] == 'total') {
-                      continue;
-                    }?>
-
-                    <tr>
-                      <td nowrap="nowrap">
-                        <?php echo $item['title']; ?>:
-                      </td>
-                      <td>
-                        <?php
+                    foreach ($line_items as $item):
+                      if ($item['line_item_id'] == 'subtotal' || $item['line_item_id'] == 'total'):
+                        continue;
+                      endif;
+                      ?>
+
+                      <tr>
+                        <td nowrap="nowrap">
+                          <?php echo $item['title']; ?>:
+                        </td>
+                        <td>
+                          <?php
                           $context['subject']['line_item'] = $item;
                           echo uc_price($item['amount'], $context);
-                        ?>
-                      </td>
-                    </tr>
-
-                    <?php } ?>
-
+                          ?>
+                        </td>
+                      </tr>
+                    <?php endforeach; ?>
                     <tr>
                       <td>&nbsp;</td>
                       <td>------</td>
                     </tr>
-
                     <tr>
                       <td nowrap="nowrap">
                         <b><?php echo t('Total for this Order:'); ?>&nbsp;</b>
@@ -219,14 +203,12 @@
                         <b>[order-total]</b>
                       </td>
                     </tr>
-
                     <tr>
                       <td colspan="2">
                         <br /><br /><b><?php echo t('Products on order:'); ?>&nbsp;</b>
-
                         <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
-
-                          <?php if (is_array($order->products)) {
+                          <?php
+                          if (is_array($order->products)) {
                             $context = array(
                               'revision' => 'formatted',
                               'type' => 'order_product',
@@ -242,65 +224,63 @@
                               $context['subject']['order_product'] = $product;
                               $context['subject']['node'] = node_load($product->nid);
                               ?>
-                          <tr>
-                            <td valign="top" nowrap="nowrap">
-                              <b><?php echo $product->qty; ?> x </b>
-                            </td>
-                            <td width="98%">
-                              <b><?php echo $product->title .' - '. uc_price($price_info, $context); ?></b>
-                              <?php if ($product->qty > 1) {
-                                $price_info['qty'] = 1;
-                                echo t('(!price each)', array('!price' => uc_price($price_info, $context)));
-                              } ?>
-                              <br />
-                              <?php echo t('SKU: ') . $product->model; ?><br />
-                              <?php if (is_array($product->data['attributes']) && count($product->data['attributes']) > 0) {?>
-                              <?php foreach ($product->data['attributes'] as $attribute => $option) {
-                                echo '<li>'. t('@attribute: @options', array('@attribute' => $attribute, '@options' => implode(', ', (array)$option))) .'</li>';
-                              } ?>
-                              <?php } ?>
-                              <br />
-                            </td>
-                          </tr>
-                          <?php }
-                              }?>
+                              <tr>
+                                <td valign="top" nowrap="nowrap">
+                                  <b><?php echo $product->qty; ?> x </b>
+                                </td>
+                                <td width="98%">
+                                  <b><?php echo $product->title . ' - ' . uc_price($price_info, $context); ?></b>
+                                  <?php
+                                  if ($product->qty > 1) {
+                                    $price_info['qty'] = 1;
+                                    echo t('(!price each)', array('!price' => uc_price($price_info, $context)));
+                                  }
+                                  ?>
+                                  <br />
+                                  <?php echo t('SKU: ') . $product->model; ?><br />
+                                  <?php if (is_array($product->data['attributes']) && count($product->data['attributes']) > 0): ?>
+                                    <?php
+                                    foreach ($product->data['attributes'] as $attribute => $option) {
+                                      echo '<li>' . t('@attribute: @options', array('@attribute' => $attribute, '@options' => implode(', ', (array) $option))) . '</li>';
+                                    }
+                                    ?>
+                                  <?php endif; ?>
+                                  <br />
+                                </td>
+                              </tr>
+                              <?php
+                            }
+                          }
+                          ?>
                         </table>
-
                       </td>
                     </tr>
                   </table>
-
-                </td>
-              </tr>
-
-              <?php if ($help_text || $email_text || $store_footer) { ?>
-              <tr>
-                <td colspan="2">
-                  <hr noshade="noshade" size="1" /><br />
-
-                  <?php if ($help_text) { ?>
-                  <p><b><?php echo t('Where can I get help with reviewing my order?'); ?></b><br />
-                  <?php echo t('To learn more about managing your orders on [store-link], please visit our <a href="[store-help-url]">help page</a>.'); ?>
-                  <br /></p>
-                  <?php } ?>
-
-                  <?php if ($email_text) { ?>
-                  <p><?php echo t('Please note: This e-mail message is an automated notification. Please do not reply to this message.'); ?></p>
-
-                  <p><?php echo t('Thanks again for shopping with us.'); ?></p>
-                  <?php } ?>
-
-                  <?php if ($store_footer) { ?>
-                  <p><b>[store-link]</b><br /><b>[site-slogan]</b></p>
-                  <?php } ?>
                 </td>
               </tr>
-              <?php } ?>
-
+              <?php if ($help_text || $email_text || $store_footer): ?>
+                <tr>
+                  <td colspan="2">
+                    <hr noshade="noshade" size="1" /><br />
+                    <?php if ($help_text): ?>
+                      <p><b><?php echo t('Where can I get help with reviewing my order?'); ?></b><br />
+                        <?php echo t('To learn more about managing your orders on [store-link], please visit our <a href="[store-help-url]">help page</a>.'); ?>
+                        <br /></p>
+                    <?php endif; ?>
+                    <?php if ($email_text): ?>
+                      <p><?php echo t('Please note: This e-mail message is an automated notification. Please do not reply to this message.'); ?></p>
+                      <p><?php echo t('Thanks again for shopping with us.'); ?></p>
+                    <?php endif; ?>
+                    <?php if ($store_footer): ?>
+                      <p><b>[store-link]</b><br /><b>[site-slogan]</b></p>
+                    <?php endif; ?>
+                  </td>
+                </tr>
+              <?php endif; ?>
             </table>
           </td>
         </tr>
       </table>
     </td>
   </tr>
-</table>
+</table>
\ No newline at end of file
diff --git a/templates/uc-order--admin_agr.tpl.php b/templates/uc-order--admin_agr.tpl.php
index 6eaf8fc..0b0b63b 100644
--- a/templates/uc-order--admin_agr.tpl.php
+++ b/templates/uc-order--admin_agr.tpl.php
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * This file is the default admin notification template for Ubercart.
@@ -7,29 +6,28 @@
 ?>
 
 <p>
-<?php print t('Date 1:'); ?> <?php print $agrdate1; ?><br />
-<?php print t('Date 2:'); ?> <?php print $agrdate2; ?><br />
-<?php print t('Order number:'); ?> <?php print $order_admin_link; ?><br />
-<?php print t('Customer:'); ?> <?php print $order_first_name; ?> <?php print $order_last_name; ?> - <?php print $order_email; ?><br />
-<?php print t('Order total:'); ?> <?php print $order_total; ?><br />
-<?php print t('Shipping method:'); ?> <?php print $order_shipping_method; ?>
+  <?php print t('Date 1:'); ?> <?php print $agrdate1; ?><br />
+  <?php print t('Date 2:'); ?> <?php print $agrdate2; ?><br />
+  <?php print t('Order number:'); ?> <?php print $order_admin_link; ?><br />
+  <?php print t('Customer:'); ?> <?php print $order_first_name; ?> <?php print $order_last_name; ?> - <?php print $order_email; ?><br />
+  <?php print t('Order total:'); ?> <?php print $order_total; ?><br />
+  <?php print t('Shipping method:'); ?> <?php print $order_shipping_method; ?>
 </p>
 
 <p>
-<?php print t('Products:'); ?><br />
-<?php foreach ($products as $product): ?>
-- <?php print $product->qty; ?> x <?php print $product->title; ?> - <?php print $product->total_price; ?><br />
-&nbsp;&nbsp;<?php print t('SKU'); ?>: <?php print $product->model; ?><br />
+  <?php print t('Products:'); ?><br />
+  <?php foreach ($products as $product): ?>
+    - <?php print $product->qty; ?> x <?php print $product->title; ?> - <?php print $product->total_price; ?><br />
+    &nbsp;&nbsp;<?php print t('SKU'); ?>: <?php print $product->model; ?><br />
     <?php if (!empty($product->data['attributes'])): ?>
-    <?php foreach ($product->data['attributes'] as $attribute => $option): ?>
-    &nbsp;&nbsp;<?php print t('@attribute: @options', array('@attribute' => $attribute, '@options' => implode(', ', (array)$option))); ?><br />
-    <?php endforeach; ?>
+      <?php foreach ($product->data['attributes'] as $attribute => $option): ?>
+        &nbsp;&nbsp;<?php print t('@attribute: @options', array('@attribute' => $attribute, '@options' => implode(', ', (array) $option))); ?><br />
+      <?php endforeach; ?>
     <?php endif; ?>
-<br />
-<?php endforeach; ?>
+    <br />
+  <?php endforeach; ?>
 </p>
-
 <p>
-<?php print t('Order comments:'); ?><br />
-<?php print $order_comments; ?>
-</p>
+  <?php print t('Order comments:'); ?><br />
+  <?php print $order_comments; ?>
+</p>
\ No newline at end of file
diff --git a/templates/uc-order--customer_agr.tpl.php b/templates/uc-order--customer_agr.tpl.php
index 1531ebb..bc4ea96 100644
--- a/templates/uc-order--customer_agr.tpl.php
+++ b/templates/uc-order--customer_agr.tpl.php
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * This file is the default customer invoice template for Ubercart.
@@ -44,59 +43,53 @@
     <td>
       <table width="100%" border="0" cellspacing="0" cellpadding="5" align="center" bgcolor="#FFFFFF" style="font-family: verdana, arial, helvetica; font-size: small;">
         <?php if ($business_header): ?>
-        <tr valign="top">
-          <td>
-            <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
-              <tr>
-                <td>
-                  <?php print $site_logo; ?>
-                </td>
-                <td width="98%">
-                  <div style="padding-left: 1em;">
-                  <span style="font-size: large;"><?php print $store_name; ?></span><br />
-                  <?php print $site_slogan; ?>
-                  </div>
-                </td>
-                <td nowrap="nowrap">
-                  <?php print $store_address; ?><br /><?php print $store_phone; ?>
-                </td>
-              </tr>
-            </table>
-          </td>
-        </tr>
+          <tr valign="top">
+            <td>
+              <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
+                <tr>
+                  <td>
+                    <?php print $site_logo; ?>
+                  </td>
+                  <td width="98%">
+                    <div style="padding-left: 1em;">
+                      <span style="font-size: large;"><?php print $store_name; ?></span><br />
+                      <?php print $site_slogan; ?>
+                    </div>
+                  </td>
+                  <td nowrap="nowrap">
+                    <?php print $store_address; ?><br /><?php print $store_phone; ?>
+                  </td>
+                </tr>
+              </table>
+            </td>
+          </tr>
         <?php endif; ?>
-
         <tr valign="top">
           <td>
-
             <?php if ($thank_you_message): ?>
-            <p><b><?php print t('Thanks for your order, !order_first_name!', array('!order_first_name' => $order_first_name)); ?></b></p>
-
-            <?php if (isset($order->data['new_user'])): ?>
-            <p><b><?php print t('An account has been created for you with the following details:'); ?></b></p>
-            <p><b><?php print t('Username:'); ?></b> <?php print $order_new_username; ?><br />
-            <b><?php print t('Password:'); ?></b> <?php print $order_new_password; ?></p>
-            <?php endif; ?>
-
-            <p><b><?php print t('Want to manage your order online?'); ?></b><br />
-            <?php print t('If you need to check the status of your order, please visit our home page at !store_link and click on "My account" in the menu or login with the following link:', array('!store_link' => $store_link)); ?>
-            <br /><br /><?php print $site_login_link; ?></p>
+              <p><b><?php print t('Thanks for your order, !order_first_name!', array('!order_first_name' => $order_first_name)); ?></b></p>
+              <?php if (isset($order->data['new_user'])): ?>
+                <p><b><?php print t('An account has been created for you with the following details:'); ?></b></p>
+                <p><b><?php print t('Username:'); ?></b> <?php print $order_new_username; ?><br />
+                  <b><?php print t('Password:'); ?></b> <?php print $order_new_password; ?></p>
+              <?php endif; ?>
+              <p><b><?php print t('Want to manage your order online?'); ?></b><br />
+                <?php print t('If you need to check the status of your order, please visit our home page at !store_link and click on "My account" in the menu or login with the following link:', array('!store_link' => $store_link)); ?>
+                <br /><br /><?php print $site_login_link; ?></p>
             <?php endif; ?>
-
             <table cellpadding="4" cellspacing="0" border="0" width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
               <tr>
                 <td colspan="2" bgcolor="#006699" style="color: white;">
                   <b><?php print t('Purchasing Information:'); ?></b>
                 </td>
               </tr>
-               <tr>
+              <tr>
                 <td nowrap="nowrap"><b><?php echo t('Checkin:'); ?></b> <?php print $agrdate1; ?>
-
                 </td>
                 <td ><b><?php echo t('Checkout:'); ?></b>
-                   <?php print $agrdate2; ?>
+                  <?php print $agrdate2; ?>
                 </td>
-              </tr>              
+              </tr>
               <tr>
                 <td nowrap="nowrap">
                   <b><?php print t('E-mail Address:'); ?></b>
@@ -107,7 +100,6 @@
               </tr>
               <tr>
                 <td colspan="2">
-
                   <table width="100%" cellspacing="0" cellpadding="0" style="font-family: verdana, arial, helvetica; font-size: small;">
                     <tr>
                       <td valign="top" width="50%">
@@ -118,17 +110,16 @@
                         <?php print $order_billing_phone; ?><br />
                       </td>
                       <?php if ($shippable): ?>
-                      <td valign="top" width="50%">
-                        <b><?php print t('Shipping Address:'); ?></b><br />
-                        <?php print $order_shipping_address; ?><br />
-                        <br />
-                        <b><?php print t('Shipping Phone:'); ?></b><br />
-                        <?php print $order_shipping_phone; ?><br />
-                      </td>
+                        <td valign="top" width="50%">
+                          <b><?php print t('Shipping Address:'); ?></b><br />
+                          <?php print $order_shipping_address; ?><br />
+                          <br />
+                          <b><?php print t('Shipping Phone:'); ?></b><br />
+                          <?php print $order_shipping_phone; ?><br />
+                        </td>
                       <?php endif; ?>
                     </tr>
                   </table>
-
                 </td>
               </tr>
               <tr>
@@ -147,24 +138,20 @@
                   <?php print $order_payment_method; ?>
                 </td>
               </tr>
-
               <tr>
                 <td colspan="2" bgcolor="#006699" style="color: white;">
                   <b><?php print t('Order Summary:'); ?></b>
                 </td>
               </tr>
-
               <?php if ($shippable): ?>
-              <tr>
-                <td colspan="2" bgcolor="#EEEEEE">
-                  <font color="#CC6600"><b><?php print t('Shipping Details:'); ?></b></font>
-                </td>
-              </tr>
+                <tr>
+                  <td colspan="2" bgcolor="#EEEEEE">
+                    <font color="#CC6600"><b><?php print t('Shipping Details:'); ?></b></font>
+                  </td>
+                </tr>
               <?php endif; ?>
-
               <tr>
                 <td colspan="2">
-
                   <table border="0" cellpadding="1" cellspacing="0" width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
                     <tr>
                       <td nowrap="nowrap">
@@ -174,7 +161,6 @@
                         <?php print $order_link; ?>
                       </td>
                     </tr>
-
                     <tr>
                       <td nowrap="nowrap">
                         <b><?php print t('Order Date: '); ?></b>
@@ -183,18 +169,16 @@
                         <?php print $order_created; ?>
                       </td>
                     </tr>
-
                     <?php if ($shipping_method && $shippable): ?>
-                    <tr>
-                      <td nowrap="nowrap">
-                        <b><?php print t('Shipping Method:'); ?></b>
-                      </td>
-                      <td width="98%">
-                        <?php print $order_shipping_method; ?>
-                      </td>
-                    </tr>
+                      <tr>
+                        <td nowrap="nowrap">
+                          <b><?php print t('Shipping Method:'); ?></b>
+                        </td>
+                        <td width="98%">
+                          <?php print $order_shipping_method; ?>
+                        </td>
+                      </tr>
                     <?php endif; ?>
-
                     <tr>
                       <td nowrap="nowrap">
                         <?php print t('Products Subtotal:'); ?>&nbsp;
@@ -203,26 +187,21 @@
                         <?php print $order_subtotal; ?>
                       </td>
                     </tr>
-
                     <?php foreach ($line_items as $item): ?>
-                    <?php if ($item['type'] == 'subtotal' || $item['type'] == 'total')  continue; ?>
-
-                    <tr>
-                      <td nowrap="nowrap">
-                        <?php print $item['title']; ?>:
-                      </td>
-                      <td>
-                        <?php print $item['formatted_amount']; ?>
-                      </td>
-                    </tr>
-
+                      <?php if ($item['type'] == 'subtotal' || $item['type'] == 'total') continue; ?>
+                      <tr>
+                        <td nowrap="nowrap">
+                          <?php print $item['title']; ?>:
+                        </td>
+                        <td>
+                          <?php print $item['formatted_amount']; ?>
+                        </td>
+                      </tr>
                     <?php endforeach; ?>
-
                     <tr>
                       <td>&nbsp;</td>
                       <td>------</td>
                     </tr>
-
                     <tr>
                       <td nowrap="nowrap">
                         <b><?php print t('Total for this Order:'); ?>&nbsp;</b>
@@ -231,63 +210,52 @@
                         <b><?php print $order_total; ?></b>
                       </td>
                     </tr>
-
                     <tr>
                       <td colspan="2">
                         <br /><br /><b><?php print t('Products on order:'); ?>&nbsp;</b>
-
                         <table width="100%" style="font-family: verdana, arial, helvetica; font-size: small;">
-
                           <?php foreach ($products as $product): ?>
-                          <tr>
-                            <td valign="top" nowrap="nowrap">
-                              <b><?php print $product->qty; ?> x </b>
-                            </td>
-                            <td width="98%">
-                              <b><?php print $product->title; ?> - <?php print $product->total_price; ?></b>
-                              <?php print $product->individual_price; ?><br />
-                              <?php print t('SKU'); ?>: <?php print $product->model; ?><br />
-                              <?php print $product->details; ?>
-                            </td>
-                          </tr>
+                            <tr>
+                              <td valign="top" nowrap="nowrap">
+                                <b><?php print $product->qty; ?> x </b>
+                              </td>
+                              <td width="98%">
+                                <b><?php print $product->title; ?> - <?php print $product->total_price; ?></b>
+                                <?php print $product->individual_price; ?><br />
+                                <?php print t('SKU'); ?>: <?php print $product->model; ?><br />
+                                <?php print $product->details; ?>
+                              </td>
+                            </tr>
                           <?php endforeach; ?>
                         </table>
-
                       </td>
                     </tr>
                   </table>
-
                 </td>
               </tr>
-
               <?php if ($help_text || $email_text || $store_footer): ?>
-              <tr>
-                <td colspan="2">
-                  <hr noshade="noshade" size="1" /><br />
-
-                  <?php if ($help_text): ?>
-                  <p><b><?php print t('Where can I get help with reviewing my order?'); ?></b><br />
-                  <?php print t('To learn more about managing your orders on !store_link, please visit our <a href="!store_help_url">help page</a>.', array('!store_link' => $store_link, '!store_help_url' => $store_help_url)); ?>
-                  <br /></p>
-                  <?php endif; ?>
-
-                  <?php if ($email_text): ?>
-                  <p><?php print t('Please note: This e-mail message is an automated notification. Please do not reply to this message.'); ?></p>
-
-                  <p><?php print t('Thanks again for shopping with us.'); ?></p>
-                  <?php endif; ?>
-
-                  <?php if ($store_footer): ?>
-                  <p><b><?php print $store_link; ?></b><br /><b><?php print $site_slogan; ?></b></p>
-                  <?php endif; ?>
-                </td>
-              </tr>
+                <tr>
+                  <td colspan="2">
+                    <hr noshade="noshade" size="1" /><br />
+                    <?php if ($help_text): ?>
+                      <p><b><?php print t('Where can I get help with reviewing my order?'); ?></b><br />
+                        <?php print t('To learn more about managing your orders on !store_link, please visit our <a href="!store_help_url">help page</a>.', array('!store_link' => $store_link, '!store_help_url' => $store_help_url)); ?>
+                        <br /></p>
+                    <?php endif; ?>
+                    <?php if ($email_text): ?>
+                      <p><?php print t('Please note: This e-mail message is an automated notification. Please do not reply to this message.'); ?></p>
+                      <p><?php print t('Thanks again for shopping with us.'); ?></p>
+                    <?php endif; ?>
+                    <?php if ($store_footer): ?>
+                      <p><b><?php print $store_link; ?></b><br /><b><?php print $site_slogan; ?></b></p>
+                    <?php endif; ?>
+                  </td>
+                </tr>
               <?php endif; ?>
-
             </table>
           </td>
         </tr>
       </table>
     </td>
   </tr>
-</table>
+</table>
\ No newline at end of file
diff --git a/theme/agreservations-calendar-month-1.tpl.php b/theme/agreservations-calendar-month-1.tpl.php
index ca6e41a..156e89e 100644
--- a/theme/agreservations-calendar-month-1.tpl.php
+++ b/theme/agreservations-calendar-month-1.tpl.php
@@ -2,7 +2,7 @@
 /**
  * @file
  * Template to display a view as a calendar month.
- * 
+ *
  * @see template_preprocess_calendar_month.
  *
  * $day_names: An array of the day of week names for the table header.
@@ -13,87 +13,70 @@
  * $block: Whether or not this calendar is in a block.
  * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
  * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
- * $date_id: a css id that is unique for this date, 
+ * $date_id: a css id that is unique for this date,
  *   it is in the form: calendar-nid-field_name-delta
- * 
+ *
  */
 //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
 ?>
-<div class="calendar-calendar"><div class="month-view">
-        <table>
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (!isset($currentcategory)) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedweek);?>"><?php print (t('show all categories')); ?></a>
-                </th>
-                <?php foreach ($categories as $category): ?>
-                <th class="agreservations-calendar th categories">
-                    <a class="<?php print (isset($currentcategory)&&$currentcategory==$category->nid) ?  "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedweek."/".$category->nid);?>"><?php print ($category->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>
-        <table>
-            <tr class="agreservations-calendar">
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (!isset($currentunittype)) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedweek."/".$currentcategory);?>"><?php print (t('show all units')); ?></a>
-                </th>
-                <?php foreach ($unittypes as $unittype): ?>
-                <th class="agreservations-calendar th unittypes">
-                    <a class="<?php print (isset($currentunittype)&&$currentunittype==$unittype->nid) ?  "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path().$agrescurrentpath."/".$currentselectedweek."/".$currentcategory."/".$unittype->nid);?>"><?php print ($unittype->title); ?></a>
-                </th>
-                <?php endforeach; ?>
-            </tr>
-        </table>    
-<table>
-<!--  <thead>
-    <tr>
-      <?php foreach ($day_names as $cell): ?>
-        <th class="<?php print $cell['class']; ?>">
-          <?php print $cell['data']; ?>
+<div class="calendar-calendar">
+  <div class="month-view">
+    <table>
+      <tr class="agreservations-calendar">
+        <th class="agreservations-calendar th categories">
+          <a class="<?php print (!isset($currentcategory)) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedweek); ?>"><?php print (t('show all categories')); ?></a>
         </th>
-      <?php endforeach; ?>
-    </tr>
-  </thead>-->
-  <tbody>
-  <?php foreach ((array) $units as $unit): ?>
-        <tr>
-                            <td class="agreservations-calendar">
-
-                        <a href="<?php print(base_path());?>node/<?php print $unit->nid ?>"><?php print $unit->title  ?></a>
-                        <span class="agreservations-calendar-hour"><?php print $by_hour_count > 0 ? t('Night') : ''; ?></span>
-                    </td>  
-    <?php foreach ((array) $rows as $row): ?>
-
-        <?php foreach ($row as $cell): ?>
-
-                                    <?php if (isset($cell[$unit->title]['data'])) : ?>
-                                       
-                                            <?php if (isset($cell[$unit->title])) : ?>
-                                                
-                                                  <td class="agreservations-calendar-agenda-items">
-                                                  <div class="agreservations-inner ">
-                                                  <?php print ($cell[$unit->title]['data']);?>
-                                                    </div>
-                                                  </td>
-                                                  <?php endif; ?>
-                                           
-                                      
-                                    <?php else: ?>
-                                     <td class="agreservations-calendar-agenda-items">
-                                       <?php print ($day['datebox']);?>
-                                       <a href="<?php print(base_path());?>node/add/agreservation?&agres_sel_unit=<?php print $unit->nid ?>&default_agres_title=Reservation&default_agres_date=<?php print$day[date]?> 14:00 ">+</a>
-                          
-                                  </td>
-                                   <?php endif; ?>                      
-                    
-          <td id="<?php print $cell['id']; ?>" class="<?php print $cell[$unit->title]['class']; ?>">
-            <?php print $cell[$unit->title]['data']; ?>
-          </td>
+        <?php foreach ($categories as $category): ?>
+          <th class="agreservations-calendar th categories">
+            <a class="<?php print (isset($currentcategory) && $currentcategory == $category->nid) ? "agreservations-calendar a categorysel" : "agreservations-calendar a categories"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedweek . "/" . $category->nid); ?>"><?php print ($category->title); ?></a>
+          </th>
+        <?php endforeach; ?>
+      </tr>
+    </table>
+    <table>
+      <tr class="agreservations-calendar">
+        <th class="agreservations-calendar th unittypes">
+          <a class="<?php print (!isset($currentunittype)) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedweek . "/" . $currentcategory); ?>"><?php print (t('show all units')); ?></a>
+        </th>
+        <?php foreach ($unittypes as $unittype): ?>
+          <th class="agreservations-calendar th unittypes">
+            <a class="<?php print (isset($currentunittype) && $currentunittype == $unittype->nid) ? "agreservations-calendar a unittypessel" : "agreservations-calendar a unittypes"; ?>" href="<?php print(base_path() . $agrescurrentpath . "/" . $currentselectedweek . "/" . $currentcategory . "/" . $unittype->nid); ?>"><?php print ($unittype->title); ?></a>
+          </th>
+        <?php endforeach; ?>
+      </tr>
+    </table>
+    <table>
+      <tbody>
+        <?php foreach ((array) $units as $unit): ?>
+          <tr>
+            <td class="agreservations-calendar">
+              <a href="<?php print(base_path()); ?>node/<?php print $unit->nid ?>"><?php print $unit->title ?></a>
+              <span class="agreservations-calendar-hour"><?php print $by_hour_count > 0 ? t('Night') : ''; ?></span>
+            </td>
+            <?php foreach ((array) $rows as $row): ?>
+              <?php foreach ($row as $cell): ?>
+                <?php if (isset($cell[$unit->title]['data'])) : ?>
+                  <?php if (isset($cell[$unit->title])) : ?>
+                    <td class="agreservations-calendar-agenda-items">
+                      <div class="agreservations-inner ">
+                        <?php print ($cell[$unit->title]['data']); ?>
+                      </div>
+                    </td>
+                  <?php endif; ?>
+                <?php else: ?>
+                  <td class="agreservations-calendar-agenda-items">
+                    <?php print ($day['datebox']); ?>
+                    <a href="<?php print(base_path()); ?>node/add/agreservation?&agres_sel_unit=<?php print $unit->nid ?>&default_agres_title=Reservation&default_agres_date=<?php print$day[date] ?> 14:00 ">+</a>
+                  </td>
+                <?php endif; ?>
+                <td id="<?php print $cell['id']; ?>" class="<?php print $cell[$unit->title]['class']; ?>">
+                  <?php print $cell[$unit->title]['data']; ?>
+                </td>
+              <?php endforeach; ?>
+            <?php endforeach; ?>
+          </tr>
         <?php endforeach; ?>
-
-    <?php endforeach; ?>
-            </tr>
- <?php endforeach; ?>
-  </tbody>
-</table>
-</div></div>
\ No newline at end of file
+      </tbody>
+    </table>
+  </div>
+</div>
\ No newline at end of file
