Index: trunk/prototype/modules/calendar/css/style.css
===================================================================
--- trunk/prototype/modules/calendar/css/style.css	(revision 5442)
+++ trunk/prototype/modules/calendar/css/style.css	(revision 5510)
@@ -181,5 +181,5 @@
 }
 
-.mini-calendar .ui-datepicker { width: auto; }
+.mini-calendar .ui-datepicker { width: auto; background: none repeat scroll 0 0 transparent; }
 .mini-calendar .ui-widget-content {	border: none; background-color: transparent; }
 .mini-calendar .ui-widget-header { background: transparent; color: #000; border: 0 none;}
Index: trunk/prototype/modules/calendar/js/calendar.date.js
===================================================================
--- trunk/prototype/modules/calendar/js/calendar.date.js	(revision 5437)
+++ trunk/prototype/modules/calendar/js/calendar.date.js	(revision 5510)
@@ -102,6 +102,39 @@
 			Hour += (Hour.length == 5) ? " pm" : "";
 		}else
-			Hour = "0"+(HourAmPm[0]-12)+":"+HourAmPm[1]+ ((Hour.length == 5) ? " pm" : "");
+			Hour = (((HourAmPm[0]-12)>=10) ? "" : "0") +(HourAmPm[0]-12)+":"+HourAmPm[1]+ ((Hour.length == 5) ? " pm" : "");
 		return Hour;
+	},
+	
+	AmPmTo24 : function (Hour)
+	{
+		var Hour24h = Hour.trim();
+		var AmPm;
+		if (Hour24h.length == 0) return;
+		if (Hour24h.length > 5) {
+		  AmPm = Hour24h.slice(-2);
+		  Hour24h = Hour24h.substring(0,5);
+		}
+		
+		var Hour24h = Hour24h.split(":");
+		
+		if (Hour24h[0] == 12)
+		  Hour24h[0] = "00";
+
+		if (AmPm === "pm") {
+		  Hour24h[0] = parseInt(Hour24h[0]) + 12;
+		} 
+		
+		return Hour24h[0] + ":" + Hour24h[1];
+	},
+	
+    // 01:00 retorna 1, 10:00 retorna 10, 22:00 retorna 10
+    getShortestTime : function(Hour) {
+                var _hour = this.defaultToAmPm(Hour);
+                if (_hour[0] == 0)
+                  _hour = _hour[1];
+                else
+                  _hour = _hour.substring(0,2);
+                
+                return _hour;
 	},
 	
Index: trunk/prototype/modules/calendar/js/helpers.js
===================================================================
--- trunk/prototype/modules/calendar/js/helpers.js	(revision 5442)
+++ trunk/prototype/modules/calendar/js/helpers.js	(revision 5510)
@@ -19,5 +19,5 @@
 	var startDate = Date.parseExact( isAllDay ? start_date+ " 00:00": start_date + " " + $.trim(start_time) , formatString );
 	var endDate = Date.parseExact( isAllDay ? end_date+ " 00:00": end_date + " " + $.trim(end_time) , formatString );
-	
+
 	if(startDate == null || startDate.getTime() < 0 )
 		return 'Data inicial inválida';
@@ -676,4 +676,72 @@
 			
 			tabPrefCalendar.find('.number').numeric();
+			
+			tabPrefCalendar.find('input.time').timepicker({ 
+				closeText: 'Ok',
+				hourGrid: 4,
+				minuteGrid: 10,
+				ampm : (parseInt($("select[name=hourFormat] option:selected").val().length) > 5 ? true : false), //((User.preferences.hourFormat.length > 5) ? true: false),
+				timeFormat: "hh:mm tt",
+				onSelect: function (selectedDateTime){
+					if(!(User.preferences.hourFormat.length == 5)) {
+						$(this).val(selectedDateTime.replace(/[\.]/gi, ""));
+					}
+				},
+				onClose : function (selectedDateTime){
+					if(!(User.preferences.hourFormat.length == 5)) {
+						$(this).val(selectedDateTime.replace(/[\.]/gi, ""));
+					}
+				}
+			});
+			
+			$.mask.definitions['{']='[ap]';
+			$.mask.definitions['}']='[m]';
+			tabPrefCalendar.find("input.time").mask( ((User.preferences.hourFormat.length > 5) ? "99:99 {}" : "99:99"), {
+                completed:function(){
+					$(this).val(dateCalendar.defaultToAmPm($(this).val()));
+					$(this).timepicker("refresh");
+					$(this).val($(this).val().replace(/[\.]/gi, ""));					
+				}
+			});
+			                                   
+         	tabPrefCalendar.find("select[name=hourFormat]").change( function() { // evento ao selecionar formato de hora
+         	
+				tabPrefCalendar.find("input.time").timepicker("destroy");
+
+                tabPrefCalendar.find('input.time').timepicker({ 
+					closeText: 'Ok',
+					hourGrid: 4,
+					minuteGrid: 10,
+					ampm : (parseInt($("select[name=hourFormat] option:selected").val().length) > 5 ? true : false),
+					timeFormat: "hh:mm tt",
+					onSelect: function (selectedDateTime){
+						if(!(User.preferences.hourFormat.length == 5)) {
+							$(this).val(selectedDateTime.replace(/[\.]/gi, ""));
+						}							
+					},
+					onClose : function (selectedDateTime){
+						if(!(User.preferences.hourFormat.length == 5)) {
+							$(this).val(selectedDateTime.replace(/[\.]/gi, ""));
+						}
+					}
+                });
+                             	
+              	var defaultStartHour = tabPrefCalendar.find("input[name=defaultStartHour]").val().trim();
+              	var defaultEndHour = tabPrefCalendar.find("input[name=defaultEndHour]").val().trim();
+              	
+				tabPrefCalendar.find("input.time").mask( (($("select[name=hourFormat] option:selected").val().trim().length > 5) ? "99:99 {}" : "99:99") );
+                
+                	if (parseInt($("select[name=hourFormat] option:selected").val().length) > 5) { // am/pm
+						tabPrefCalendar.find("input[name=defaultStartHour]").val(dateCalendar.defaultToAmPm(defaultStartHour));
+						tabPrefCalendar.find("input[name=defaultEndHour]").val(dateCalendar.defaultToAmPm(defaultEndHour))
+					
+					} else { //24h
+						tabPrefCalendar.find("input[name=defaultStartHour]").val(dateCalendar.AmPmTo24(defaultStartHour));
+						tabPrefCalendar.find("input[name=defaultEndHour]").val(dateCalendar.AmPmTo24(defaultEndHour));
+					}
+			});			
+                        
+                        
+			
 		});		
 	} else {
Index: trunk/prototype/modules/calendar/js/init.js
===================================================================
--- trunk/prototype/modules/calendar/js/init.js	(revision 5442)
+++ trunk/prototype/modules/calendar/js/init.js	(revision 5510)
@@ -1,4 +1,3 @@
 $(document).ready(function() {
-
 	refresh_calendars();
 	$tabs = $('#tabs').tabs({
@@ -163,4 +162,5 @@
 			right: 'agendaDay,agendaWeek,month,year'
 		},
+		firstHour: dateCalendar.getShortestTime(User.preferences.defaultStartHour ? User.preferences.defaultStartHour : '6'),
 		firstDay: dateCalendar.dayOfWeek[User.preferences.weekStart],
 		editable: true,
@@ -197,4 +197,27 @@
 		*/
 		select: function( start, end, allDay, event, view ){
+			if (view.name == "month") {
+				if (User.preferences.defaultStartHour) {
+				  _start = User.preferences.defaultStartHour;
+				  
+				  if (_start.length > 4) 
+			        _start = _start.trim().substring(0,5); // remove o am/pm
+			      
+			      _start = _start.split(":");
+			      start.setHours(_start[0]);
+			      start.setMinutes(_start[1]);
+			    }
+				  
+				if (User.preferences.defaultEndHour) {
+				  _end = User.preferences.defaultEndHour;
+				  if (_end.length > 4)
+			        _end = _end.trim().substring(0,5); // remove o am/pm
+			      			      
+			      _end = _end.split(":");			   
+			      end.setHours(_end[0]);			    
+			      end.setMinutes(_end[1]);
+				}		    
+			} // END if (view.name == "month")
+			
 			eventDetails( { 'start': start,
 					'end': end,
Index: trunk/prototype/modules/calendar/templates/preferences_calendar.ejs
===================================================================
--- trunk/prototype/modules/calendar/templates/preferences_calendar.ejs	(revision 5341)
+++ trunk/prototype/modules/calendar/templates/preferences_calendar.ejs	(revision 5510)
@@ -54,4 +54,14 @@
 					<option value="SAT" <%= data.preferences.weekStart =='SAT' ? 'selected="selected"':'' %>>Sábado</option>
 				</select>
+			</p>			
+                        
+			<p class="input-group">
+                <label for="defaultStartHour">Hora de início padrão:</label>
+				<input type="text" class="time" value="<%= (data.preferences.defaultStartHour) ? data.preferences.defaultStartHour : '' %>" name="defaultStartHour" /> 
+			</p>
+			
+			<p class="input-group">
+                <label for="defaultEndHour">Hora de término padrão:</label>
+				<input type="text" class="time" value="<%= (data.preferences.defaultEndHour) ? data.preferences.defaultEndHour : '' %>" name="defaultEndHour" /> 
 			</p>
 			
