Index: trunk/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 6980)
+++ trunk/expressoMail1_2/js/main.js	(revision 6996)
@@ -1,4 +1,5 @@
 // Tempo do auto refresh (em milisegundos)
 var time_refresh = 300000;
+
 // tempo do auto save (em milisegundos)
 // 20000 = 20 segundos
@@ -6,6 +7,10 @@
 var results_search_messages = ""; 
 var cabecalho = '<h4>ExpressoLivre - ExpressoMail</h4>'; 
-// Variavel para controle de atualização das mensagens listadas na modal de alerta de filtro por remetente
-var checkAlarmsFilter = false;
+
+var auxNotificationCriteriaVetor = [];
+var auxNotification;
+
+var countNewMessage = 0;
+var notifyNewMessageFilter = [];
 
 var dynamicPersonalContacts = new Array();
@@ -20,5 +25,5 @@
 	} 
 }
-	
+
 function mount_url_folder(folders){
 	return folders.join(cyrus_delimiter);
@@ -75,5 +80,5 @@
 		
  	                if(preferences.show_name_print_messages == "1") { 
-							var getUserName = document.getElementById("user_info"); 
+				var getUserName = document.getElementById("user_info"); 
  	                        var userName = getUserName.innerHTML; 
  	                        var position = userName.indexOf("-"); 
@@ -572,5 +577,5 @@
 
 function auto_refresh(){
-	refresh(preferences.alert_new_msg);
+	refresh(preferences.alert_new_msg, preferences.notifications);
 	setTimeout('auto_refresh()', time_refresh);
 }
@@ -581,15 +586,35 @@
 }
 
-function refresh(alert_new_msg){
+function notificationFilter(data, notifyCriteria){
+	
+	if(parseInt(notifyCriteria)  && data.length > 0 && !activePage ){
+	
+		var howManyCriteria = $('div.gray.filtersDeadline .message-list li').length;
+		var differenceOfNewCriteria = data.length - howManyCriteria;
+		
+		if(differenceOfNewCriteria > 0){
+			for(var i=data.length - differenceOfNewCriteria; i < data.length; i++){
+	
+				desktopNotification.sentNotification("",get_lang("Filter criteria"),  truncate(new Date(data[i].udate).toString('dd/MM HH:mm') + ' - ' + data[i].from+' - '+data[i].subject, 75));
+				desktopNotification.showNotification(false, function(){
+					window.focus();
+					this.cancel();
+				});
+			}
+		}
+	}
+}
+
+function refresh(alert_new_msg, notifyPermission){
+
 	getFromAlertRules();
 	var handler_refresh = function(data){
-		if(checkAlarmsFilter){
-			handlerMessageFilter = function (data) {
-				alarmFollowupflagged('filtersAlarms', data);
-			}
-			/* Busca  nas pastas indexadas para ver se há novas mensagens com a flag $FilteredMessage */
-			cExecute ("$this.imap_functions.getFlaggedAlertMessages&folders="+fromRules, handlerMessageFilter);
-		}
-		checkAlarmsFilter = true;
+		handlerMessageFilter = function (data) {			
+			alarmFollowupflagged('filtersAlarms', data);
+			notificationFilter(data, notifyPermission);
+		}
+		/* Busca  nas pastas indexadas para ver se há novas mensagens com a flag $FilteredMessage */
+		cExecute ("$this.imap_functions.getFlaggedAlertMessages&folders="+fromRules, handlerMessageFilter);
+
 		if(data['msg_range_end'])
 			if(data['msg_range_end'] > 0)
@@ -603,5 +628,5 @@
 			showEmptyBoxMsg(box);
 
-		if (data.length > 0){
+		if (data.length > 0 || countNewMessage > 0){
 			for(var i=0;i< data.length;i++){
 				if (!onceOpenedHeadersMessages[current_folder])
@@ -742,7 +767,28 @@
 			if(parseInt(preferences.use_shortcuts))
 				select_msg("null","reload_msg","null");
-
-			if(parseInt(alert_new_msg) && data.new_msgs > 0)
+		
+			if(parseInt(alert_new_msg) && data.new_msgs > 0 && activePage)
 				alert(data['new_msgs'] > 1 ? get_lang("You have %1 new messages", data['new_msgs']) + "!" : get_lang("You have 1 new message") +"!");
+			
+			
+			if(parseInt(notifyPermission)  && (data.new_msgs > 0 || !!countNewMessage) && !activePage ){
+			
+				countNewMessage += data.length;
+				
+				desktopNotificationAux = desktopNotification.sentNotification("",get_lang("Notification"), countNewMessage > 1 ? get_lang("You have %1 new messages", countNewMessage) + "!" : get_lang("You have 1 new message") + "!");
+				
+				if(auxNotification !== 'undefined')
+					desktopNotification.cancelByReference(auxNotification);
+				
+				desktopNotification.showNotification(function(){
+					countNewMessage = 0;
+				}, function(){
+					window.focus();
+					this.cancel();
+					countNewMessage = 0;
+				});
+				
+				auxNotification = desktopNotificationAux;
+			}
 			build_quota(data['quota']);
 		}
@@ -4018,4 +4064,116 @@
 }
 
+//Normalização dos dados evita ter que reemplementar toda as funcionalidades do calendar
+function decodeCreateSchedulable(type, ID){
+	var startEvent = new Date();  
+	if(startEvent.toString('mm') < 30) 
+		startEvent.add({minutes: (30 - parseInt(startEvent.toString('mm')))}); 
+	else 
+		startEvent.add({hours: 1, minutes: '-'+startEvent.toString('mm')}); 
+	var endEvent = function(date){ 
+	if(!!User.preferences.defaultCalendar){ 
+		return  new Date(parseInt(date.getTime()) + 
+			(!!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration ?  
+			(Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration * 60000) :
+			(User.preferences.defaultDuration * 60000)
+		));
+	}else 
+		return new Date(parseInt(date.getTime()) + (User.preferences.defaultDuration * 60000)); 
+	};       
+
+	var emails = $("#to_values_"+ID).val().split(',');
+	
+	var schedulable = {};
+	
+	schedulable = { 
+		acl: {inviteGuests: true, organization: true ,participationRequired: false, read: true, write: true},
+		alarms: [],
+		allDay: false,
+		attachments: [],
+		isAttendee: true,
+		attendee: '',//TODOOOOOO,
+		category: '',
+		'class': '1',
+		delegatedFrom: {},
+		endDate: startEvent.toString(User.preferences.dateFormat),
+		startDate: endEvent(startEvent).toString(User.preferences.dateFormat),
+		startHour: startEvent.toString(User.preferences.hourFormat),
+		endHour: endEvent(startEvent).toString(User.preferences.hourFormat),
+		timezone: User.preferences.defaultCalendar ? Calendar.signatureOf[User.preferences.defaultCalendar].calendar.timezone : User.preferences.timezone,
+		summary : $("#subject_"+ID).text(),
+		description : $("#body_" + ID).text(),
+		startTime: startEvent.getTime(),
+		endTime: endEvent(startEvent),
+		timezones: Timezone.timezones,
+		me: {name: User.me.name, mail: User.me.mail, acl: 'rowi', status: '1', delegatedFrom: '0', id: User.me.id},
+		organizer: {name: User.me.name, mail: User.me.mail, acl: 'rowi', status: '1', delegatedFrom: '0' , id: User.me.id},
+		statusParticipants: {accepted: 0, cancelled: 0, tentative: 0, unanswered:emails.length},
+		location: '',
+		attendee: $.map(emails, function( mail ){			
+			var contact = false;
+			var decoded =  Encoder.htmlDecode(mail);
+			var newAttendeeName = "";
+
+			var name = decoded.match(/"([^"]*)"/) ? decoded.match(/"([^"]*)"/)[1] : '';
+			var mail = decoded.match(/<([^<]*)>[\s]*$/) ? decoded.match(/<([^<]*)>[\s]*$/)[1].toLowerCase() : decoded; 
+
+
+			var user = DataLayer.get('user', ["=", "mail", mail], true);
+			
+			if( $.type(user) == "array" )
+				user = user[0];
+
+			if(user != ''){
+				//user = {name : name , mail : mail};
+				if(User.me.mail == user.mail)
+					return(null);
+				user.isExternal = (!!user && !(!!user.isExternal)) ? 0 : 1;
+
+				return  DataLayer.merge({
+					name: user.name,
+					mail: user.mail,
+					acl:  'r',
+					delegatedFrom: '0',
+					status: '4',
+					isExternal: user.isExternal
+				}, !!user.id ? {id : DataLayer.put('participant', {user: user.id, isExternal: user.isExternal})} : {id: DataLayer.put('participant', {user: user})}); 
+			}else if(mail.match(/[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])/)){
+				
+				var userId = DataLayer.put('user', {
+				name: name, 
+				mail: mail, 
+				isExternal: '1'
+				});
+				var newAttendeeId = DataLayer.put('participant', {
+				user: userId, 
+				isExternal: '1'
+				});
+
+				return  {
+					id: newAttendeeId,
+					name: name,
+					mail: mail,
+					acl:  'r',
+					delegatedFrom: '0',
+					status: '4',
+					isExternal: '1'
+				};
+				
+			}else
+				return (null);
+		})
+	};
+
+	schedulable  = DataLayer.merge(schedulable, 
+		type == 'event' ? 
+		{calendar: User.preferences.defaultCalendar ? User.preferences.defaultCalendar : Calendar.calendars[0], calendars: Calendar.calendars}
+		: {group: Calendar.groups[0].id, groups: Calendar.groups, percentage: 0}
+	);
+	
+	return schedulable;
+	    
+
+}
+
 function import_implements_calendar(){
 
@@ -4031,7 +4189,9 @@
 		$.ajax({url: "../prototype/modules/calendar/js/map.disponibility.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});
 		$.ajax({url: "../prototype/modules/calendar/js/helpers.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});
+		$.ajax({url: "../prototype/modules/calendar/js/task.helpers.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});
 		//$.ajax({ url: "../prototype/modules/calendar/js/timezone.js", async: false});
 		//$.ajax({ url: "../prototype/modules/calendar/js/calendar.codecs.js", async: false});
 		$.ajax({url: "../prototype/plugins/encoder/encoder.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});
+		$.ajax({url: "../prototype/plugins/jquery.spinner/jquery.spinner.min.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});
 		//$.ajax({url: "../prototype/plugins/dateFormat/dateFormat.js", async: false, beforeSend: function( xhr ) { xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}});
 
@@ -4073,6 +4233,6 @@
 		wfolders.makeWindow('null','import');
 }
-
-function decodeOwner(){
+    //Verifica o contexto de importação
+    function decodeOwner(){
 	owner = User.me.id;
 	var imapBox = openTab.imapBox[currentTab].split(cyrus_delimiter);
@@ -4082,195 +4242,189 @@
 	}	
 	return owner;
-}
-function import_calendar(data){
-    var import_url = '$this.db_functions.import_vcard&msg_folder='+data;
-    var logUser;
-    var up;
-    var owner;   
-    function handler_import_calendar(data){
-            if(data === true){
-                    write_msg(get_lang("The event was imported successfully."));
-            }
-            else if( data['url'] )
-            {
-                var form = document.createElement( "form" );
-
-                form.setAttribute( "action", DEFAULT_URL + data['url'] + '&isPost=true' );
-                form.setAttribute( "method", "POST" );
-
-                document.body.appendChild( form );
-
-                form.submit();
-            }
-            else
-                write_msg(get_lang(data));
-    }	
+    }
+
+   function import_calendar(data){
+        var import_url = '$this.db_functions.import_vcard&msg_folder='+data;
+        var logUser;
+        var up;
+        var owner;
+
+        function handler_import_calendar(data){
+	    if(data === true){
+		write_msg(get_lang("The event was imported successfully."));
+	    }
+	    else if( data['url'] )
+	    {
+		var form = document.createElement( "form" );
+
+		form.setAttribute( "action", DEFAULT_URL + data['url'] + '&isPost=true' );
+		form.setAttribute( "method", "POST" );
+
+		document.body.appendChild( form );
+
+		form.submit();
+	    }
+	    else
+		write_msg(get_lang(data));
+        }   
 	if(defaultCalendar == "expressoCalendar" && $("#expressoCalendarid")[0]){
-		import_implements_calendar();
+	    import_implements_calendar();
 		$( "#import-dialog" ).dialog({
-			autoOpen: false,
-			height: 220,
-			modal: true,
-			resizable : false,
-            open: function(event, ui) 
-            {
-                if(typeof(shortcut) != 'undefined') shortcut.disabled = true; 
-            },
-            close: function(event, ui) 
-            {
-                event.stopPropagation();
-                if(typeof(shortcut) != 'undefined') shortcut.disabled = false; 
-            },
-			closeOnEscape: true
+		    autoOpen: false,
+		    height: 220,
+		    modal: true,
+		    resizable : false,
+		    open: function(event, ui) {
+			if(typeof(shortcut) != 'undefined') shortcut.disabled = true; 
+		    },
+		    close: function(event, ui){
+			event.stopPropagation();
+			if(typeof(shortcut) != 'undefined') shortcut.disabled = false; 
+		    },
+		    closeOnEscape: true
 		});
-		
+                   
 		$.ajax({
-			url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&readable=true&cirus_delimiter='+cyrus_delimiter+'&analize=true&uidAccount='+decodeOwner(),
-			async: false,
-			success: function(data){
-					data = connector.unserialize(data);
-
-
-					var createDialog = function(typeImport, propaget){
-					    
-						if(typeof(typeImport) == "object"){
-						    var calendarPermission = typeImport.calendar;
-						    typeImport = typeImport.action;
+		    url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&readable=true&cirus_delimiter='+cyrus_delimiter+'&analize=true&uidAccount='+decodeOwner(),
+		    async: false,
+		    success: function(data){
+			data = connector.unserialize(data);
+			var createDialog = function(typeImport, propaget){
+                                               
+			    if(typeof(typeImport) == "object"){
+				var calendarIds = !!typeImport.calendar ? typeImport.calendar : Calendar[typeImport.type];
+				typeImport = typeImport.action;
+			    }
+                                                   
+			    switch(parseInt(typeImport)){
+				case 1:
+				case 7:
+				case 10:
+				    $("#select-agenda").html('');
+
+				    var options = '';
+
+				    if(calendarIds){
+					for(var i = 0; i < calendarIds.length; i++)
+					    options += '<option value="'+calendarIds[i]+'">'+Calendar.signatureOf[calendarIds[i]].calendar.name+'</option>'
+				    }
+
+				    $("#select-agenda").append(options);
+				    $("#select-agenda").css("display", "block");
+
+				    $("#import-dialog" ).dialog({
+					buttons: {
+					    Cancel: function() {
+						$( this ).dialog( "close" );
+					    },
+					    "Importar" : function(){
+						    $.ajax({
+							url: "controller.php?action="+import_url+'&from_ajax=true&selected='+$("#select-agenda option:selected").val()+'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(),
+							success: function(msg){
+							    var alt = ( (msg = connector.unserialize(msg)) == "ok") ? "Importado com sucesso para " : "Ocorreu um erro ao importar o evento/tarefa para a agenda ";
+							    alert( alt + $("#select-agenda option:selected").text() );
+							}
+						    });
+						    $( this ).dialog( "close" );
+					    }
+					}
+				    });
+    
+				    if(typeImport == 7){
+					$("#import-dialog").find('#select-status option[value=1]').attr('selected','selected').trigger('change');
+					$("#import-dialog").find('#select-status').attr('disabled','disabled');
+				    }
+				    break;
+				case 3:
+				    $.ajax({
+					url: "controller.php?action="+import_url+'&from_ajax=true&selected=true',
+					success: function(msg){
+					    alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento/tarefa foi removido " : "Ocorreu um erro ao remover o evento/tarefa" );
+					}
+				    });
+				    return;
+				    break; 
+				case 5:
+				    $.ajax({
+					url: "controller.php?action="+import_url+'&from_ajax=true&selected=true',
+					success: function(msg){
+					    alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento/tarefa foi Atualizado com sucesso" : "Ocorreu um erro ao atualizar evento/tarefa" );
+					}
+				    });
+				    return;
+				    break; 
+				case 6:
+					var acceptedSuggestion = confirm("Deseja atualizar o evento/tarefa de acordo com a sugestão ?");
+					$.ajax({
+					    url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&selected=true&cirus_delimiter='+cyrus_delimiter+'&acceptedSuggestion='+acceptedSuggestion+"&from="+document.getElementById('from_values_'+currentTab).value+'&uidAccount='+decodeOwner(),
+					    success: function(msg){
+						if(acceptedSuggestion)
+						    alert( ( ( connector.unserialize(msg)) == "ok") ? "Evento/tarefa atualizado com sucesso " : "Ocorreu um erro ao atualizar o evento" );
 						}
-						
-						switch(parseInt(typeImport)){
-						case 1:
-						case 7:
-						case 10:
-						    $("#select-agenda").html('');
-
-						    var options = '';
-
-						    if(typeImport == 10){
-							for(var i = 0; i < calendarPermission.length; i++)
-							    options += '<option value="'+calendarPermission[i]+'">'+Calendar.signatureOf[calendarPermission[i]].calendar.name+'</option>'
-						    }else{
-							for(var id in Calendar.signatures)
-							   options += parseInt(Calendar.signatures[id].isOwner) ? '<option value="'+Calendar.signatures[id].calendar.id+'">'+Calendar.signatures[id].calendar.name+'</option>' : '';							
+					});
+					return;
+					break;
+					case 9:
+					    alert('Seu evento/tarefa não possui alterações!');
+					    return;
+					    break;
+					case 11:
+					    alert('Este evento/tarefa já fora importando por algum dos particpantes e já se encontra disponível em sua agenda compartilhada!');
+					    return;
+					    break;
+					default:
+					    up = true;
+					    $("#select-agenda").css("display", "none");
+					    $("#import-dialog" ).children("p:first-child").css("display", "none");
+					    $("#import-dialog" ).dialog({
+						height: 160,
+						title: 'Atualizar Evento/Tarefa',
+						buttons: {
+						    Cancel: function() {
+							$( this ).dialog( "close" );
+						    },
+						    "Atualizar": function() {
+							$.ajax({
+							    url: "controller.php?action="+import_url+'&from_ajax=true&cirus_delimiter='+cyrus_delimiter+'&selected='+ (parseInt(typeImport) == 2 || parseInt(typeImport) == 4 ? 'true' : $("#select-agenda option:selected").val()) +'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(),
+							    success: function(msg){
+								alert( ( (msg = connector.unserialize(msg)) == "ok") ? "Atualizado com sucesso" : "Ocorreu um erro ao atualizar o evento" );
+							    }
+							});
+							$( this ).dialog( "close" );
 						    }
-						    
-						    $("#select-agenda").append(options);
-						    $("#select-agenda").css("display", "block");
-						    
-						    $("#import-dialog" ).dialog({
-							buttons: {
-							    Cancel: function() {
-								$( this ).dialog( "close" );
-							    },
-							    "Importar" : function(){
-								    $.ajax({
-									url: "controller.php?action="+import_url+'&from_ajax=true&selected='+$("#select-agenda option:selected").val()+'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(),
-									success: function(msg){
-									    var alt = ( (msg = connector.unserialize(msg)) == "ok") ? "Importado com sucesso para " : "Ocorreu um erro ao importar o evento para a agenda ";
-									    alert( alt + $("#select-agenda option:selected").text() );
-									}
-								    });
-								    $( this ).dialog( "close" );
-							    }
-							}
-							});
-
-							if(typeImport == 7){
-							    $("#import-dialog").find('#select-status option[value=1]').attr('selected','selected').trigger('change');
-							    $("#import-dialog").find('#select-status').attr('disabled','disabled');
-							}
-						    break;
-						case 3:
-							$.ajax({
-								url: "controller.php?action="+import_url+'&from_ajax=true&selected=true',
-								success: function(msg){
-									alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi removido " : "Ocorreu um erro ao remover o evento" );
-								}
-							});
-							return;
-							break;	
-						case 5:
-							$.ajax({
-								url: "controller.php?action="+import_url+'&from_ajax=true&selected=true',
-								success: function(msg){
-									alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi Atualizado com sucesso" : "Ocorreu um erro ao atualizar evento" );
-								}
-							});
-							return;
-							break;	
-						case 6:
-							var acceptedSuggestion = confirm("Deseja atualizar o evento de acordo com a sugestão ?");
-							$.ajax({
-								url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&selected=true&cirus_delimiter='+cyrus_delimiter+'&acceptedSuggestion='+acceptedSuggestion+"&from="+document.getElementById('from_values_'+currentTab).value+'&uidAccount='+decodeOwner(),
-								success: function(msg){
-									if(acceptedSuggestion)
-										alert( ( ( connector.unserialize(msg)) == "ok") ? "Evento atualizado com sucesso " : "Ocorreu um erro ao atualizar o evento" );
-								}
-							});
-							return;
-							break;
-						case 9:
-							alert('Seu evento não possui alterações!');
-							return;
-							break;
-						case 11:
-							alert('Este evento já fora importando por algum dos particpantes e já se encontra disponível em sua agenda compartilhada!');
-							return;
-							break;
-						default:
-							up = true;
-							$("#select-agenda").css("display", "none");
-							$("#import-dialog" ).children("p:first-child").css("display", "none");
-							$("#import-dialog" ).dialog({
-								height: 160,
-								title: 'Atualizar Evento',
-								buttons: {
-									Cancel: function() {
-										$( this ).dialog( "close" );
-									},
-								   "Atualizar": function() {
-										
-										$.ajax({
-											 url: "controller.php?action="+import_url+'&from_ajax=true&cirus_delimiter='+cyrus_delimiter+'&selected='+ (parseInt(typeImport) == 2 || parseInt(typeImport) == 4 ? 'true' : $("#select-agenda option:selected").val()) +'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(),
-											 success: function(msg){
-													alert( ( (msg = connector.unserialize(msg)) == "ok") ? "Atualizado com sucesso" : "Ocorreu um erro ao atualizar o evento" );
-											}
-										});
-										$( this ).dialog( "close" );
-									}
-								},
-                                close:function(event, ui) 
-                                {
-                                    if(typeof(shortcut) != 'undefined') shortcut.disabled = false; 
-                                },
-                                open: function(event, ui) 
-                                {
-                                    if(typeof(shortcut) != 'undefined') shortcut.disabled = true; 
-                                }
-							});
-							$(".ui-dialog-buttonpane").find(".ui-button:last").children().html("Atualizar");
+						},
+						close:function(event, ui) 
+						{
+						    if(typeof(shortcut) != 'undefined') shortcut.disabled = false; 
+						},
+						open: function(event, ui) 
+						{
+						    if(typeof(shortcut) != 'undefined') shortcut.disabled = true; 
 						}
-						$( "#import-dialog" ).dialog( "open" );	
-																
-					};
-					createDialog(data, true);
-                                
-                },
-                beforeSend: function( jqXHR, settings ){
-				  	connector.showProgressBar();
-				},
-				complete: function( jqXHR, settings ){
-				  	connector.hideProgressBar();
-				}
-            });
-			
-		}
-		else
-		{
-		    if(confirm(get_lang("Do you confirm this import to your Calendar?"))){
-			cExecute( import_url + "&from_ajax=true", handler_import_calendar);
-		    }
-		}
-}
+					    });
+					    $(".ui-dialog-buttonpane").find(".ui-button:last").children().html("Atualizar");
+				    }
+				    $( "#import-dialog" ).dialog( "open" );
+                                                                                                                                   
+				};
+				createDialog(data, true);
+                                   
+			    },
+			    beforeSend: function( jqXHR, settings ){
+				connector.showProgressBar();
+			    },
+			    complete: function( jqXHR, settings ){
+				connector.hideProgressBar();
+			    }
+			});    
+                    }
+                    else
+                    {
+                        if(confirm(get_lang("Do you confirm this import to your Calendar?"))){
+                            cExecute( import_url + "&from_ajax=true", handler_import_calendar);
+                        }
+                    }
+    }
+    
 function open_msg_part(data){
 	var handler_open_msg_part = function (data)
