Index: trunk/expressoMail1_2/js/jscode/drag_area.js
===================================================================
--- trunk/expressoMail1_2/js/jscode/drag_area.js	(revision 2521)
+++ trunk/expressoMail1_2/js/jscode/drag_area.js	(revision 2529)
@@ -160,8 +160,8 @@
 document.onmousemove = function(e) {
 	var	_target = is_ie ? window.event.srcElement : e.target;
-	if(_dragArea._mousemove)
+	/*if(_dragArea._mousemove)
 		_dragArea._mousemove(e);
 	
-	else if(_dragArea.msg_number && _target.type != 'checkbox') {
+	else*/ if(_dragArea.msg_number && _target.type != 'checkbox') {
 		_dragArea.mouseMoveDrag(e);
 	}
Index: trunk/expressoMail1_2/index.php
===================================================================
--- trunk/expressoMail1_2/index.php	(revision 2519)
+++ trunk/expressoMail1_2/index.php	(revision 2529)
@@ -1,208 +1,204 @@
 <?php
 
-/***************************************************************************
-        * Expresso Livre                                                           *
-        * http://www.expressolivre.org                                             *
-        * --------------------------------------------                             *
-        *  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.                                              *
-        \**************************************************************************/
-		
-	$GLOBALS['phpgw_info']['flags'] = array(
-		//'noheader' => False,
-		//'nonavbar' => False,
-		'currentapp' => 'expressoMail1_2',
-		'update_version'	=> '1.235',
-		'enable_nextmatchs_class' => True
-	);
-
-	require_once('../header.inc.php');
-
-	include_once("inc/load_lang.php");
-
-	$_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
-
-	//Enable/Disable VoIP Service -> Voip Server Config
-	$voip_enabled = false;
-	$voip_groups = array();	
-	if($GLOBALS['phpgw_info']['server']['voip_groups']) {
-		$emailVoip = false;
-		foreach(explode(",",$GLOBALS['phpgw_info']['server']['voip_groups']) as $i => $voip_group){
-			$a_voip = explode(";",$voip_group);			
-			$voip_groups[] = $a_voip[1];
-		}
-		foreach($GLOBALS['phpgw']->accounts->membership() as $idx => $group){			
-			if(array_search($group['account_name'],$voip_groups) !== FALSE){		 
-				$voip_enabled = true;
-				$emailVoip = $GLOBALS['phpgw_info']['server']['voip_email_redirect'];
-				break;
-			}
+/**************************************************************************\
+* Expresso Livre                                                           *
+* http://www.expressolivre.org                                             *
+* --------------------------------------------                             *
+*  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.                                              *
+\**************************************************************************/
+
+$GLOBALS['phpgw_info']['flags'] = array(
+	//'noheader' => False,
+	//'nonavbar' => False,
+	'currentapp' => 'expressoMail1_2',
+	'update_version'	=> '1.235',
+	'enable_nextmatchs_class' => True
+);
+
+require_once('../header.inc.php');
+
+include_once("inc/load_lang.php");
+
+$_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
+
+//Enable/Disable VoIP Service -> Voip Server Config
+$voip_enabled = false;
+$voip_groups = array();
+if($GLOBALS['phpgw_info']['server']['voip_groups']) {
+	$emailVoip = false;
+	foreach(explode(",",$GLOBALS['phpgw_info']['server']['voip_groups']) as $i => $voip_group){
+		$a_voip = explode(";",$voip_group);
+		$voip_groups[] = $a_voip[1];
+	}
+	foreach($GLOBALS['phpgw']->accounts->membership() as $idx => $group){
+		if(array_search($group['account_name'],$voip_groups) !== FALSE){
+			$voip_enabled = true;
+			$emailVoip = $GLOBALS['phpgw_info']['server']['voip_email_redirect'];
+			break;
 		}
 	}
-
-	// Get Data from ldap_manager and emailadmin.
-	$ldap_manager = CreateObject('contactcenter.bo_ldap_manager');
-	$boemailadmin	= CreateObject('emailadmin.bo');
-	$emailadmin_profile = $boemailadmin->getProfileList();
-    // Loading Admin Config Module
-    $c = CreateObject('phpgwapi.config','expressoMail1_2');
-    $c->read_repository();
-    $current_config = $c->config_data;    
-
-	$_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
+}
+
+// Get Data from ldap_manager and emailadmin.
+$ldap_manager = CreateObject('contactcenter.bo_ldap_manager');
+$boemailadmin = CreateObject('emailadmin.bo');
+$emailadmin_profile = $boemailadmin->getProfileList();
+
+// Loading Admin Config Module
+$c = CreateObject('phpgwapi.config','expressoMail1_2');
+$c->read_repository();
+$current_config = $c->config_data;
+
+$_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
 //	$_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
-	$_SESSION['phpgw_info']['expressomail']['max_folders_to_show'] = $current_config['expressoMail_Max_folders_to_show'] ? $current_config['expressoMail_Max_folders_to_show'] : "200";
-	$_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server'];
-	$_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null;
-	$_SESSION['phpgw_info']['expressomail']['user']['email'] = $GLOBALS['phpgw']->preferences->values['email'];
-	
-	$preferences = $GLOBALS['phpgw']->preferences->read();
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = $preferences['expressoMail'];
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_enabled'] = $voip_enabled;
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_email_redirect'] = $emailVoip;
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['outoffice'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['outoffice'];
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number'] = $GLOBALS['phpgw_info']['user']['telephonenumber'];
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_cache'] = $current_config['expressoMail_enable_cache'];
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['number_of_contacts'] = $current_config['expressoMail_Number_of_dynamic_contacts'] ? $current_config['expressoMail_Number_of_dynamic_contacts'] : "0";
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['notification_domains'] = $current_config['expressoMail_notification_domains'];
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['googlegears_url'] = $current_config['expressoMail_googlegears_url'];	
-    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_assinar_criptografar'] = $GLOBALS['phpgw_info']['server']['use_assinar_criptografar'] ?  $GLOBALS['phpgw_info']['server']['use_assinar_criptografar'] : "0";
-    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital_cripto'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital_cripto'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital_cripto'] : "0";
-    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital'] : "0";
-    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['search_result_number'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['search_result_number'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['search_result_number'] : "50";
-    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['search_characters_number'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['search_characters_number'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['search_characters_number'] : "4";
-    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['num_max_certs_to_cipher'] = $GLOBALS['phpgw_info']['server']['num_max_certs_to_cipher'] ?  $GLOBALS['phpgw_info']['server']['num_max_certs_to_cipher'] : "10";
-    $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_signature_cripto'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_cripto'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_cripto'] : "0";
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['keep_after_auto_archiving'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['keep_after_auto_archiving'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['keep_after_auto_archiving'] : "0";
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size'] = $current_config['expressoMail_Max_attachment_size'] ? $current_config['expressoMail_Max_attachment_size']."M" : ini_get('upload_max_filesize'); 
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_email_per_page'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['max_email_per_page'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['max_email_per_page'] : "50";
-
-	$template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
-	$template->set_var("txt_loading",lang("Loading"));
-	$template->set_var("txt_clear_trash",lang("message(s) deleted from your trash folder."));
-    $template->set_var("new_message", lang("New Message"));
-	$template->set_var("lang_inbox", lang("Inbox"));
-    $template->set_var("refresh", lang("Refresh"));
-    $template->set_var("tools", lang("Tools"));	
-	$template->set_var("lang_Open_Search_Window", lang("Open search window") . '...');
-	$template->set_var("lang_search_user", lang("Search user") . '...'); 
-	$template->set_var("upload_max_filesize",ini_get('upload_max_filesize'));
-	$template->set_var("msg_folder",$_GET['msgball']['folder']);
-	$template->set_var("msg_number",$_GET['msgball']['msgnum'] ? $_GET['msgball']['msgnum'] : $_GET['to']);
-	$template->set_var("user_email",$_SESSION['phpgw_info']['expressomail']['user']['email']);
-
-	$acc = CreateObject('phpgwapi.accounts');
-
-	$template->set_var("user_organization", $acc->get_organization($GLOBALS['phpgw_info']['user']['account_dn']));
-	$template->set_var("cyrus_delimiter",$_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter']);	
-
-	// Fix problem with cyrus delimiter changes in preferences.
-	// Dots in names: enabled/disabled.
-	$save_in_folder = @eregi_replace("INBOX/", "INBOX".$_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'], $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder']);
-	$save_in_folder = @eregi_replace("INBOX.", "INBOX".$_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'], $save_in_folder);
-	$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder'] = $save_in_folder;
-	// End Fix.
-	
-	$template->set_file(Array('expressoMail' => 'index.tpl'));
-	$template->set_var( 'url', $GLOBALS[ 'phpgw' ] -> link( '/expressoMail1_2' ) );
-	$template->set_block('expressoMail','list');
-	$template->pfp('out','list');
-
-	$GLOBALS['phpgw']->common->phpgw_footer();
-
-    $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_enable_log_messages'] = $current_config['expressoMail_enable_log_messages'];
-
-    // Begin Set Anti-Spam options.
-    $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_ham'] = $current_config['expressoMail_command_for_ham'];
-    $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_spam'] = $current_config['expressoMail_command_for_spam'];
-    $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_use_spam_filter'] = $current_config['expressoMail_use_spam_filter'];   
-    echo '<script> var use_spam_filter = "' . $current_config['expressoMail_use_spam_filter'] . '"</script>';
-	// End Set Anti-Spam options.
-
-    // Set Imap Folder names options
-
-    $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'] 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']	? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']		: lang("Trash");
-    $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] 	: lang("Drafts");
-    $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'] 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']	? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']		: lang("Spam");
-    $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] 	? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] 		: lang("Sent");
-
-    // gera paramero com tokens suportados ....
-    $var_tokens = '';
-    for($ii = 1; $ii < 11; $ii++)
-    {
-        if($GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'])
-            $var_tokens .= $GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'] . ',';
-    }
-
-    if(!$var_tokens)
-    {
-        $var_tokens = 'ePass2000Lx;/usr/lib/libepsng_p11.so,ePass2000Win;c:/windows/system32/ngp11v211.dll';
-    }
-
-
-	if ( ! @is_object($GLOBALS['phpgw']->js ) )
-		$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
-
-	$GLOBALS['phpgw']->js->validate_file( 'dJSWin', 'dJSWin' );
-	$GLOBALS['phpgw']->js->validate_file( 'dftree', 'dftree' );
-
-	$GLOBALS['phpgw']->js->validate_file( 'modal', 'modal', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscalendar', 'calendar', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscalendar', 'calendar-setup', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscalendar', 'lang/calendar-br', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'globals', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'sniff_browser', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'common_functions', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'abas', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'doiMenuData', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'drag_area', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'draw_api', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'DropDownContacts', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'InfoContact', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'main', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'local_messages', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'messages_controller', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'rich_text_editor', 'expressoMail1_2' );
-	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'wfolders', 'expressoMail1_2' );
-
-	if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'])
-		$GLOBALS['phpgw']->js->validate_file( 'jscode', 'shortcut', 'expressoMail1_2' );
-
-	if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages'])
-		$GLOBALS['phpgw']->js->validate_file( 'jscode', 'gears_init', 'expressoMail1_2' );
-
-
-	$expressoMail_url = $GLOBALS[ 'phpgw' ] -> link( '/expressoMail1_2' );
-	$phpgwapi_url = $GLOBALS[ 'phpgw' ] -> link( '/phpgwapi' );
-
-	$script = '<link rel="stylesheet" type="text/css" href="' . $expressoMail_url . '/templates/' . $GLOBALS['phpgw_info']['server']['template_set'] . '/main.css">';
-	$script .= '<link rel="stylesheet" type="text/css" href="' . $phpgwapi_url . '/js/dftree/dftree.css">';
-	$script .= '<style type="text/css">@import url(' . $phpgwapi_url . '/js/jscalendar/calendar-win2k-1.css);</style>';
-	$script .= '<script type="text/javascript">var template = "' . $GLOBALS['phpgw_info']['server']['template_set'] . '";';
-	$script .= 'var special_folders = new Array(4);';
-	$script .= 'special_folders["'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'].'"] = \'Trash\';';
-	$script .= 'special_folders["'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'].'"] = \'Drafts\';';
-	$script .= 'special_folders["'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'].'"] = \'Spam\';';
-	$script .= 'special_folders["'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'].'"] = \'Sent\';';
-	$script .= 'var trashfolder = "'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'].'";';
-	$script .= 'var draftsfolder = "'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'].'";';
-	$script .= 'var sentfolder = "'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'].'";';
-	$script .= 'var spamfolder = "'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'].'";';
-	$script .= 'var token_param = "'.$var_tokens.'";';
-	$script .= 'var locale = "'.$GLOBALS['phpgw']->common->getPreferredLanguage().'";';
-	$script .= 'var account_id = ' . $GLOBALS['phpgw_info']['user']['account_id'] . ';var expresso_offline = false;</script>';
-	$script .= '</script>';
-
-	$update_version = $GLOBALS['phpgw_info']['flags']['update_version'];
-
-	echo $script
-		. $GLOBALS[ 'phpgw' ] -> common -> get_java_script( )
-		. '<script language="Javascript">expresso.connector.updateVersion = "'. $update_version . '";init();</script>';
-
-	// Get Preferences or redirect to preferences page.
-	$GLOBALS['phpgw']->preferences->read_repository();
-	//print_r($_SESSION['phpgw_info']['user']['preferences']['expressoMail']);
+$_SESSION['phpgw_info']['expressomail']['max_folders_to_show'] = $current_config['expressoMail_Max_folders_to_show'] ? $current_config['expressoMail_Max_folders_to_show'] : "200";
+$_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server'];
+$_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null;
+$_SESSION['phpgw_info']['expressomail']['user']['email'] = $GLOBALS['phpgw']->preferences->values['email'];
+
+$preferences = $GLOBALS['phpgw']->preferences->read();
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail'] = $preferences['expressoMail'];
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_enabled'] = $voip_enabled;
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_email_redirect'] = $emailVoip;
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['outoffice'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['outoffice'];
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number'] = $GLOBALS['phpgw_info']['user']['telephonenumber'];
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_cache'] = $current_config['expressoMail_enable_cache'];
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['number_of_contacts'] = $current_config['expressoMail_Number_of_dynamic_contacts'] ? $current_config['expressoMail_Number_of_dynamic_contacts'] : "0";
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['notification_domains'] = $current_config['expressoMail_notification_domains'];
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['googlegears_url'] = $current_config['expressoMail_googlegears_url'];
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_assinar_criptografar'] = $GLOBALS['phpgw_info']['server']['use_assinar_criptografar'] ?  $GLOBALS['phpgw_info']['server']['use_assinar_criptografar'] : "0";
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital_cripto'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital_cripto'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital_cripto'] : "0";
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_digital'] : "0";
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['search_result_number'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['search_result_number'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['search_result_number'] : "50";
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['search_characters_number'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['search_characters_number'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['search_characters_number'] : "4";
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['num_max_certs_to_cipher'] = $GLOBALS['phpgw_info']['server']['num_max_certs_to_cipher'] ?  $GLOBALS['phpgw_info']['server']['num_max_certs_to_cipher'] : "10";
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_signature_cripto'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_cripto'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_signature_cripto'] : "0";
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['keep_after_auto_archiving'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['keep_after_auto_archiving'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['keep_after_auto_archiving'] : "0";
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size'] = $current_config['expressoMail_Max_attachment_size'] ? $current_config['expressoMail_Max_attachment_size']."M" : ini_get('upload_max_filesize');
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_email_per_page'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['max_email_per_page'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['max_email_per_page'] : "50";
+
+$template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+$template->set_var("txt_loading",lang("Loading"));
+$template->set_var("txt_clear_trash",lang("message(s) deleted from your trash folder."));
+$template->set_var("new_message", lang("New Message"));
+$template->set_var("lang_inbox", lang("Inbox"));
+$template->set_var("refresh", lang("Refresh"));
+$template->set_var("tools", lang("Tools"));
+$template->set_var("lang_Open_Search_Window", lang("Open search window") . '...');
+$template->set_var("lang_search_user", lang("Search user") . '...');
+$template->set_var("upload_max_filesize",ini_get('upload_max_filesize'));
+$template->set_var("msg_folder",$_GET['msgball']['folder']);
+$template->set_var("msg_number",$_GET['msgball']['msgnum'] ? $_GET['msgball']['msgnum'] : $_GET['to']);
+$template->set_var("user_email",$_SESSION['phpgw_info']['expressomail']['user']['email']);
+
+$acc = CreateObject('phpgwapi.accounts');
+
+$template->set_var("user_organization", $acc->get_organization($GLOBALS['phpgw_info']['user']['account_dn']));
+$template->set_var("cyrus_delimiter",$_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter']);
+
+// Fix problem with cyrus delimiter changes in preferences.
+// Dots in names: enabled/disabled.
+$save_in_folder = @eregi_replace("INBOX/", "INBOX".$_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'], $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder']);
+$save_in_folder = @eregi_replace("INBOX.", "INBOX".$_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'], $save_in_folder);
+$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['save_in_folder'] = $save_in_folder;
+// End Fix.
+
+$template->set_file(Array('expressoMail' => 'index.tpl'));
+$template->set_var( 'url', $GLOBALS[ 'phpgw' ] -> link( '/expressoMail1_2' ) );
+$template->set_block('expressoMail','list');
+$template->pfp('out','list');
+
+$GLOBALS['phpgw']->common->phpgw_footer();
+
+$_SESSION['phpgw_info']['server']['expressomail']['expressoMail_enable_log_messages'] = $current_config['expressoMail_enable_log_messages'];
+
+// Begin Set Anti-Spam options.
+$_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_ham'] = $current_config['expressoMail_command_for_ham'];
+$_SESSION['phpgw_info']['server']['expressomail']['expressoMail_command_for_spam'] = $current_config['expressoMail_command_for_spam'];
+$_SESSION['phpgw_info']['server']['expressomail']['expressoMail_use_spam_filter'] = $current_config['expressoMail_use_spam_filter'];
+echo '<script> var use_spam_filter = "' . $current_config['expressoMail_use_spam_filter'] . '"</script>';
+// End Set Anti-Spam options.
+
+// Set Imap Folder names options
+$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'] 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']	? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']		: lang("Trash");
+$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] ? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'] 	: lang("Drafts");
+$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'] 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']	? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder']		: lang("Spam");
+$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder']	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] 	? $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'] 		: lang("Sent");
+
+// gera paramero com tokens suportados ....
+$var_tokens = '';
+for($ii = 1; $ii < 11; $ii++)
+{
+	if($GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'])
+		$var_tokens .= $GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'] . ',';
+}
+
+if(!$var_tokens)
+{
+	$var_tokens = 'ePass2000Lx;/usr/lib/libepsng_p11.so,ePass2000Win;c:/windows/system32/ngp11v211.dll';
+}
+
+
+if ( ! @is_object($GLOBALS['phpgw']->js ) )
+	$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
+
+$GLOBALS['phpgw']->js->validate_file( 'dJSWin', 'dJSWin' );
+$GLOBALS['phpgw']->js->validate_file( 'dftree', 'dftree' );
+
+$GLOBALS['phpgw']->js->validate_file( 'modal', 'modal', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscalendar', 'calendar', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscalendar', 'calendar-setup', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscalendar', 'lang/calendar-br', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'globals', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'sniff_browser', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'common_functions', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'abas', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'doiMenuData', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'drag_area', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'draw_api', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'DropDownContacts', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'InfoContact', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'main', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'local_messages', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'messages_controller', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'rich_text_editor', 'expressoMail1_2' );
+$GLOBALS['phpgw']->js->validate_file( 'jscode', 'wfolders', 'expressoMail1_2' );
+
+if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'])
+	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'shortcut', 'expressoMail1_2' );
+
+if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_local_messages'])
+	$GLOBALS['phpgw']->js->validate_file( 'jscode', 'gears_init', 'expressoMail1_2' );
+
+
+$expressoMail_url = $GLOBALS[ 'phpgw' ] -> link( '/expressoMail1_2' );
+$phpgwapi_url = $GLOBALS[ 'phpgw' ] -> link( '/phpgwapi' );
+
+$script = '<link rel="stylesheet" type="text/css" href="' . $expressoMail_url . '/templates/' . $GLOBALS['phpgw_info']['server']['template_set'] . '/main.css">';
+$script .= '<link rel="stylesheet" type="text/css" href="' . $phpgwapi_url . '/js/dftree/dftree.css">';
+$script .= '<style type="text/css">@import url(' . $phpgwapi_url . '/js/jscalendar/calendar-win2k-1.css);</style>';
+$script .= '<script type="text/javascript">var template = "' . $GLOBALS['phpgw_info']['server']['template_set'] . '";';
+$script .= 'var special_folders = new Array(4);';
+$script .= 'special_folders["'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'].'"] = \'Trash\';';
+$script .= 'special_folders["'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'].'"] = \'Drafts\';';
+$script .= 'special_folders["'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'].'"] = \'Spam\';';
+$script .= 'special_folders["'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'].'"] = \'Sent\';';
+$script .= 'var trashfolder = "'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'].'";';
+$script .= 'var draftsfolder = "'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultDraftsFolder'].'";';
+$script .= 'var sentfolder = "'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSentFolder'].'";';
+$script .= 'var spamfolder = "'.$_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultSpamFolder'].'";';
+$script .= 'var token_param = "'.$var_tokens.'";';
+$script .= 'var locale = "'.$GLOBALS['phpgw']->common->getPreferredLanguage().'";';
+$script .= 'var account_id = ' . $GLOBALS['phpgw_info']['user']['account_id'] . ';var expresso_offline = false;</script>';
+$script .= '</script>';
+
+$update_version = $GLOBALS['phpgw_info']['flags']['update_version'];
+
+echo $script
+	. $GLOBALS[ 'phpgw' ] -> common -> get_java_script( )
+	. '<script language="Javascript">expresso.connector.updateVersion = "'. $update_version . '";init();</script>';
 ?>
 <!-----Expresso Mail - Version Updated:<?=$update_version?>-------->
