Index: trunk/expressoCalendar/xsl/viewMonth.xsl
===================================================================
--- trunk/expressoCalendar/xsl/viewMonth.xsl	(revision 665)
+++ trunk/expressoCalendar/xsl/viewMonth.xsl	(revision 696)
@@ -6,5 +6,5 @@
 	<div id="{$today}"></div>
 </div>
-<div width="100%" class="title" align="left" ><label id="l_date"></label><br/><br/>
+<div width="100%" class="title" align="left" ><br/>
 	<table class="table_common" height="auto" width="100%" cellpadding="0" cellspacing="0">
 		<tbody>
Index: trunk/expressoCalendar/xsl/viewWeek.xsl
===================================================================
--- trunk/expressoCalendar/xsl/viewWeek.xsl	(revision 665)
+++ trunk/expressoCalendar/xsl/viewWeek.xsl	(revision 696)
@@ -6,5 +6,5 @@
 	<div id="{$today}"></div>
 </div>
-<div width="100%" class="title" align="left" ><label id="l_date"></label><br/><br/>
+<div width="100%" class="title" align="left" ><br/>
 <table class="table_common" width="100%" cellpadding="0" cellspacing="0" border="0">
 	<tr>
Index: trunk/expressoCalendar/xsl/viewDay.xsl
===================================================================
--- trunk/expressoCalendar/xsl/viewDay.xsl	(revision 665)
+++ trunk/expressoCalendar/xsl/viewDay.xsl	(revision 696)
@@ -6,5 +6,5 @@
 	<div id="{$today}"></div>
 </div>
-<div width="100%" class="title" align="left" ><label id="l_date"></label><br/><br/>
+<div width="100%" class="title" align="left" ><br/>
 	<table class="table_common" width="100%" cellpadding="0" cellspacing="0" border="0">
 <tbody>
Index: trunk/expressoCalendar/inc/class.uicalendar.inc.php
===================================================================
--- trunk/expressoCalendar/inc/class.uicalendar.inc.php	(revision 665)
+++ trunk/expressoCalendar/inc/class.uicalendar.inc.php	(revision 696)
@@ -114,4 +114,7 @@
 		if (isset ($_REQUEST["uid"]))
 			$this->db_obj->user_id = $_REQUEST["uid"];
+		if (isset ($_REQUEST["cat"]))
+			$this->db_obj->cat_id = $_REQUEST["cat"];
+
 		$fromBo = $this->db_obj->requestDayCal($dayTime);
 
@@ -155,4 +158,6 @@
 		if (isset($_REQUEST["uid"]))
 			$this->db_obj->user_id = $_REQUEST["uid"];
+		if (isset ($_REQUEST["cat"]))
+			$this->db_obj->cat_id = $_REQUEST["cat"];
 
 		$dayViewTime -= (date('N', $dayViewTime)%7)*86400;
@@ -195,4 +200,6 @@
 		if (isset($_REQUEST["uid"]))
 			$this->db_obj->user_id = $_REQUEST["uid"];
+		if (isset ($_REQUEST["cat"]))
+			$this->db_obj->cat_id = $_REQUEST["cat"];
 
 		$fromBo = $this->db_obj->requestMonthCal($todayTime);
@@ -234,5 +241,5 @@
 		$currentWeekDay = date('w', $monthViewTime);
 
-		for($i = $this->workweekstarts+$currentWeekDay; $i <= $this->workweekends+$currentWeekDay; $i++){
+		for($i = ($this->workweekstarts+$currentWeekDay)-1; $i <= $this->workweekends+$currentWeekDay; $i++){
 			// Dayid is year+month+dayofMonth (currentDay-(dayofWeek+$i))
 			$retorno.= "<dayofweek><dayname>".$this->daysofweek[$i%7]."</dayname></dayofweek>";
Index: trunk/expressoCalendar/inc/class.bocalendar.inc.php
===================================================================
--- trunk/expressoCalendar/inc/class.bocalendar.inc.php	(revision 656)
+++ trunk/expressoCalendar/inc/class.bocalendar.inc.php	(revision 696)
@@ -18,5 +18,6 @@
 			$_SESSION['calendar']['server']['db_type']
 		);
-		$this -> user_id = $_SESSION['calendar']['user']['account_id']; 
+		$this -> user_id = $_SESSION['calendar']['user']['account_id'];
+		$this -> cat_id  = 0;	
 	}
 
@@ -30,5 +31,5 @@
 	function requestDayCal ($dayTime) {
 		$day = getdate($dayTime);
-		$query = ("SELECT * FROM phpgw_cal where (owner = '".$this->user_id."') and ((datetime > ".mktime(0,0,0,$day['mon'],$day['mday'],$day['year'])." and datetime < ".(mktime(0,0,0,$day['mon'],($day['mday']+1),$day['year'])).") or (edatetime > ".mktime(0,0,0,$day['mon'],$day['mday'],$day['year'])." and edatetime < ".(mktime(0,0,0,$day['mon'],$day['mday']+1,$day['year']))."))");
+		$query = ("SELECT * FROM phpgw_cal where ".($this->cat_id>0?"(category=".$this->cat_id.") and":"")."(owner = '".$this->user_id."') and ((datetime > ".mktime(0,0,0,$day['mon'],$day['mday'],$day['year'])." and datetime < ".(mktime(0,0,0,$day['mon'],($day['mday']+1),$day['year'])).") or (edatetime > ".mktime(0,0,0,$day['mon'],$day['mday'],$day['year'])." and edatetime < ".(mktime(0,0,0,$day['mon'],$day['mday']+1,$day['year']))."))");
 		if (!$this->db->query($query))
 			return false;
@@ -51,5 +52,5 @@
 	function requestWeekCal ($dayTime) {
 		// Performing SQL query
-		$query = "SELECT cal_id, title, description, datetime, edatetime FROM phpgw_cal where (owner = '".$this->user_id."') and ((datetime > ".$dayTime." and datetime < ".($dayTime+604800).") or (edatetime > ".$dayTime." and edatetime < ".($dayTime+604800)."))";
+		$query = "SELECT cal_id, title, description, datetime, edatetime FROM phpgw_cal where ".($this->cat_id>0?"(category=".$this->cat_id.") and":"")." (owner = '".$this->user_id."') and ((datetime > ".$dayTime." and datetime < ".($dayTime+604800).") or (edatetime > ".$dayTime." and edatetime < ".($dayTime+604800)."))";
 		if (!$this->db->query($query))
 			return false;
@@ -77,5 +78,5 @@
 		// Performing SQL query
 		$day = getdate($dayTime);
-		$query = "SELECT cal_id, title, description, datetime, edatetime FROM phpgw_cal where (owner = '".$this->user_id."') and ((datetime > ".mktime(0,0,0,$day['mon'],$day['mday'],$day['year'])." and datetime < ".mktime(0,0,0,$day['mon']+1,$day['mday'],$day['year']).") or (edatetime > ".mktime(0,0,0,$day['mon'],$day['mday'],$day['year'])." and edatetime < ".mktime(0,0,0,$day['month']+1,$day['day'],$day['year'])."))";
+		$query = "SELECT cal_id, title, description, datetime, edatetime FROM phpgw_cal where ".($this->cat_id>0?"(category=".$this->cat_id.") and":"")." (owner = '".$this->user_id."') and ((datetime > ".mktime(0,0,0,$day['mon'],$day['mday'],$day['year'])." and datetime < ".mktime(0,0,0,$day['mon']+1,$day['mday'],$day['year']).") or (edatetime > ".mktime(0,0,0,$day['mon'],$day['mday'],$day['year'])." and edatetime < ".mktime(0,0,0,$day['month']+1,$day['day'],$day['year'])."))";
 		if (!$this->db->query($query))
 			return false;
@@ -90,5 +91,5 @@
 	function requestYearCal ($dayTime) {
 		// Performing SQL query
-		$query = "SELECT cal_id, title, description, datetime, edatetime FROM phpgw_cal where (owner = '".$this->user_id."') and ((datetime > ".$dayTime." and datetime < ".($dayTime+31104000).") or (edatetime > ".$dayTime." and edatetime < ".($dayTime+2592000)."))";
+		$query = "SELECT cal_id, title, description, datetime, edatetime FROM phpgw_cal where ".($this->cat_id>0?"(category=".$this->cat_id.") and":"")." (owner = '".$this->user_id."') and ((datetime > ".$dayTime." and datetime < ".($dayTime+31104000).") or (edatetime > ".$dayTime." and edatetime < ".($dayTime+2592000)."))";
 		if (!$this->db->query($query))
 			return false;
Index: trunk/expressoCalendar/js/calendar_functions.js
===================================================================
--- trunk/expressoCalendar/js/calendar_functions.js	(revision 665)
+++ trunk/expressoCalendar/js/calendar_functions.js	(revision 696)
@@ -10,4 +10,6 @@
 	this.previousView;
 	this.uid = calUid;
+	this.cat = '';
+	this.currentTime = new Date();
 }
 
@@ -73,6 +75,18 @@
 
 }
-Calendar.prototype.getView = function(idEl, type, data)
+Calendar.prototype.getView = function(idEl, type, viewTime)
 {
+	if (typeof(type) == 'undefined')
+		return false;
+	if (typeof(viewTime) == 'undefined')
+		viewTime = calendar.currentTime.getTime();
+	if (type == 'Year'){
+		var handler = function (data) {
+			var div_main = document.getElementById('div_main');
+			div_main.innerHTML = data;
+		}
+		cExecute('../index.php?menuaction=calendar.uicalendar.year&plain=True',handler);
+		return;
+	}
 	this.idEl = idEl;
 	var _this = this;
@@ -82,29 +96,29 @@
 	{
 			_this.parseView(XMLdata,type);
-
+			calendar.currentTime.setTime(id2timeStamp(document.getElementById('day').firstChild.id));
+			var dayMS = (60*60*24*1000);
 			if (viewType == "Week"){
-				var Today = new Date;
-				Today.setTime(id2timeStamp(document.getElementById('day').firstChild.id));
-				var lastWeek = new Date;
-				lastWeek.setTime(Today.getTime()-(60*60*24*7*1000));
-				this.previousView = (lastWeek.getYear()+1900)+normDec(lastWeek.getDate()-7)+normDec(lastWeek.getMonth()+1);
-				Today.setTime(Today.getTime()+(60*60*24*8*1000));
-				this.nextView = (Today.getYear()+1900)+normDec(Today.getDate())+normDec(Today.getMonth()+1);
+				var previousWeek = new Date;
+				previousWeek.setTime(calendar.currentTime.getTime()-(dayMS*7));
+				this.previousView = previousWeek.getTime();
+				var nextWeek = new Date;
+				nextWeek.setTime(calendar.currentTime.getTime()+(dayMS*8));
+				this.nextView =	nextWeek.getTime();
 			}
 			if (viewType == "Day"){
-				var Today = new Date;
-				Today.setTime(id2timeStamp(document.getElementById('day').firstChild.id));
-				this.previousView = (Today.getYear()+1900)+normDec(Today.getDate()-1)+normDec(Today.getMonth()+1);
-				Today.setDate(Today.getDate()+1);
-				this.nextView = (Today.getYear()+1900)+normDec(Today.getDate())+normDec(Today.getMonth()+1);
+				this.previousView = calendar.currentTime.getTime()-dayMS;
+				this.nextView = calendar.currentTime.getTime()+dayMS;
 			}
 			if (viewType == 'Month'){
-				var Today = new Date;
-				Today.setTime(id2timeStamp(document.getElementById('day').firstChild.id));
-				this.previousView = (Today.getYear()+1900)+normDec(Today.getDate())+normDec(Today.getMonth());
-				Today.setMonth(Today.getMonth()+1);
-				this.nextView = (Today.getYear()+1900)+normDec(Today.getDate())+normDec(Today.getMonth()+1);
+				var previousMonth = new Date;
+				previousMonth.setTime(calendar.currentTime.getTime());
+				previousMonth.setMonth(calendar.currentTime.getMonth()-1);
+				this.previousView = previousMonth.getTime();
+				var nextMonth = new Date;
+                                nextMonth.setTime(calendar.currentTime.getTime());
+				nextMonth.setMonth(calendar.currentTime.getMonth()+1);
+				this.nextView = nextMonth.getTime();
 			}
-			document.getElementById("l_date").innerHTML =  "<a href=\"javascript:calendar.getView('div_main','"+viewType+"','&time='+this.previousView);\">\<\<&nbsp;</a>";
+			document.getElementById("l_date").innerHTML =  "<a href=\"javascript:calendar.getView('div_main','"+viewType+"',this.previousView);\">\<\<&nbsp;</a>";
 			if (viewType == "Week")
 				document.getElementById("l_date").innerHTML += calendar.parseWeek(id2timeStamp(document.getElementById('day').firstChild.id));
@@ -113,5 +127,5 @@
 			if (viewType == "Month")
 				document.getElementById("l_date").innerHTML += calendar.parseMonth(id2timeStamp(document.getElementById('day').firstChild.id));
-			document.getElementById("l_date").innerHTML += "<a href=\"javascript:calendar.getView('div_main','"+viewType+"','&time='+this.nextView);\">&nbsp;\>\></a>";
+			document.getElementById("l_date").innerHTML += "<a href=\"javascript:calendar.getView('div_main','"+viewType+"',this.nextView);\">&nbsp;\>\></a>";
 
 		var getEventsDay = function (data)
@@ -125,5 +139,5 @@
 		}
 	        XMLTools.__RETURN_MODE__ = 'XML';
-		XMLTools.request('$this.uicalendar.getEvents'+type+(data?data:'')+'&uid='+calendar.uid, 'GET', getEventsDay);
+		XMLTools.request('$this.uicalendar.getEvents'+type+"&time="+timeStamp2id(calendar.currentTime.getTime())+'&uid='+calendar.uid+'&cat='+calendar.cat, 'GET', getEventsDay);
 
 	};
@@ -132,6 +146,6 @@
 	viewType = type;
 	screenTable = new Array();
-	XMLTools.request('$this.uicalendar.getView'+type+(data?data:'')+'&uid='+this.uid, 'GET', handler_getView);  
-};
+	XMLTools.request('$this.uicalendar.getView'+type+"&time="+timeStamp2id(viewTime)+'&uid='+this.uid, 'GET', handler_getView);
+	};
 
 Calendar.prototype.resetView = function()
@@ -312,7 +326,6 @@
 		eventDiv.onmouseover = function () { this.style.height = "auto"; this.style.zIndex = 2;};
 		eventDiv.onmouseout = function () { this.style.height = "20px"; this.style.zIndex = 1; };
-		eventDiv.onclick = function () { calendar.getView('div_main','Day','&time='+timeStamp2id(eventDiv.childNodes[1].id).substr(0,8)); };
-	}
-
+		eventDiv.onclick = function () { calendar.getView('div_main','Day',eventDiv.childNodes[1].id); };
+	}
 	var tdElement = document.getElementById(timeStamp2id(eventDiv.childNodes[0].id));
 
@@ -323,5 +336,5 @@
 		eventDiv.onmouseover = function () { if (this.childNodes[2].length > 9) this.style.width = "auto"; this.style.zIndex = 2; };
 		eventDiv.onmouseout = function () { this.style.width = "60px"; this.style.zIndex = 1; };
-		eventDiv.onclick = function () { calendar.getView('div_main','Day','&time='+timeStamp2id(eventDiv.childNodes[1].id).substr(0,8)); };
+		eventDiv.onclick = function () { calendar.getView('div_main','Day',eventDiv.childNodes[1].id); };
 		eventDiv.style.cursor = "pointer";
 
@@ -333,8 +346,34 @@
 			eventDiv.style.margin = "0 0 0 "+(20+(tdElement.childNodes.length-1)*25);
 	}
-
-	eventDiv.style.top  =  (tdElement.offsetTop + 160) + "px";
-	tdElement.appendChild(eventDiv);
-}
-
-
+	if (tdElement == null)
+	{
+		orphan_table = document.getElementById('orphan_table');
+		if (!orphan_table)
+		{
+			orphan_table = document.createElement('table');
+			orphan_table.id = "orphan_table";
+			orphan_table.className = "table_common";
+			orphan_table.innerHTML = "<tbody></tbody>";
+			document.getElementById('div_main').appendChild(orphan_table);
+
+		}
+		tr_el = document.createElement('TR');
+		td_el = document.createElement('TD');
+		td_el.className = "td_header";
+		td_el.innerHTML = get_lang("Out of table preferences");
+		tr_el.appendChild(td_el);
+		td_el = document.createElement('TD');
+		td_el.className = "td_common";
+		tr_el.appendChild(td_el);
+		eventDiv.style.position = "relative";
+		td_el.appendChild(eventDiv);
+		orphan_table.firstChild.appendChild(tr_el);
+	}
+	else
+	{
+		eventDiv.style.top  =  (tdElement.offsetTop + 160) + "px";
+		tdElement.appendChild(eventDiv);
+	}
+}
+
+
Index: trunk/expressoCalendar/index.php
===================================================================
--- trunk/expressoCalendar/index.php	(revision 656)
+++ trunk/expressoCalendar/index.php	(revision 696)
@@ -36,4 +36,6 @@
 	$cat->app_name = 'calendar'; // The categories still the same from egroupwareCalendar
 	$optionCategories = $cat->formated_list('select','all',$bo->cat_id,'True');
+	$optionCategories .= '<option selected value="0">'.lang("all").'</option>' . "\n";
+	
 	foreach ($bo->list_cals() as $cal_)
 		if (! strstr($cal_['value'],'g_'))
Index: trunk/expressoCalendar/templates/default/config.tpl
===================================================================
--- trunk/expressoCalendar/templates/default/config.tpl	(revision 696)
+++ trunk/expressoCalendar/templates/default/config.tpl	(revision 696)
@@ -0,0 +1,60 @@
+<!-- BEGIN header -->
+<form method="POST" action="{action_url}">
+<table border="0" align="center">
+   <tr bgcolor="{th_bg}">
+    <td colspan="2"><font color="{th_text}">&nbsp;<b>{title}</b></font></td>
+   </tr>
+<!-- END header -->
+
+<!-- BEGIN body -->
+   <tr bgcolor="{row_on}">
+    <td colspan="2">&nbsp;</td>
+   </tr>
+
+   <tr bgcolor="{row_off}">
+    <td colspan="2"><b>{lang_Calendar_settings}</b></td>
+   </tr>
+   <tr bgcolor="{row_on}">
+    <td>{lang_Do_you_wish_to_autoload_calendar_holidays_files_dynamically?}</td>
+    <td>
+     <select name="newsettings[auto_load_holidays]">
+      <option value=""{selected_auto_load_holidays_False}>{lang_No}</option>
+      <option value="True"{selected_auto_load_holidays_True}>{lang_Yes}</option>
+     </select>
+    </td>
+   </tr>
+   <tr bgcolor="{row_off}">
+    <td>{lang_Location_to_autoload_from}:</td>
+    <td>
+     <select name="newsettings[holidays_url_path]">
+      <option value="localhost"{selected_holidays_url_path_localhost}>localhost</option>
+      <option value="http://www.phpgroupware.org/cal"{selected_holidays_url_path_http://www.phpgroupware.org/cal}>www.phpgroupware.org</option>
+     </select>
+     </td>
+     </tr>
+     <tr bgcolor="{row_on}">
+     <td>{lang_Do_you_want_to_cache_php_requests_in_javascript?}</td>
+     <td>
+     <select name="newsettings[expressoCalendar_enable_cache]">
+     <option value=""{selected_expressoCalendar_enable_cache_False}>{lang_No}</option>
+     <option value="True"{selected_expressoCalendar_enable_cache_True}>{lang_Yes}</option>
+     </select>
+     </td>
+     </tr>
+<!-- END body -->
+
+<!-- BEGIN footer -->
+  <tr bgcolor="{th_bg}">
+    <td colspan="2">
+&nbsp;
+    </td>
+  </tr>
+  <tr>
+    <td colspan="2" align="center">
+      <input type="submit" name="submit" value="{lang_submit}">
+      <input type="submit" name="cancel" value="{lang_cancel}">
+    </td>
+  </tr>
+</table>
+</form>
+<!-- END footer -->
Index: trunk/expressoCalendar/templates/default/index.tpl
===================================================================
--- trunk/expressoCalendar/templates/default/index.tpl	(revision 656)
+++ trunk/expressoCalendar/templates/default/index.tpl	(revision 696)
@@ -4,5 +4,5 @@
 <tr>
 <td>
-<select id="cat_id">
+<select id="cat_id" onchange="calendar.cat=this.value; calendar.getView('div_main',viewType);">
 {cat_options}
 </select>
@@ -12,4 +12,7 @@
 {cal_options}
 </select>
+</td>
+<td align="right">
+<label id="l_date"></label>
 </td>
 </tr>
