Index: branches/2.4/prototype/modules/calendar/js/helpers.js
===================================================================
--- branches/2.4/prototype/modules/calendar/js/helpers.js	(revision 6412)
+++ branches/2.4/prototype/modules/calendar/js/helpers.js	(revision 6453)
@@ -13,4 +13,24 @@
 
 function validDateEvent(){
+   
+    var errors = { 
+            'emptyInitData': 'Por favor, informe uma data inicial', 
+            'emptyEndData': 'Por favor, informe uma data final', 
+            'emptyInitHour': 'Por favor, informe uma hora inicial', 
+            'emptyEndHour': 'Por favor, informe uma hora final', 
+             
+            'invalidInitData' : 'Data inicial inválida', 
+            'invalidEndData' : 'Data final inválida', 
+             
+            'equalData' : 'Hora inicial igual a final', 
+            'theirData' : 'Hora final menor que a inicial', 
+             
+            'emptyOcurrence' : 'Por favor, informe o número de ocorrências', 
+            'invalidOcurrence' : 'Por favor, informe um valor válido para a quantidade de ocorrências', 
+              
+            'emptyInterval' : 'Por favor, informe o intervalo', 
+            'invalidInterval' : 'Por favor informe um valor válido para o intervalo' 
+    }; 
+
     var start_date = $(".new-event-win.active .start-date").val();
     var end_date   = $(".new-event-win.active .end-date").val();
@@ -23,45 +43,49 @@
     
     if(start_date == "")
-	return 'Por favor, informe uma data inicial';
+	return errors['emptyInitData']; 
     else if(end_date == "")
-	return 'Por favor, informe uma data final';
+	return errors['emptyEndData']; 
     else if(!isAllDay && start_time == "")
-	return 'Por favor, informe uma hora inicial';
+	return errors['emptyInitHour']; 
     else if(!isAllDay && end_time == "")
-	return 'Por favor, informe uma hora final';
-	
-    var formatString = (isAllDay)? User.preferences.dateFormat+" HH:mm" : User.preferences.dateFormat + " " + User.preferences.hourFormat;
-		
-    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 );
+	return errors['emptyEndHour']; 
+ 	      
+ 	var formatString = User.preferences.dateFormat + " " + User.preferences.hourFormat; 
+ 	             
+ 	var startDate = Date.parseExact( start_date + " " + $.trim(start_time) , formatString ); 
+ 	var endDate = Date.parseExact( end_date + " " + $.trim(end_time) , formatString ); 
 
     if(startDate == null || startDate.getTime() < 0 )
-	return 'Data inicial inválida';
+	return errors['invalidInitData'];
     if(endDate == null || endDate.getTime() < 0)
-	return 'Data final inválida';
-	
-    if((endDate.compareTo(startDate) != 1) && !((endDate.compareTo(startDate) == 0) && (isAllDay))){
-	return (start_date == end_date) ? 
-	((end_time == start_time) ? 'Hora inicial igual a final' : 'Hora final menor que a inicial') :
-	'Data final menor que a inicial';
-    }
+	return errors['invalidEndData']; 
+ 	     
+ 	if(isAllDay){ 
+ 	        startDate.clearTime(); 
+ 	        endDate.clearTime(); 
+ 	        if(endDate.compareTo(startDate) == -1) 
+ 	                return errors['theirData']; 
+ 	}else{ 
+ 	        var conditon = endDate.compareTo(startDate); 
+ 	        if(conditon != 1)  
+ 	                return errors[conditon == 0 ? 'equalData' : 'theirData']; 
+ 	} 
     
-    if (customDate){     
-	if ( !($('.new-event-win.active .customDateEnd').val().length) )
-           return 'Por favor, informe uma data final';     
-    }
-    
-    if (occurrences){
-	if ( !($('.occurrencesEnd').val().length) ) 
-           return 'Por favor, informe o número de ocorrências';
-       else if (parseInt($('.occurrencesEnd').val(),10) <= 0 || parseInt($('.occurrencesEnd').val(),10).toString() == "NaN")
-           return 'Por favor, informe um valor válido para a quantidade de ocorrências';
-    }
+   if (customDate)     
+ 	      if ( !($('.new-event-win.active .customDateEnd').val().length) ) 
+ 	         return errors['emptyEndData']; 
+ 	   
+   if (occurrences){
+       if ( !($('.occurrencesEnd').val().length) )  
+ 	  return errors['emptyOcurrence']; 
+       else if (parseInt($('.occurrencesEnd').val(),10) <= 0 || parseInt($('.occurrencesEnd').val(),10).toString() == "NaN") 
+          return errors['invalidOcurrence']; 
+   } 
 
     if (!($('.new-event-win.active p.input-group.finish_event.repeat-in').hasClass('hidden'))){
         if (!eventInterval.length)
-            return 'Por favor, informe o intervalo';
+           return errors['emptyInterval']; 
         else if (parseInt(eventInterval,10) < 1 || parseInt(eventInterval,10).toString() == "NaN")
-            return 'Por favor informe um valor válido para o intervalo';
+           return errors['invalidInterval']; 
     }    
     return false;
@@ -453,5 +477,7 @@
 
     UI.dialogs.addEvent.find('#calendar_addevent_details3').html(repeatHtml);
-    $(".date").datepicker();
+    $(".date").datepicker({ 
+ 	        dateFormat: User.preferences.dateFormat.replace(/M/g, 'm').replace(/yyyy/g, 'yy') 
+ 	        }); 
 		  
     if(objEvent.repeat) 
@@ -821,5 +847,5 @@
 
 var dates = UI.dialogs.addEvent.find('input.date').datepicker({
-    dateFormat: 'dd/mm/yy',
+    dateFormat: User.preferences.dateFormat.replace(/M/g, 'm').replace(/yyyy/g, 'yy'),
     onSelect : function( selectedDate ){
 	updateMap();
@@ -2470,50 +2496,52 @@
 }
 // não há resultados	
+
+var currentView = '#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || ''); 
+
 if ((((typeof(results) == 'undefined') || (!results.events_list )) && selecteds) &&(keyword != '' && keyword != null)) {
-    jQuery('#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html(
-	'<div title="Lista de eventos" class="events-list events-list-win active empty">' +
-	'<label>Não foi encontrado nenhum evento correspondente à sua pesquisa.</label>' +
-	'</div>'
+    $(currentView).html( 
+                '<div title="Lista de eventos" class="events-list events-list-win active empty">' + 
+                '<label>Não foi encontrado nenhum evento correspondente à sua pesquisa.</label>' + 
+                '</div>' 
 	);
 // há resultados e Agendas Selecionadas
 } else{ 
     if(typeof(results) != 'undefined'){
-	results['page_index'] = page_index;
-	results['keyword'] = keyword;
-			
-	DataLayer.render( 'templates/event_list.ejs', results, function( html ){
-	    var currentView = '#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || '');
-	    jQuery(currentView).html( html );
-	    jQuery('.events-list-win .menu-container .button').button();
-														
-	    $(".event-details-item").parent().click(function(){
-
-		$(this).siblings("div.details-event-list").toggleClass("hidden")
-		.find('.button.delete').click(function(){
-		    var eventId = $(this).siblings('[name="eventid"]').val();
-                    var calendarId = $(this).siblings('[name="calendarid"]').val();
-
-                    remove_event(eventId, calendarId);
-		})
-		.end().find('.button.edit').click(function(){				
-		    eventDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true );					
+		results['page_index'] = page_index; 
+	 	results['keyword'] = keyword; 
+	 	                                 
+	 	DataLayer.render( 'templates/event_list.ejs', results, function( html ){ 
+	 		                         
+	 	        $(currentView).html( html ); 
+	 	        $('.events-list-win .menu-container .button').button(); 
+	 	                                                                                                              
+	 	        $(".event-details-item").parent().click(function(){ 
+	 	
+	 	        $(this).siblings("div.details-event-list").toggleClass("hidden") 
+	 	        .find('.button.delete').click(function(){ 
+	 	                var eventId = $(this).siblings('[name="eventid"]').val(); 
+	 	                var calendarId = $(this).siblings('[name="calendarid"]').val(); 
+	 	
+	 	                remove_event(eventId, calendarId); 
+	 	        }) 
+	 	        .end().find('.button.edit').click(function(){                            
+	 	                eventDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true );                                        
+	 	        }); 
+	 		 
+	 	        }); 
+	 	        paginatorListEvent(currentView, (keyword == '' || keyword == null) ? 'list' : 'search',  !!view ? view : User.preferences.defaultCalView); 					
 		});
-
-	    });
-	    paginatorListEvent(currentView, (keyword == '' || keyword == null) ? 'list' : 'search',  !!view ? view : User.preferences.defaultCalView);
-	});
     }else{
-	var currentView = '#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || '');
-	jQuery('#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html(
-	    '<div title="Lista de eventos" class="events-list events-list-win active empty">' +
-	    '<input type="hidden" name="page_index" value="'+page_index+'"></inpunt>'+
-	    '<input type="hidden" name="keyword" value="'+keyword+'"></inpunt>'+
-	    '<label class="empty-result">Não foram encontrados eventos neste intervalo.</label>' +
-	    '</div>'
-	    );
-	paginatorListEvent(currentView, 'list', !!view ? view : User.preferences.defaultCalView);
-    }
-		
-}
+	$(currentView).html( 
+ 	        '<div title="Lista de eventos" class="events-list events-list-win active empty">' + 
+ 	        '<input type="hidden" name="page_index" value="'+page_index+'"></inpunt>'+ 
+ 	        '<input type="hidden" name="keyword" value="'+keyword+'"></inpunt>'+ 
+ 	        '<label class="empty-result">Não foram encontrados eventos neste intervalo.</label>' + 
+ 	        '</div>' 
+ 	        ); 
+ 	paginatorListEvent(currentView, 'list', !!view ? view : User.preferences.defaultCalView); 
+    } 
+} 
+      $tabs.tabs("select", currentView); 
 	
 }
