Index: /trunk/prototype/modules/calendar/interceptors/DBMapping.php
===================================================================
--- /trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 5746)
+++ /trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 5752)
@@ -110,5 +110,5 @@
 	  $occ = array();
 
-	  if( $occurrences = self::checkOccurrences( $start, $end, intval($criteria['deepness']) + 1 ) )
+	  if( $occurrences = self::checkOccurrences( $start, $end ) )
 	      foreach( $occurrences as $id => $occurrence )
 	      {
@@ -188,5 +188,5 @@
     }
 
-    public function checkOccurrences( $start, $end, $deep ){
+    public function checkOccurrences( $start, $end ){
 
 	$ranges = Controller::find( array( 'concept' => 'repeatRange' ), array( 'rangeStart', 'rangeEnd' ),  array( 'filter' => array( '=', 'user', Config::me("uidNumber") ) ) );
@@ -217,5 +217,5 @@
 
 	    if( !isset( $result[ $id ] ) )
-		$result[ $id ] = array();
+                $result[ $id ] = !$initialized ?  array( $repeat['startTime'] ) : array();
 
 	    if( !$initialized )
@@ -329,5 +329,5 @@
 
     $return = array();
-
+    
     while($result = $r->next())
     { 
Index: /trunk/prototype/modules/calendar/js/calendar.codecs.js
===================================================================
--- /trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 5746)
+++ /trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 5752)
@@ -986,9 +986,8 @@
 		    isRepeat = true;
 		    occurrences = evt.occurrences;
-		}
-
-		occurrences[ occurrences.length ] = evt.startTime;
-
-		occurrences = DataLayer.unique( occurrences );
+		}else
+                    occurrences[ occurrences.length ] = evt.startTime;
+
+		//occurrences = DataLayer.unique( occurrences ).sort();
 		  
 		for( var i = 0; i < occurrences.length; i++ )
Index: /trunk/prototype/modules/calendar/js/helpers.js
===================================================================
--- /trunk/prototype/modules/calendar/js/helpers.js	(revision 5746)
+++ /trunk/prototype/modules/calendar/js/helpers.js	(revision 5752)
@@ -657,5 +657,8 @@
 			canDiscardEventDialog = true;
 			
-                        var exit = function(){
+                        var exit = function(event){
+                            if(event)
+                                DataLayer.remove('schedulable', event, false); 
+
                             UI.dialogs.addEvent.children().find('form.form-addevent').submit();
                             UI.dialogs.addEvent.dialog("close");
@@ -665,5 +668,5 @@
                                DataLayer.remove('repeat', false);
                                DataLayer.put('repeat', repeat);
-                               DataLayer.commit('repeat', false, exit);
+                               DataLayer.commit('repeat', false, exit(repeat.schedulable));
                         }else
                             exit();
@@ -1628,5 +1631,5 @@
 
     edit.repeat.startTime = new Date(parseInt(edit.repeat.startTime)).toString('yyyy-MM-dd HH:mm:00');
-    edit.repeat.endTime = new Date(parseInt(edit.repeat.endTime)).toString('yyyy-MM-dd HH:mm:00');
+    edit.repeat.endTime = parseInt(edit.repeat.count) > 0 ? '0' : new Date(parseInt(edit.repeat.endTime)).toString('yyyy-MM-dd HH:mm:00');
     
     edit.repeat.exceptions = (schedulable.occurrences[idException]);         
Index: /trunk/prototype/modules/calendar/js/init.js
===================================================================
--- /trunk/prototype/modules/calendar/js/init.js	(revision 5746)
+++ /trunk/prototype/modules/calendar/js/init.js	(revision 5752)
@@ -242,5 +242,6 @@
                                  DataLayer.put('repeat', repeat);
                                  DataLayer.commit('repeat', false, function(data){
-                                     
+                                    
+                                    DataLayer.remove('schedulable', repeat.schedulable, false); 
                                     DataLayer.put('schedulable', schedulable);
                                      
@@ -275,4 +276,5 @@
                                  DataLayer.commit('repeat', false, function(data){
                                      
+                                    DataLayer.remove('schedulable', repeat.schedulable, false); 
                                     DataLayer.put('schedulable', schedulable);
                                      
