Index: trunk/preferences/preferences.php
===================================================================
--- trunk/preferences/preferences.php	(revision 43)
+++ trunk/preferences/preferences.php	(revision 873)
@@ -192,7 +192,15 @@
 
 			$t->fp('rows',process_help($help) ? 'help_row' : 'row',True);
-		}
-
-	function create_select_box($label,$name,$values,$help='',$default='',$run_lang=True)
+	}
+	function create_html_code($code)
+	{
+		global $t;
+		$t->set_var('row_value',$code);
+		$t->set_var('row_name',lang("signature"));
+		$GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t);
+		$t->fp('rows','row',True);
+	}
+
+	function create_select_box($label,$name,$values,$help='',$default='',$run_lang=True,$select_prop = '')
 	{
 		global $t,$prefs;
@@ -227,5 +235,5 @@
 			$def_text = $def_text != '' ? ' <i><font size="-1">'.lang('default').':&nbsp;'.$values[$def_text].'</font></i>' : '';
 		}
-		$t->set_var('row_value',"<select name=\"${GLOBALS[type]}[$name]\">$s</select>$def_text");
+		$t->set_var('row_value',"<select name=\"${GLOBALS[type]}[$name]\" $select_prop>$s</select>$def_text");
 		$t->set_var('row_name',lang($label));
 		$GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t);
Index: trunk/expressoMail1_2/inc/hook_preferences.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/hook_preferences.inc.php	(revision 2)
+++ trunk/expressoMail1_2/inc/hook_preferences.inc.php	(revision 873)
@@ -1,10 +1,9 @@
 <?php
 {
-// Only Modify the $file and $title variables.....
-	$title = 'expressoMail1_2';
-	$file = Array(
-		'Preferences' => $GLOBALS['phpgw']->link('/'.$title.'/preferences.php'),
+	$title = $appname;
+	$file = array(
+		'Preferences'     => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname='.$appname)
 	);
-//Do not modify below this line
+	//Do not modify below this line
 	display_section($appname,$title,$file);
 }
Index: trunk/expressoMail1_2/inc/hook_settings.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/hook_settings.inc.php	(revision 873)
+++ trunk/expressoMail1_2/inc/hook_settings.inc.php	(revision 873)
@@ -0,0 +1,104 @@
+<?php
+	/**************************************************************************\
+	* eGroupWare - ExpressoMail Preferences                                    *
+	* http://www.expressolivre.org                                             *	
+	* Modified by Alexandre Felipe Muller de Souza <amuller@celepar.pr.gov.br> *
+	* --------------------------------------------                             *
+	*  This program is free software; you can redistribute it and/or modify it *
+	*  under the terms of the GNU General Public License as published by the   *
+	*  Free Software Foundation; either version 2 of the License, or (at your  *
+	*  option) any later version.                                              *
+	\**************************************************************************/
+include_once("fckeditor.php");
+$type = $_GET['type']; // FIX ME
+
+$default = array(
+	'25'	=> '25',
+	'50'	=> '50',
+	'75'	=> '75',
+	'100'	=> '100'
+);
+
+create_select_box(lang('What is the maximum number of messages per page?'),'max_email_per_page',$default,
+	'What is the maximum number of messages per page?');
+create_check_box(lang('Save deleted messages in trash folder?'),'save_deleted_msg','Save deleted messages in trash folder?');
+$default = array(
+	'1'    => lang('1 day'),
+	'2'    => lang('2 days'),
+	'3'    => lang('3 days'),
+	'4'   => lang('4 days'),
+	'5'   => lang('5 days')
+);
+
+create_select_box(lang('Delete trash messages after how many days?'),'delete_trash_messages_after_n_days',$default,lang('Delete trash messages after how many days?'));
+create_check_box(lang('Would you like to use local messages?'),'use_local_messages','');
+create_check_box(lang('Would you like to keep archived messages?'),'keep_archived_messages','');
+create_check_box(lang('Show previous message, after delete actual message?'),'delete_and_show_previous_message','');
+create_check_box(lang('Do you wanna receive an alert for new messages?'),'alert_new_msg','');
+create_check_box(lang('Show default view on main screen?'),'mainscreen_showmail','');
+create_check_box(lang('Do you want to use remove attachments function?'),'remove_attachments_function','');
+create_check_box(lang('Do you want to use important flag in email editor?'),'enable_important_flag','');
+
+//TODO use default folders from email admin
+$default = array(
+	'INBOX'	=>	lang('INBOX'),
+	'INBOX/'.lang('Drafts')	=> lang('Drafts'),
+	'INBOX/'.lang('Sent')	=> lang('Sent'),
+	'INBOX/'.lang('Trash')	=> lang('Trash')
+);
+create_select_box(lang('Save sent messages in folder'),'save_in_folder',$default,'');
+create_check_box(lang('Hide menu folders?'),'check_menu','');
+
+$default = array(
+	'20' => lang('normal'),
+	'30' => lang('medium'),
+	'40' => lang('big')
+);
+
+create_select_box(lang('What is the height of the lines in the list of messages?'),'line_height',$default,'');
+$default = array(
+	'10' => lang('small'),
+	'11' => lang('normal'),
+	'15' => lang('big')
+);
+
+create_select_box(lang('What the font size in the list of messages?'),'font_size',$default,'');
+create_check_box(lang('Use dynamic contacts?'),'use_dynamic_contacts','');
+create_check_box(lang('Use shortcuts?'),'use_shotcuts','');
+create_check_box(lang('Auto save draft'),'auto_save_draft','');
+
+$default = array(
+	'text' => lang('simple text'),
+	'html' => lang('rich text')
+);
+
+create_select_box(lang('Signature Type'),'type_signature',$default,'','','','onchange="javascript:changeType(this.value);" onload="javascript:alert(this.value);"');
+
+if ($type == 'user'){
+	$oFCKeditor = new FCKeditor('html_signature');
+	$oFCKeditor->BasePath   = '../expressoMail1_2/js/fckeditor/';
+	$oFCKeditor->ToolbarSet = 'ExpressoLivre';
+
+	$vars = $GLOBALS['phpgw']->preferences->user[$appname];
+
+	create_html_code("<div id='text_signature'>
+		<textarea rows='5' cols='50' id='user[signature]' name='user[signature]'></textarea></div>
+		<div style='display:none;' id='html_signature'>".$oFCKeditor->Create()."</div>
+		<script language='javascript'>
+document.getElementById('user[signature]').value  = '".$vars['signature']."';
+function changeType(value){
+	var html_signature = FCKeditorAPI.GetInstance(\"html_signature\");
+	if(value == 'text'){
+		document.getElementById('user[signature]').value = html_signature.GetHTML();
+		document.getElementById(\"text_signature\").style.display = '';
+		document.getElementById(\"html_signature\").style.display = 'none';
+}
+else if(value == 'html'){
+	html_signature.SetHTML(document.getElementById('user[signature]').value);
+	document.getElementById(\"text_signature\").style.display = 'none';
+	document.getElementById(\"html_signature\").style.display  = '';							     }
+}
+setTimeout('changeType(document.getElementsByName(\'user[type_signature]\')[0].value)',1500);
+</script>");
+}
+?>
Index: trunk/expressoMail1_2/js/common_functions.js
===================================================================
--- trunk/expressoMail1_2/js/common_functions.js	(revision 845)
+++ trunk/expressoMail1_2/js/common_functions.js	(revision 873)
@@ -559,5 +559,5 @@
 function preferences_mail(){
 	if(preferences.type_signature && preferences.type_signature == 'html') {
-		location.href="preferences.php";
+		location.href="../preferences/preferences.php?appname=expressoMail1_2";
 	}
 	else {
Index: trunk/expressoMail1_2/index.php
===================================================================
--- trunk/expressoMail1_2/index.php	(revision 859)
+++ trunk/expressoMail1_2/index.php	(revision 873)
@@ -82,39 +82,7 @@
 		$GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages'] = 0;
 	}
-
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = array(
-			'voip_enabled'						=> $voip_enabled,
-			'voip_email_redirect'				=> $emailVoip,
-			'outoffice'							=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['outoffice'],
-			'telephone_number'					=> $GLOBALS['phpgw_info']['user']['telephonenumber'],
-			'max_email_per_page' 				=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['max_email_per_page'],
-    		'save_deleted_msg' 					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['save_deleted_msg'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['save_deleted_msg'] : "0",
-            'delete_trash_messages_after_n_days'=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['delete_trash_messages_after_n_days'],
-    		'delete_and_show_previous_message' 	=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['delete_and_show_previous_message'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['delete_and_show_previous_message'] : "0",
-    		'alert_new_msg' 					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['alert_new_msg'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['alert_new_msg'] : "0",
-    		'mainscreen_showmail' 				=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['mainscreen_showmail'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['mainscreen_showmail'] : "0",
-    		'signature' 						=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['signature'],
-    		'type_signature' 					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['type_signature'],
-    		'use_signature' 					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature'] : "0",
-		'hide_folders' 						=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['hide_folders'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['hide_folders'] : "0",    		
-    		'save_in_folder' 					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder'] : "-1",
-    		'line_height' 						=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['line_height'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['line_height'] : "30",
-    		'font_size' 						=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['font_size'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['font_size'] : "11",
-    		'use_shortcuts' 					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'] : "0",
-    		'auto_save_draft'					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_save_draft'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_save_draft'] : "0",
-		'use_dynamic_contacts' 					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'] : "0",
-		'number_of_contacts' 					=> $current_config['expressoMail_Number_of_dynamic_contacts'] ? $current_config['expressoMail_Number_of_dynamic_contacts'] : "0",
-		'use_cache' 						=> $current_config['expressoMail_enable_cache'],
-		'notification_domains'					=> $current_config['expressoMail_notification_domains'],
-		'remove_attachments_function'				=> $current_config['expressoMail_remove_attachments_function'],
-		'use_important_flag'					=> $current_config['expressoMail_enable_important_flag'],
-   		'use_local_messages'	 			=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages'] : "0",
-   		'keep_archived_messages'	 		=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['keep_archived_messages'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['keep_archived_messages'] : "0"
-
-
-
-
-	);
-
+	$preferences = $GLOBALS['phpgw']->preferences->read();
+	$_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = $preferences['expressoMail1_2'];
+	$_SESSION['debug'] = $_SESSION['phpgw_info']['user']['preferences']['expressoMail'];
 
 	$template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
@@ -206,9 +174,4 @@
 	// Get Preferences or redirect to preferences page.
 	$GLOBALS['phpgw']->preferences->read_repository();
-	if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail'] == null){
-		echo '<script>alert("' . lang('Dear user,\nthis is your first time in the ExpressoMail, your preferences must be saved.\nPlease, choose your preferences and click on the button Save.') . '")</script>';
-		echo "<script>location.href='./preferences.php'</script>";
-	}	
-
 ?>
 
