Index: /trunk/prototype/modules/mail/css/foldertree.css
===================================================================
--- /trunk/prototype/modules/mail/css/foldertree.css	(revision 5504)
+++ /trunk/prototype/modules/mail/css/foldertree.css	(revision 5516)
@@ -1,8 +1,8 @@
 #content_folders.foldertree-skin-prognus span.selected {font-weight:bold;}
 #content_folders.foldertree-skin-prognus span.inbox {}
-#content_folders.foldertree-skin-prognus span.trash {background-image: url(../img/bin.png)!important;}
-#content_folders.foldertree-skin-prognus span.drafts {background-image: url(../img/folder_page_white.png)!important;}
-#content_folders.foldertree-skin-prognus span.spam {background-image: url(../img/folder_delete.png)!important;}
-#content_folders.foldertree-skin-prognus span.sent {background-image: url(../img/folder_go.png)!important;}
+#content_folders.foldertree-skin-prognus span.trash {background-image: url(../img/bin.png);}
+#content_folders.foldertree-skin-prognus span.drafts {background-image: url(../img/folder_page_white.png);}
+#content_folders.foldertree-skin-prognus span.spam {background-image: url(../img/folder_delete.png);}
+#content_folders.foldertree-skin-prognus span.sent {background-image: url(../img/folder_go.png);}
 #content_folders.foldertree-skin-prognus span.folder {display: block;padding-bottom: 1px;padding-left: 18px;padding-right: 0;padding-top: 1px;}
 #content_folders.treeview .closed {display:block;}
@@ -52,4 +52,5 @@
 
 .collapse_folders_td{
+	cursor : pointer;
 	width: 12px;
 	height:100%;
Index: /trunk/prototype/modules/mail/js/foldertree.js
===================================================================
--- /trunk/prototype/modules/mail/js/foldertree.js	(revision 5505)
+++ /trunk/prototype/modules/mail/js/foldertree.js	(revision 5516)
@@ -26,5 +26,5 @@
 			if($(children_of_this_folder[index]).attr('id') == openTab.imapBox[$(borders_open[i]).find("input[type=hidden]").attr("name")]){
 				error = true;
-				alert(get_lang("One or more messages from any sub-folder are open"));
+				write_msg(get_lang("One or more messages from any sub-folder are open"));
 				return error;
 				
@@ -37,5 +37,5 @@
 		if(openTab.imapBox[$(borders_open[i]).find("input[type=hidden]").attr("name")] == folder_to_move){
 			error = true;
-			alert(get_lang("One or more messages from this folder are open"));
+			write_msg(get_lang("One or more messages from this folder are open"));
 			return error;
 		}
@@ -79,7 +79,12 @@
 			
 			// MUDANÇA DE PASTAS!
-			var target = $(this);		
+			var target = $(this);	
+			
+			if($(".folders_loading").length)
+				return;
+				
 			if( target.is('.collapsable-hitarea, .expandable-hitarea, .lastCollapsable-hitarea, .lastExpandable-hitarea, .treeview ,.folder_unseen,.ui-icon, .float-menu, .new_folder, .folders_loading') )
 				return;
+			
 			if( target.parent().find(".new_folder").length)
 				return;
@@ -95,6 +100,7 @@
 				$(target).children('.folder').addClass('selected');
 			}
+			$(this).addClass("folders_loading");
 			selected = target.attr('id');
-			change_folder(target.attr('id'), child.attr('title'));			
+			change_folder(target.attr('id'), child.attr('title'));	
 		}).end();
 		folders_html.find('[id="'+selected+'"]').children().addClass("selected").end().end().find("li:first").find(".folder").not(".head_folder,.inbox,.drafts,.sent,.spam,.trash").draggable({
@@ -182,25 +188,25 @@
 					// VALIDA SE O USUARIO ESTA TENTANDO MOVER A PASTA PARA O eventSMO LOCAL
 					if(teste == folder_to_move){
-						return alert(get_lang("Thie folder is already in this place"));
+						return write_msg(get_lang("Thie folder is already in this place"));
 					}
 					
 					// VALIDA SE O USUARIO ESTA TENTANDO MOVER A PASTA ABERTA NO momentO
 					if(folder_to_move == get_current_folder()){
-						return alert(get_lang("It's not possible move this folder, because it is being used in the moment!"));
+						return write_msg(get_lang("It's not possible move this folder, because it is being used in the moment!"));
 					}
 					
 					// VALIDA SE O USUARIO ESTA TENTANDO MOVER UMA PASTA FILHA DA PASTA ABERTA NO momentO
 					if(ui.draggable.parent().find(".selected")[0]){
-						return alert(get_lang("It's not possible move this folder, because its subfolder is being used in the moment!"));
+						return write_msg(get_lang("It's not possible move this folder, because its subfolder is being used in the moment!"));
 					}
 					
 					// VALIDA SE O USUARIO ESTA TENTANDO MOVER UMA PASTA PAI PARA DENTRO DE UMA FILHA
 					if(ui.draggable.parent().find('[id="'+folder_to+'"]')[0]){
-						return alert(get_lang("It's not possible to move this folder to its subfolders!"));
+						return write_msg(get_lang("It's not possible to move this folder to its subfolders!"));
 					}
 					//teste = teste.split(cyrus_delimiter);
 					
 					if($('[id="'+teste+'"]').length){
-						return alert(get_lang("Can not move this folder to this location, because the target has already a folder with this name"));
+						return write_msg(get_lang("Can not move this folder to this location, because the target has already a folder with this name"));
 					}
 					
@@ -209,7 +215,13 @@
 					$.ajax({
 						url : "controller.php?action=$this.imap_functions.move_folder&folder_to_move="+folder_to_move+"&folder_to="+folder_to,
-						success : function(){
-							cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu);
-							write_msg(get_lang("The folder was successfully moved"));
+						success : function(data){
+							data = connector.unserialize(data);
+							if(data){
+								cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu);
+								write_msg(get_lang("The folder was successfully moved"));
+							}
+							else{
+								write_msg(get_lang("ERROR moving your folder."));
+							}
 						}
 					});
@@ -234,7 +246,7 @@
 							var name = $.trim($(this).parents(".closed:first").find("span:first").text().split("[")[0]);
 							if($(this).parents(".closed:first").find("span:first").hasClass("selected"))
-								return alert(get_lang("It's not possible rename this folder, because it is being used in the moment!"));
+								return write_msg(get_lang("It's not possible rename this folder, because it is being used in the moment!"));
 							if($(this).parents(".closed:first").find(".selected").length)
-								return alert(get_lang("It's not possible rename this folder, because its subfolder is being used in the moment!")); 
+								return write_msg(get_lang("It's not possible rename this folder, because its subfolder is being used in the moment!")); 
 							$(this).parents(".closed:first").find("span:first").empty().append("<input class='new_folder folder' type='text' maxlength='100'></input>")
 							$(".new_folder").focus().keydown(function(event){
@@ -243,5 +255,5 @@
 									if($(this).val() != ""){
 										if($(this).val().match(/[\/\\\!\@\#\$\%\&\*\+\(\)]/gi)){
-											return alert(get_lang("cannot create folder. try other folder name"));
+											return write_msg(get_lang("cannot create folder. try other folder name"));
 										}
 										var new_name = folder_id.replace(/[a-zA-Z0-9á-úÁ-Ú]+$/gi, $(this).val());
@@ -289,9 +301,9 @@
 							if($(this).parents(".closed:first").find("ul").length){
 								$(this).parents(".closed:first").find(".folder").removeClass("folders_loading");
-								return alert(get_lang("Delete/move subfolders first"));
+								return write_msg(get_lang("Delete/move subfolders first"));
 							}
 							if($(this).parents(".closed:first").find(".selected").length){
 								$(this).parents(".closed:first").find(".folder").removeClass("folders_loading");
-								return alert(get_lang("It's not possible delete this folder, because it is being used in the moment!")); 
+								return write_msg(get_lang("It's not possible delete this folder, because it is being used in the moment!")); 
 							}
 							var confirm_text = get_lang("Do you wish to exclude the folder ");
@@ -347,5 +359,5 @@
 								if(event.keyCode == 13){
 									if($(this).val().match(/[\\\!\@\#\$\%\&\*\+\(\)]/gi)){
-										return alert(get_lang("cannot create folder. try other folder name"));
+										return write_msg(get_lang("cannot create folder. try other folder name"));
 									}
 									$(".new_folder").parent().addClass("folders_loading");
@@ -375,4 +387,7 @@
 									if(confirm(get_lang("Do you want to cancel the folder creation?")))
 										draw_new_tree_folder();
+									else{
+										$(this).focus();
+									}
 								}
 							});
Index: /trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 5509)
+++ /trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 5516)
@@ -101,4 +101,16 @@
             return $this->mbox;
 	 }
+
+	/**
+	* Move as pastas que vieram do resultado de um Drag & Drop da arvore de pastas do Expresso Mail
+	*
+	* @license    http://www.gnu.org/copyleft/gpl.html GPL
+	* @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
+	* @sponsor    Caixa Econômica Federal
+	* @author     Gustavo Pereira dos Santos Stabelini	
+	* @param      array $params Contem dois indices : um contem o caminho atual da pasta, e o outro contem o caminho futuro da pasta
+	* @return     boolean
+	* @access     public
+	*/
 	 
 	function move_folder($params){
@@ -108,5 +120,6 @@
 		$to_folder = mb_convert_encoding($params['folder_to'], 'UTF7-IMAP','UTF-8, ISO-8859-1, UTF7-IMAP');
 		$mbox = imap_open('{'.$this->imap_server.":".$this->imap_port.$this->imap_options.'}'.$new_folder[0], $this->username, $this->password);
-		imap_renamemailbox($mbox, '{'.$this->imap_server.":".$this->imap_port.$this->imap_options.'}'.$old_folder, '{'.$this->imap_server.":".$this->imap_port.$this->imap_options.'}'.$to_folder.$this->imap_delimiter.$new_folder[count($new_folder)-1]);
+		if(!imap_renamemailbox($mbox, '{'.$this->imap_server.":".$this->imap_port.$this->imap_options.'}'.$old_folder, '{'.$this->imap_server.":".$this->imap_port.$this->imap_options.'}'.$to_folder.$this->imap_delimiter.$new_folder[count($new_folder)-1]));
+			return false;
 		imap_close($mbox); 
 		return true;
Index: /trunk/expressoMail1_2/js/main.js
===================================================================
--- /trunk/expressoMail1_2/js/main.js	(revision 5514)
+++ /trunk/expressoMail1_2/js/main.js	(revision 5516)
@@ -951,5 +951,5 @@
 					//cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + current_folder, show_msg);
 					if(!not_opem_previus){
-						Execute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + url_encode(folder), show_msg);
+						cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + url_encode(folder), show_msg);
 					}
 				}
Index: /trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- /trunk/expressoMail1_2/js/draw_api.js	(revision 5507)
+++ /trunk/expressoMail1_2/js/draw_api.js	(revision 5516)
@@ -461,10 +461,13 @@
 			$("#new_m").html(($(".selected").find(".folder_unseen").html() != "0" && $(".selected").find(".folder_unseen").html() != null)? $(".selected").find(".folder_unseen").html() : "0").css("color", "red");
 			//update_menu();
+			$(".folders_loading").removeClass("folders_loading");
 			return true;
 		}
 		proxy_mensagens.messages_list(current_folder,1,preferences.max_email_per_page,sort_box_type,search_box_type,sort_box_reverse,preferences.preview_msg_subject,preferences.preview_msg_tip,handler_draw_box);
 	}
-	else
+	else{
+		$(".folders_loading").removeClass("folders_loading");
 		alternate_border(0);
+	}
 }
 
