Index: /trunk/prototype/modules/mail/templates/importEmails.ejs
===================================================================
--- /trunk/prototype/modules/mail/templates/importEmails.ejs	(revision 5858)
+++ /trunk/prototype/modules/mail/templates/importEmails.ejs	(revision 5858)
@@ -0,0 +1,36 @@
+<div id="importMessageAccordion"  style="overflow:hidden;">
+	<h3>
+		<a href="#">
+			<%= get_lang('Choose the file')%>
+		</a>
+	</h3>			 
+	<div>
+		<div class="row fileupload-buttonbar">
+			<div class="button-files-upload">
+		    	<span class="button small btn-success fileinput-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button">
+					<span class="ui-button-text">
+					    <span><%= get_lang("Select a zip file or eml")%></span>
+					    <form id="importFileMessages" method="POST" name="form_import" enctype="multipart/form-data">
+					    	<input type="file" name="file_1" />
+					    	<input type="hidden" name="countFiles" value="1" />
+					    	<input type="hidden" name="folder" />
+					    </form>
+ 				  	</span>
+				</span> 
+	    	</div>
+		</div>
+		
+		<div style="margin-top: 35px;">
+			<label><%= get_lang('File name')%>:</label>
+			<label id="lblFileName"></label>
+		</div>
+	</div>
+	<h3>
+		<a href="#"><%= get_lang('Select a folder')%></a>
+	</h3>
+	<div style="overflow : auto;">
+		<div id="foldertree-container-importMessage" class="empty-container">
+			<span class="message"><%=get_lang('no folder found')%></span>
+		</div>
+	</div>
+</div>
Index: /trunk/expressoMail1_2/templates/default/index.tpl
===================================================================
--- /trunk/expressoMail1_2/templates/default/index.tpl	(revision 5786)
+++ /trunk/expressoMail1_2/templates/default/index.tpl	(revision 5858)
@@ -208,3 +208,5 @@
 <div id="followupFlag" class="followupflag-configure-win" style="display: none;"></div>
 <div class="expressomail-module-container" style="display: none;"></div>
+<div id="importEmails" style="display:none;padding:5px;"></div>
+
 <!-- END list -->
Index: /trunk/expressoMail1_2/setup/phpgw_pt-br.lang
===================================================================
--- /trunk/expressoMail1_2/setup/phpgw_pt-br.lang	(revision 5830)
+++ /trunk/expressoMail1_2/setup/phpgw_pt-br.lang	(revision 5858)
@@ -76,4 +76,5 @@
 Check Spelling	expressoMail1_2	pt-br	Corretor Ortográfico
 Choose a name	expressoMail1_2	pt-br	Escolha um nome
+Choose the file	expressoMail1_2	pt-br	Escolha o arquivo
 Chose the text you want transform in link before.	expressoMail1_2	pt-br	Selecione o texto que deseja transformar em link.
 Clean	expressoMail1_2	pt-br	Limpar
@@ -184,4 +185,5 @@
 File extension forbidden or invalid file	expressoMail1_2	pt-br	Extensão de arquivo proibido ou arquivo inválido
 files	expressoMail1_2	pt-br	arquivos
+File name	expressoMail1_2	pt-br	Nome do arquivo
 Filters	expressoMail1_2	pt-br	Filtros
 Filters maintenance	expressoMail1_2	pt-br	Manutenção de Filtros
@@ -465,4 +467,5 @@
 attachment(s)	expressoMail1_2	pt-br	anexo(s).
 Select a name	expressoMail1_2	pt-br	Selecione um nome
+Select a zip file or eml	expressoMail1_2	pt-br	Selecione um arquivo zip ou eml
 Select an organization and click on button <b>Search</b>	expressoMail1_2	pt-br	Selecione uma Organização e clique no botão <b>Pesquisar</b>
 Select Date	expressoMail1_2	pt-br	Selecione uma data
Index: /trunk/expressoMail1_2/js/main.js
===================================================================
--- /trunk/expressoMail1_2/js/main.js	(revision 5844)
+++ /trunk/expressoMail1_2/js/main.js	(revision 5858)
@@ -3168,84 +3168,144 @@
 }
 
-function import_window(){
-	var win = arrayJSWin["import_window"];
-	var form_upload = Element("form_upload");
-	if(!win) {
-		var form = document.createElement("DIV");
-		form.id  = "import_window";
-		form.style.visibility = "hidden";
-		form.style.position = "absolute";
-		form.style.background = "#eeeeee";
-		form.style.left = "0px";
-		form.style.top  = "0px";
-		form.style.width = "0px";
-		form.style.height = "0px";
-		document.body.appendChild(form);
-		form_upload = document.createElement("DIV");
-		form_upload.id = "form_upload";
-		form_upload.style.position = "absolute";
-		form_upload.style.top = "5px";
-		form_upload.style.left = "5px";
-		form_upload.name =  get_lang('zip mails to import');
-		form_upload.style.width = "450px";
-		form_upload.style.height = "100px";
-		form.appendChild(form_upload);
-		form.style.width  =  form.firstChild.style.width;
-		form.style.height = form.firstChild.style.height;
-		form.style.zIndex = "10000";
-		var title = form.firstChild.name;
-		var wHeight = form.offsetHeight + "px";
-		var wWidth =  form.offsetWidth   + "px";
-		form.style.width = form.offsetWidth - 5;
-		win = new dJSWin({
-			id: 'win_'+form.id,
-			content_id: form.id,
-			width: wWidth,
-			height: wHeight,
-			title_color: '#3978d6',
-			bg_color: '#eee',
-			title: title,
-			title_text_color: 'white',
-			button_x_img: '../phpgwapi/images/winclose.gif',
-			border: true});
-		win.draw();
-	}
+function import_window()
+{
+	var importEmails = $("#importEmails");
+		importEmails.html( DataLayer.render( BASE_PATH + "modules/mail/templates/importEmails.ejs", {}));
+		importEmails.dialog(
+		{
+			height		: 280,
+			width		: 500,
+			resizable	: false,
+			title		: get_lang('zip mails to import'),
+			modal		: true,
+			buttons		: [
+							 {
+							 	text	: get_lang("Close"), 
+							 	click	: function()
+							 	{
+							 		importEmails.dialog("destroy");
+							 	}
+							 },
+							 {
+							 	text	: get_lang("Import"), 
+							 	click	: function()
+							 	{
+							 		var input_file	 = importEmails.find("input[type=file]");
+							 		var input_hidden = importEmails.find("input[name=folder]"); 
+							 		
+							 		if( input_file.attr("value") == "" )
+							 		{
+							 			$.Zebra_Dialog(get_lang("You must choose a file") + " !",{
+							 				'type'				: 'warning',
+							 				'overlay_opacity'	: '0.5',
+							 				'onClose'			:  function(){
+							 					$("#importMessageAccordion").accordion('activate',0);	
+							 				}
+							 			});
+							 		}
+							 		else
+							 		{
+								 		if( input_hidden.attr("value") == "" )
+											$.Zebra_Dialog( get_lang("You must choose a folder") + " !" , {
+												'type'				: 'warning',
+												'overlay_opacity'	: '0.5',
+								 				'onClose'			:  function(){
+								 					$("#importMessageAccordion").accordion('activate',1);	
+								 				}
+											});
+								 		else
+								 		{
+								 			var handler_return = function(data)
+								 			{
+								 				importEmails.dialog("destroy");
+								 				
+								 				return_import_msgs( data, input_hidden.attr("value") );
+								 			}
+
+								 			var formSend =  document.getElementById("importFileMessages");
+								 			
+								 			write_msg(get_lang('You must wait while the messages will be imported...'));
+											
+								 			cExecuteForm('$this.imap_functions.import_msgs', formSend , handler_return );
+								 		}
+							 		}
+							 	}
+							 }
+						]
+		});
+
+	importEmails.css("overflow","hidden");
+		
+	importEmails.find("input[type=file]").change(function()
+	{ 
+		var deniedExtension = true;
+		var fileExtension 	= ["eml","zip"];
+		var fileName 		= importEmails.find("input[type=file]").attr('value');
+			fileName 		= fileName.split(".");
+		
+		if( fileName[1] )
+		{
+			for( var i in fileExtension )
+			{
+				if( fileExtension[i].toUpperCase() === fileName[1].toUpperCase() )
+				{
+					deniedExtension = false;
+					break;
+				}
+			}
+		}
+
+		if( deniedExtension )
+		{
+			$.Zebra_Dialog( get_lang('File extension forbidden or invalid file') , {
+				'type'				: 'warning',
+				'overlay_opacity'	: '0.5'
+			});
+		}
+
+		$("#lblFileName").html( ( !deniedExtension ) ? importEmails.find("input[type=file]").attr('value') : "" );
+		
+	});	
+		
+	$("#importMessageAccordion").accordion();	
+
+	var foldersTree = jQuery("#foldertree-container-importMessage")
+	.removeClass('empty-container')
+	.html(DataLayer.render(BASE_PATH + 'api/templates/foldertree.ejs', {folders: [cp_tree1, cp_tree2, [] ]}))
+	.find("#foldertree").treeview()
+	.click(function(event)
+	{
+		//request new selected folder messages
+		var target = $(event.target);
+
+		if( target.is('.collapsable-hitarea, .expandable-hitarea, .lastCollapsable, .lastExpandable, .treeview') )
+		    return;
+
+		if( !target.attr('id') )
+		    target = target.parent();
+
+        if (target.attr('id') == "foldertree") return;
+		
+		var targetId = target.attr('id');
+		var child = target.find('.folder');
+		
+		$('.filetree span.folder.selected').removeClass('selected');
+		if(!target.is('#foldertree > .expandable, #foldertree > .collapsable'))
+			$(target).children('.folder').addClass('selected');
+		
+		selectedFolder = {
+		    id: targetId, 
+		    name: child.attr('title'),
+		    'class': child.attr('class')
+		};
+		
+		importEmails.find("input[name=folder]").attr("value", targetId);
+	});
 	
-    form_upload.innerHTML = '<div style="margin:3px;">' +  
-							'<fieldset>' + 
-								'<legend>' + get_lang('zip mails to import') + '</legend>' + 
-								'<form method="POST" name="form_import" enctype="multipart/form-data">' + 
-									'<input name="file_1" maxlength="255" size="35" id="file_1" type="file"><br>' + 
-									'<input style="margin:5px;" title="'+get_lang('Select a folder')+'" value="'+get_lang('Select a folder')+'" type="button" onclick="javascript:select_import_folder()">'+ 
-									'<input title="'+get_lang("Close")+'" value="'+get_lang("Close")+'" type="button" onclick="arrayJSWin[\'import_window\'].close();">' + 
-								'</form>' +                                                              
-							'</fieldset>' + 
-							'</div>'; 
-    win.open();
-}
-
-function import_msgs(wfolders_tree){
-	function handler(data){
-		// Its necessary to encapsulate the data returned (IE bugfix)
-		return_import_msgs(data,wfolders_tree);
-	}
-	var countFiles = document.form_import.countFiles;
-	if(!countFiles){
-		countFiles = document.createElement("INPUT");
-		countFiles.type = "hidden";
-		countFiles.name = "countFiles";
-		countFiles.value = "1";
-		document.form_import.appendChild(countFiles);
-	}
-	var folder = document.createElement("INPUT");
-	folder.type = "hidden";
-	folder.name = "folder";
-	folder.value = wfolders_tree._selected.id;
-	document.form_import.appendChild(folder);
-	write_msg(get_lang('You must wait while the messages will be imported...'));
-
-	cExecuteForm('$this.imap_functions.import_msgs', document.form_import, handler);
-}
-function return_import_msgs(data, wfolders_tree){
+	$("#lblFileName").prev().css("margin-left", "10px");
+	$("#lblFileName").prev().css("font-weight", "bold");
+}
+
+function return_import_msgs(data, folderID){
 	if(data && data.error){
 		write_msg(data.error);
@@ -3274,5 +3334,5 @@
 					Element("dJSWin_wfolders_bok").blur();
 				}				
-				if(openTab.imapBox[0] == wfolders_tree._selected.id)
+				if(openTab.imapBox[0] == folderID)
 				{
 					openTab.imapBox[0] = '';
