Index: branches/2.5/prototype/modules/calendar/js/helpers.js
===================================================================
--- branches/2.5/prototype/modules/calendar/js/helpers.js	(revision 8036)
+++ branches/2.5/prototype/modules/calendar/js/helpers.js	(revision 8047)
@@ -590,4 +590,7 @@
             if( newDt > endDate ) 
                 $(".end-date").val(storeSelectedDate); 
+        }, 
+        onClose: function(){ 
+                UI.dialogs.addEvent.find(".end-date").val(UI.dialogs.addEvent.find(".start-date").val()); 
         } 
     }); 
@@ -1003,4 +1006,8 @@
 dateSameValue(); 
  
+var fixHour = function(){ 
+    currentTimeStart = UI.dialogs.addEvent.find("input.start-time").val(); 
+    UI.dialogs.addEvent.find("input.start-time").val(currentTimeStart.replace(".","").replace(".","")); 
+}    
  
 var setTime = function( selectedDateTime ) { 
@@ -1028,5 +1035,7 @@
     var minutes = dt.getMinutes().toString(); 
     var hours = dt.getHours(); 
- 
+UI.dialogs.addEvent.find("input.start-time").val(selectedDateTime.replace(".","").replace(".","")); 
+     
+     
     if (time[1].indexOf("p.m.") != -1 ) { 
         var startHours = startHours == 12 ? 12 : startHours; 
@@ -1045,5 +1054,7 @@
         var startHours = startHours == 12 ? 00 : startHours; 
     } 
-    dtFormat = (time[1].indexOf("p.m.") != -1 || time[1].indexOf("a.m.") != -1) ? ((((User.preferences.defaultDuration / 60) + startHours) >= 12 && (startHours + 4) < 24) ? " pm" : " am") : ""; 
+ 
+ 
+    dtFormat = (time[1].indexOf("p.m.") != -1 || time[1].indexOf("a.m.") != -1) ? ((((User.preferences.defaultDuration / 60) + startHours) >= 12 && (startHours + (User.preferences.defaultDuration / 60)) < 24) ? " pm" : " am") : ""; 
         
     var newHours = ""; 
@@ -1071,13 +1082,13 @@
 } 
  
-$(".start-date").focusout(function(data){  
-    $(".end-date").val($(this).val()); 
-});
- 
-if($("#calendar").fullCalendar('getView').name == "month"){ 
+    UI.dialogs.addEvent.find(".start-date").focusout(function(data){  
+        UI.dialogs.addEvent.find(".end-date").val($(this).val()); 
+    }); 
 
     var oldTime = UI.dialogs.addEvent.find('input.start-time').val();
     $(".start-time").focusout(function(data){ 
-        setTime( $(this).val() ); 
+        if($("#calendar").fullCalendar('getView').name == "month"){ 
+            setTime( $(this).val() ); 
+        } 
     }); 
   
@@ -1086,11 +1097,28 @@
         timeFormat: "hh:mm tt", 
         onSelect: function( selectedDateTime ){ 
-            setTime( selectedDateTime ); 
-        }    
+            if($("#calendar").fullCalendar('getView').name == "month"){ 
+                if ( selectedDateTime.indexOf("p.m.") == -1 || !selectedDateTime.indexOf("a.m.") == -1 ) { 
+                    var selectedTime = selectedDateTime.split(":"); 
+                    var endTime = UI.dialogs.addEvent.find(".end-time").val(); 
+                    endTime = endTime.split(":"); 
+ 
+                    var t1 = new Date(false,false,false,selectedTime[0],selectedTime[1],false); 
+                    var t2 = new Date(false,false,false,endTime[0],endTime[1],false); 
+ 
+                    if (t1 < t2) return true; 
+                } 
+ 
+                setTime( selectedDateTime ); 
+            } 
+        }, 
+        onClose : function (selectedDateTime){ 
+            fixHour(); 
+        } 
+ 
     }); 
  
-} 
- 
-UI.dialogs.addEvent.find('input.time').timepicker({ 
+
+ 
+UI.dialogs.addEvent.find('input.end-time').timepicker({ 
     closeText: 'Ok',
     hourGrid: 4,
@@ -1104,8 +1132,36 @@
 	    	$(this).val(selectedDateTime.replace(/[\.]/gi, ""));								
 		updateMap();
+ 
+        if ( selectedDateTime.indexOf("p.m.") == -1 || !selectedDateTime.indexOf("a.m.") == -1 ) { 
+            var startT = UI.dialogs.addEvent.find('input.start-time'); 
+ 
+            var lessZeroTime = function( sTime ) { 
+                sTime = sTime.split(":"); 
+                sTime = new Date(false,false,false,sTime[0],sTime[1],false); 
+                sTimeReady = parseInt(sTime.getHours() - (User.preferences.defaultDuration / 60)); 
+ 
+                if( sTimeReady < 0 ) 
+                    return false; // If the value is less than 0, return false. 
+                     
+                return sTimeReady.toString().length == 1 ? "0"+sTimeReady+":00" : sTimeReady+":00"; 
+            } 
+ 
+            var hEnd = new Date(false,false,false,selectedDateTime.split(":")[0],selectedDateTime.split(":")[1],false); 
+            var hStart = new Date(false,false,false,startT.val().split(":")[0],startT.val().split(":")[1],false); 
+             
+            if ( hEnd <= hStart ){ 
+                var lessTime = lessZeroTime( selectedDateTime ); 
+                if ( !lessTime ){ 
+                    startT.val( "00:00" ); 
+                    return true; 
+                } 
+                startT.val( lessTime ); 
+            } 
+        } 
     },
     onClose : function (selectedDateTime){
 	if(!(User.preferences.hourFormat.length == 5))
 	    $(this).val(selectedDateTime.replace(/[\.]/gi, ""));
+    fixHour(); 
     },
     beforeShow: function (selectedDateTime) {
