Index: /trunk/instant_messenger/index2.php
===================================================================
--- /trunk/instant_messenger/index2.php	(revision 20)
+++ /trunk/instant_messenger/index2.php	(revision 20)
@@ -0,0 +1,60 @@
+<?php
+$GLOBALS['phpgw_info']['flags'] = array
+(
+  'noheader'                => true,
+  'nonavbar'                => true,
+  'currentapp'              => 'instant_messenger',
+  'update_version'          => '1.2019',
+  'enable_nextmatchs_class' => false
+);
+
+require_once "../header.inc.php";
+
+$_SESSION['phpgw_info']['instant_messenger']['user']            	  = $GLOBALS['phpgw_info']['user']['account_lid'];
+$_SESSION['phpgw_info']['instant_messenger']['passwd']          	  = $GLOBALS['phpgw_info']['user']['passwd'];
+$_SESSION['phpgw_info']['instant_messenger']['name_jabber']     	  = $GLOBALS['phpgw_info']['server']['name_jabber'];
+$_SESSION['phpgw_info']['instant_messenger']['port_jabber']     	  = $GLOBALS['phpgw_info']['server']['port_jabber'];
+$_SESSION['phpgw_info']['instant_messenger']['resource_jabber'] 	  = $GLOBALS['phpgw_info']['server']['resource_jabber'];
+$_SESSION['phpgw_info']['instant_messenger']['send_file_jabber']	  = $GLOBALS['phpgw_info']['server']['send_file_jabber'];
+//Conf. Ldap
+$_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']    = $GLOBALS['phpgw_info']['server']['server_ldap_jabber'];
+$_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']   = $GLOBALS['phpgw_info']['server']['context_ldap_jabber'];
+$_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']      = $GLOBALS['phpgw_info']['server']['user_ldap_jabber'];
+$_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber']  = $GLOBALS['phpgw_info']['server']['password_ldap_jabber'];
+$_SESSION['phpgw_info']['instant_messenger']['size_file_jabber']  	  = $GLOBALS['phpgw_info']['server']['size_file_jabber'];	
+
+$_SESSION['phpgw_info']['instant_messenger']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name'];
+$_SESSION['phpgw_info']['instant_messenger']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host'];
+$_SESSION['phpgw_info']['instant_messenger']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port'];
+$_SESSION['phpgw_info']['instant_messenger']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user'];
+$_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass'];
+$_SESSION['phpgw_info']['instant_messenger']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type'];
+
+$webserver_url = $_SESSION['phpgw_info']['instant_messenger']['path'];
+
+$js = array(
+               $webserver_url . 'js/xml.js',
+               $webserver_url . 'js/json.js',
+               $webserver_url . 'js/im_connector.js',
+               $webserver_url . 'js/im_fcommon.js',
+               $webserver_url . 'js/im_var_globals.js',
+               $webserver_url . 'js/im_images.js',
+               $webserver_url . 'js/im_templates.js',
+               $webserver_url . 'js/im_functions.js',
+               $webserver_url . 'inc/load_lang.php',
+               $webserver_url . 'js/im_win.js',
+               $webserver_url . 'js/im_menu_action.js',
+               $webserver_url . 'js/im_conf_font.js',
+               $webserver_url . 'js/im_sincro.js',
+               $webserver_url . 'js/im_preferences.js'
+            );
+
+$_js = 'new_js = new Array();';
+foreach ( $js as $key => $val )
+   $_js .= 'new_js[' . $key . '] = \'' . $val . '?' . filemtime($_SERVER['DOCUMENT_ROOT'] . '/' . $val) . '\';';
+
+print $_js;
+print 'var im_send_file="' . $_SESSION['phpgw_info']['instant_messenger']['send_file_jabber'] . '";';
+print 'var im_path="' . $webserver_url . '";IM_loadScript("' . $webserver_url . 'js/im_init.js?' . filemtime($_SERVER['DOCUMENT_ROOT'] . '/' . $webserver_url . 'js/im_init.js') . '")';
+
+?>
Index: /trunk/instant_messenger/setup/tables_current.inc.php
===================================================================
--- /trunk/instant_messenger/setup/tables_current.inc.php	(revision 20)
+++ /trunk/instant_messenger/setup/tables_current.inc.php	(revision 20)
@@ -0,0 +1,24 @@
+<?php
+	/***************************************************************************\
+	* Mensageiro Instantâneo												    *
+	* Alexandre Correia / Rodrigo Souza										    *
+	* ------------------------------------------------------------------------- *
+	*  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.                                               *
+	\***************************************************************************/
+  
+	$phpgw_baseline = array(
+		'phpgw_im_auth_user' => array(
+			'fd' => array(
+				'im_from' => array( 'type' => 'varchar', 'precision' => 150, 'nullable' => false ),
+				'im_to' => array( 'type' => 'varchar', 'precision' => 150, 'nullable' => false )
+			),
+			'pk' => array(),
+			'fk' => array(),
+			'ix' => array(),
+			'uc' => array()
+		),
+	);
+?>
Index: /trunk/instant_messenger/setup/setup.inc.php
===================================================================
--- /trunk/instant_messenger/setup/setup.inc.php	(revision 20)
+++ /trunk/instant_messenger/setup/setup.inc.php	(revision 20)
@@ -0,0 +1,34 @@
+<?php
+	/****************************************************\
+	 * Im - Instant Messenger							*
+	 * Alexandre Correia								*
+	 * Rodrigo Souza									*
+	\****************************************************/
+	
+	$setup_info['instant_messenger']['name']      	= 'instant_messenger';
+	$setup_info['instant_messenger']['title']     	= 'Mensageiro Instantâneo';
+	$setup_info['instant_messenger']['version']   	= '0.001';
+	$setup_info['instant_messenger']['app_order'] 	= 9;
+	$setup_info['instant_messenger']['enable']    	= 1;
+	
+	/* Conf Table */
+	$setup_info['instant_messenger']['tables'][] = 'phpgw_im_auth_user';
+
+	$setup_info['instant_messenger']['author'] 			= '<b>Coordenadores do Projeto</b> : <br> - Joao Alfredo Knopik Junior (jakjr@celepar.pr.gov.br)<br> - Nilton Emilio Buhrer Neto (niltonneto@celepar.pr.gov.br)<br> <b>Desenvolvedores</b> <br> - Alexandre Correia (alexandrecorreia@celepar.pr.gov.br)<br>- Rodrigo Souza Santos (rodsouza@celepar.pr.gov.br)';
+	$setup_info['instant_messenger']['maintainer']	 	=  'Os mesmos';
+	$setup_info['instant_messenger']['maintainer_email']= '';
+
+	$setup_info['instant_messenger']['license']  	= 'GPL';
+	$setup_info['instant_messenger']['description'] = 'Módulo de IM com protocolo Jabber';
+
+	/* The hooks this app includes, needed for hooks registration */
+	$setup_info['instant_messenger']['hooks'][] = 'preferences';
+	$setup_info['instant_messenger']['hooks'][] = 'admin';
+	$setup_info['instant_messenger']['hooks'][] = 'home';	
+	
+	/* Dependencies for this app to work */
+	$setup_info['instant_messenger']['depends'][] = array(
+		'appname' => 'phpgwapi',
+		'versions' => Array('0.9.14','0.9.15','1.0.0')
+	);
+?>
Index: /trunk/instant_messenger/xsl/window.xsl
===================================================================
--- /trunk/instant_messenger/xsl/window.xsl	(revision 20)
+++ /trunk/instant_messenger/xsl/window.xsl	(revision 20)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="html" omit-xml-declaration="yes"/>
+
+<xsl:template match="/window">
+   <html>
+   <head>
+   </head>
+   <body>
+      <div id="{@id}_im_window_master" class="master" style="top:{@top};left:{@left};height:{(@height + 48)};width:{(@width + 12)};{@style}">
+         <div id="{@id}_im_window" class="pai" style="height:{(@height + 40)}">
+            <div class="tit"><xsl:value-of select="@title" /></div>
+            <xsl:apply-templates select="/" mode='buttons' />
+            <div class="filho" id="{@id}_im_window_body_inner" style="width:{@width};height:{@height}" />
+         </div>
+      </div>
+      <div class="im-windowfantom-des" id="{@id}_im_window_fantom" />
+      <div class="im-windowfantom-des" id="{@id}_im_window_movable" />
+      <div class="im-window-resizehandle" id="{@id}_im_window_resize" />
+   </body>
+   </html>
+</xsl:template>
+
+<xsl:template match="/window" mode="buttons">
+   <xsl:if test='@close and @close="true"'>
+      <div class="im-window-button im-window-closebutton" style="z-index:6000;right:4px" onclick="im_win.windowClose(this.parentNode.id);" />
+   </xsl:if>
+
+   <xsl:if test='@maximize and @maximize="true"'>
+      <xsl:choose>
+         <xsl:when test='@close and @close="true"'>
+            <div class="im-window-button im-window-maximizerestorebutton" style="z-index:6000;right:20px" onclick="im_win.windowMaximizeRestore(this.parentNode.id);" />
+         </xsl:when>
+         <xsl:otherwise>
+            <div class="im-window-button im-window-maximizerestorebutton" style="z-index:6000;right:4px" onclick="im_win.windowMaximizeRestore(this.parentNode.id);" />
+         </xsl:otherwise>
+      </xsl:choose>
+   </xsl:if>
+
+   <xsl:if test='@minimize and @minimize="true"'>
+      <xsl:choose>
+         <xsl:when test='@close and @close="true" and @maximize and @maximize="true"'>
+            <div class="im-window-button im-window-minimizebutton" style="z-index:6000;right:36px" onclick="im_win.windowMinimize(this.parentNode.id);" />
+         </xsl:when>
+         <xsl:when test='(@close and @close="true" or @maximize and @maximize="true") and not (@close and @close="true" and @maximize and @maximize="true")'>
+            <div class="im-window-button im-window-minimizebutton" style="z-index:6000;right:20px" onclick="im_win.windowMinimize(this.parentNode.id);" />
+         </xsl:when>
+         <xsl:otherwise>
+            <div class="im-window-button im-window-minimizebutton" style="z-index:6000;right:4px" onclick="im_win.windowMinimize(this.parentNode.id);" />
+         </xsl:otherwise>
+      </xsl:choose>
+   </xsl:if>
+</xsl:template>
+
+</xsl:stylesheet>
Index: /trunk/instant_messenger/controller.php
===================================================================
--- /trunk/instant_messenger/controller.php	(revision 20)
+++ /trunk/instant_messenger/controller.php	(revision 20)
@@ -0,0 +1,90 @@
+<?php
+	//	Explode action from cExecuteForm function
+	$cExecuteFormReturn = false;
+ 	if($_POST['_action']) { 		
+ 		if($_FILES) {
+ 			$count_files = $_POST['countFiles'];
+			$array_files = array(); 		
+ 			for($idx = 1; $idx <= $count_files; $idx++) { 		
+ 				if($_FILES['file_'.$idx] && !$_FILES['file_'.$idx]['error'])
+ 					$array_files[] = $_FILES['file_'.$idx]; 					 
+ 			}
+ 			$_POST['FILES'] = $array_files;
+ 		} 		  		
+ 		list($app,$class,$method) = explode('.',@$_POST['_action']);
+ 		$cExecuteFormReturn = true;
+ 	}
+ 	//	Explode action from cExecute function
+ 	else if($_GET['action'])
+		list($app,$class,$method) = explode('.',@$_GET['action']);
+	// NO ACTION
+	else
+		return $_SESSION['response'] = 'false';
+	
+	// Load dinamically class file.
+	if($app == '$this')
+		$filename = 'inc/class.'.$class.'.inc.php';
+	else
+		$filename = '../'.$app.'/inc/class.'.$class.'.inc.php';
+		
+	include_once($filename);	
+	
+	// Create new Object  (class loaded).	
+	$obj = new $class;
+	
+	// Prepare parameters for execution.	
+	$params = array();
+	
+	// If array $_POST is not null , the submit method is POST. 
+	if($_POST) {
+		$params = $_POST;
+	}
+	// If array $_POST is null , and the array $_GET > 1, the submit method is GET.
+	else if(count($_GET) > 1)	{		
+		array_shift($_GET);
+		$params = $_GET;
+	}
+
+	$result = array();
+	
+	
+	// if params is not empty, then class method with parameters.	
+	if($params)
+		$result = $obj -> $method($params);
+	else 		
+		$result = $obj -> $method();
+		
+	// Return result json string into xml object.	
+	if(!$cExecuteFormReturn)
+   {
+      encode($result, 'encode');
+      $result = ( !is_object($result) && !is_array($result) ) ? $result : json_encode($result);
+
+		$dom = new DOMDocument;//('1.0', 'UTF-8');
+
+		$root = $dom->appendChild(new DOMElement('retorno'));
+		$root->appendChild($dom->createCDATASection($result));
+
+		$retorno = $dom->saveXML();
+      header('Pragma: anytextexeptno-cache', true);
+      header('Content-type: text/xml');
+		print $retorno;
+   }
+	else
+		$_SESSION['response'] = $result;
+
+   function encode(&$item, $val = 'encode')
+   {
+      switch( gettype($item) )
+      {
+         case 'object' :
+                     $item = get_object_vars($item);
+                     encode($item);
+         break;
+         case 'array' :
+                     array_walk_recursive($item, 'encode');
+         break;
+         default : $item = utf8_encode($item);
+      }
+   }
+?>
Index: /trunk/instant_messenger/inc/class.XML.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.XML.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/class.XML.inc.php	(revision 20)
@@ -0,0 +1,139 @@
+<?php
+/*
++------------------------------------------------+
+| @AUTHOR: [NUTS] Rodrigo Souza                  |
+| @DATE: Seg 18 Dez 2006 09:32:04 BRST           |
+| @LAST CHANGE: Qua 20 Dez 2006 16:14:11 BRST::  |
++------------------------------------------------+
+*/
+
+class XML
+{
+   function __construct()
+   {
+   }
+
+   function __destruct()
+   {
+   }
+
+	final function xmlize($data, $white=1, $encoding='UTF-8')
+   {
+		$data = trim($data);
+		$vals = $index = $array = array();
+		$parser = xml_parser_create($encoding);
+
+		xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
+		xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, $white);
+		//xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
+
+      xml_parse_into_struct($parser, $data, $vals, $index);
+      /*
+      if ( !xml_parse_into_struct($parser, $data, $vals, $index) )
+      {
+         die(sprintf("XML error: %s at line %d",
+            xml_error_string(xml_get_error_code($parser)),
+            xml_get_current_line_number($parser)));
+      }
+      */
+
+		xml_parser_free($parser);
+
+		$i = 0;
+
+		$tagname = $vals[$i]['tag'];
+		if ( isset ($vals[$i]['attributes'] ) )
+		{
+			$array[$tagname]['@'] = $vals[$i]['attributes'];
+		}
+      else
+      {
+			$array[$tagname]['@'] = array();
+		}
+
+		$array[$tagname]["#"] = $this->_xml_depth($vals, $i);
+
+		return $array;
+	}
+
+	private final function _xml_depth($vals, &$i)
+   {
+		$children = array();
+
+		if ( isset($vals[$i]['value']) )
+		{
+			array_push($children, $vals[$i]['value']);
+		}
+
+		while ( ++$i < count($vals) )
+      {
+			switch ($vals[$i]['type'])
+         {
+				case 'open':
+                           if ( isset ( $vals[$i]['tag'] ) )
+                           {
+                              $tagname = $vals[$i]['tag'];
+                           }
+                           else
+                           {
+                              $tagname = '';
+                           }
+
+                           if ( isset ( $children[$tagname] ) )
+                           {
+                              $size = sizeof($children[$tagname]);
+                           }
+                           else
+                           {
+                              $size = 0;
+                           }
+
+                           if ( isset ( $vals[$i]['attributes'] ) )
+                           {
+                              $children[$tagname][$size]['@'] = $vals[$i]["attributes"];
+                           }
+
+                           $children[$tagname][$size]['#'] = $this->_xml_depth($vals, $i);
+            // end case 'open'
+				break;
+				case 'cdata':
+                           array_push($children, $vals[$i]['value']);
+            // end case 'cdata'
+				break;
+				case 'complete':
+                           $tagname = $vals[$i]['tag'];
+
+                           if( isset ($children[$tagname]) )
+                           {
+                              $size = sizeof($children[$tagname]);
+                           }
+                           else
+                           {
+                              $size = 0;
+                           }
+
+                           if( isset ( $vals[$i]['value'] ) )
+                           {
+                              $children[$tagname][$size]["#"] = $vals[$i]['value'];
+                           }
+                           else
+                           {
+                              $children[$tagname][$size]["#"] = array();
+                           }
+
+                           if ( isset ($vals[$i]['attributes']) )
+                           {
+                              $children[$tagname][$size]['@'] = $vals[$i]['attributes'];
+                           }
+            // end case 'complete'
+ 				break;
+				case 'close':
+                           return $children;
+            // end case 'close'
+            break;
+			}
+		}
+		return $children;
+	}
+}
+?>
Index: /trunk/instant_messenger/inc/im_acl.inc.php
===================================================================
--- /trunk/instant_messenger/inc/im_acl.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/im_acl.inc.php	(revision 20)
@@ -0,0 +1,64 @@
+<?php
+   for ( $i = 0; $i < sizeof($GLOBALS['phpgw_info']['user']['acl']); $i++ )
+      if ( $GLOBALS['phpgw_info']['user']['acl'][$i]['appname'] == 'instant_messenger')
+      {
+         $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
+         $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
+
+         if ( strrpos($webserver_url, '/') === false || strrpos($webserver_url, '/') != (strlen($webserver_url)-1) )
+            $webserver_url .= '/';
+
+         $INSTANT_MESSENGER_PATH = $webserver_url . 'instant_messenger/';
+
+         $_SESSION['phpgw_info']['instant_messenger']['path'] = $INSTANT_MESSENGER_PATH;
+
+         /*
+          *
+          * Os método PORTA (PROGRAMAÇÂO ORIENTADA A RECURSO TÉCNICO ALTERNATIVO) mais exatamente
+          * métodos POG (PROGRAMAÇÂO ORIENTADO A GAMBIARRA) usados a seguir é devido a integração
+          * dos diverso módulos do expresso com o mensageiro instantâneo e para manter a aplicação
+          * crossbrowser!
+          *
+          * [NUTS] Rodrigo Souza - 29/01/2007
+          *
+          */
+         print '
+               <script>
+                  ini_wzdd = false;
+                  function IM_loadScript(pFile)
+                  {
+                     head = document.getElementsByTagName(\'head\').item(0);
+                     eScript = document.createElement("script");
+                     eScript.setAttribute(\'src\', pFile);
+                     head.appendChild(eScript);
+                  }
+                  if ( !window.dd )
+                  {
+                     ini_wzdd = true;
+                     document.write(\'\<script src="' . $INSTANT_MESSENGER_PATH . 'js/wz_dragdrop.js"\>\<\/script\>\');
+                  }
+               </script>';
+         /*
+          *
+          * isso se faz necessário para que não seja carregado duas vezes o arquivo wz_dragdrop
+          * e que a função SET_DHTML seja executada uma única vez, caso contrário causa um erro
+          * que finaliza a execução de todos as chamadas javascript em execução e as futuras
+          * chamadas também não serão executadas
+          *
+          */
+         print '
+               <script>
+                  if ( ini_wzdd ) SET_DHTML("backFantom"+NO_DRAG);
+                  setTimeout(\'IM_loadScript("' . $INSTANT_MESSENGER_PATH . 'index2.php")\',5000);
+               </script>';
+         /*
+          *
+          * instrução break utilizada decorrente ao fato que o usuário pode ter multiplas permissão de
+          * acesso ao modulo de mensagem instantanea ou seja pode possuir permissão tanto nos diversos
+          * grupos que faz parte assim como permissão individual de acesso (permissão de acesso dada
+          * especificamente ao usuaário)
+          *
+          */
+         break;
+      }
+?>
Index: /trunk/instant_messenger/inc/class.contacts_im.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.contacts_im.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/class.contacts_im.inc.php	(revision 20)
@@ -0,0 +1,74 @@
+<?php
+
+require_once "class.ldap_im.inc.php";
+require_once "class.db_im.inc.php"; 
+
+class contacts_im
+{
+	private $ldap_users;
+	private $db_user;
+	
+	function __construct()
+	{
+		$this->ldap_users = new ldap_im();
+		$this->db_user = new db_im();		
+	}
+		
+	function list_contacts($param)
+	{
+		$org_ldap = $param['ou'];
+		$array_db = $this->db_user->get_accounts_acl();
+		$array_groups_ldap = array();
+		$j = 0;
+
+		for($i=0 ; $i < count($array_db); $i++)
+			$array_1[] = $this->ldap_users->list_users_ldap($org_ldap,"uidNumber", $array_db[$i]['acl_account']);
+	
+		for($i=0; $i < count($array_1); $i++){
+			if(array_key_exists("count",$array_1[$i])){
+				$array_groups_ldap[] = $array_1[$i]['uidnumber'];
+			}		
+		}
+	
+		for($i=0; $i < count($array_groups_ldap); $i++)
+			$array_2[]['members'] = $this->ldap_users->list_groups_ldap($org_ldap,$array_groups_ldap[$i]);
+	
+		foreach($array_2 as $tmp){
+			if($tmp['members'] > 0){
+				foreach($tmp['members'] as $tmp1)	
+					$array_3[] = $tmp1;
+			}
+		}
+		
+		for($i=0; $i < count($array_1); $i++)
+			if($array_1[$i]['uid'] != "")
+				$array_3[] = $array_1[$i]['uid'];
+	
+		@natsort($array_3);
+		$array_4 = @array_values(@array_unique($array_3));
+		
+		for($i=0; $i < count($array_4); $i++)
+			$array_5[] = $this->ldap_users->list_users_ldap($org_ldap,"uid", $array_4[$i]);
+
+		for($i=0 ; $i < count($array_5); $i++){
+			if($array_5[$i]['phpgwAccountVisible'] != "-1"){
+				$array_6[] = $array_5[$i]['cn'] . ";" . $array_5[$i]['mail'];
+			}
+		}
+		
+		sort($array_6);	
+
+		for($i=0; $i < count($array_6); $i++){
+			$aux = explode(";", $array_6[$i]);
+			$array_7[$j]['cn'] = $aux[0];
+			$array_7[$j]['mail'] = $aux[1];			
+			$j++;
+		}
+		
+		if(count($array_7) > 0)
+			return $array_7;
+		else
+			return false;
+	}
+}
+?>
Index: /trunk/instant_messenger/inc/class.upload.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.upload.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/class.upload.inc.php	(revision 20)
@@ -0,0 +1,81 @@
+<?php
+class upload
+{
+	
+	private $pathToSave;
+	private $ArrayFiles;
+
+	function __construct()
+	{
+		ini_set("session.save_path","/php_sessions");
+		$this->pathToSave = ini_get("session.save_path");
+		$this->ArrayFiles = array (
+			"server" => $_SERVER['SERVER_ADDR'],
+			"path" => $_SESSION['phpgw_info']['instant_messenger']['path'],
+			"filePhp" => "inc/class.download.inc.php?file="
+		);
+
+	}
+
+	public function Load_file($Array_FILES)
+	{
+
+		$maxsize = ini_get('upload_max_filesize');
+	    if (!is_numeric($maxsize)) {
+		   if (strpos($maxsize, 'M') !== false){
+		       $maxsize = intval($maxsize)*1024*1024;
+		   }elseif (strpos($maxsize, 'K') !== false){
+		       $maxsize = intval($maxsize)*1024;
+		   }elseif (strpos($maxsize, 'G') !== false){
+		       $maxsize = intval($maxsize)*1024*1024*1024;
+		   }
+		}
+
+		if ($Array_FILES['file']['name'] != '') {
+			$tmp_name = $Array_FILES['file']['tmp_name'];
+			$file = trim(md5(time()) . "_IM_SendFile_" . $Array_FILES['file']['name']);
+			$this->ArrayFiles['fileUp'] = $file;
+			unset ($_SESSION['instant_messenger']['fileIM']);
+
+			$_SESSION['instant_messenger']['fileIM']['name_file'] = $file;
+			$_SESSION['instant_messenger']['fileIM']['size_file'] = $Array_FILES['file']['size'];
+			$_SESSION['instant_messenger']['fileIM']['ArrayServer'] = serialize($this->ArrayFiles);
+			$this->upload_file($tmp_name, $file);
+		}
+	}
+
+	public function upload_file($tmp_name, $file)
+	{
+		if (!move_uploaded_file($tmp_name, $this->pathToSave ."/". $file)) {
+			echo "<script>alert('Erro no Upload!')</script>";
+		}
+	}
+
+	public function size_file()
+	{
+		$Name_file = $_SESSION['instant_messenger']['fileIM']['name_file'];
+		$Size_file = $_SESSION['instant_messenger']['fileIM']['size_file'];
+
+		if (intval($Size_file / 1024) == intval(filesize($this->pathToSave ."/". $Name_file) / 1024)) {
+			// ALEXANDRE CORREIA - MEIO XUNXXO
+			//return "1-A : " . intval($Size_file / 1024). "---" ."U : " . intval(filesize($this->pathToSave.$Name_file) / 1024);
+			return true;
+		} else {
+			// ALEXANDRE CORREIA - MEIO XUNXXO
+			//return "2-A : " . intval($Size_file / 1024). "---" ."U : " . intval(filesize($this->pathToSave.$Name_file) / 1024);
+			return false;
+		}
+	}
+
+	public function name_file()
+	{
+		return base64_encode($_SESSION['instant_messenger']['fileIM']['ArrayServer']);
+	}
+}
+
+// Requisições via POST
+if (isset ($_POST['to'])) {
+	$Obj_up = new upload();
+	$Obj_up->Load_file($_FILES);
+}
+?>
Index: /trunk/instant_messenger/inc/hook_admin.inc.php
===================================================================
--- /trunk/instant_messenger/inc/hook_admin.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/hook_admin.inc.php	(revision 20)
@@ -0,0 +1,22 @@
+<?php
+	/**************************************************************************\
+	* eGroupWare                                                               *
+	* http://www.egroupware.org                                                *
+	* Written by Joseph Engo <jengo@phpgroupware.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.                                              *
+	\**************************************************************************/
+
+// Only Modify the $file and $title variables.....
+	$title = 'instant_messenger';
+	$file = array(
+		'Site Configuration'	=> $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)
+	);
+	
+//Do not modify below this line
+	display_section($appname,$title,$file);
+
+?>
Index: /trunk/instant_messenger/inc/load_lang.php
===================================================================
--- /trunk/instant_messenger/inc/load_lang.php	(revision 20)
+++ /trunk/instant_messenger/inc/load_lang.php	(revision 20)
@@ -0,0 +1,26 @@
+<?
+// Load the lang of the module.
+	if(!$_SESSION['phpgw_info']['instant_messenger']['lang']) 
+	{
+		$array_keys = array();
+		$fn = '../setup/phpgw_pt-br.lang';			
+		if (file_exists($fn)){
+			$fp = fopen($fn,'r');
+			while ($data = fgets($fp,16000))	{
+				list($message_id,$app_name,$null,$content) = explode("\t",substr($data,0,-1));			
+				$_SESSION['phpgw_info']['instant_messenger']['lang'][$message_id] =  $content;
+			}
+			fclose($fp);
+		}
+	}
+	$script  = "IM.array_lang_im[0] = new Array();";
+	$script .= "IM.array_lang_im[1] = new Array();";		
+	$i = 0;
+	foreach($_SESSION['phpgw_info']['instant_messenger']['lang'] as $key => $value) {		
+		$script .= "IM.array_lang_im[0][".$i."] = '".str_replace("'","\'",strtolower($key))."';";		
+		$script .= "IM.array_lang_im[1][".$i."] = '".str_replace("'","\'",$value)."';";
+		$i++;					
+	}
+	
+	echo $script;
+?>
Index: /trunk/instant_messenger/inc/class.Jabber.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.Jabber.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/class.Jabber.inc.php	(revision 20)
@@ -0,0 +1,251 @@
+<?php
+/*
++-------------------------------------------------------------------------+
+| @FILE_NAME:   class.Jabber.inc.php                                      |
+| @CLASS_NAME:  Jabber                                                    |
+|                                                                         |
+| @AUTHOR:      Alexandre Correia    - alexandrecorreia@celepar.pr.gov.br |
+|               [NUTS] Rodrigo Souza - rodsouza@celepar.pr.gov.br         |
+|                                                                         |
+| @DATE:        Seg 18 Dez 2006 10:10:59 BRST                             |
+| @LAST_CHANGE: Qui 21 Dez 2006 09:10:28 BRST::                           |
+|                                                                         |
+| @BRIEF:       Classe para acesso e comunicação ao                       |
+|               Servidor Jabberd2 com TLS                                 |
++-------------------------------------------------------------------------+
+*/
+
+require_once "class.Socket.inc.php";
+require_once "class.XML.inc.php";
+
+class Jabber extends Socket
+{
+	private $charset;
+
+	private $server;
+	private $port;
+						
+	private $username;
+	private $password;
+
+	private $jid;
+	private $resource;
+
+	private $log_error = false;
+	
+	private $array_teste = array();
+
+	function __construct($pJid = false, $pPassword = false, $pPort = false)
+	{
+      if ( $pJid && $pPassword )
+      {
+         $this->xml = new XML();
+         $this->charset = 'UTF-8';
+         
+         $this->jid        = substr($pJid, 0, strpos($pJid, '/'));
+
+         $this->username   = substr($pJid, 0, strpos($pJid, '@'));
+         $this->password   = $pPassword;
+
+         $pJid = substr($pJid, strpos($pJid, '@')+1);
+         $this->resource   = substr($pJid, strpos($pJid, '/')+1);
+
+         $this->server     = substr($pJid, 0, strpos($pJid, '/'));;
+         $this->port       = $pPort ? $pPort : 5222;
+
+         if ( $this->open('tcp://'.$this->server.':'.$this->port, 1, 1) )
+            $this->setConnect();
+      }
+      else
+      {
+         // LOG ERRO
+      }
+	}
+
+	function __destruct()
+	{
+	}
+
+   /*
+    * funcoes derivadas de outras classes
+    */
+   protected final function xmlize($pXML)
+   {
+      return $this->xml->xmlize($pXML);
+   }
+   
+	protected final function sendPacket($pPacket)
+	{
+		return $this->write($pPacket);
+	}
+
+   /*
+    * funcoes implementadas nesta classe
+    */
+
+   /*
+    * funcoes privadas
+    */
+	private final function _iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false )
+	{
+		$xml  = "<iq type='" . $pType . "' id='" . $pId . "'";
+		$xml .= ( $pTo ) ? " to='" . $pTo . "'" : "";
+		$xml .= ( $pFrom ) ? " from='" . $pFrom . "'" : "";
+
+		if ( $pXmlns == "vcard-temp" )
+      {
+			$xml .= ">";
+			$xml .= $pLoad;
+		}
+      else
+      {
+			$xml .= "><query xmlns='" . $pXmlns . "'";
+			$xml .= ( $pLoad ) ? ">" . $pLoad . "</query>" : "/>";
+		}
+
+		$xml .= "</iq>";
+		
+		return $xml;	
+	}
+
+   private final function authPlain()
+   {
+		$xml  = "<username>" . $this->username . "</username>";
+		$xml .= "<password>" . $this->password . "</password>";
+		$xml .= "<resource>" . $this->resource . "</resource>";
+
+		if ( !$this->sendIq('set', 'auth_1', NULL, NULL, "jabber:iq:auth", $xml) )
+      	{
+		   return false;
+		}
+      	usleep(90000);
+   }
+
+   private function setConnect()
+   {
+      $xml  = "<?xml version='1.0' encoding='UTF-8'?><stream:stream to='" . $this->server . "' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>";
+      $this->write($xml);
+      $xml = $this->read();
+
+      $xml = $this->xmlize($xml);
+
+      if ( @array_key_exists('starttls', $xml['stream:stream']['#']['stream:features']['0']['#']) &&
+           @array_key_exists('required', $xml['stream:stream']['#']['stream:features']['0']['#']['starttls']['0']['#']) )
+         $this->setTLS();
+      else
+         $this->simple_authentication();		
+   }
+
+   private function setTLS()
+   {
+      $xml = "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>";
+      $this->write($xml);
+
+      $xml = $this->read();
+      $xml = $this->xmlize($xml);
+
+      if ( array_key_exists('proceed', $xml) )
+      {
+		   stream_socket_enable_crypto($this->returnSocket(), TRUE, STREAM_CRYPTO_METHOD_SSLv23_CLIENT);
+
+         $xml = "<stream:stream to='" . $this->server . "' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>";
+         $this->write($xml);
+
+         $xml = $this->read();
+         $xml = $this->xmlize($xml);
+
+         socket_set_blocking($this->returnSocket(), 0);
+
+         $this->authPlain();
+      }
+      else
+      {
+         // LOG ERRO
+      }
+   }
+
+   private function simple_authentication()
+   {
+         socket_set_blocking($this->returnSocket(), 0);
+         
+         $this->authPlain();
+   }
+
+   /*
+    * funcoes do pacote
+    */
+
+	protected final function presence($pType = false, $pTo = false, $pShow = false, $pStatus = false, $pPriority = false)
+	{
+		$xml  = "<presence";
+		$xml .= ($pTo)   ? " to='{$pTo}'" : '';
+		$xml .= ($pType) ? " type='{$pType}'" : '';
+		$xml .= ($pStatus || $pShow || $pPriority) ? ">" : "/>";
+
+		$xml .= ($pStatus)   ? "	<status>{$pStatus}</status>" : '';
+		$xml .= ($pShow)     ? "	<show>{$pShow}</show>" : '';
+		$xml .= ($pPriority) ? "	<priority>{$pPriority}</priority>" : '';
+		$xml .= ($pStatus || $pShow || $pPriority) ? "</presence>" : '';
+
+		if ( $this->sendPacket($xml) )
+		{
+	        usleep(90000);
+
+			return true;
+		}
+		else
+		{
+			$this->writeLog("ERROR: send_presence() #1");
+			return false;
+		}
+	}
+
+	protected final function readSocketFromServer()
+	{
+	  $retorno = "<resposta>" . $this->read(true) . "</resposta>";
+      $this->array_teste[] = $retorno;
+      $retorno = $this->xmlize($retorno);
+      $retorno = $retorno['resposta']['#'];
+      return $retorno;
+	}
+
+	protected final function sendIq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false )
+	{
+		if ( !preg_match("/^(get|set|result|error)$/i", $pType, $matches, PREG_OFFSET_CAPTURE) )
+		{
+			$this->writeLog("ERROR: _iq() #2 - type must be 'get', 'set', 'result' or 'error'");
+			return false;
+		}
+
+		if ( $this->sendPacket($this->_iq($pType, $pId, $pTo, $pFrom, $pXmlns, $pLoad)) )
+        {
+			return true;
+		}
+		return false;
+	}
+
+   protected final function writeLog($pLog = false)
+   {
+      switch ( substr($pLog, 0, strpos($pLog, ':')) )
+      {
+         case 'ERROR' :
+                        if ( $this->log_error === true )
+                        {
+                           $log = NULL;
+                           $log .= $pLog . ' :: ';
+                           $log .= $this->jid . ' :: ';
+                           $log .= date('m/d/Y H:i:s');
+                           $log .= "\n";
+                           if ( $fp = fopen ($this->log_error_file, "a+") )
+                           {
+                              fwrite($fp, $log);
+                              fclose($fp);
+                           }
+                        }
+         // end case 'ERROR'
+         break;
+      }
+   }
+
+}
+?>
Index: /trunk/instant_messenger/inc/class.ldap_im.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.ldap_im.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/class.ldap_im.inc.php	(revision 20)
@@ -0,0 +1,147 @@
+<?php
+class ldap_im
+{
+	private $ldap_host;
+	private $ldap_context;
+	private $conn;
+	private $user;
+	private $password;
+	
+	function __construct()
+	{
+		$this->ldap_host 	= $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber'];
+		$this->ldap_context = $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber'];
+		$this->user 		= $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber'];
+		$this->password 	= $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'];
+		$this->connect_ldap(false);
+	}
+	
+	function __destruct()
+	{
+		ldap_close($this->conn);
+	}
+	
+	function connect_ldap($refer)
+	{
+		$this->conn = ldap_connect($this->ldap_host);
+		ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+		ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $refer);
+		if(trim($this->user) != "")
+			ldap_bind($this->conn,$this->user,$this->password);
+		else		
+			ldap_bind($this->conn);
+	}
+	
+	function get_photo_ldap($user,$getPhoto)
+	{
+		$result = "";
+		if ($this->conn) {
+			$filter="uid=".$user;		
+			$justthese = array("jpegphoto");
+			$search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese);
+			$entry = ldap_first_entry($this->conn, $search);
+			if($entry != 'undefined'){
+				$jpeg_data = @ldap_get_values_len($this->conn, $entry, "jpegphoto");
+				$photo = imagecreatefromstring($jpeg_data[0]);
+				if($photo){
+					if($getPhoto){
+						header("Content-Type: image/jpeg");
+						$width = imagesx($photo);
+						$height = imagesy($photo);
+						$twidth = 49;
+						$theight = 65;
+						$small_photo = imagecreatetruecolor ($twidth, $theight);
+						imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
+						imagejpeg($small_photo,'',100);
+						return;		
+					}else{
+						return true;
+					}				
+				}else{
+					return false;
+				}
+			}else{
+				return false;
+			}
+		}
+	}
+	
+	function photo_ldap($user)
+	{
+		return $this->get_photo_ldap($user['uid'],false);
+	}
+	
+	function list_users_ldap($orgLdap,$type,$uid)
+	{
+		$result_users = array();
+		$i = 0;
+		
+		if ($this->conn) {
+			$filter = $type ."=". $uid;		
+			$justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible");
+			$search = ldap_search($this->conn,"ou=".$orgLdap.",".$this->ldap_context, $filter, $justthese);
+			$entry = ldap_get_entries($this->conn, $search);
+		}
+		
+		if($entry['count'] == 0){
+			$result_users['count'] = 0;
+			$result_users['uidnumber'] = $uid;
+			return $result_users;	
+		}
+		
+		$result_users['uid'] = $entry[0]['uid'][0];
+		$result_users['uidnumber'] = $entry[0]['uidnumber'][0];
+		$result_users['cn'] = $entry[0]['cn'][0];
+		$result_users['mail'] = $entry[0]['mail'][0];
+		$result_users['phpgwAccountVisible'] = @$entry[0]['phpgwaccountvisible'][0];
+
+		return $result_users;
+	}
+	
+	function list_groups_ldap($orgLdap, $gid)
+	{
+		$result_groups = "";
+		$i = 0;
+		
+		if ($this->conn) {
+			$filter="gidNumber=".$gid;		
+			$justthese = array("gidnumber","cn","memberuid");
+			$search = ldap_search($this->conn,"ou=".$orgLdap.",".$this->ldap_context, $filter, $justthese);
+			$entry = ldap_get_entries($this->conn, $search);
+		}
+	
+		if($entry['count'] == "1"){
+			$result_groups = array_shift($entry[0]['memberuid']);
+			return $entry[0]['memberuid'];
+		}		
+		return false;
+	}
+	
+	function list_organizations_ldap()
+	{
+		$result_org = array();
+		$i = 0;
+		if ($this->conn) {
+			$filter="ou=*";		
+			$justthese = array("ou");
+			$search = ldap_list($this->conn,$this->ldap_context, $filter, $justthese);
+			$entry = ldap_get_entries($this->conn, $search);
+		}
+		
+		foreach($entry as $tmp){
+			if($tmp['ou'][0] != ""){
+				$result_org[$i]['ou'] = $tmp['ou'][0];
+				$i++;
+			}
+		}
+		return $result_org;
+	}
+	
+}
+
+if(trim($_REQUEST['user']) != ""){
+	$obj_img = new ldap_im();
+	$obj_img->get_photo_ldap($_REQUEST['user'],true);
+}
+
+?>
Index: /trunk/instant_messenger/inc/class.download.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.download.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/class.download.inc.php	(revision 20)
@@ -0,0 +1,155 @@
+<?php
+
+class download
+{
+	
+	function Decode_String($string)
+	{
+		$base64 = $string;	
+		$base64_de = base64_decode($base64);
+		$array_info = unserialize($base64_de);
+	
+		if($array_info['server'] == $_SERVER['SERVER_ADDR']){
+			$this->down_file($array_info['fileUp']);
+		}else{
+			$url = "http://".$array_info['server'].$array_info['path'].$array_info['filePhp'].$base64;
+			header("Location:" . $url);
+		}
+	}
+
+	function down_file($file)
+	{   
+		 
+		ini_set("session.save_path","/php_sessions");
+		$size = filesize(ini_get("session.save_path").'/'. $file);
+		$NameFile = explode("_IM_SendFile_",$file);
+	
+		 if (!empty($file))
+	     {
+		        if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
+		           $UserBrowser = "Opera";
+		        elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
+		            $UserBrowser = "IE";
+	            else
+		            $UserBrowser = '';
+
+				$strFileType = strrev(substr(strrev($NameFile),0,4));
+				$ContentType = "application/octet-stream";
+
+			   	if ($strFileType == ".asf") 
+			   		$ContentType = "video/x-ms-asf";
+			   	if ($strFileType == ".avi")
+			   		$ContentType = "video/avi";
+			   	if ($strFileType == ".doc")
+			   		$ContentType = "application/msword";
+			   	if ($strFileType == ".zip")
+			   		$ContentType = "application/zip";
+			   	if ($strFileType == ".xls")
+			   		$ContentType = "application/vnd.ms-excel";
+			   	if ($strFileType == ".gif")
+			   		$ContentType = "image/gif";
+			   	if ($strFileType == ".jpg" || $strFileType == "jpeg")
+			   		$ContentType = "image/jpeg";
+			   	if ($strFileType == ".wav")
+			   		$ContentType = "audio/wav";
+			   	if ($strFileType == ".mp3")
+			   		$ContentType = "audio/mpeg3";
+			   	if ($strFileType == ".mpg" || $strFileType == "mpeg")
+			   		$ContentType = "video/mpeg";
+			   	if ($strFileType == ".rtf")
+			   		$ContentType = "application/rtf";
+			   	if ($strFileType == ".htm" || $strFileType == "html")
+			   		$ContentType = "text/html";
+			   	if ($strFileType == ".xml") 
+			   		$ContentType = "text/xml";
+			   	if ($strFileType == ".xsl") 
+			   		$ContentType = "text/xsl";
+			   	if ($strFileType == ".css") 
+			   		$ContentType = "text/css";
+			   	if ($strFileType == ".php") 
+			   		$ContentType = "text/php";
+			   	if ($strFileType == ".asp") 
+			   		$ContentType = "text/asp";
+			   	if ($strFileType == ".pdf")
+			   		$ContentType = "application/pdf";
+			   	if ($strFileType == ".txt")
+			   		$ContentType = "text/plain";
+			   	if ($strFileType == ".log")
+			   		$ContentType = "text/plain";
+			   	if ($strFileType == ".wmv")
+			   		$ContentType = "video/x-ms-wmv";
+				if ($strFileType == ".sxc")
+					$ContentType = "application/vnd.sun.xml.calc";
+				if ($strFileType == ".odt")
+					$ContentType = "application/vnd.oasis.opendocument.text";
+				if ($strFileType == ".stc")
+					$ContentType = "application/vnd.sun.xml.calc.template";
+				if ($strFileType == ".sxd")
+					$ContentType = "application/vnd.sun.xml.draw";
+				if ($strFileType == ".std")
+					$ContentType = "application/vnd.sun.xml.draw.template";
+				if ($strFileType == ".sxi")
+					$ContentType = "application/vnd.sun.xml.impress";
+				if ($strFileType == ".sti")
+					$ContentType = "application/vnd.sun.xml.impress.template";
+				if ($strFileType == ".sxm")
+					$ContentType = "application/vnd.sun.xml.math";
+				if ($strFileType == ".sxw")
+					$ContentType = "application/vnd.sun.xml.writer";
+				if ($strFileType == ".sxq")
+					$ContentType = "application/vnd.sun.xml.writer.global";
+				if ($strFileType == ".stw")
+					$ContentType = "application/vnd.sun.xml.writer.template";
+				if ($strFileType == ".ps")
+					$ContentType = "application/postscript";
+				if ($strFileType == ".pps")
+					$ContentType = "application/vnd.ms-powerpoint";
+				if ($strFileType == ".odt")
+					$ContentType = "application/vnd.oasis.opendocument.text";
+				if ($strFileType == ".ott")
+					$ContentType = "application/vnd.oasis.opendocument.text-template";
+				if ($strFileType == ".oth")
+					$ContentType = "application/vnd.oasis.opendocument.text-web";
+				if ($strFileType == ".odm")
+					$ContentType = "application/vnd.oasis.opendocument.text-master";
+				if ($strFileType == ".odg")
+					$ContentType = "application/vnd.oasis.opendocument.graphics";
+				if ($strFileType == ".otg")
+					$ContentType = "application/vnd.oasis.opendocument.graphics-template";
+				if ($strFileType == ".odp")
+					$ContentType = "application/vnd.oasis.opendocument.presentation";
+				if ($strFileType == ".otp")
+					$ContentType = "application/vnd.oasis.opendocument.presentation-template";
+				if ($strFileType == ".ods")
+					$ContentType = "application/vnd.oasis.opendocument.spreadsheet";
+				if ($strFileType == ".ots")
+					$ContentType = "application/vnd.oasis.opendocument.spreadsheet-template";
+				if ($strFileType == ".odc")
+					$ContentType = "application/vnd.oasis.opendocument.chart";
+				if ($strFileType == ".odf")
+					$ContentType = "application/vnd.oasis.opendocument.formula";
+				if ($strFileType == ".odi")
+					$ContentType = "application/vnd.oasis.opendocument.image";
+				if ($strFileType == ".ndl")
+					$ContentType = "application/vnd.lotus-notes";
+								
+		        $mime_type = ($UserBrowser == 'IE' || $UserBrowser == 'Opera') ? 'application/octetstream' : 'application/octet-stream';
+	
+		        header("Content-Type: $ContentType");
+		        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+		        header("Pragma: public");
+		        header("Expires: 0");
+		        header("Content-Disposition: attachment; filename=\"" . $NameFile[1] . "\"");
+				header("Content-length: " . $size);
+				readfile(ini_get("session.save_path") . "/" . $file); 
+				die();
+	    }
+	}
+}
+
+if(isset ($_REQUEST['file'])){
+	$obj_down = new download();
+	$obj_down->Decode_String($_REQUEST['file']);
+}
+
+?>
Index: /trunk/instant_messenger/inc/class.Socket.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.Socket.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/class.Socket.inc.php	(revision 20)
@@ -0,0 +1,96 @@
+<?php
+	/************************************************************
+	 * 	Classe Jabber - Expresso								*
+	 *  ------------------------------------------------------- *  
+	 *  Com Autenticação no Servidor Jabber com Tls				*	
+	 *  Rodrigo Souza - rodsouza@celepar.pr.gov.br				*
+	 * 	Alexandre Correia - alexandrecorreia@celepar.pr.gov.br  *
+	 ************************************************************/
+
+class Socket
+{
+	private $socket;
+		
+	protected final function open($pRemoteSocket, $pTimeOut = 1, $pBlockingMode = 0 )
+	{
+		if ( ($this->socket = stream_socket_client($pRemoteSocket, $errno, $errstr)) )
+      {
+         //$this->socket = stream_socket_client($pRemoteSocket, $errno, $errstr);//, 1, STREAM_CLIENT_CONNECT+STREAM_CLIENT_PERSISTENT);
+         //stream_set_write_buffer($this->socket, 0);
+         stream_set_blocking($this->socket, $pBlockingMode);
+         stream_set_timeout($this->socket, 1);//$pTimeOut);
+         return true;
+      }
+
+      return false;
+	}
+
+	protected final function close()
+	{
+		if ( $this->isConnected() )
+			return fclose($this->socket);
+		else
+			return false;
+	}
+
+	protected final function read($pLine = false, $pEnding = false, $pLength = 4096)
+   /*
+    *
+    * the jabber's documentation recommends to read
+    * the packages of socket with size of 4096 (2^12) KB
+    *
+    ******************************************************
+    *
+    * a documentação do jabber recomenda ler
+    * os pacotes do socket com tamanho de 4096 (2^12) KB
+    *
+    */
+	{
+		if ( !$this->isConnected() )
+         return false;
+
+      if ( !$pLine )
+         return @stream_get_line($this->socket, $pLength);
+
+      $retorno = NULL;
+      do
+      {
+         $line = NULL;
+         $line = @stream_get_line($this->socket, $pLength);
+         if ( $line != NULL )
+         {
+            $retorno .= $line;
+         }
+      }
+      while ( $line != NULL );
+
+      return $retorno;
+	}
+
+	protected final function write($pData)
+	{
+		if ( $this->isConnected() )
+			return fwrite($this->socket, $pData);
+		else
+			return false;
+	}
+
+	protected final function isConnected()
+	{
+		if(is_resource($this->socket))
+			return true;
+		else
+			return false;	
+	}
+	
+	protected final function returnSocket()
+	{
+		return $this->socket;	
+	}
+
+	protected function __destruct()
+	{
+			//fclose($this->resource);
+	}
+}
+?>
Index: /trunk/instant_messenger/inc/class.Ujabber.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.Ujabber.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/class.Ujabber.inc.php	(revision 20)
@@ -0,0 +1,471 @@
+<?php
+	/************************************************************
+	 * 	Classe Jabber - Expresso								*
+	 *  ------------------------------------------------------- *  
+	 *	Com Autenticação no Servidor Jabber com Tls			    *
+	 * 	Rodrigo Souza - rodsouza@celepar.pr.gov.br				*
+	 * 	Alexandre Correia - alexandrecorreia@celepar.pr.gov.br  *
+	 ************************************************************/
+
+require_once "class.Jabber.inc.php";
+require_once "class.db_im.inc.php";
+
+class Ujabber extends Jabber
+{
+
+	private $server = "localhost";
+	private $port   = "5222";
+	
+	private $username = false;
+	private $password = false;
+	private $resource = false;
+	
+	private $jid = false;
+	
+	private $log_error_file = 'erro.log';
+		
+	function __construct()
+	{
+		
+		$this->username = $_SESSION['phpgw_info']['instant_messenger']['user'];
+		$this->password = $_SESSION['phpgw_info']['instant_messenger']['passwd'];
+		$this->server   = $_SESSION['phpgw_info']['instant_messenger']['name_jabber'];
+		$this->port     = $_SESSION['phpgw_info']['instant_messenger']['port_jabber'];
+		$this->resource = $_SESSION['phpgw_info']['instant_messenger']['resource_jabber'];
+		$this->jid      = $this->username."@".$this->server . "/" . $this->resource;
+		
+		parent :: __construct($this->jid, $this->password, $this->port);
+
+	}
+	
+	function __destruct()
+	{
+		parent :: __destruct();
+	}
+
+	/*
+	 * List Users
+	 */
+
+	function list_user()
+	{
+		$contacts = $this->UpdateContacts();
+		$group_users = array();
+		$group_nusers = array();
+		
+		for($i=0; $i < count($contacts); $i++){
+			$group_users[] = strtolower($contacts[$i]['group']).";".$contacts[$i]['name'].";".$contacts[$i]['jid'].";".$contacts[$i]['subscription'].";".$contacts[$i]['online'];			
+		}
+	
+		// VCARD - PESSOAL
+
+		$VCARD_P = $this->getVcard($this->username."@".$this->server);
+		
+		$group_nusers[0]['VCARD_FN'] = $VCARD_P['FN'];
+		$group_nusers[0]['VCARD_NICKNAME'] = $VCARD_P['NICKNAME']; 
+		$group_nusers[0]['VCARD_ORGNAME'] = $VCARD_P['ORGNAME'];
+		$group_nusers[0]['VCARD_ORGUNIT'] = $VCARD_P['ORGUNIT']; 
+		$group_nusers[0]['VCARD_ROLE'] = $VCARD_P['ROLE']; 
+		$group_nusers[0]['VCARD_BDAY'] = $VCARD_P['BDAY']; 
+		$group_nusers[0]['VCARD_DESC'] = $VCARD_P['DESC'];
+		$group_nusers[0]['VCARD_JID'] = $VCARD_P['JID'];				
+
+		natcasesort($group_users);		
+		$i=1;
+
+		// VCARD / CONTATOS - USUARIOS
+		
+		foreach($group_users as $tmp){
+			$aux = explode(";",$tmp);
+			$group_nusers[$i]['group'] = $aux[0];
+			$group_nusers[$i]['name'] = $aux[1];
+			$group_nusers[$i]['jid'] = $aux[2];
+			$group_nusers[$i]['subscription'] = trim($aux[3]);
+			$group_nusers[$i]['online'] = $aux[4];
+			$aux_jid = explode("@",$aux[2]);
+		
+			$VCARD_U = $this->getVcard($aux_jid[0]."@".$this->server);
+		
+			$group_nusers[$i]['VCARD_FN'] = $VCARD_U['FN'];
+			$group_nusers[$i]['VCARD_NICKNAME'] = $VCARD_U['NICKNAME'];
+			$group_nusers[$i]['VCARD_ORGNAME']  = $VCARD_U['ORGNAME'];
+			$group_nusers[$i]['VCARD_ORGUNIT']  = $VCARD_U['ORGUNIT'];
+			$group_nusers[$i]['VCARD_ROLE'] = $VCARD_U['ROLE'];
+			$group_nusers[$i]['VCARD_BDAY'] = $VCARD_U['BDAY'];
+			$group_nusers[$i]['VCARD_DESC'] = $VCARD_U['DESC'];
+			$group_nusers[$i]['VCARD_JID']  = $VCARD_U['JID'];				
+		
+			$i++;										
+		}
+
+		return $group_nusers;
+	}
+
+	/*
+	 * Contacts - Update - Add - Remove
+	 */
+	
+	function UpdateContacts()
+	{
+		$array_contacts = array();
+		$array_db = array();
+		$array_return = array();
+
+		$this->sendIq('get', 'update1', NULL, NULL, 'jabber:iq:roster');
+        usleep(50000);
+		$result = $this->readSocketFromServer();
+		
+		if(count($result['iq'][1]['#']['query'][0]['#']['item']) > 0){
+			$array_contacts = $result['iq'][1]['#']['query'][0]['#']['item'];
+		}
+		
+		$j = 0;
+		
+		// Consulta no Servidor Jabber;
+		if(count($array_contacts) > 0 ){
+			for($i=0 ; $i < count($array_contacts); $i++)
+	        {
+				$array_return[$j]['subscription'] = $array_contacts[$i]['@']['subscription'];
+				$array_return[$j]['name'] = $array_contacts[$i]['@']['name'];			
+				$array_return[$j]['jid'] = $array_contacts[$i]['@']['jid'];
+				$array_return[$j]['group'] = $array_contacts[$i]['#']['group']['0']['#'];
+				$aux_jid = explode("@",$array_return[$j]['jid']); 
+				
+				$array_return[$j]['online'] = ($this->Last_access_User(trim($aux_jid[0]."@".$this->server))) ? 1:0;
+				$j++;			
+			}
+		}			
+		
+		// Consulta no Bd Postgres;
+		$db_im = new db_im();
+		$array_db = $db_im->get_contacts_im(NULL,$this->jid);
+		
+		if(count($array_db) > 0 )
+        {
+			for($i=0 ; $i < count($array_db); $i++)
+            {
+				$array_return[$j]['subscription'] = 'to';
+				$array_return[$j]['name'] = '';
+				$array_return[$j]['jid'] = $array_db[$i]['im_from'];
+				$array_return[$j]['group'] = '';
+				$array_return[$j]['online'] = 0;
+				$j++;
+			}
+		}
+		return $array_return;
+	}
+	
+	function AddNewContacts($pUser)
+	{
+		$jid = explode("@",$pUser['email']);
+		$pJid = $jid[0]."@".$this->server;
+		$pName = $pUser['name'];
+		$pGroup = $pUser['group'];
+		
+		if(trim($jid[0]) != trim($this->username)){
+			$addid = ( $addid ) ? $addid : "adduser_" . time();
+			if ( $pJid )
+			{
+				$newcontact  = "<item jid='$pJid'";
+				$newcontact .= ($pName) ? " name='" . $pName . "'" : '';
+				$newcontact .= (($pGroup) ? "><group>" . $pGroup . "</group>\n</item" : "/") . ">";
+	
+				if($this->sendIq('set', $addid, NULL, NULL, "jabber:iq:roster", $newcontact)){
+					// Bd;
+					$db_im = new db_im();
+					if($db_im->delete_contacts($pJid,$this->jid)){
+						$this->Subscribe($pJid);
+					}
+                    $this->AcceptRequest($request = array("jid" => $pJid,"subscription" => $pUser['subscription']));		
+					return true;
+				}else{
+					return false;
+				}
+			}
+			else
+			{
+				$this->writeLog("ERROR: RosterAddUser() #1");
+				return false;
+			}
+		}else{
+			return false;
+		}
+	}
+	
+	function UpdateUser($pUser)
+	{
+		$pJid = $pUser['jid'];
+		$pName = $pUser['name'];
+		$pGroup = $pUser['group'];
+	
+		$upid = ( $upid ) ? $upid : "updateuser_" . time();
+
+		if ( $pJid )
+		{
+			$updatecontact  = "<item jid='$pJid'";
+			$updatecontact .= ($pName) ? " name='" . $pName . "'" : '';
+			$updatecontact .= (($pGroup) ? "><group>" . $pGroup . "</group>\n</item" : "/") . ">";
+
+			if($this->sendIq('set', $upid, NULL, NULL, "jabber:iq:roster", $updatecontact)){
+				return true;
+			}else{
+				return false;
+			}
+		}
+		else
+		{
+			$this->writeLog("ERROR: RosterUpdateUser() #1");
+			return false;
+		}
+	}
+	
+	function RosterRemoveUser($pUser)
+	{
+		$pJid = $pUser['jid'];
+		$pId  = 'deluser_' . time();
+
+		if ($pJid && $pId)
+		{
+			$db_im = new db_im();
+			$db_im->delete_contacts($pJid,$this->jid);
+			if(!$this->sendIq('set',$pId,NULL,NULL,"jabber:iq:roster","<item jid='$pJid' subscription='remove'/>")){
+				return false;				
+			}
+			return true;
+		}else{
+			$this->writeLog("ERROR: RosterRemoveUser() #1");
+			return false;
+		}
+	}
+	
+	/*
+	 * GetVcard
+	 */
+	
+	function getVcard($pJid)
+	{
+		$array_vcard = array();
+		$id_n = explode("@",$pJid);
+		$id = $id_n[0];
+
+		$this->sendIq('get',$id,$pJid,NULL,"vcard-temp","<vCard xmlns='vcard-temp'/>");		
+		usleep(50000);
+		$result = $this->readSocketFromServer();
+		$arr = $result['iq'][0]['#']['vCard'][0]['#'];
+		
+		// vCard
+		$array_vcard['FN'] = trim($arr['FN']['0']['#']) ? $arr['FN']['0']['#']: $id;
+		$array_vcard['NICKNAME'] = trim($arr['NICKNAME']['0']['#']) ? $arr['NICKNAME']['0']['#'] : $pJid;
+		$array_vcard['ORGNAME'] = trim($arr['ORG']['0']['#']['ORGNAME']['0']['#']) ? $arr['ORG']['0']['#']['ORGNAME']['0']['#'] : "";
+		$array_vcard['ORGUNIT'] = trim($arr['ORG']['0']['#']['ORGUNIT']['0']['#']) ? $arr['ORG']['0']['#']['ORGUNIT']['0']['#'] : "";		
+		$array_vcard['ROLE'] = trim($arr['ROLE']['0']['#']) ? $arr['ROLE']['0']['#'] : "";				
+		$array_vcard['BDAY'] = trim($arr['BDAY']['0']['#']) ? $arr['BDAY']['0']['#'] : "";
+		$array_vcard['DESC'] = trim($arr['DESC']['0']['#']) ? $arr['DESC']['0']['#'] : "";
+		$array_vcard['JID'] = $pJid;
+		return $array_vcard;
+	}
+
+	function newVcard($pVcard_User)
+	{
+		
+		$pVcard = explode(";",$pVcard_User['vcard']);
+		$nid = explode("@",$this->jid);
+		$id = $nid[0];
+		$xmlVcard = "";
+		
+		// Vcard			
+		$xmlVcard  = "<iq id='$id' type='set'>";
+		$xmlVcard .= "<vCard xmlns='vcard-temp'>";		
+		$xmlVcard .= "<FN>$pVcard[0]</FN>";
+		$xmlVcard .= "<NICKNAME>$pVcard[1]</NICKNAME>";									 
+		$xmlVcard .= "<ORG>";
+		$xmlVcard .= "<ORGNAME>$pVcard[2]</ORGNAME>";
+		$xmlVcard .= "<ORGUNIT>$pVcard[3]</ORGUNIT>";
+		$xmlVcard .= "</ORG>";
+		$xmlVcard .= "<ROLE>$pVcard[4]</ROLE>";
+		$xmlVcard .= "<BDAY>$pVcard[5]</BDAY>";
+		$xmlVcard .= "<DESC>$pVcard[6]</DESC>";	
+		$xmlVcard .= "</vCard></iq>";
+		
+		if(!$this->SendPacket($xmlVcard))
+			return false;
+		return true;
+		
+	 }
+
+	/*
+	 * getMessage
+	 */
+
+	function getMessages()
+	{
+		$this->presence();
+
+		$this->sendIq('get','roster',NULL,NULL,"jabber:x:offline");
+
+		$array_return1 = $this->readSocketFromServer();
+      
+		$array_message = array();
+		$j = 0;
+		for($i=0; $i < count($array_return1['message']); $i++)
+        {
+			$array_message[$j]['from'] = $array_return1['message'][$i]['@']['from'];
+			$array_message[$j]['to'] = $array_return1['message'][$i]['@']['to'];			
+			$array_message[$j]['body'] = urldecode(($array_return1['message'][$i]['#']['body'][0]['#']));
+			$j++;	
+		}
+		
+		return $array_message;
+	}
+	
+	function SendMessage($pSendMessage)
+	{
+		//$this->presence();
+		$to = $pSendMessage['to'];
+		$type = "normal";
+		$id = "";
+		$content = array(
+			"subject" => $pSendMessage['subject'] ? $pSendMessage['subject'] : "",
+			"thread" => $pSendMessage['thread'] ? $pSendMessage['thread'] : "", 
+			"body" => $pSendMessage['body'] ? urlencode((trim(preg_replace('/^<br>|<br>$/', '', $pSendMessage['body'])))) : ""
+		);
+		$payload = "";
+		
+		if ($to && is_array($content))
+		{
+			if (!$id)
+			{
+				$id = $type . "_" . time();
+			}
+
+			$xml = "<message to='$to' type='$type' id='$id'>\n";
+
+			if ($content['subject'])
+			{
+				$xml .= "<subject>" . $content['subject'] . "</subject>\n";
+			}
+
+			if ($content['thread'])
+			{
+				$xml .= "<thread>" . $content['thread'] . "</thread>\n";
+			}
+
+			$xml .= "<body>" . $content['body'] . "</body>\n";
+			$xml .= $payload;
+			$xml .= "</message>\n";
+			unset($id);
+
+			if ($this->SendPacket($xml))
+			{
+				return TRUE;
+			}
+			else
+			{
+				$this->writeLog("ERROR: SendMessage() #1");
+				return FALSE;
+			}
+		}
+		else
+		{
+			$this->writeLog("ERROR: SendMessage() #2");
+			return FALSE;
+		}
+	}
+
+	/*
+	 *  Log - 
+	 */
+	
+	
+	/*
+     * Verifica os acessos de cada contato no servidor;
+     */
+    
+    function Last_access_User($pJid)
+    {
+    	$id = "last_" . time();		
+    	$result = array();
+		$this->sendIq('get',$id,$pJid,NULL,'jabber:iq:last');
+        usleep(50000);
+
+		$result = $this->readSocketFromServer();
+
+		$time_offline = $result['iq'][0]['#']['query'][0]['@']['seconds'];
+		return $this->time_off_line($time_offline);
+		
+    }
+    
+    function time_off_line($pTime)
+    {
+    	$time_access = $pTime / 15;
+    	if($time_access < 2)
+    		return TRUE;
+    	else
+    		return FALSE;	
+    }
+    
+    /*
+	 * Permissão - Autorizar /  Negar ; 
+	 */
+
+	function AcceptRequest($pRequest)
+	{
+		$jid = explode("@",$pRequest['jid']); 
+		$pToJid = $jid[0]."@".$this->server;
+
+		if(trim($pRequest['subscription']) == 'none' || trim($pRequest['subscription']) == 'from'){
+			$db_im = new db_im();
+			if(count($db_im->get_contacts_im($this->jid, $pToJid)) == 0){
+				 if(!$db_im->insert_contacts($this->jid , $pToJid))
+				 	return false;
+				 else
+				 	return $this->SubscriptionAcceptRequest($pToJid);
+			 }else{
+				return false;				 	
+			 }
+		}else{
+			if(trim($pRequest['subscription']) == 'to'){
+				return $this->SubscriptionAcceptRequest($pToJid);
+			}else{
+				return false;
+			}
+		}
+	}
+
+	function SubscriptionAcceptRequest($to = NULL)
+	{
+		return ($to) ? $this->presence("subscribed", $to) : FALSE;
+	}
+
+	function SubscriptionDenyRequest($to = NULL)
+	{
+		return ($to) ? $this->presence("unsubscribed", $to) : FALSE;
+	}
+
+	function Subscribe($to = NULL)
+	{
+		return ($to) ? $this->presence("subscribe", $to) : FALSE;
+	}
+
+	function Unsubscribe($to = NULL)
+	{
+		return ($to) ? $this->presence("unsubscribe", $to) : FALSE;
+	}
+// TESTE 
+
+   function encode(&$item, $val = 'encode') 
+   { 
+      switch( gettype($item) ) 
+      { 
+         case 'object' : 
+            $item = get_object_vars($item); 
+            encode($item); 
+         break; 
+         case 'array' : 
+            array_walk_recursive($item, 'encode'); 
+         break;
+         default : $item = utf8_encode($item); 
+      } 
+   } 
+}
+?>
Index: /trunk/instant_messenger/inc/class.db_im.inc.php
===================================================================
--- /trunk/instant_messenger/inc/class.db_im.inc.php	(revision 20)
+++ /trunk/instant_messenger/inc/class.db_im.inc.php	(revision 20)
@@ -0,0 +1,87 @@
+<?php
+define('PHPGW_INCLUDE_ROOT','../');	
+define('PHPGW_API_INC','../phpgwapi/inc');
+require_once(PHPGW_API_INC.'/class.db.inc.php');
+	
+class db_im
+{	
+	
+	var $db;
+	var $db_name;
+	var $db_host;
+	var $db_port;
+	var $db_user;
+	var $db_pass;
+	var $db_type;
+	var $teste;
+	
+	function db_im(){
+		$this->db_name = $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'];
+		$this->db_host = $_SESSION['phpgw_info']['instant_messenger']['server']['db_host'];
+		$this->db_port = $_SESSION['phpgw_info']['instant_messenger']['server']['db_port'];
+		$this->db_user = $_SESSION['phpgw_info']['instant_messenger']['server']['db_user'];
+		$this->db_pass = $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'];
+		$this->db_type = $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'];
+		
+		$this->db = new db();		
+		$this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type);
+	}
+
+	function get_contacts_im($pFrom = false, $pTo)
+	{		
+		$result = array();
+ 		$from = explode("/",$pFrom);
+ 		$to = explode("/",$pTo);
+ 		if($pFrom)
+ 			$query = "select im_from, im_to from phpgw_im_auth_user where im_from = '".$from[0]."' and im_to = '".$to[0]."'";
+		else
+			$query = "select im_from, im_to from phpgw_im_auth_user where im_to = '".$to[0]."' order by im_from"; 			
+        
+        if (!$this->db->query($query))
+        	return null;
+		
+		while($this->db->next_record())
+			$result[] = $this->db->row();
+
+		return $result;
+	}
+	
+	function insert_contacts($pFrom, $pTo)
+	{
+		$from = explode("/",$pFrom);
+ 		$to = explode("/",$pTo);
+		$query = "insert into phpgw_im_auth_user values('".$from[0]."','".$to[0]."')";
+		return $this->query_db($query);		
+	}
+	
+	function delete_contacts($pFrom, $pTo)
+	{
+		$from = explode("/",$pFrom);
+ 		$to = explode("/",$pTo);
+		$query = "delete from phpgw_im_auth_user where im_from = '".$from[0]."' and im_to = '".$to[0]."'";
+		return $this->query_db($query);
+	}
+	
+	function get_accounts_acl()
+	{
+		$result = array();
+		$query = "select acl_appname, acl_account from phpgw_acl where acl_appname = 'instant_messenger' order by acl_account";	
+ 		
+ 		if (!$this->db->query($query))
+        	return null;
+		
+		while($this->db->next_record())
+			$result[] = $this->db->row();
+
+		return $result;
+	}
+	
+	function query_db($pQuery)
+	{
+		if (!$this->db->query($pQuery))
+        	return false;
+		else
+			return true;
+	}
+}
+?>
Index: /trunk/instant_messenger/js/json.js
===================================================================
--- /trunk/instant_messenger/js/json.js	(revision 20)
+++ /trunk/instant_messenger/js/json.js	(revision 20)
@@ -0,0 +1,135 @@
+JSONTools = {
+	"toStr" : function(pType)
+	{
+		switch ( pType.constructor )
+		{
+			case Object  : return this.object(pType);  break;
+			case Array   : return this.array(pType);   break;
+			case String  : return this.string(pType);  break;
+			case Number  : return this.number(pType);  break;
+			case Boolean : return this.boolean(pType); break;
+			case Date    : return this.date(pType);    break;
+		}
+	},
+	"object" : function(pType)
+	{
+	    var a = ['{'],
+            b,
+            k,
+            v,
+            _this = this;
+        function p(s)
+        {
+            if ( b )
+                a.push(',');
+            a.push(_this.toStr(k), ':', s);
+            b = true;
+        }
+        for ( k in pType )
+        {
+            if ( pType.hasOwnProperty(k) )
+            {
+                v = pType[k];
+                switch ( typeof v )
+                {
+                case 'object':
+                    if (v)
+                    	p(this.toStr(v));
+                    else
+                        p("null");	
+                    break;
+
+            case 'string':
+            case 'number':
+            case 'boolean':
+                    p(this.toStr(v));
+                }
+            }
+        }
+        a.push('}');
+        return a.join('');
+	},
+	"array" : function(pType)
+	{
+        var a = ['['],
+            b,
+            i,
+            l = pType.length,
+            v;
+        function p(s)
+        {
+            if ( b )
+                a.push(',');
+            a.push(s);
+            b = true;
+        }
+        for ( i = 0; i < l; i += 1 )
+        {
+            v = pType[i];
+            switch ( typeof v )
+            {
+            case 'object':
+                if ( v )
+                {
+                        p(this.toStr(v));
+                } else {
+                    p("null");
+                }
+                break;
+            case 'string':
+            case 'number':
+            case 'boolean':
+                p(this.toStr(v));
+            }
+        }
+        a.push(']');
+        return a.join('');
+	},
+    "string" : function(pType)
+    {
+        var m = {
+            '\b': '\\b',
+            '\t': '\\t',
+            '\n': '\\n',
+            '\f': '\\f',
+            '\r': '\\r',
+            '"' : '\\"',
+            '\\': '\\\\'
+        };
+            if ( /[\\\x00-\x1f]/.test(pType) )
+            {
+                return '"' + pType.replace(/([\x00-\x1f\\])/g, function(a, b)
+                {
+                    var c = m[b];
+                    if (c) {
+                        return c;
+                    }
+                    c = b.charCodeAt();
+                    return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
+                }) + '"';
+            }
+            return '"' + pType + '"';
+	},
+    "boolean" : function(pType)
+    {
+        return String(pType);
+    },
+    "date" : function(pType)
+    {
+        function f(n)
+        {
+            return n < 10 ? '0' + n : n;
+        }
+
+        return '"' + pType.getFullYear() + '-' +
+                f(pType.getMonth() + 1) + '-' +
+                f(pType.getDate()) + 'T' +
+                f(pType.getHours()) + ':' +
+                f(pType.getMinutes()) + ':' +
+                f(pType.getSeconds()) + '"';
+    },
+    "number" : function(pType)
+    {
+        return isFinite(pType) ? String(pType) : "null";
+    }
+}
Index: /trunk/instant_messenger/js/im_connector.js
===================================================================
--- /trunk/instant_messenger/js/im_connector.js	(revision 20)
+++ /trunk/instant_messenger/js/im_connector.js	(revision 20)
@@ -0,0 +1,91 @@
+function cIM()
+{
+	this.DEFAULT_URL = im_path + 'controller.php?action=';
+	this.connector = XMLTools;
+	this._onmouseup = document.onmouseup;
+	this.isExecuteForm = false;
+	this.id = [];
+   this._handler = false;
+   this.json = false;
+}
+
+cIM.prototype.cExecute = function (url, handler, params, form)
+{
+   var _this = this;
+   if ( this.isExecuteForm )
+   {
+      _this.isExecuteForm = false;
+      document.onmouseup = this._onmouseup;
+   }
+
+   if ( form )
+   {
+      //this.cExecuteForm(url, form);
+      return;
+   }
+
+   url = _this.DEFAULT_URL + url;
+
+   var _date = new Date();
+   var id = url + '&thread_time=' + _date.getHours() + _date.getMinutes() + _date.getSeconds() + _date.getMilliseconds();
+   if ( _this.id[id] )
+      return false;
+   else
+      _this.id[id] = handler;
+
+   if ( params )
+      method = "POST";
+   else
+      method = "GET";
+
+   handler = _this._interface;
+   _this.connector.request(id, url, method, handler, params);
+}
+cIM.prototype._interface = function(data, url)
+{
+   data = data.getElementsByTagName('retorno').item(0);
+   data = data.firstChild.nodeValue;
+   if ( /^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(data) )
+   {
+      eval('data = ' + data);
+      if ( cIM.json )
+         cIM.json = false;
+      else
+         data = json2array(data);
+   }
+
+   var handler = cIM.id[url];
+   cIM.id[url] = false;
+   delete cIM.id[url];
+   handler(data);
+}
+var cIM = new cIM;
+
+
+function json2array(pObject)
+{
+   var retorno = [];
+   for( var i in pObject )
+      if( pObject[i].constructor == Object )
+      {
+         retorno[i] = [];
+         retorno[i] = json2array(pObject[i]);
+      }
+      else
+         retorno[i] = pObject[i];
+
+   return retorno;
+}
+function json2str(pObject)
+{
+   var retorno = '{';
+   for( var i in pObject )
+      if( pObject[i].constructor == Object )
+         retorno += '\'' + i + '\':' + json2str(pObject[i]) + ',';
+      else
+         retorno += '\'' + i + '\':\'' + pObject[i] + '\',';
+
+   retorno = retorno.substr(0, (retorno.length - 1));
+   retorno += '}';
+   return retorno;
+}
Index: /trunk/instant_messenger/js/im_var_globals.js
===================================================================
--- /trunk/instant_messenger/js/im_var_globals.js	(revision 20)
+++ /trunk/instant_messenger/js/im_var_globals.js	(revision 20)
@@ -0,0 +1,105 @@
+/**
+* @AUTHOR: [NUTS] Rodrigo Souza
+* @DATE: 2006/10/23 11:37:30
+* @LAST CHANGE: Qui 14 Dez 2006 14:28:12 BRST::
+*/
+
+var focusFlag = true;
+
+window.onblur = windowBlur;
+window.onfocus = windowFocus;
+window.onclick = windowFocus;
+
+window_title = document.title;
+
+function windowBlur() {focusFlag = false; document.title = window_title;}
+function windowFocus() {focusFlag = true; document.title = window_title;}
+
+var WINDOW_STATE_REGULAR = "regular";
+var WINDOW_STATE_MINIMIZED = "minimized";
+var WINDOW_STATE_MAXIMIZED = "maximized";
+var WINDOW_STATE_CLOSED = "closed";
+
+var TASKBAR_STATE_SELECTED = "selected";
+var TASKBAR_STATE_UNSELECTED = "unselected";
+var TASKBAR_STATE_MINIMIZED = "minimized";
+var TASKBAR_STATE_FLASH = "flash";
+
+var windowState = WINDOW_STATE_REGULAR;
+var taskbarItems = new Object();
+var windowItems = new Object();
+
+var zValue = 1000;
+
+var TASKBAR_HEIGHT=27;
+
+var ACTIVE_OBJECTID = "contacts";
+	
+var isEmotionSelectionVisible = false;
+var isFontNameSelectionVisible = false;
+var isFontSizeSelectionVisible = false;
+var isFontColorSelectionVisible = false;
+var isFontStyleSelectionVisible = false;
+var activeChatWindowId = "";
+
+var newMessageTimer;
+var messages_timeout = false;
+var contacts_timeout = false;
+
+var im_busy = false;
+
+var cod_emotions = new Array();
+	cod_emotions[1] = /\:\)/gi;
+	cod_emotions[2] = /\:d/gi;
+	cod_emotions[3] = /\;\)/gi;
+	cod_emotions[4] = /\:o/gi;
+	cod_emotions[5] = /\:p/gi;
+	cod_emotions[6] = /\(h\)/gi;
+	cod_emotions[7] = /\:\@/gi;
+	cod_emotions[8] = /\:\$/gi;
+	cod_emotions[9] = /\:s/gi;
+	cod_emotions[10] = /\:\(/gi;
+	cod_emotions[11] = /\:\'\(/gi;
+	cod_emotions[12] = /\:\|/gi;
+	cod_emotions[13] = /\(6\)/gi;
+	cod_emotions[14] = /\(a\)/gi;
+	cod_emotions[15] = /\(l\)/gi;
+	cod_emotions[16] = /\(u\)/gi;
+	cod_emotions[17] = /\(m\)/gi;
+	cod_emotions[18] = /\(\@\)/gi;
+	cod_emotions[19] = /\(\&\)/gi;
+	cod_emotions[20] = /\(S\)/gi;
+	cod_emotions[21] = /\(\*\)/gi;
+	cod_emotions[22] = /\(\~\)/gi;
+	cod_emotions[23] = /\(8\)/gi;
+	cod_emotions[24] = /\(e\)/gi;
+	cod_emotions[25] = /\(f\)/gi;
+	cod_emotions[26] = /\(w\)/gi;
+	cod_emotions[27] = /\(o\)/gi;
+	cod_emotions[28] = /\(k\)/gi;
+	cod_emotions[29] = /\(g\)/gi;
+	cod_emotions[30] = /\(\^\)/gi;
+	cod_emotions[31] = /\(p\)/gi;
+	cod_emotions[32] = /\(i\)/gi;
+	cod_emotions[33] = /\(c\)/gi;
+	cod_emotions[34] = /\(t\)/gi;
+	cod_emotions[35] = /\(\{\)/gi;
+	cod_emotions[36] = /\(\}\)/gi;
+	cod_emotions[37] = /\(b\)/gi;
+	cod_emotions[38] = /\(d\)/gi;
+	cod_emotions[39] = /\(z\)/gi;
+	cod_emotions[40] = /\(x\)/gi;
+	cod_emotions[41] = /\(y\)/gi;
+	cod_emotions[42] = /\(n\)/gi;
+	cod_emotions[43] = /\:\[/gi;
+	cod_emotions[44] = /\(\?\)/gi;
+	cod_emotions[45] = /\(\%\)/gi;
+	cod_emotions[46] = /\(\#\)/gi;
+	cod_emotions[47] = /\(r\)/gi;
+	cod_emotions[48] = /\:\-\#/gi;
+	cod_emotions[49] = /8o\|/gi;
+	cod_emotions[50] = /8\-\|/gi;
+	cod_emotions[51] = /\^o\)/gi;
+	cod_emotions[52] = /\:\-\*/gi;
+	cod_emotions[53] = /\+o\(/gi;
+	cod_emotions[54] = /\(sn\)/gi;
Index: /trunk/instant_messenger/js/im_sincro.js
===================================================================
--- /trunk/instant_messenger/js/im_sincro.js	(revision 20)
+++ /trunk/instant_messenger/js/im_sincro.js	(revision 20)
@@ -0,0 +1,23 @@
+// Instant Messenger
+// im_sincro.js
+
+	function Sincro()
+	{
+		this.wait = 15000; 			// 15 segundos
+		this.count = 0;				// para atualização da lista
+
+	}
+
+	Sincro.prototype.synchronize = function()
+	{
+		if ( this.count++ < 4 )
+         IM.getMessage();
+      else
+         IM.UpdateContacts();
+
+      setTimeout("Sincro.synchronize()", this.wait);
+	}
+	
+// Build Object	
+	var Sincro = new Sincro();	
+	messages_timeout = setTimeout("Sincro.synchronize()",Sincro.wait);
Index: /trunk/instant_messenger/js/im_win.js
===================================================================
--- /trunk/instant_messenger/js/im_win.js	(revision 20)
+++ /trunk/instant_messenger/js/im_win.js	(revision 20)
@@ -0,0 +1,1038 @@
+var im_win = {
+
+   chat_pJid : null,
+   _imWindowTemplate : null,
+   xslWin : false,
+
+   "load" : function()
+   {
+      backFantom = func.newEl('div');
+      func.confEl(backFantom, 'id', 'backFantom');
+      func.confEl(backFantom, 'style', 'position:absolute;top:0px;left:0px;width:100%;height:100%;');
+
+      test = func.newEl('div');
+      func.confEl(test, 'id', 'test');
+      func.confEl(test, 'style', 'visibility: hidden;');
+
+      emotions = func.newEl('div');
+      func.confEl(emotions, 'id', 'shared_emotions');
+      func.confEl(emotions, 'class', 'emotionFrame');
+      func.confEl(emotions, 'style', 'position:absolute;padding:1px;left:350px;visibility:hidden;top:0px');
+
+      font_name = func.newEl('div');
+      func.confEl(font_name, 'id', 'shared_fontName');
+      func.confEl(font_name, 'class', 'statusMenu');
+      func.confEl(font_name, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
+
+      font_size = func.newEl('div');
+      func.confEl(font_size, 'id', 'shared_fontSize');
+      func.confEl(font_size, 'class', 'statusMenu');
+      func.confEl(font_size, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
+
+      font_color = func.newEl('div');
+      func.confEl(font_color, 'id', 'shared_fontColor');
+      func.confEl(font_color, 'class', 'statusMenu');
+      func.confEl(font_color, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
+
+      font_style = func.newEl('div');
+      func.confEl(font_style, 'id', 'shared_fontStyle');
+      func.confEl(font_style, 'class', 'statusMenu');
+      func.confEl(font_style, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
+
+      func.insEl(backFantom, test, emotions, font_name, font_size, font_color, font_style, false);
+
+      emotions.innerHTML = Templates.emotions();
+      font_name.innerHTML = Templates.font_name();
+      font_size.innerHTML = Templates.font_size();
+      font_color.innerHTML = Templates.font_color();
+      font_style.innerHTML = Templates.font_style();
+
+      pId = 'contacts';
+
+      main_menu_all = func.newEl('div');
+      func.confEl(main_menu_all, 'style', 'margin: 3px;');
+
+      main_menu_head = func.newEl('div');
+      func.confEl(main_menu_head, 'id', pId + '_im_window_body_inner_head');
+      func.confEl(main_menu_head, 'style', 'margin: 0px 0px 3px 0px; border: 1px solid #809aa9; display: block;');
+
+      main_menu_body = func.newEl('div');
+      func.confEl(main_menu_body, 'id', 'div_contacts');
+      func.confEl(main_menu_body, 'style', 'border: 1px solid #809aa9;');
+
+      func.insEl(main_menu_head, main_menu_body, main_menu_all);
+
+      main_menu_head_picture = func.newEl('img');
+      func.confEl(main_menu_head_picture, 'id', pId + '_avatar');
+      func.confEl(main_menu_head_picture, 'src', img_photo.src);
+      func.confEl(main_menu_head_picture, 'style', 'float: left; height: 65px; margin: 2px; width: 49px;');
+
+      main_menu_head_name = func.newEl('span');
+      func.confEl(main_menu_head_name, 'id', 'span_nickname');
+      main_menu_head_name_txt = document.createTextNode(" your nickname");
+      func.insEl(main_menu_head_name_txt, main_menu_head_name);
+
+      br1 = func.newEl('br');
+
+      main_menu_head_message = func.newEl('span');
+      func.confEl(main_menu_head_message, 'id', 'span_message');
+      main_menu_head_message_txt = document.createTextNode(' your message');
+      func.insEl(main_menu_head_message_txt, main_menu_head_message);
+
+      br2 = func.newEl('br');
+
+      main_menu_head_pref = func.newEl('span');
+      func.confEl(main_menu_head_pref, 'id', 'span_menu_pref');
+	   func.confEl(main_menu_head_pref,'style','float: left;');
+
+      br3 = func.newEl('br');
+      func.confEl(br3, 'style', 'clear: both');
+
+      func.insEl(main_menu_head_picture, main_menu_head_name, br1, main_menu_head_message, br2, main_menu_head_pref, br3, main_menu_head);
+
+      main_menu_head_pref_img = func.newEl('img');
+      func.confEl(main_menu_head_pref_img, 'src', img_group_close.src);
+      func.confEl(main_menu_head_pref_img, 'id', 'img_pref');
+
+  	   main_menu_head_pref.onclick = function(){IM.menu_preferences('menu_preferences');};
+      main_menu_head_pref_txt = document.createTextNode(IM.get_lang('preferences'));
+
+	   main_menu_head_div = func.newEl("div");
+	   func.confEl(main_menu_head_div,'id','menu_preferences');
+	   func.confEl(main_menu_head_div,'class','menu_im');
+	   func.confEl(main_menu_head_div,'style','float: left;cursor:pointer');
+
+      func.insEl(main_menu_head_pref_img, main_menu_head_pref_txt, main_menu_head_div, main_menu_head_pref);
+
+      params = new Array();
+      params['body']       = main_menu_all;
+      params['close']      = true;
+      params['height']     = 260;
+      params['left']       = 10;
+      params['id']         = pId;
+      params['maximize']   = true;
+      params['style']      = 'visibility:hidden';
+      params['title']      = ".: " + IM.get_lang("instant_messenger") + " :.";
+      params['top']        = 10;
+      params['width']      = 250;
+      this.build(params);
+
+      this.config(pId);
+
+      this.windowMinimize(pId + '_im');
+   },
+
+   "config" : function(pId)
+   {
+      ADD_DHTML("backFantom"+NO_DRAG);
+      ADD_DHTML("shared_fontStyle"+NO_DRAG);
+      ADD_DHTML("shared_fontColor"+NO_DRAG);
+      ADD_DHTML("shared_fontSize"+NO_DRAG);
+      ADD_DHTML("shared_fontName"+NO_DRAG);
+      ADD_DHTML("shared_emotions"+NO_DRAG);
+      ADD_DHTML(pId+"_im_window_body_inner"+NO_DRAG);
+      ADD_DHTML(pId+"_im_window"+NO_DRAG);
+      ADD_DHTML(pId+"_im_window_master"+NO_DRAG);
+      ADD_DHTML(pId+"_im_window_fantom"+NO_DRAG);
+      ADD_DHTML(pId+"_im_window_movable"+CURSOR_MOVE);
+      ADD_DHTML(pId+"_im_window_resize"+CURSOR_NW_RESIZE);
+
+
+      dd.elements.backFantom.setOpacity(0);
+      document.getElementById("backFantom").style.zIndex = -1;
+
+
+      dd.elements.contacts_im_window_resize.moveTo(dd.elements.contacts_im_window.x+dd.elements.contacts_im_window.w-dd.elements.contacts_im_window_resize.w-2, dd.elements.contacts_im_window.y+dd.elements.contacts_im_window.h-dd.elements.contacts_im_window_resize.h-2);
+      dd.elements.contacts_im_window_movable.moveTo(dd.elements.contacts_im_window.x, dd.elements.contacts_im_window.y);
+      dd.elements.contacts_im_window_movable.setOpacity(0);
+
+      dd.elements.contacts_im_window_resize.setOpacity(1);
+      dd.elements.contacts_im_window_resize.moveTo(dd.elements.contacts_im_window_fantom.x+dd.elements.contacts_im_window_fantom.w-dd.elements.contacts_im_window_resize.w-2, dd.elements.contacts_im_window_fantom.y+dd.elements.contacts_im_window_fantom.h-dd.elements.contacts_im_window_resize.h-2);
+
+      var contacts_im_window = new Object();
+      contacts_im_window.x = dd.elements.contacts_im_window_master.x;
+      contacts_im_window.y = dd.elements.contacts_im_window_master.y;
+      contacts_im_window.w = dd.elements.contacts_im_window_master.w;
+      contacts_im_window.h = dd.elements.contacts_im_window_master.h;
+      contacts_im_window.state = WINDOW_STATE_REGULAR;
+      windowItems[pId] = contacts_im_window;
+   },
+
+   "build" : function()
+   {
+      var pBody       = '';
+      var pClose      = true;
+      var pHeight     = 360;
+      var pId         = false;
+      var pLeft       = NaN;
+      var pMaximize   = true;
+      var pMinimize   = true;
+      var pStyle      = '';
+      var pTitle      = '';
+      var pTop        = NaN;
+      var pWidth      = 250;
+
+      for ( var i = 0; i < arguments.length; i++ )
+      {
+         if ( func.isArray(arguments[i]) )
+            for ( var n in arguments[i] )
+               if ( !func.isUndefined(arguments[i][n]) )
+                  switch ( n )
+                  {
+                     case 'body'    : pBody     = arguments[i][n]; break;
+                     case 'close'   : pClose    = arguments[i][n]; break;
+                     case 'height'  : pHeight   = arguments[i][n]; break;
+                     case 'id'      : pId       = arguments[i][n]; break;
+                     case 'left'    : pLeft     = arguments[i][n]; break;
+                     case 'maximize': pMaximize = arguments[i][n]; break;
+                     case 'minimize': pMinimize = arguments[i][n]; break;
+                     case 'style'   : pStyle    = arguments[i][n]; break;
+                     case 'title'   : pTitle    = arguments[i][n]; break;
+                     case 'top'     : pTop      = arguments[i][n]; break;
+                     case 'width'   : pWidth    = arguments[i][n]; break;
+                  }
+      }
+
+      if ( !pId || pHeight < 60 || pWidth < 100 )
+         return false;
+
+      if ( isNaN(pLeft) )
+         if ( windowItems[pId] )
+            pLeft = windowItems[pId].x;
+         else
+            pLeft = Math.floor(Math.random()*(dd.getWndH()-100));
+
+      if ( isNaN(pTop) )
+         if ( windowItems[pId] )
+            pTop = windowItems[pId].y;
+         else
+            pTop = Math.floor(Math.random()*(dd.getWndW()-pHeight-480))
+
+      if ( windowItems[pId] )
+      {
+         pHeight = dd.elements[pId + "_im_window_body_inner"].h;
+         pWidth = dd.elements[pId + "_im_window_body_inner"].w;
+      }
+
+      if ( !this.xslWin ) this.xslWin = XMLTools.load(im_path + 'xsl/window.xsl' + _time);
+      _xmlDoc = '<window id="' + pId + '" title="' + pTitle + '" height="' + pHeight + '" width="' + pWidth + '" left="' + pLeft + '" top="' + pTop + '" minimize="' + pMinimize + '" maximize="' + pMaximize  + '" close="' + pClose + '" style="position:absolute;' + pStyle + '" />';
+
+      a = document.createElement('div');
+
+      if (window.ActiveXObject)
+      {
+         var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
+         xmlDoc.async = "false";
+         xmlDoc.loadXML(_xmlDoc);
+      }
+      else
+      {
+         var parser = new DOMParser();
+         var xmlDoc = parser.parseFromString(_xmlDoc, "text/xml");
+      }
+      a.innerHTML = XMLTools.transform(xmlDoc, this.xslWin);
+      document.getElementsByTagName('body').item(0).appendChild(a);
+
+      switch ( typeof pBody )
+      {
+         case 'object' :
+                        func.insEl(pBody, pId + '_im_window_body_inner');
+         break;
+         case 'string' :
+                        func.byId(pId + '_im_window_body_inner').innerHTML = pBody;
+
+      }
+
+      RoundedTop('div#' + pId + '_im_window_master', '', '#cbdae4');
+      this.windowMaximizeZ(pId);
+   },
+
+   "hideAllChatSelections" : function()
+   {
+      this.hideEmotionSelection();
+      this.hideFontNameSelection();
+      this.hideFontSizeSelection();
+      this.hideFontColorSelection();
+      this.hideFontStyleSelection();
+   },
+
+   "hideWindowItem" : function(pId)
+   {
+      dd.elements[pId + "_im_window"].hide();
+      dd.elements[pId + "_im_window_master"].hide();
+      dd.elements[pId + "_im_window_fantom"].hide();
+      dd.elements[pId + "_im_window_resize"].hide();
+      dd.elements[pId + "_im_window_movable"].hide();
+      if ( (name_document = document.getElementById(pId + '_divEdita')) )
+      {
+         name_document.innerHTML = '';
+         var contact = func.byId(pId);
+         var _status = IM.vcard_contacts[contact.getAttribute('nuncontact')].online
+         contact.firstChild.src = ( _status == parseInt(1) ) ? img_online.src : img_offline.src;
+      }
+   },
+
+   "incZ" : function()
+   {
+      zValue += 5;
+      return zValue;
+   },
+
+   "drag" : function()
+   {
+      try
+      {
+         var objName = dd.obj.name;
+         i = objName.indexOf("_");
+         objName = objName.substr(0,i);
+
+         this.incZ();
+         document.getElementById(objName + "_im_window_fantom").style.zIndex = zValue;
+         dd.elements[objName + "_im_window_fantom"].setOpacity(0.5);
+
+         document.getElementById(objName + "_im_window_fantom").className = "im_window_fantom";
+
+         var posX = dd.obj.x;
+         var posY = dd.obj.y;
+         if ( posX < 0 )
+            posX = 0;
+         if ( posY < 0 )
+            posY = 0;
+
+         dd.elements[objName + "_im_window_resize"].setOpacity(0);
+
+         if ( dd.obj.name == (objName + "_im_window_resize") )
+         {
+            windowState = WINDOW_STATE_REGULAR;
+
+            // check if the re-size goes out of the screen
+            if ( posX > ( dd.getWndW() - 15 ) )
+               posX = dd.getWndW()-15;
+            if ( posY > ( dd.getWndH() - 13 ) )
+               posY = dd.getWndH()-13;
+
+            // everything is fine, let's change the size of all required objects
+            var newW = posX-dd.elements[objName + "_im_window_fantom"].x+15;
+            var newH = posY-dd.elements[objName + "_im_window_fantom"].y+15;
+            if ( newW < 100) newW = 100;
+            if ( newH < 100) newH = 100;
+            dd.elements[objName + "_im_window_fantom"].resizeTo(newW, newH);
+            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
+            var windowItem = windowItems[objName];
+            windowItem.state = WINDOW_STATE_REGULAR;
+         }
+         else
+         {
+            if ( posX > ( dd.getWndW() - dd.elements[objName + "_im_window_master"].w ) )
+               posX = dd.getWndW() - dd.elements[objName + "_im_window_master"].w;
+
+            if ( posY > ( dd.getWndH() - dd.elements[objName + "_im_window_master"].h ) )
+               posY = dd.getWndH() - dd.elements[objName + "_im_window_master"].h;
+
+            dd.elements[objName + "_im_window_fantom"].moveTo(posX, posY);
+         }
+      }
+      catch(e)
+      {
+      }
+   },
+
+   "drop" : function()
+   {
+      try
+      {
+         document.getElementById("backFantom").style.zIndex = -1;
+
+         var objName = dd.obj.name;
+         i = objName.indexOf("_");
+         objName = objName.substr(0,i);
+
+         var posX = dd.obj.x;
+         var posY = dd.obj.y;
+         if ( posX < 0 )
+            posX = 0;
+         if ( posY < 0 )
+            posY = 0;
+         if ( posX > ( dd.getWndW() - dd.elements[objName + "_im_window_master"].w ) )
+            posX = dd.getWndW() - dd.elements[objName + "_im_window_master"].w;
+         if ( posY > ( dd.getWndH() - dd.elements[objName + "_im_window_master"].h ) )
+            posY = dd.getWndH() - dd.elements[objName + "_im_window_master"].h;
+
+         dd.elements[objName + "_im_window_resize"].setOpacity(1);
+
+         if ( dd.obj.name == (objName + "_im_window_resize") )
+         {
+            var newW = dd.obj.x-dd.elements[objName + "_im_window_fantom"].x+17;
+            var newH = dd.obj.y-dd.elements[objName + "_im_window_fantom"].y+17;
+
+            if ( newW < 100) newW = 100;
+            if ( newH < 100) newH = 100;
+
+            var winW = dd.elements[objName + "_im_window_master"].w - dd.elements[objName + "_im_window"].w;
+            var winH = dd.elements[objName + "_im_window_master"].h - dd.elements[objName + "_im_window"].h;
+
+            dd.elements[objName + "_im_window_fantom"].resizeTo(newW, newH);
+            dd.elements[objName + "_im_window_master"].resizeTo(newW, newH);
+
+            var bodyW = dd.elements[objName + "_im_window"].w - dd.elements[objName + "_im_window_body_inner"].w;
+            var bodyH = dd.elements[objName + "_im_window"].h - dd.elements[objName + "_im_window_body_inner"].h;
+
+            dd.elements[objName + "_im_window"].resizeTo(newW - winW, newH - winH);
+
+            bodyW = dd.elements[objName + "_im_window"].w - bodyW;
+            bodyH = dd.elements[objName + "_im_window"].h - bodyH;
+
+            dd.elements[objName + "_im_window_body_inner"].resizeTo(bodyW, bodyH);
+
+            dd.elements[objName + "_im_window_movable"].resizeTo(newW-55, 25);
+            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
+         }
+         else
+         {
+            dd.elements[objName + "_im_window_fantom"].moveTo(posX, posY);
+            dd.elements[objName + "_im_window_master"].moveTo(posX, posY);
+            dd.elements[objName + "_im_window"].moveTo(posX, (posY+4));
+            dd.elements[objName + "_im_window_movable"].moveTo(posX, posY);
+            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-3, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-3);
+         }
+
+         this.windowMaximizeZ(objName);
+
+         dd.elements[objName + "_im_window_fantom"].setOpacity(0);
+         var windowItem = windowItems[objName];
+
+         if ( windowItem != null )
+         {
+            windowItem.x = dd.elements[objName + "_im_window_master"].x;
+            windowItem.y = dd.elements[objName + "_im_window_master"].y;
+            windowItem.w = dd.elements[objName + "_im_window_master"].w;
+            windowItem.h = dd.elements[objName + "_im_window_master"].h;
+         }
+      }
+      catch(e)
+      {
+         //alert(e)
+      }
+   },
+
+   "pick" : function()
+   {
+      document.getElementById("backFantom").style.zIndex = zValue;
+      this.hideAllChatSelections();
+      var objName = dd.obj.name;
+      i = objName.indexOf("_im");
+      objName = objName.substr(0,i);
+      ACTIVE_OBJECTID = objName;
+   },
+
+   "showWindowItem" : function(pId)
+   {
+      if ( (name_document = document.getElementById(pId + '_divEdita')) )
+      {
+         name_document.innerHTML = '<iframe name="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '_edita" class="edit_message" id="' + pId + '_edita" frameborder="0" style="border:margin: 3px 1px 0px 2px; width:290px; height:50px; float:left;"></iframe>';
+
+         name_document = document.getElementById(pId + '_edita');
+         name_document.contentWindow.document.write('<html><body id="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '" style="margin:0px;padding:0px"></body></html>');
+         name_document.contentWindow.document.close();
+         name_document.contentWindow.document.designMode = "On";
+
+         func.attachEvent(name_document.contentWindow.document, 'keypress', im_win.getText);
+         func.attachEvent(name_document.contentWindow.document, 'keyup', im_win.clearText);
+
+         name_document.contentWindow.focus();
+      }
+
+      dd.elements[pId + "_im_window_master"].show();
+      dd.elements[pId + "_im_window"].show();
+      dd.elements[pId + "_im_window_fantom"].show();
+      dd.elements[pId + "_im_window_resize"].show();
+      dd.elements[pId + "_im_window_movable"].show();
+   },
+
+   "windowMaximizeZ" : function(objName)
+   {
+      this.incZ();
+      document.getElementById(objName + "_im_window_fantom").style.zIndex = zValue-3;
+      document.getElementById(objName + "_im_window_master").style.zIndex = zValue-2;
+      document.getElementById(objName + "_im_window").style.zIndex = zValue-1;
+      document.getElementById(objName + "_im_window_body_inner").style.zIndex = zValue-1;
+      document.getElementById(objName + "_im_window_resize").style.zIndex = zValue;
+      document.getElementById(objName + "_im_window_movable").style.zIndex = zValue;
+      if ( dd.elements[objName + "_im_window_movable"] )
+         dd.elements[objName + "_im_window_movable"].z = zValue+1;
+   },
+
+   "windowMinimize" : function(objName)
+   {
+      with(objName)
+         objName = substr(0, indexOf('_im'));
+
+      this.hideWindowItem(objName);
+      windowItem = windowItems[objName];
+      if ( windowItem != null )
+      {
+         windowItem.state = WINDOW_STATE_MINIMIZED;
+      }
+      //this.hideAllChatSelections();
+   },
+
+   "windowMaximizeRestore" : function(objName)
+   {
+      with(objName)
+         objName = substr(0, indexOf('_im'));
+
+      this.hideAllChatSelections();
+
+      windowItem = windowItems[objName];
+
+      if ( windowItem != null )
+      {
+         var bodyW = dd.elements[objName + "_im_window"].w - dd.elements[objName + "_im_window_body_inner"].w;
+         var bodyH = dd.elements[objName + "_im_window"].h - dd.elements[objName + "_im_window_body_inner"].h;
+
+         if ( windowItem.state==WINDOW_STATE_REGULAR )
+         {
+            windowItem.x = dd.elements[objName + "_im_window_master"].x;
+            windowItem.y = dd.elements[objName + "_im_window_master"].y;
+            windowItem.w = dd.elements[objName + "_im_window_master"].w;
+            windowItem.h = dd.elements[objName + "_im_window_master"].h;
+
+            var bodyX = dd.elements[objName + "_im_window_body_inner"].x + dd.elements[objName + "_im_window"].x;
+            var bodyY = dd.elements[objName + "_im_window_body_inner"].y + dd.elements[objName + "_im_window"].y;
+
+            dd.elements[objName + "_im_window_fantom"].moveTo(0, 0);
+            dd.elements[objName + "_im_window_master"].moveTo(0, 0);
+            dd.elements[objName + "_im_window"].moveTo(0, 4);
+
+            dd.elements[objName + "_im_window_fantom"].resizeTo(dd.getWndW(), dd.getWndH());
+            dd.elements[objName + "_im_window_master"].resizeTo(dd.getWndW(), dd.getWndH());
+            dd.elements[objName + "_im_window"].resizeTo(dd.getWndW(), dd.getWndH() - 5);
+            dd.elements[objName + "_im_window_body_inner"].resizeTo(dd.getWndW() - bodyW, dd.getWndH() - bodyH - 5);
+
+            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
+            windowItem.state = WINDOW_STATE_MAXIMIZED;
+
+            window.status = objName + "'s Z: " + document.getElementById(objName+"_im_window").style.zIndex;
+
+            /*
+            windowItem.x = dd.elements[objName + "_im_window"].x;
+            windowItem.y = dd.elements[objName + "_im_window"].y;
+            windowItem.w = dd.elements[objName + "_im_window"].w;
+            windowItem.h = dd.elements[objName + "_im_window"].h;
+            */
+         }
+         else
+         {
+            dd.elements[objName + "_im_window_fantom"].resizeTo(windowItem.w, windowItem.h);
+            dd.elements[objName + "_im_window_master"].resizeTo(windowItem.w, windowItem.h);
+            dd.elements[objName + "_im_window"].resizeTo(windowItem.w, windowItem.h - 5);
+            dd.elements[objName + "_im_window_body_inner"].resizeTo(windowItem.w - bodyW, windowItem.h - bodyH - 5);
+
+            dd.elements[objName + "_im_window_fantom"].moveTo(windowItem.x, windowItem.y);
+            dd.elements[objName + "_im_window_master"].moveTo(windowItem.x, windowItem.y);
+            dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
+            //document.getElementById(objName + "_im_window_body_inner").style.width="100%";
+            //document.getElementById(objName + "_im_window_body_inner").style.height="100%";
+            windowItem.state = WINDOW_STATE_REGULAR;
+         }
+
+      dd.elements[objName + "_im_window_movable"].moveTo(dd.elements[objName + "_im_window"].x, dd.elements[objName + "_im_window"].y);
+      dd.elements[objName + "_im_window_movable"].resizeTo(dd.elements[objName + "_im_window"].w-55, 25);
+
+      this.showWindowItem(objName);
+      this.windowMaximizeZ(objName);
+      }
+   },
+
+   "create_window" : function()
+   {
+      pId = arguments[0]['id'];
+
+      if ( document.getElementById(pId + '_im_window'))
+      {
+         this.windowMaximizeZ(pId);
+      	this.showWindowItem(pId);
+      }
+      else
+      {
+         this.build(arguments[0]);
+
+         ADD_DHTML(pId + "_im_window_body_inner"+NO_DRAG);
+         ADD_DHTML(pId + "_im_window"+NO_DRAG);
+         ADD_DHTML(pId + "_im_window_master"+NO_DRAG);
+         ADD_DHTML(pId + "_im_window_fantom"+NO_DRAG);
+         ADD_DHTML(pId + "_im_window_movable"+CURSOR_MOVE);
+         ADD_DHTML(pId + "_im_window_resize"+CURSOR_NW_RESIZE);
+
+         dd.elements[pId + "_im_window_movable"].moveTo(dd.elements[pId + "_im_window"].x, dd.elements[pId + "_im_window"].y);
+         dd.elements[pId + "_im_window_movable"].resizeTo(dd.elements[pId + "_im_window"].w-20, 25);
+         dd.elements[pId + "_im_window_movable"].setOpacity(0);
+
+         dd.elements[pId + "_im_window_resize"].setOpacity(1);
+
+         dd.elements[pId + "_im_window_resize"].moveTo(dd.elements[pId + "_im_window"].x+dd.elements[pId + "_im_window"].w-dd.elements[pId + "_im_window_resize"].w-2, dd.elements[pId + "_im_window"].y+dd.elements[pId + "_im_window"].h-dd.elements[pId + "_im_window_resize"].h-2);
+         dd.elements[pId + "_im_window_resize"].moveTo(dd.elements[pId + "_im_window_fantom"].x+dd.elements[pId + "_im_window_fantom"].w-dd.elements[pId + "_im_window_resize"].w-2, dd.elements[pId + "_im_window_fantom"].y+dd.elements[pId + "_im_window_fantom"].h-dd.elements[pId + "_im_window_resize"].h-2);
+
+         var windowItem = new Object();
+         windowItem.x = dd.elements[pId + "_im_window_master"].x;
+         windowItem.y = dd.elements[pId + "_im_window_master"].y;
+         windowItem.w = dd.elements[pId + "_im_window_master"].w;
+         windowItem.h = dd.elements[pId + "_im_window_master"].h;
+         windowItem.state = WINDOW_STATE_MINIMIZED;
+         windowItems[pId] = windowItem;
+
+         title = (arguments[0]['title']) ? arguments[0]['title'] : arguments[0]['id'];
+         this.windowMinimize(pId + '_im');
+         this.windowMaximizeRestore(pId + '_im');
+      }
+   },
+
+   "open_chat" : function(pId)
+   {
+      if ( !func.byId(pId + '_im_window') )
+      {
+         text = '';
+         text += '<div class=border id="' + pId + '_chatMessages" style="width:99%; height:130px; margin: 0 0 2px 0; overflow:auto;"></div>'
+         text += '<br style="clear:both;"/>'
+         text += '<div class="myAvatar">'
+         text += '   <img id="' + pId + '_avatar" alt="Display Picture" title="Display Picture" src="' + im_path + 'templates/default/images/photo.png" width="49" height="65" border="0" />'
+         text += '</div>'
+         text += '<dl>'
+         text += '   <dd class="small">'
+         text += '      &nbsp;<span id="selectEmotionsDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showEmotionSelection(\'' + pId + '\');" title="Select Imotions here!"><img src="' + im_path + 'templates/default/images/img/1.gif" width="15" height="15" alt="Select Imotions here!" style="vertical-align:	text-top;" /></span>'
+         text += '   </dd>'
+         text += '   <dd class="small">|</dd>'
+         text += '   <dd class="small">'
+         text += '      <span id="selectFontNameDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontNameSelection(\'' + pId + '\');" title="Select Font Name here!" style="height:19px;">'+IM.get_lang('Font')+'</span>'
+         text += '   </dd>'
+         text += '   <dd class="small">|</dd>'
+         text += '   <dd class="small">'
+         text += '      <span id="selectFontSizeDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontSizeSelection(\'' + pId + '\')" title="Select Font Size here!" style="height:19px;">'+IM.get_lang('Size')+'</span>'
+         text += '   </dd>'
+         text += '   <dd class="small">|</dd>'
+         text += '   <dd class="small">'
+         text += '      <span id="selectFontColorDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontColorSelection(\'' + pId + '\')" title="Select Font Color here!" style="height:19px;">'+IM.get_lang('Color')+'</span>'
+         text += '   </dd>'
+         text += '   <dd class="small">|</dd>'
+         text += '   <dd class="small">'
+         text += '      <span id="selectFontStyleDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="im_win.showFontStyleSelection(\'' + pId + '\')" title="Select Font Color here!" style="height:19px;">'+IM.get_lang('Style')+'</span>'
+         text += '   </dd>'
+         text += '   <dd class="small">|</dd>'
+         text += '   <dd class="small">'
+         text += '      <span id="selectFontStyleDiv" class="des-small" onmouseover="selectDiv(this)" onmouseout="unselectDiv(this)" onclick="Preferences.SendFile(\'' + pId + '\')" title="Select Send File here!" style="height:19px;">'+IM.get_lang('Send File')+'</span>'
+         text += '   </dd>'
+         text += '</dl>'
+         text += '<div id="' + pId + '_divEdita"><iframe name="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '_edita" class="edit_message" id="' + pId + '_edita" frameborder="0" style="border:margin: 3px 1px 0px 2px; width:290px; height:50px; float:left;"></iframe></div>'
+         text += '<a onclick="javascript:IM.sendMessage(\'' + pId + '\')" title="Send a message" style="float:left"><img src="' + im_path + 'templates/default/images/img/skins/deathdart/send.gif" width="102" height="50" border=0 style="margin-top:3px"></a>';
+
+         params = [];
+         params['body']     = text;
+         params['height']   = 215;
+         params['id']       = pId;
+         params['maximize'] = false;
+         params['minimize'] = false;
+         params['title']    = pId;
+         params['width']    = 475;
+         this.create_window(params);
+
+         // Photo Ldap;
+         this.get_photo_ldap(pId);
+
+         name_document = document.getElementById(pId + '_edita');
+         name_document.contentWindow.document.write('<html><body id="' + pId.replace('@', '_at_').replace(/\./g, '_dot_') + '" style="margin:0px;padding:0px"></body></html>');
+         name_document.contentWindow.document.close();
+         name_document.contentWindow.document.designMode = "On";
+
+         func.attachEvent(name_document.contentWindow.document, 'keypress', im_win.getText);
+         func.attachEvent(name_document.contentWindow.document, 'keyup', im_win.clearText);
+
+         name_document.contentWindow.focus();
+      }
+      else
+      {
+         this.showWindowItem(pId);
+      }
+   },
+
+   "get_photo_ldap" : function(IdLdap)
+   {
+		var uid_ldap = IdLdap.substr(0,IdLdap.indexOf('@'));
+		var handler_photo_ldap = function(data){
+			if(data){
+				IdLdap = ( IM.vcard_user['VCARD_JID'] == IdLdap ) ? 'contacts' : IdLdap;
+				if(document.getElementById(IdLdap + "_avatar")){
+					var photo_img_0 = document.getElementById(IdLdap + "_avatar");
+					photo_img_0.src = im_path + "inc/class.ldap_im.inc.php?user="+uid_ldap;
+				}
+			}
+		}
+		cIM.cExecute("$this.ldap_im.photo_ldap",handler_photo_ldap,"uid="+uid_ldap);
+   },
+
+   "windowClose" : function(objName)
+   {
+      with(objName)
+         objName = substr(0, indexOf('_im'));
+
+      this.hideWindowItem(objName);
+      this.hideAllChatSelections();
+
+      var windowItem = windowItems[objName];
+      if ( windowItem != null )
+         windowItem.state = WINDOW_STATE_CLOSED;
+
+      if ( objName != 'contacts' )
+      {
+         var window = document.getElementById(objName + '_im_window');
+         var resize = document.getElementById(objName + '_im_window_resize');
+         var fantom = document.getElementById(objName + '_im_window_fantom');
+         var movable = document.getElementById(objName + '_im_window_movable');
+
+         window.parentNode.removeChild(window);
+         resize.parentNode.removeChild(resize);
+         fantom.parentNode.removeChild(fantom);
+         movable.parentNode.removeChild(movable);
+
+         // delete windowItem;
+      }
+   },
+
+   "hideEmotionSelection" : function()
+   {
+      emotionsDiv = document.getElementById("shared_emotions");
+      if ( isEmotionSelectionVisible )
+      {
+         emotionsDiv.style.visibility = "hidden";
+         isEmotionSelectionVisible = false;
+      }
+   },
+
+   "highlightie5" : function (e)
+   {
+      if ( e.className == "emotionItem" )
+         e.className = "emotionItem-sel";
+      else if ( e.className == "menuitems" )
+         e.className = "menuitems-sel";
+
+   },
+
+   "lowlightie5" : function(e)
+   {
+      if ( e.className == "emotionItem-sel" )
+         e.className = "emotionItem";
+      else if ( e.className == "menuitems-sel" )
+         e.className = "menuitems";
+   },
+
+   "addEmotion" : function(emotion)
+   {
+	 n_document = document.getElementById(this.chat_pJid + '_edita');
+	 var edita = n_document.contentWindow.document.getElementsByTagName('body').item(0);
+	 edita.innerHTML += IM.emotions_icons(emotion);
+
+     this.hideEmotionSelection();
+   },
+
+   "showEmotionSelection" : function(objName)
+   {
+      this.chat_pJid = objName;
+      activeChatWindowId = objName;
+      var emotionsDiv = document.getElementById("shared_emotions");
+      if(!isEmotionSelectionVisible)
+      {
+         this.hideAllChatSelections();
+         chatObj = dd.elements[objName + "_im_window"];
+         x = chatObj.x + 6;
+         y = chatObj.y + chatObj.h - 200;
+         dd.elements.shared_emotions.moveTo(x,y);
+         this.incZ();
+         document.getElementById("shared_emotions").style.zIndex = zValue;
+         emotionsDiv.style.visibility = "visible";
+         isEmotionSelectionVisible = true;
+      }
+      else
+      {
+         this.hideAllChatSelections();
+      }
+   },
+
+   "showFontNameSelection" : function(objName)
+   {
+      this.chat_pJid = objName;
+      activeChatWindowId = objName;
+      var objDiv = document.getElementById("shared_fontName");
+      if(!isFontNameSelectionVisible)
+      {
+         this.hideAllChatSelections();
+         chatObj = dd.elements[objName + "_im_window"];
+         x = chatObj.x + 85;
+         y = chatObj.y + chatObj.h - 185;
+         dd.elements.shared_fontName.moveTo(x,y);
+         this.incZ();
+         document.getElementById("shared_fontName").style.zIndex = zValue;
+         objDiv.style.visibility = "visible";
+         isFontNameSelectionVisible = true;
+      }
+      else
+      {
+         this.hideAllChatSelections();
+      }
+   },
+
+   "hideFontNameSelection" : function()
+   {
+      var objDiv = document.getElementById("shared_fontName");
+      if ( isFontNameSelectionVisible )
+      {
+         objDiv.style.visibility = "hidden";
+         isFontNameSelectionVisible = false;
+      }
+   },
+
+   "showFontSizeSelection" : function(objName)
+   {
+
+      this.chat_pJid = objName;
+      activeChatWindowId = objName;
+      var objDiv = document.getElementById("shared_fontSize");
+      if ( !isFontSizeSelectionVisible )
+      {
+         this.hideAllChatSelections();
+         chatObj = dd.elements[objName + "_im_window"];
+         x = chatObj.x + 154;
+         y = chatObj.y + chatObj.h - 200;
+         dd.elements.shared_fontSize.moveTo(x,y);
+         this.incZ();
+         document.getElementById("shared_fontSize").style.zIndex = zValue;
+         objDiv.style.visibility = "visible";
+         isFontSizeSelectionVisible = true;
+      }
+      else
+      {
+         this.hideAllChatSelections();
+      }
+   },
+
+   "hideFontSizeSelection" : function()
+   {
+      var objDiv = document.getElementById("shared_fontSize");
+      if ( isFontSizeSelectionVisible )
+      {
+         objDiv.style.visibility = "hidden";
+         isFontSizeSelectionVisible = false;
+      }
+   },
+
+   "showFontColorSelection" : function(objName)
+   {
+      this.chat_pJid = objName;
+      activeChatWindowId = objName;
+      var objDiv = document.getElementById("shared_fontColor");
+      if ( !isFontColorSelectionVisible )
+      {
+         this.hideAllChatSelections();
+         chatObj = dd.elements[objName + "_im_window"];
+         x = chatObj.x + 191;
+         y = chatObj.y + chatObj.h - 200;
+         dd.elements.shared_fontColor.moveTo(x,y);
+         this.incZ();
+         document.getElementById("shared_fontColor").style.zIndex = zValue;
+         objDiv.style.visibility = "visible";
+         isFontColorSelectionVisible = true;
+      }
+      else
+      {
+         this.hideAllChatSelections();
+      }
+   },
+
+   "showFontStyleSelection" : function(objName)
+   {
+      this.chat_pJid = objName;
+      activeChatWindowId = objName;
+      var objDiv = document.getElementById("shared_fontStyle");
+      if ( !isFontStyleSelectionVisible )
+      {
+         this.hideAllChatSelections();
+         chatObj = dd.elements[objName + "_im_window"];
+         x = chatObj.x + 234;
+         y = chatObj.y + chatObj.h - 181;
+         dd.elements.shared_fontStyle.moveTo(x,y);
+         this.incZ();
+         document.getElementById("shared_fontStyle").style.zIndex = zValue;
+         objDiv.style.visibility = "visible";
+         isFontStyleSelectionVisible = true;
+      }
+      else
+      {
+         this.hideAllChatSelections();
+      }
+   },
+
+   "showMessageHistoryWindow" : function()
+   {
+	   // Revisar ALC
+      alert("Função Indisponivel");
+      return false;
+   },
+
+   "hideFontColorSelection" : function()
+   {
+      var objDiv = document.getElementById("shared_fontColor");
+      if ( isFontColorSelectionVisible )
+      {
+         objDiv.style.visibility = "hidden";
+         isFontColorSelectionVisible = false;
+      }
+   },
+
+   "hideFontStyleSelection" : function()
+   {
+      var objDiv = document.getElementById("shared_fontStyle");
+      if ( isFontStyleSelectionVisible )
+      {
+         objDiv.style.visibility = "hidden";
+         isFontStyleSelectionVisible = false;
+      }
+   },
+
+   "newMessageNotification" : function()
+   {
+      if ( !focusFlag )
+      {
+         if ( document.title=="......................" )
+            document.title = "New Message!";
+         else
+            document.title = "......................";
+         if ( newMessageTimer )
+            clearTimeout(newMessageTimer);
+         newMessageTimer = setTimeout("im_win.newMessageNotification()", 1000);
+      }
+      else
+      {
+         if ( newMessageTimer ) clearTimeout(newMessageTimer);
+      }
+   },
+
+   "getText" : function(e)
+   {
+      if ( !focusFlag ) windowFocus();
+      evt = e.keyCode;
+      pId = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0).id;
+      pId = pId.replace('_at_', '@').replace(/_dot_/g, '.')
+      switch ( evt )
+      {
+         case 13 :
+                  if ( !e.shiftKey )
+                     IM.sendMessage(pId);
+                  return false;
+         break;
+         case 27 :
+                  im_win.windowClose(pId + '_im');
+         break;
+      }
+   },
+
+   "clearText" : function(e)
+   {
+      if ( !focusFlag ) windowFocus();
+      evt = e.keyCode;
+      _text = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0);
+
+      switch ( evt )
+      {
+         case 13 :
+                  //if ( !e.shiftKey )
+                     _text.innerHTML = '';
+                     return false;
+         break;
+      }
+   }
+}
+
+function my_DragFunc()
+{
+   im_win.drag();
+}
+function my_DropFunc()
+{
+   im_win.drop();
+}
+function my_PickFunc()
+{
+   im_win.pick();
+}
+function selectDiv(obj) {
+  obj.className = "sel-small";
+}
+function unselectDiv(obj) {
+  obj.className = "des-small";
+}
+function getElementsBySelector(selector)
+{
+   var i;
+   var s=[];
+   var selid="";
+   var selclass="";
+   var tag=selector;
+   var objlist=[];
+   if ( selector.indexOf(" ") > 0 )
+   {//descendant selector like "tag#id tag"
+      s=selector.split(" ");
+      var fs=s[0].split("#");
+      if ( fs.length == 1 )
+         return(objlist);
+      return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
+   }
+   if ( selector.indexOf("#") > 0 )
+   {//id selector like "tag#id"
+      s=selector.split("#");
+      tag=s[0];
+      selid=s[1];
+   }
+   if ( selid != "" )
+   {
+      objlist.push(document.getElementById(selid));
+      return(objlist);
+   }
+   if ( selector.indexOf(".") > 0 )
+   {//class selector like "tag.class"
+      s=selector.split(".");
+      tag=s[0];
+      selclass=s[1];
+   }
+   var v = document.getElementsByTagName(tag);  // tag selector like "tag"
+   if ( selclass == "" )
+      return(v);
+
+   for ( i = 0; i < v.length; i++ )
+      if ( v[i].className ==selclass )
+         objlist.push(v[i]);
+
+   return(objlist);
+}
+function AddTop(el,bk,color,size){
+   var i;
+   var d=document.createElement("b");
+   var cn="_r";
+   var lim=4;
+   if(size && size=="small"){ cn="_rs"; lim=2}
+   d.className="_rtop";
+   d.style.backgroundColor=bk;
+   for(i=1;i<=lim;i++)
+   {
+      var x=document.createElement("b");
+      x.className=cn + i;
+      x.style.backgroundColor=color;
+      d.appendChild(x);
+   }
+   el.insertBefore(d,el.firstChild);
+}
+function RoundedTop(selector,bk,color,size){
+   var i;
+   var v=getElementsBySelector(selector);
+   for(i=0;i<v.length;i++)
+          AddTop(v[i],bk,color,size);
+}
+
+im_win.load();
Index: /trunk/instant_messenger/js/wz_dragdrop.js
===================================================================
--- /trunk/instant_messenger/js/wz_dragdrop.js	(revision 20)
+++ /trunk/instant_messenger/js/wz_dragdrop.js	(revision 20)
@@ -0,0 +1,1427 @@
+/* This notice must be untouched at all times.
+
+wz_dragdrop.js    v. 4.55
+The latest version is available at
+http://www.walterzorn.com
+or http://www.devira.com
+or http://www.walterzorn.de
+
+Copyright (c) 2002-2003 Walter Zorn. All rights reserved.
+Created 26. 8. 2002 by Walter Zorn (Web: http://www.walterzorn.com )
+Last modified: 23. 5. 2004
+
+This DHTML & Drag&Drop Library adds Drag&Drop functionality
+to the following types of html-elements:
+- images, even if not positioned via layers,
+  nor via stylesheets or any other kind of "hard-coding"
+- relatively and absolutely positioned layers (DIV elements).
+Moreover, it provides extended DHTML abilities.
+
+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.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY;
+without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License
+at http://www.gnu.org/copyleft/gpl.html for more details.
+*/
+
+
+// PATH TO THE TRANSPARENT 1*1 PX IMAGE (required by NS 4 as spacer)
+var spacer = 'transparentpixel.gif';
+
+
+
+
+//window.onerror = new Function('return true;');
+
+
+// Optional commands passed to SET_DHTML() on the html-page (g: may be applied globally, i: individually)
+var CLONE            = 'C10nE';   // i  img      clone image
+var COPY             = 'C0pY';    // i  img      create copies
+var DETACH_CHILDREN  = 'd37aCH';  // i  lyr      detach images
+var HORIZONTAL       = 'H0r1Z';   // i  img,lyr  horizontally draggable only
+var MAXHEIGHT        = 'm7x8I';   // i  img,lyr  maximum height limit, "
+var MAXOFFBOTTOM     = 'm7xd0wN'; // i  img,lyr  downward offset limit
+var MAXOFFLEFT       = 'm7x23Ft'; // i  img,lyr  leftward offset limit
+var MAXOFFRIGHT      = 'm7x0Ff8'; // i  img,lyr  rightward offset limit
+var MAXOFFTOP        = 'm7xu9';   // i  img,lyr  upward offset limit
+var MAXWIDTH         = 'm7xW1';   // i  img,lyr  maximum width limit, use with resizable or scalable
+var MINWIDTH         = 'm1nw1';   // i  img,lyr  minimum width limit, "
+var MINHEIGHT        = 'm1n8I';   // i  img,lyr  minimum height limit, "
+var NO_ALT           = 'no81T';   // gi img      disable alt and title attributes
+var NO_DRAG          = 'N0d4Ag';  // i  img,lyr  disable draggability
+var RESET_Z          = 'r35E7z';  // gi img,lyr  reset z-index when dropped
+var RESIZABLE        = 'r5IZbl';  // gi img,lyr  resizable if <ctrl> or <shift> pressed
+var SCALABLE         = 'SCLbl';   // gi img,lyr  scalable           "
+var SCROLL           = 'sC8lL';   // gi img,lyr  enable auto scroll functionality
+var VERTICAL         = 'V3Rt1C';  // i  img,lyr  vertically draggable only
+
+var dd_cursors = new Array(
+	'c:default',
+	'c:crosshair',
+	'c:e-resize',
+	'c:hand',
+	'c:help',
+	'c:move',
+	'c:n-resize',
+	'c:ne-resize',
+	'c:nw-resize',
+	'c:s-resize',
+	'c:se-resize',
+	'c:sw-resize',
+	'c:text',
+	'c:w-resize',
+	'c:wait'
+);
+var dd_i = dd_cursors.length; while(dd_i--)
+	eval('var CURSOR_' + (dd_cursors[dd_i].substring(2).toUpperCase().replace('-', '_')) + ' = "' + dd_cursors[dd_i] + '";');
+
+var dd_u = "undefined";
+
+function WZDD()
+{
+	this.n = navigator.userAgent.toLowerCase();
+	this.db = (document.compatMode && document.compatMode.toLowerCase() != "backcompat")?
+		document.documentElement
+		: (document.body || null);
+	this.op = !!(window.opera && document.getElementById);
+	this.op6 = !!(this.op && !(this.db && this.db.innerHTML));
+	if (this.op && !this.op6) document.onmousedown = new Function('e',
+		'if (((e = e || window.event).target || e.srcElement).tagName == "IMAGE") return false;'
+	);
+	this.ie = !!(this.n.indexOf("msie") >= 0 && document.all && this.db && !this.op);
+	this.iemac = !!(this.ie && this.n.indexOf("mac") >= 0);
+	this.ie4 = !!(this.ie && !document.getElementById);
+	this.n4 = !!(document.layers && typeof document.classes != dd_u);
+	this.n6 = !!(typeof window.getComputedStyle != dd_u && typeof document.createRange != dd_u);
+	this.w3c = !!(!this.op && !this.ie && !this.n6 && document.getElementById);
+	this.ce = !!(document.captureEvents && document.releaseEvents);
+	this.px = (this.n4 || this.op6)? '' : 'px';
+}
+var dd = new WZDD();
+
+dd.Int = function(d_x, d_y)
+{
+	return isNaN(d_y = parseInt(d_x))? 0 : d_y;
+};
+
+dd.getWndW = function()
+{
+	return dd.Int(
+		(dd.db && !dd.op && !dd.w3c && dd.db.clientWidth)? dd.db.clientWidth
+		: (window.innerWidth || 0)
+	);
+};
+
+dd.getWndH = function()
+{
+	return dd.Int(
+		(dd.db && !dd.op && !dd.w3c && dd.db.clientHeight)? dd.db.clientHeight
+		: (window.innerHeight || 0)
+	);
+};
+
+dd.getScrollX = function()
+{
+	return dd.Int(window.pageXOffset || (dd.db? dd.db.scrollLeft : 0));
+};
+
+dd.getScrollY = function()
+{
+	return dd.Int(window.pageYOffset || (dd.db? dd.db.scrollTop : 0));
+};
+
+dd.getPageXY = function(d_o)
+{
+	if (dd.n4 && d_o)
+	{
+		dd.x = d_o.pageX || 0;
+		dd.y = d_o.pageY || 0;
+	}
+	else
+	{
+		dd.x = dd.y = 0; //global helper vars
+		while (d_o)
+		{
+			dd.x += dd.Int(d_o.offsetLeft);
+			dd.y += dd.Int(d_o.offsetTop);
+			d_o = d_o.offsetParent || null;
+		}
+	}
+};
+
+dd.getCssXY = function(d_o)
+{
+	if (d_o.div)
+	{
+		if (dd.n4)
+		{
+			d_o.cssx = d_o.div.x;
+			d_o.cssy = d_o.div.y;
+		}
+		else if (dd.ie4)
+		{
+			d_o.cssx = d_o.css.pixelLeft;
+			d_o.cssy = d_o.css.pixelTop;
+		}
+		else
+		{
+			d_o.css.left = d_o.css.top = 0 + dd.px;
+			dd.getPageXY(d_o.div);
+			d_o.cssx = d_o.x - dd.x;
+			d_o.cssy = d_o.y - dd.y;
+			d_o.css.left = d_o.cssx + dd.px;
+			d_o.css.top = d_o.cssy + dd.px;
+		}
+	}
+	else
+	{
+		d_o.cssx = 0;
+		d_o.cssy = 0;
+	}
+};
+
+dd.getImgW = function(d_o)
+{
+	return d_o? dd.Int(d_o.width) : 0;
+};
+
+dd.getImgH = function(d_o)
+{
+	return d_o? dd.Int(d_o.height) : 0;
+};
+
+dd.getDivW = function(d_o)
+{
+	return dd.Int(
+		dd.n4? (d_o.div? d_o.div.clip.width : 0)
+		: d_o.div? (d_o.div.offsetWidth || d_o.css.pixelWidth || d_o.css.width || 0)
+		: 0
+	);
+};
+
+dd.getDivH = function(d_o)
+{
+	return dd.Int(
+		dd.n4? (d_o.div? d_o.div.clip.height : 0)
+		: d_o.div? (d_o.div.offsetHeight || d_o.css.pixelHeight || d_o.css.height || 0)
+		: 0
+	);
+};
+
+dd.getWH = function(d_o)
+{
+	d_o.w = dd.getDivW(d_o);
+	d_o.h = dd.getDivH(d_o);
+	if (d_o.css)
+	{
+		d_o.css.width = d_o.w + dd.px;
+		d_o.css.height = d_o.h + dd.px;
+		d_o.dw = dd.getDivW(d_o)-d_o.w;
+		d_o.dh = dd.getDivH(d_o)-d_o.h;
+		d_o.css.width = (d_o.w-d_o.dw) + dd.px;
+		d_o.css.height = (d_o.h-d_o.dh) + dd.px;
+	}
+	else d_o.dw = d_o.dh = 0;
+};
+
+dd.getCssProp = function(d_o, d_pn6, d_pstyle, d_pn4)
+{
+	if (d_o && dd.n6) return ''+window.getComputedStyle(d_o, null).getPropertyValue(d_pn6);
+	if (d_o && d_o.currentStyle) return ''+eval('d_o.currentStyle.'+d_pstyle);
+	if (d_o && d_o.style) return ''+eval('d_o.style.'+d_pstyle);
+	if (d_o && dd.n4) return ''+eval('d_o.'+d_pn4);
+	return '';
+};
+
+dd.getDiv = function(d_x, d_d)
+{
+	d_d = d_d || document;
+	if (dd.n4)
+	{
+		if (d_d.layers[d_x]) return d_d.layers[d_x];
+		for (var d_i = d_d.layers.length; d_i--;)
+		{
+			var d_y = dd.getDiv(d_x, d_d.layers[d_i].document);
+			if (d_y) return d_y;
+		}
+	}
+	if (dd.ie) return d_d.all[d_x] || null;
+	if (d_d.getElementById) return d_d.getElementById(d_x) || null;
+	return null;
+};
+
+dd.getImg = function(d_o, d_nm, d_xy, d_w)
+{
+	d_w = d_w || window;
+	var d_img;
+	if ((d_img = d_w.document.images[d_nm]) && d_img.name == d_nm)
+	{
+		if (d_xy)
+		{
+			if (dd.n4)
+			{
+				dd.getPageXY(d_w);
+				d_o.defx = d_img.x + dd.x;
+				d_o.defy = d_img.y + dd.y;
+			}
+			else
+			{
+				dd.getPageXY(d_img);
+				d_o.defx = dd.x;
+				d_o.defy = dd.y;
+			}
+		}
+		return d_img;
+	}
+	if (dd.n4) for (var d_i = d_w.document.layers.length; d_i--;)
+	{
+		var d_y = dd.getImg(d_o, d_nm, d_xy, d_w.document.layers[d_i]);
+		if (d_y) return d_y;
+	}
+	return null;
+};
+
+dd.getParent = function(d_o)
+{
+	if (dd.n4)
+	{
+		for (var d_p, d_i = dd.elements.length; d_i--;)
+		{
+			if (!((d_p = dd.elements[d_i]).is_image) && d_p.div && (d_p.div.document.layers[d_o.name] || d_o.oimg && d_p.div.document.images[d_o.oimg.name]))
+				d_p.addChild(d_o, d_p.detach, 1);
+		}
+	}
+	else
+	{
+		var d_p = d_o.is_image? dd.getImg(d_o, d_o.oimg.name) : (d_o.div || null);
+		while (d_p && !!(d_p = d_p.offsetParent || d_p.parentNode || null))
+		{
+			if (d_p.ddObj)
+			{
+				d_p.ddObj.addChild(d_o, d_p.ddObj.detach, 1);
+				break;
+			}
+		}
+	}
+};
+
+dd.getCmd = function(d_o, d_cmd, d_cmdStr)
+{
+	var d_i = d_o.id.indexOf(d_cmd), d_j,
+	d_y = (d_i >= 0)*1;
+	if (d_y)
+	{
+		d_j = d_i+d_cmd.length;
+		if (d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j);
+		d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);
+	}
+	return d_y;
+};
+
+dd.getCmdVal = function(d_o, d_cmd, d_cmdStr, int0)
+{
+	var d_i = d_o.id.indexOf(d_cmd), d_j,
+	d_y = (d_o.id.indexOf(d_cmd) >= 0)? dd.Int(d_o.id.substring(d_o.id.indexOf(d_cmd)+d_cmd.length)) : int0? -1 : 0;
+	if (!int0 && d_y || int0 && d_y >= 0)
+	{
+		d_j = d_i+d_cmd.length+d_y.toString().length;
+		if (d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j);
+		d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);
+	}
+	return d_y;
+};
+
+dd.addElt = function(d_o, d_p)
+{
+	dd.elements[dd.elements.length] = dd.elements[d_o.name] = d_o;
+	if (d_p) d_p.copies[d_p.copies.length] = d_p.copies[d_o.name] = d_o;
+};
+
+dd.mkWzDom = function()
+{
+	var d_i = dd.elements.length; while(d_i--) dd.getParent(dd.elements[d_i]);
+	d_i = dd.elements.length; while(d_i--)
+		d_o = dd.elements[d_i];
+		if (d_o.children && !d_o.parent)
+		{
+			var d_j = d_o.children.length; while(d_j--)
+				d_o.children[d_j].setZ(d_o.z+d_o.children[d_j].z, 1);
+		}
+};
+
+dd.addProps = function(d_o)
+{
+	var d_i, d_c;
+	if (d_o.is_image)
+	{
+		d_o.div = dd.getDiv(d_o.id);
+		if (d_o.div && typeof d_o.div.style != "undefined") d_o.css = d_o.div.style;
+		d_o.nimg = (dd.n4 && d_o.div)? d_o.div.document.images[0] : (document.images[d_o.id+'NImG'] || null);
+		if (!d_o.noalt && !dd.noalt)
+		{
+			d_o.nimg.alt = d_o.oimg.alt || '';
+			if (d_o.oimg.title) d_o.nimg.title = d_o.oimg.title;
+		}
+		d_o.bgColor = '';
+	}
+	else
+	{
+		d_o.bgColor = dd.getCssProp(d_o.div, 'background-color','backgroundColor','bgColor').toLowerCase();
+		if (dd.n6 && d_o.div)
+		{
+			if ((d_c = d_o.bgColor).indexOf('rgb') >= 0)
+			{
+				d_c = d_c.substring(4, d_c.length-1).split(',');
+				d_o.bgColor = '#';
+				for (var d_i = 0; d_i < d_c.length; d_i++) d_o.bgColor += parseInt(d_c[d_i]).toString(0x10);
+			}
+			else d_o.bgColor = d_c;
+		}
+	}
+	if (dd.scalable) d_o.scalable = d_o.resizable^1;
+	else if (dd.resizable) d_o.resizable = d_o.scalable^1;
+	d_o.setZ(d_o.defz);
+	d_o.cursor = d_o.cursor || dd.cursor || 'auto';
+	d_o._setCrs(d_o.nodrag? 'auto' : d_o.cursor);
+	d_o.visible = true;
+};
+
+dd.initz = function()
+{
+	if (!(dd && (dd.n4 || dd.n6 || dd.ie || dd.op || dd.w3c))) return;
+	if (dd.op6) WINSZ(2);
+	else if (dd.n6 || dd.ie || dd.op && !dd.op6 || dd.w3c) dd.recalc(1);
+	var d_drag = (document.onmousemove == DRAG),
+	d_resize = (document.onmousemove == RESIZE);
+	if (dd.loadFunc) dd.loadFunc();
+	if (d_drag && document.onmousemove != DRAG) dd.setEvtHdl(1, DRAG);
+	else if (d_resize && document.onmousemove != RESIZE) dd.setEvtHdl(1, RESIZE);
+	if ((d_drag || d_resize) && document.onmouseup != DROP) dd.setEvtHdl(2, DROP);
+	dd.setEvtHdl(0, PICK);
+};
+
+dd.finlz = function()
+{
+	if (dd.ie && dd.elements)
+	{
+		var d_i = dd.elements.length; while (d_i--)
+			dd.elements[d_i].del();
+	}
+};
+
+dd.setEvtHdl = function(d_typ, d_func)
+{
+	if (!d_typ)
+	{
+		if (document.onmousedown != d_func) dd.downFunc = document.onmousedown || null;
+		document.onmousedown = d_func;
+	}
+	else if (d_typ&1)
+	{
+		if (document.onmousemove != d_func) dd.moveFunc = document.onmousemove || null;
+		document.onmousemove = d_func;
+	}
+	else
+	{
+		if (document.onmouseup != d_func) dd.upFunc = document.onmouseup || null;
+		document.onmouseup = d_func;
+	}
+	if (dd.ce)
+	{
+		var d_e = (!d_typ)? Event.MOUSEDOWN : (d_typ&1)? Event.MOUSEMOVE : Event.MOUSEUP;
+		d_func? document.captureEvents(d_e) : document.releaseEvents(d_e);
+	}
+};
+
+dd.evt = function(d_e)
+{
+	this.but = (this.e = d_e || window.event).which || this.e.button || 0;
+	this.button = (this.e.type == 'mousedown')? this.but
+		: (dd.e && dd.e.button)? dd.e.button
+		: 0;
+	this.src = this.e.target || this.e.srcElement || null;
+	this.src.tag = (this.src.tagName || this.src).toString().toLowerCase();
+	this.x = dd.Int(this.e.pageX || this.e.clientX || 0);
+	this.y = dd.Int(this.e.pageY || this.e.clientY || 0);
+	if (dd.ie)
+	{
+		this.x += dd.getScrollX() - (dd.ie && !dd.iemac)*1;
+		this.y += dd.getScrollY() - (dd.ie && !dd.iemac)*1;
+	}
+	this.modifKey = this.e.modifiers? (this.e.modifiers&Event.SHIFT_MASK || this.e.modifiers&Event.CONTROL_MASK)
+		: (this.e.shiftKey || this.e.ctrlKey || false);
+};
+
+dd.recalc = function(d_x)
+{
+	if (dd.elements)
+	{
+		var d_o, d_i = dd.elements.length; while(d_i--)
+		{
+			if (!(d_o = dd.elements[d_i]).is_image && d_o.div)
+			{
+				dd.getWH(d_o);
+				if (d_o.div.pos_rel)
+				{
+					dd.getPageXY(d_o.div);
+					var d_dx = dd.x - d_o.x, d_dy = dd.y - d_o.y;
+					d_o.defx += d_dx;
+					d_o.x += d_dx;
+					d_o.defy += d_dy;
+					d_o.y += d_dy;
+					var d_p, d_j = d_o.children.length; while(d_j--)
+					{
+						if (!(d_p = d_o.children[d_j]).detached && (d_o != d_p.defparent || !(d_p.is_image && dd.getImg(d_p, d_p.oimg.name, 1))))
+						{
+							d_p.defx += d_dx;
+							d_p.defy += d_dy;
+							d_p.moveBy(d_dx, d_dy);
+						}
+					}
+				}
+			}
+			else if (d_o.is_image && !dd.op6 && !dd.n4)
+			{
+				if (dd.n6 && d_x && !d_o.defw) d_o.resizeTo(d_o.defw = dd.getImgW(d_o.oimg), d_o.defh = dd.getImgH(d_o.oimg));
+				var d_defx = d_o.defx, d_defy = d_o.defy;
+				if (!(d_o.parent && d_o.parent != d_o.defparent) && (d_x || !d_o.detached || d_o.horizontal || d_o.vertical) && dd.getImg(d_o, d_o.oimg.name, 1))
+					d_o.moveBy(d_o.defx-d_defx, d_o.defy-d_defy);
+			}
+		}
+	   }
+};
+
+
+
+function WINSZ(d_x)
+{
+	if (d_x)
+	{
+		if (dd.n4 || dd.op6 && d_x&2)
+		{
+			dd.iW = innerWidth;
+			dd.iH = innerHeight;
+			if (dd.op6) setTimeout("WINSZ()", 0x1ff);
+		}
+		window.onresize = new Function('WINSZ();');
+	}
+	else if ((dd.n4 || dd.op6) && (innerWidth != dd.iW || innerHeight != dd.iH)) location.reload();
+	else if (dd.op6) setTimeout("WINSZ()", 0x1ff);
+	else if (!dd.n4) setTimeout('dd.recalc()', 0xa);
+}
+WINSZ(1);
+
+
+
+function DDObj(d_o, d_i)
+{
+	this.id = d_o;
+	this.cmd = '';
+	this.cpy_n = dd.getCmdVal(this, COPY);
+	this.maxoffb = dd.getCmdVal(this, MAXOFFBOTTOM, 0, 1);
+	this.maxoffl = dd.getCmdVal(this, MAXOFFLEFT, 0, 1);
+	this.maxoffr = dd.getCmdVal(this, MAXOFFRIGHT, 0, 1);
+	this.maxofft = dd.getCmdVal(this, MAXOFFTOP, 0, 1);
+	var d_j = dd_cursors.length; while(d_j--)
+		if (dd.getCmd(this, dd_cursors[d_j], 1)) this.cursor = dd_cursors[d_j].substring(2);
+	this.clone = dd.getCmd(this, CLONE, 1);
+	this.detach = dd.getCmd(this, DETACH_CHILDREN);
+	this.scalable = dd.getCmd(this, SCALABLE, 1);
+	this.horizontal = dd.getCmd(this, HORIZONTAL);
+	this.noalt = dd.getCmd(this, NO_ALT, 1);
+	this.nodrag = dd.getCmd(this, NO_DRAG);
+	this.scroll = dd.getCmd(this, SCROLL, 1);
+	this.resizable = dd.getCmd(this, RESIZABLE, 1);
+	this.re_z = dd.getCmd(this, RESET_Z, 1);
+	this.vertical = dd.getCmd(this, VERTICAL);
+	this.maxw = dd.getCmdVal(this, MAXWIDTH, 1, 1);
+	this.minw = Math.abs(dd.getCmdVal(this, MINWIDTH, 1, 1));
+	this.maxh = dd.getCmdVal(this, MAXHEIGHT, 1, 1);
+	this.minh = Math.abs(dd.getCmdVal(this, MINHEIGHT, 1, 1));
+
+	this.name = this.id + (d_i || '');
+	this.oimg = dd.getImg(this, this.id, 1);
+	this.is_image = !!this.oimg;
+	this.copies = new Array();
+	this.children = new Array();
+	this.parent = this.original = null;
+	if (this.oimg)
+	{
+		this.id += 'div' + (d_i || '');
+		this.w = dd.getImgW(this.oimg);
+		this.h = dd.getImgH(this.oimg);
+		this.dw = this.dh = 0;
+		this.defz = dd.Int(dd.getCssProp(this.oimg, 'z-index','zIndex','zIndex')) || 1;
+		this.defsrc = this.src = this.oimg.src;
+		this.htm = '<img name="' + this.id + 'NImG"'+
+			' src="' + this.oimg.src + '" '+
+			'width="' + this.w + '" height="' + this.h + '">';
+		this.t_htm = '<div id="' + this.id +
+			'" style="position:absolute;'+
+			'left:' + (this.cssx = this.x = this.defx) + 'px;'+
+			'top:' + (this.cssy = this.y = this.defy) + 'px;'+
+			'width:' + this.w + 'px;'+
+			'height:' + this.h + 'px;">'+
+			this.htm + '<\/div>';
+	}
+	else
+	{
+		if (!!(this.div = dd.getDiv(this.id)) && typeof this.div.style != "undefined") this.css = this.div.style;
+		dd.getWH(this);
+		if (this.div)
+		{
+			this.div.ddObj = this;
+			this.div.pos_rel = ((this.div.parentNode? this.div.parentNode.tagName : this.div.parentElement? this.div.parentElement.tagName : '').toString().toLowerCase().indexOf('body') < 0);
+		}
+		dd.getPageXY(this.div);
+		this.defx = this.x = dd.x;
+		this.defy = this.y = dd.y;
+		dd.getCssXY(this);
+		this.defz = dd.Int(dd.getCssProp(this.div, 'z-index','zIndex','zIndex'));
+	}
+	this.defw = this.w || 0;
+	this.defh = this.h || 0;
+}
+
+DDObj.prototype.moveBy = function(d_x, d_y, d_kds, d_o)
+{
+	if (!this.div) return;
+	this.x += (d_x = dd.Int(d_x));
+	this.y += (d_y = dd.Int(d_y));
+	if (!d_kds || this.is_image || this.parent != this.defparent)
+	{
+		(d_o = this.css || this.div).left = (this.cssx += d_x) + dd.px;
+		d_o.top = (this.cssy += d_y) + dd.px;
+	}
+	var d_i = this.children.length; while (d_i--)
+	{
+		if (!(d_o = this.children[d_i]).detached) d_o.moveBy(d_x, d_y, 1);
+		d_o.defx += d_x;
+		d_o.defy += d_y;
+	}
+};
+
+DDObj.prototype.moveTo = function(d_x, d_y)
+{
+	this.moveBy(dd.Int(d_x)-this.x, dd.Int(d_y)-this.y);
+};
+
+DDObj.prototype.hide = function(d_m, d_o, d_p)
+{
+	if (this.div && this.visible)
+	{
+		d_p = this.css || this.div;
+		if (d_m && !dd.n4)
+		{
+			this.display = dd.getCssProp(this.div, "display", "display", "display");
+			if (this.oimg)
+			{
+				this.oimg.display = dd.getCssProp(this.oimg, "display", "display", "display");
+				this.oimg.style.display = "none";
+			}
+			d_p.display = "none";
+			dd.recalc();
+		}
+		else d_p.visibility = "hidden";
+	}
+	this.visible = false;
+	var d_i = this.children.length; while (d_i--)
+		if (!(d_o = this.children[d_i]).detached) d_o.hide(d_m);
+};
+
+DDObj.prototype.show = function(d_o, d_p)
+{
+	if (this.div)
+	{
+		d_p = this.css || this.div;
+		if (d_p.display && d_p.display == "none")
+		{
+			d_p.display = this.display || "block";
+			if (this.oimg) this.oimg.style.display = this.oimg.display || "inline";
+			dd.recalc();
+		}
+		else d_p.visibility = "visible";
+	}
+	this.visible = true;
+	var d_i = this.children.length; while (d_i--)
+		if (!(d_o = this.children[d_i]).detached) d_o.show();
+};
+
+DDObj.prototype.resizeTo = function(d_w, d_h, d_o)
+{
+	if (!this.div) return;
+	d_w = (this.w = dd.Int(d_w))-this.dw;
+	d_h = (this.h = dd.Int(d_h))-this.dh;
+	if (dd.n4)
+	{
+		this.div.resizeTo(d_w, d_h);
+		if (this.is_image)
+		{
+			this.write('<img src="' + this.src + '" width="' + d_w + '" height="' + d_h + '">');
+			(this.nimg = this.div.document.images[0]).src = this.src;
+		}
+	}
+	else if (typeof this.css.pixelWidth != "undefined")
+	{
+		this.css.pixelWidth = d_w;
+		this.css.pixelHeight = d_h;
+		if (this.is_image)
+		{
+			(d_o = this.nimg.style).pixelWidth = d_w;
+			d_o.pixelHeight = d_h;
+		}
+	}
+	else
+	{
+		this.css.width = d_w + dd.px;
+		this.css.height = d_h + dd.px;
+		if (this.is_image)
+		{
+			(d_o = this.nimg).width = d_w;
+			d_o.height = d_h;
+			if (!d_o.complete) d_o.src = this.src;
+		}
+	}
+};
+
+DDObj.prototype.resizeBy = function(d_dw, d_dh)
+{
+	this.resizeTo(this.w+dd.Int(d_dw), this.h+dd.Int(d_dh));
+};
+
+DDObj.prototype.swapImage = function(d_x, d_cp)
+{
+	if (!this.nimg) return;
+	this.nimg.src = d_x;
+	this.src = this.nimg.src;
+	if (d_cp)
+	{
+		var d_i = this.copies.length; while (d_i--)
+			this.copies[d_i].src = this.copies[d_i].nimg.src = this.nimg.src;
+	}
+};
+
+DDObj.prototype.setBgColor = function(d_x)
+{
+	if (dd.n4 && this.div) this.div.bgColor = d_x;
+	else if (this.css) this.css.background = d_x;
+	this.bgColor = d_x;
+};
+
+DDObj.prototype.write = function(d_x, d_o)
+{
+	this.text = d_x;
+	if (!this.div) return;
+	if (dd.n4)
+	{
+		(d_o = this.div.document).open();
+		d_o.write(d_x);
+		d_o.close();
+		dd.getWH(this);
+	}
+	else if (!dd.op6)
+	{
+		this.css.height = 'auto';
+		this.div.innerHTML = d_x;
+		if (!dd.ie4) dd.recalc();
+		if (dd.ie4 || dd.n6) setTimeout('dd.recalc();', 0); // n6.0: recalc twice
+	}
+};
+
+DDObj.prototype.copy = function(d_n, d_p)
+{
+	if (!this.oimg) return;
+	d_n = d_n || 1;
+	while (d_n--)
+	{
+		var d_l = this.copies.length,
+		d_o = new DDObj(this.name+this.cmd, d_l+1);
+		if (dd.n4)
+		{
+			d_o.id = (d_p = new Layer(d_o.w)).name;
+			d_p.clip.height = d_o.h;
+			d_p.visibility = 'show';
+			(d_p = d_p.document).open();
+			d_p.write(d_o.htm);
+			d_p.close();
+		}
+		else if (dd.db.insertAdjacentHTML) dd.db.insertAdjacentHTML("AfterBegin", d_o.t_htm);
+		else if (document.createElement && dd.db && dd.db.appendChild)
+		{
+			dd.db.appendChild(d_p = document.createElement('div'));
+			d_p.innerHTML = d_o.htm;
+			d_p.id = d_o.id;
+			d_p.style.position = 'absolute';
+			d_p.style.width = d_o.w + 'px';
+			d_p.style.height = d_o.h + 'px';
+		}
+		else if (dd.db && dd.db.innerHTML) dd.db.innerHTML += d_o.t_htm;
+		d_o.defz = this.defz+1+d_l;
+		dd.addProps(d_o);
+		d_o.original = this;
+		dd.addElt(d_o, this);
+		if (this.parent)
+		{
+			this.parent.addChild(d_o, this.detached);
+			d_o.defparent = this.defparent;
+		}
+		d_o.moveTo(d_o.defx = this.defx, d_o.defy = this.defy);
+		if (dd.n4) d_o.defsrc = d_o.src = this.defsrc;
+		d_o.swapImage(this.src);
+	}
+};
+
+DDObj.prototype.addChild = function(d_kd, detach, defp)
+{
+	if (typeof d_kd != "object") d_kd = dd.elements[d_kd];
+	if (d_kd.parent && d_kd.parent == this || d_kd == this || !d_kd.is_image && d_kd.defparent && !defp) return;
+
+	this.children[this.children.length] = this.children[d_kd.name] = d_kd;
+	d_kd.detached = detach || 0;
+	if (defp) d_kd.defparent = this;
+	else if (this == d_kd.defparent && d_kd.is_image) dd.getImg(this, d_kd.oimg.name, 1);
+	if (!d_kd.defparent || this != d_kd.defparent)
+	{
+		d_kd.defx = d_kd.x;
+		d_kd.defy = d_kd.y;
+	}
+	if (!detach)
+	{
+		d_kd.defz = d_kd.defz+this.defz-(d_kd.parent? d_kd.parent.defz : 0)+(!d_kd.is_image*1);
+		d_kd.setZ(d_kd.z+this.z-(d_kd.parent? d_kd.parent.z : 0)+(!d_kd.is_image*1), 1);
+	}
+	if (d_kd.parent) d_kd.parent._removeChild(d_kd, 1);
+	d_kd.parent = this;
+};
+
+DDObj.prototype._removeChild = function(d_kd, d_newp)
+{
+	if (typeof d_kd != "object") d_kd = this.children[d_kd];
+	var d_oc = this.children, d_nc = new Array();
+	for (var d_i = 0; d_i < d_oc.length; d_i++)
+		if (d_oc[d_i] != d_kd) d_nc[d_nc.length] = d_oc[d_i];
+	this.children = d_nc;
+	d_kd.parent = null;
+	if (!d_newp)
+	{
+		d_kd.detached = d_kd.defp = 0;
+		if (d_kd.is_image) dd.getImg(d_kd, d_kd.oimg.name, 1);
+	}
+};
+
+DDObj.prototype.attachChild = function(d_kd)
+{
+	(d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 0;
+	d_kd.setZ(d_kd.defz + this.z-this.defz, 1);
+};
+
+DDObj.prototype.detachChild = function(d_kd)
+{
+	(d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 1;
+};
+
+DDObj.prototype.setZ = function(d_x, d_kds)
+{
+	if (d_kds)
+	{
+		var d_dz = d_x-this.z,
+		d_i = this.children.length; while (d_i--)
+			if (!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.z+d_dz, 1);
+	}
+	dd.z = Math.max(dd.z, this.z = this.div? ((this.css || this.div).zIndex = d_x) : 0);
+};
+
+DDObj.prototype.maximizeZ = function()
+{
+	this.setZ(dd.z+1, 1);
+};
+
+DDObj.prototype._resetZ = function(d_o)
+{
+	if (this.re_z || dd.re_z)
+	{
+		this.setZ(this.defz);
+		var d_i = this.children.length; while (d_i--)
+			if (!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.defz);
+	}
+};
+
+DDObj.prototype.setOpacity = function(d_x)
+{
+	this.opacity = d_x;
+	this._setOpaRel(1.0, 1);
+};
+DDObj.prototype._setOpaRel = function(d_x, d_kd, d_y, d_o)
+{
+	if(this.css && (this.diaphan || d_kd))
+	{
+		d_y = this.opacity*d_x;
+		if(typeof this.css.MozOpacity != dd_u) this.css.MozOpacity = d_y;
+		else if(typeof this.css.filter != dd_u)
+			this.css.filter = "Alpha(opacity="+parseInt(100*d_y)+")";
+		else this.css.opacity = d_y;
+		var d_i = this.children.length; while(d_i--)
+			if(!(d_o = this.children[d_i]).detached) d_o._setOpaRel(d_x, 1);
+	}
+};
+
+DDObj.prototype.setCursor = function(d_x)
+{
+	this._setCrs(this.cursor = (d_x.indexOf('c:')+1)? d_x.substring(2) : d_x);
+};
+
+DDObj.prototype._setCrs = function(d_x)
+{
+	if (this.css) this.css.cursor = ((!dd.ie || dd.iemac) && d_x == 'hand')? 'pointer' : d_x;
+};
+
+DDObj.prototype.setDraggable = function(d_x)
+{
+	this.nodrag = !d_x*1;
+	this._setCrs(d_x? this.cursor : 'auto');
+};
+
+DDObj.prototype.setResizable = function(d_x)
+{
+	this.resizable = d_x*1;
+	if (d_x) this.scalable = 0;
+};
+
+DDObj.prototype.setScalable = function(d_x)
+{
+	this.scalable = d_x*1;
+	if (d_x) this.resizable = 0;
+};
+
+DDObj.prototype.del = function(d_os, d_o)
+{
+	if (this.parent && this.parent._removeChild) this.parent._removeChild(this);
+	if (this.original)
+	{
+		this.hide();
+		if (this.original.copies)
+		{
+			d_os = new Array();
+			for (var d_i = 0; d_i < this.original.copies.length; d_i++)
+				if ((d_o = this.original.copies[d_i]) != this) d_os[d_os.length] = d_os[d_o.name] = d_o;
+			this.original.copies = d_os;
+		}
+	}
+	else if (this.is_image)
+	{
+		this.hide();
+		if (this.oimg)
+		{
+		  if (dd.n4) this.oimg.src = this.defsrc;
+		  else this.oimg.style.visibility = 'visible';
+		}
+	}
+	else if (this.moveTo)
+	{
+		if (this.css) this.css.cursor = 'default';
+		this.moveTo(this.defx, this.defy);
+		this.resizeTo(this.defw, this.defh);
+	}
+	d_os = new Array();
+	for (var d_i = 0; d_i < dd.elements.length; d_i++)
+	{
+		if ((d_o = dd.elements[d_i]) != this) d_os[d_os.length] = d_os[d_o.name] = d_o;
+		else d_o._free();
+	}
+	dd.elements = d_os;
+	if (!dd.op6 && !dd.n4) dd.recalc();
+};
+
+DDObj.prototype._free = function()
+{
+	for (var d_i in this)
+		this[d_i] = null;
+	dd.elements[this.name] = null;
+};
+
+
+
+dd.n4RectVis = function(vis)
+{
+	for (var d_i = 4; d_i--;)
+	{
+		dd.rectI[d_i].visibility = dd.rectA[d_i].visibility = vis? 'show' : 'hide';
+		if (vis) dd.rectI[d_i].zIndex = dd.rectA[d_i].zIndex = dd.z+2;
+	}
+};
+
+dd.n4RectPos = function(d_o, d_x, d_y, d_w, d_h)
+{
+	d_o.x = d_x;
+	d_o.y = d_y;
+	d_o.clip.width = d_w;
+	d_o.clip.height = d_h;
+};
+
+// NN4: draw img resize rectangle
+dd.n4Rect = function(d_w, d_h)
+{
+	if (!dd.rectI)
+	{
+		dd.rectI = new Array();
+		dd.rectA = new Array();
+	}
+	if (!dd.rectI[0])
+	{
+		for (var d_i = 4; d_i--;)
+		{
+			(dd.rectI[d_i] = new Layer(1)).bgColor = '#000000';
+			(dd.rectA[d_i] = new Layer(1)).bgColor = '#ffffff';
+		}
+	}
+	if (!dd.rectI[0].visibility || dd.rectI[0].visibility == 'hide') dd.n4RectVis(1);
+	dd.obj.w = d_w;
+	dd.obj.h = d_h;
+	for (var d_i = 4; d_i--;)
+	{
+		dd.n4RectPos(dd.rectI[d_i], dd.obj.x + (!(d_i-1)? (dd.obj.w-1) : 0), dd.obj.y + (!(d_i-2)? (dd.obj.h-1) : 0), d_i&1 || dd.obj.w, !(d_i&1) || dd.obj.h);
+		dd.n4RectPos(dd.rectA[d_i], !(d_i-1)? dd.rectI[1].x+1 : (dd.obj.x-1), !(d_i-2)? dd.rectI[2].y+1 : (dd.obj.y-1), d_i&1 || dd.obj.w+2, !(d_i&1) || dd.obj.h+2);
+	}
+};
+
+dd.reszTo = function(d_w, d_h)
+{
+	if (dd.n4 && dd.obj.is_image) dd.n4Rect(d_w, d_h);
+	else dd.obj.resizeTo(d_w, d_h);
+};
+
+dd.embedVis = function(d_vis)
+{
+	var d_o = new Array('iframe', 'applet', 'embed', 'object');
+	var d_i = d_o.length; while (d_i--)
+	{
+		var d_p = dd.ie? document.all.tags(d_o[d_i]) : document.getElementsByTagName? document.getElementsByTagName(d_o[d_i]) : null;
+		if (d_p)
+		{
+			var d_j = d_p.length; while (d_j--)
+			{
+				var d_q = d_p[d_j];
+				while (d_q.offsetParent || d_q.parentNode)
+				{
+					if ((d_q = d_q.parentNode || d_q.offsetParent || null) == dd.obj.div)
+					{
+						d_p[d_j].style.visibility = d_vis;
+						break;
+					}
+				}
+			}
+		}
+	}
+};
+
+dd.maxOffX = function(d_x, d_y)
+{
+	return (
+		(dd.obj.maxoffl+1 && (d_y = dd.obj.defx-dd.obj.maxoffl)-d_x > 0
+		|| dd.obj.maxoffr+1 && (d_y = dd.obj.defx+dd.obj.maxoffr)-d_x < 0)? d_y
+		: d_x
+	);
+};
+
+dd.maxOffY = function(d_x, d_y)
+{
+	return (
+		(dd.obj.maxofft+1 && (d_y = dd.obj.defy-dd.obj.maxofft)-d_x > 0
+		|| dd.obj.maxoffb+1 && (d_y = dd.obj.defy+dd.obj.maxoffb)-d_x < 0)? d_y
+		: d_x
+	);
+};
+
+dd.inWndW = function(d_x, d_y)
+{
+	var d_wx = dd.getScrollX(),
+	d_ww = dd.getWndW();
+	return (
+		((d_y = d_wx+2)-d_x > 0) || ((d_y = d_wx+d_ww+dd.obj.w-2)-d_x < 0)? d_y
+		: d_x
+	);
+};
+
+dd.inWndH = function(d_x, d_y)
+{
+	var d_wy = dd.getScrollY(),
+	d_wh = dd.getWndH();
+	return (
+		((d_y = d_wy+2)-d_x > 0) || ((d_y = d_wy+d_wh+dd.obj.h-2)-d_x < 0)? d_y
+		: d_x
+	);
+};
+
+// These two funcs limit the size of element when mouseresized.
+// Implemented 22.5.2003 by Gregor Lï¿œtolf <gregor@milou.ch>, modified by Walter Zorn
+dd.limW = function(d_w)
+{
+	return (
+		(dd.obj.minw-d_w > 0)? dd.obj.minw
+		: (dd.obj.maxw > 0 && dd.obj.maxw-d_w < 0)? dd.obj.maxw
+		: d_w
+	);
+};
+
+dd.limH = function(d_h)
+{
+	return (
+		(dd.obj.minh-d_h > 0)? dd.obj.minh
+		: (dd.obj.maxh > 0 && dd.obj.maxh-d_h < 0)? dd.obj.maxh
+		: d_h
+	);
+};
+
+
+// Optional autoscroll-page functionality. Courtesy Cedric Savarese.
+// Implemented by Walter Zorn
+function DDScroll()
+{
+	if (!dd.obj || !dd.obj.scroll && !dd.scroll || dd.op || dd.ie4 || dd.whratio)
+	{
+		dd.scrx = dd.scry = 0;
+		return;
+	}
+	var d_bnd = 0x1c,
+	d_wx = dd.getScrollX(), d_wy = dd.getScrollY();
+	if (dd.msmoved)
+	{
+		var d_ww = dd.getWndW(), d_wh = dd.getWndH(), d_y;
+		dd.scrx = ((d_y = dd.e.x-d_ww-d_wx+d_bnd) > 0)? (d_y>>=2)*d_y
+			: ((d_y = d_wx+d_bnd-dd.e.x) > 0)? -(d_y>>=2)*d_y
+			: 0;
+		dd.scry = ((d_y = dd.e.y-d_wh-d_wy+d_bnd) > 0)? (d_y>>=2)*d_y
+			: ((d_y = d_wy+d_bnd-dd.e.y) > 0)? -(d_y>>=2)*d_y
+			: 0;
+	}
+	if (dd.scrx || dd.scry)
+	{
+		window.scrollTo(
+			d_wx + (dd.scrx = dd.obj.is_resized? dd.limW(dd.obj.w+dd.scrx)-dd.obj.w : dd.obj.vertical? 0 : (dd.maxOffX(dd.obj.x+dd.scrx)-dd.obj.x)),
+			d_wy + (dd.scry = dd.obj.is_resized? dd.limH(dd.obj.h+dd.scry)-dd.obj.h : dd.obj.horizontal? 0 : (dd.maxOffY(dd.obj.y+dd.scry)-dd.obj.y))
+		);
+		dd.obj.is_dragged? dd.obj.moveTo(dd.obj.x+dd.getScrollX()-d_wx, dd.obj.y+dd.getScrollY()-d_wy)
+			: dd.reszTo(dd.obj.w+dd.getScrollX()-d_wx, dd.obj.h+dd.getScrollY()-d_wy);
+	}
+	dd.msmoved = 0;
+	window.setTimeout('DDScroll()', 0x33);
+}
+
+
+
+function PICK(d_ev)
+{
+	dd.e = new dd.evt(d_ev);
+	if (dd.e.x >= dd.getWndW()+dd.getScrollX() || dd.e.y >= dd.getWndH()+dd.getScrollY()) return true; // on scrollbar
+	var d_o, d_cmp = -1, d_i = dd.elements.length; while (d_i--)
+	{
+		d_o = dd.elements[d_i];
+		if (dd.n4 && dd.e.but > 1 && dd.e.src == d_o.oimg && !d_o.clone) return false;
+		if (d_o.visible && dd.e.but <= 1 && !d_o.nodrag && dd.e.x >= d_o.x && dd.e.x <= d_o.x+d_o.w && dd.e.y >= d_o.y && dd.e.y <= d_o.y+d_o.h)
+		{
+			if (d_o.z > d_cmp && dd.e.src.tag.indexOf('input') < 0 && dd.e.src.tag.indexOf('textarea') < 0 && dd.e.src.tag.indexOf('select') < 0 && dd.e.src.tag.indexOf('option') < 0)
+			{
+				d_cmp = d_o.z;
+				dd.obj = d_o;
+			}
+		}
+	}
+	if (dd.obj)
+	{
+		dd.e.e.cancelBubble = true;
+		var d_rsz = dd.e.modifKey && (dd.obj.resizable || dd.obj.scalable);
+		if (dd.op && !dd.op6)
+		{
+			(d_o = document.getElementById('OpBlUr')).style.pixelLeft = dd.e.x;
+			d_o.style.pixelTop = dd.e.y;
+			(d_o = d_o.children[0].children[0]).focus();
+			d_o.blur();
+		}
+		else if (dd.ie && !dd.ie4)
+		{
+			if (document.selection && document.selection.empty) document.selection.empty();
+			dd.db.onselectstart = function()
+			{
+				event.returnValue = false;
+			};
+		}
+		if (d_rsz)
+		{
+			dd.obj._setCrs('se-resize');
+			dd.obj.is_resized = 1;
+			dd.whratio = dd.obj.scalable? dd.obj.defw/dd.obj.defh : 0;
+			if (dd.ie)
+			{
+				if (dd.ie4)
+				{
+					window.dd_x = dd.getScrollX();
+					window.dd_y = dd.getScrollY();
+				}
+				setTimeout(
+					'if (dd.obj && document.selection && document.selection.empty)'+
+					'{'+
+						'document.selection.empty();'+
+						'if (dd.ie4) window.scrollTo(window.dd_x, window.dd_y);'+
+					'}'
+				,0);
+			}
+			dd.setEvtHdl(1, RESIZE);
+			dd.reszTo(dd.obj.w, dd.obj.h);
+		}
+		else if (!dd.obj.nodrag)
+		{
+			dd.obj.is_dragged = 1;
+			dd.setEvtHdl(1, DRAG);
+		}
+		dd.setEvtHdl(2, DROP);
+		dd.embedVis('hidden');
+		dd.obj.maximizeZ();
+		dd.ofx = dd.obj.x+dd.obj.w-dd.e.x;
+		dd.ofy = dd.obj.y+dd.obj.h-dd.e.y;
+		if (window.my_PickFunc) my_PickFunc();
+		DDScroll();
+		return !(
+			dd.obj.is_resized
+			|| dd.n4 && dd.obj.is_image
+			|| dd.n6 || dd.w3c
+		);
+	}
+	if (dd.downFunc) return dd.downFunc(d_ev);
+	return true;
+}
+
+function DRAG(d_ev)
+{
+	if (!dd.obj || !dd.obj.visible) return true;
+	if (dd.ie4 || dd.w3c || dd.n6 || dd.obj.children.length > 0xf)
+	{
+		if (dd.wait) return false;
+		dd.wait = 1;
+		setTimeout('dd.wait = 0;', 5);
+	}
+	dd.e = new dd.evt(d_ev);
+	if (dd.ie && !dd.e.but)
+	{
+		DROP(d_ev);
+		return true;
+	}
+	dd.msmoved = 1;
+	dd.obj.moveTo(
+		dd.obj.vertical? dd.obj.x : dd.maxOffX(dd.inWndW(dd.ofx+dd.e.x)-dd.obj.w),
+		dd.obj.horizontal? dd.obj.y : dd.maxOffY(dd.inWndH(dd.ofy+dd.e.y)-dd.obj.h)
+	);
+
+	if (window.my_DragFunc) my_DragFunc();
+	return false;
+}
+
+function RESIZE(d_ev)
+{
+	if (!dd.obj || !dd.obj.visible) return true;
+	if (dd.wait) return false;
+	dd.wait = 1;
+	setTimeout('dd.wait = 0;', 5);
+	dd.e = new dd.evt(d_ev);
+	if (dd.ie && !dd.e.but)
+	{
+		DROP(d_ev);
+		return true;
+	}
+	dd.msmoved = 1;
+	var d_w = dd.limW(dd.inWndW(dd.ofx+dd.e.x)-dd.obj.x);
+	if (!dd.whratio) var d_h = dd.limH(dd.inWndH(dd.ofy+dd.e.y)-dd.obj.y);
+	else
+	{
+		var d_h = dd.limH(dd.inWndH(Math.round(d_w/dd.whratio)+dd.obj.y)-dd.obj.y);
+		d_w = Math.round(d_h*dd.whratio);
+	}
+	dd.reszTo(d_w, d_h);
+	if (window.my_ResizeFunc) my_ResizeFunc();
+	return false;
+}
+
+function DROP(d_ev)
+{
+	if (dd.obj)
+	{
+		if (dd.obj.is_dragged)
+		{
+			if (!dd.obj.is_image) dd.getWH(dd.obj);
+		}
+		else if (dd.n4)
+		{
+			if (dd.obj.is_image)
+			{
+				dd.n4RectVis(0);
+				dd.obj.resizeTo(dd.obj.w, dd.obj.h);
+			}
+		}
+		if (!dd.n4 && !dd.op6 || !dd.obj.is_image) dd.recalc();
+		dd.setEvtHdl(1, dd.moveFunc);
+		dd.setEvtHdl(2, dd.upFunc);
+		if (dd.db) dd.db.onselectstart = null;
+		dd.obj._setCrs(dd.obj.cursor);
+		dd.embedVis('visible');
+		dd.obj._resetZ();
+		if (window.my_DropFunc)
+		{
+			dd.e = new dd.evt(d_ev);
+			my_DropFunc();
+		}
+		dd.msmoved = dd.obj.is_dragged = dd.obj.is_resized = dd.whratio = 0;
+		dd.obj = null;
+	}
+	dd.setEvtHdl(0, PICK);
+}
+
+
+
+function SET_DHTML()
+{
+	dd.elements = new Array();
+	var d_a = SET_DHTML.arguments, d_ai, d_htm = '', d_o, d_i = d_a.length; while (d_i--)
+	{
+		if (dd.op6)
+		{
+			var d_t0 = (new Date()).getTime();
+			while ((new Date()).getTime()-d_t0 < 0x99);
+		}
+		if (!(d_ai = d_a[d_i]).indexOf('c:')) dd.cursor = d_ai.substring(2);
+		else if (d_ai == NO_ALT) dd.noalt = 1;
+		else if (d_ai == SCROLL) dd.scroll = 1;
+		else if (d_ai == RESET_Z) dd.re_z = 1;
+		else if (d_ai == RESIZABLE) dd.resizable = 1;
+		else if (d_ai == SCALABLE) dd.scalable = 1;
+		else
+		{
+			d_o = new DDObj(d_ai);
+			dd.addElt(d_o);
+			d_htm += d_o.t_htm || '';
+			if (d_o.oimg && d_o.cpy_n)
+			{
+				var d_j = 0; while (d_j < d_o.cpy_n)
+				{
+					var d_p = new DDObj(d_o.name+d_o.cmd, ++d_j);
+					dd.addElt(d_p, d_o);
+					d_p.defz = d_o.defz+d_j;
+					d_p.original = d_o;
+					d_htm += d_p.t_htm;
+				}
+			}
+		}
+	}
+	if (dd.n4 || dd.n6 || dd.ie || dd.op || dd.w3c) document.write(
+		(dd.n4? '<div style="position:absolute;"><\/div>\n'
+		: (dd.op && !dd.op6)? '<div id="OpBlUr" style="position:absolute;visibility:hidden;width:0px;height:0px;"><form><input type="text" style="width:0px;height:0px;"><\/form><\/div>'
+		: '') + d_htm
+	);
+	dd.z = 0x33;
+	d_i = dd.elements.length; while (d_i--)
+	{
+		dd.addProps(d_o = dd.elements[d_i]);
+		if (d_o.is_image && !d_o.original && !d_o.clone)
+			dd.n4? d_o.oimg.src = spacer : d_o.oimg.style.visibility = 'hidden';
+	}
+	dd.mkWzDom();
+	if (window.onload) dd.loadFunc = window.onload;
+	window.onload = dd.initz;
+	window.onunload = dd.finlz;
+	dd.setEvtHdl(0, PICK);
+}
+
+function ADD_DHTML(d_o) // layers only!
+{
+	d_o = new DDObj(d_o);
+	dd.addElt(d_o);
+	dd.addProps(d_o);
+	dd.mkWzDom();
+}
+
+
+
+
+////////////////////////////////////////////////////////////
+// If not needed, all code below this line may be removed
+
+
+// For backward compatibility
+dd.d = document;            // < v. 2.72
+var RESET_ZINDEX = RESET_Z; // < 3.44
+var KEYDOWN_RESIZE = RESIZABLE; // < 4.43
+var CURSOR_POINTER = CURSOR_HAND; // < 4.44
+var NO_SCROLL = '';         // < v. 4.49
+
+
+
+
+////////////////////////////////////////////////////////////
+// FUNCTIONS FOR EXTENDED SCRIPTING
+// Use these for your own extensions,
+// or to call functions defined elsewhere
+
+
+
+/* my_PickFunc IS AUTOMATICALLY CALLED WHEN AN ITEM STARTS TO BE DRAGGED.
+The following objects/properties are accessible from here:
+
+- dd.e: current mouse event
+- dd.e.property: access to a property of the current mouse event.
+  Mostly requested properties:
+  - dd.e.x: document-related x co-ordinate
+  - dd.e.y: document-related y co-ord
+  - dd.e.src: target of mouse event (not identical with the drag drop object itself).
+  - dd.e.button: currently pressed mouse button. Left button: dd.e.button <= 1
+
+- dd.obj: reference to currently dragged item.
+- dd.obj.property: access to any property of that item.
+- dd.obj.method(): for example dd.obj.resizeTo() or dd.obj.swapImage() .
+  Mostly requested properties:
+	- dd.obj.name: image name or layer ID passed to SET_DHTML();
+	- dd.obj.x and dd.obj.y: co-ordinates;
+	- dd.obj.w and dd.obj.h: size;
+	- dd.obj.is_dragged: 1 while item is dragged, else 0;
+	- dd.obj.is_resized: 1 while item is resized, i.e. if <ctrl> or <shift> is pressed, else 0
+
+For more properties and details, visit the API documentation
+at http://www.walterzorn.com/dragdrop/api_e.htm (english) or
+http://www.walterzorn.de/dragdrop/api.htm (german)    */
+function my_PickFunc()
+{
+}
+
+
+
+
+/* my_DragFunc IS CALLED WHILE AN ITEM IS DRAGGED
+See the description of my_PickFunc above for what's accessible from here. */
+function my_DragFunc()
+{
+	//window.status = 'dd.elements.' + dd.obj.name + '.x  = ' + dd.obj.x + '     dd.elements.' + dd.obj.name + '.y = ' + dd.obj.y;
+}
+
+
+
+
+/* my_ResizeFunc IS CALLED WHILE AN ITEM IS RESIZED
+See the description of my_PickFunc above for what's accessible from here. */
+function my_ResizeFunc()
+{
+	//window.status = 'dd.elements.' + dd.obj.name + '.w  = ' + dd.obj.w + '     dd.elements.' + dd.obj.name + '.h = ' + dd.obj.h;
+}
+
+
+
+
+/* THIS ONE IS CALLED ONCE AN ITEM IS DROPPED
+See the description of my_PickFunc for what's accessible from here.
+Here may be investigated, for example, what's the name (dd.obj.name)
+of the dropped item, and where (dd.obj.x, dd.obj.y) it has been dropped... */
+function my_DropFunc()
+{
+}
+
+
Index: /trunk/instant_messenger/js/im_fcommon.js
===================================================================
--- /trunk/instant_messenger/js/im_fcommon.js	(revision 20)
+++ /trunk/instant_messenger/js/im_fcommon.js	(revision 20)
@@ -0,0 +1,346 @@
+/*
++------------------------------------------------+
+| @FILE:    functions.js                         |
+| @AUTHOR:  [NUTS] Rodrigo Souza                 |
+| @DATE:    Sex 27 Out 2006 12:38:22 BRST        |
+| @LAST CHANGE: Seg 27 Nov 2006 12:35:22 BRST::  |
++------------------------------------------------+
+*/
+
+/*
+ * @DESC The method has one optional boolean argument
+ *          deep which when set recursively creates a
+ *          deep copy, otherwise (when deep is false
+ *          or not defined) a shallow copy is created.
+ */
+/*Object.prototype.clone = function(deep)
+{
+   objectClone = new this.constructor();
+   for (var property in this)
+   {
+      if (!deep)
+         objectClone[property] = this[property];
+      else if (typeof this[property] == 'object')
+         objectClone[property] = this[property].clone(deep);
+      else
+         objectClone[property] = this[property];
+   }
+
+      return objectClone;
+}*/
+
+/*
+ *
+ */
+var func = {
+   "attachEvent" : function(obj, eventName, eventHandler) 
+   {
+      if ( obj )
+      {
+         if ( eventName.substring(0, 2) == 'on' )
+         {
+            eventName = eventName.substring(2,eventName.length);
+         }
+         if ( obj.addEventListener )
+         {
+            obj.addEventListener(eventName, eventHandler, false);
+         }
+         else if ( obj.attachEvent )
+         {
+            obj.attachEvent('on'+eventName, eventHandler);
+         }
+      }
+   },
+
+   "byId" : function()
+   {
+      var elements = new Array();
+      for ( var i = 0; i < arguments.length; i++ )
+      {
+         element = arguments[i];
+         if ( this.isString(element) )
+            element = document.getElementById(element);
+
+         if (arguments.length == 1)
+            return element;
+
+         elements.push(element);
+      }
+      return elements;
+   },
+
+   "byTag" : function()
+   {
+      var elements = new Array();
+      for ( var i = 0; i < arguments.length; i++ )
+      {
+         element = arguments[i];
+         if ( this.isString(element) )
+            element = document.getElementsByTagName(element);
+
+         if ( arguments.length == 1 )
+            return element;
+
+         elements.push(element);
+      }
+      return elements;
+   },
+
+   "client_height" : function()
+   {
+      if( typeof( window.innerWidth ) == 'number' )
+      {
+         //Non-IE
+         return window.innerHeight;
+      }
+      else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
+      {
+         //IE 6+ in 'standards compliant mode'
+         return document.documentElement.clientHeight;
+      }
+      else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
+      {
+         //IE 4 compatible
+         return document.body.clientHeight;
+      }
+   },
+
+   "client_width" : function()
+   {
+         if( typeof( window.innerWidth ) == 'number' )
+         {
+            //Non-IE
+            return window.innerWidth;
+         }
+         else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
+         {
+            //IE 6+ in 'standards compliant mode'
+            return document.documentElement.clientWidth;
+         }
+         else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
+         {
+            //IE 4 compatible
+            return document.body.clientWidth;
+         }
+   },
+
+   "_confEl" : function(pElement, pAttribute, pValue)
+   {
+      if ( !func.isString(pValue) )
+         return false;
+
+      if ( this.isString(pElement) )
+      {
+         pElement = document.getElementById(pElement);
+      }
+
+      switch ( pAttribute )
+      {
+         /*
+          * No IE a propriedade style nÃo funciona se adicionada via setAttribute()
+          */
+         case 'style' :
+                        pElement.style.cssText = pValue;
+         break;
+         case 'class' :
+                        pElement.setAttribute(pAttribute, pValue);
+                        pElement.setAttribute(pAttribute+'Name', pValue); // IE
+         break;
+         default :
+                        pElement.setAttribute(pAttribute, pValue);
+      } /* switch */
+   },
+
+   "confEl" : function()
+   {
+      switch ( arguments.length )
+      {
+         case 1 :
+                  matriz = arguments[0];
+                  if ( !this.isArray(matriz) )
+                     return false;
+
+                  for ( var i in matriz )
+                  {
+                     pElement = matriz[i]['element'];
+                     delete matriz[i]['element'];
+
+                     for ( var j in matriz[i] )
+                     {
+                        this._confEl(pElement, j, matriz[i][j]);
+                     }
+                  }
+         break;
+         case 2 :
+                  var pElement = arguments[0];
+
+                  if ( !this.isArray(arguments[1]) )
+                     return false;
+
+                  for ( var i in arguments[1] )
+                  {
+                     this._confEl(pElement, i, arguments[1][i]);
+                  }
+         break;
+         case 3 :
+                  var pElement = arguments[0];
+
+                  this._confEl(pElement, arguments[1], arguments[2]);
+         break;
+      }
+   },
+
+   "elH" : function(pEl)
+   {
+      // no IE a funcao scrollHeight nÃ£o retorna o valor correto
+      return document.getElementById(pEl).offsetHeight;
+   },
+
+   "elHW" : function(pEl)
+   {
+      aux = {
+               h:this.elH(pEl),
+               w:this.elW(pEl)
+            };
+      return aux;
+   },
+
+   "elW" : function(pEl)
+   {
+      return document.getElementById(pEl).offsetWidth;
+   },
+
+   "insEl" : function()
+   {
+         if ( arguments.length == 1 )
+         {
+            var body = document.getElementsByTagName('body');
+            body[0].appendChild(arguments[0]);
+         }
+         else
+         {
+            var parentEl;
+            switch ( typeof arguments[arguments.length-1] )
+            {
+               case 'object' :
+                              parentEl = arguments[arguments.length-1];
+               break;
+               case 'string' :
+                              parentEl = document.getElementById(arguments[arguments.length-1]);
+               break;
+               case 'boolean' : parentEl = document.getElementsByTagName('body').item(0);
+            }
+
+            for ( var i = 0; i < arguments.length-1; i++ )
+            {
+                  if ( this.isString(arguments[i]) )
+                     arguments[i] = document.createTextNode(arguments[i]);
+
+                  parentEl.appendChild(arguments[i]);
+            }
+         } /* else */
+         return true;
+   },
+
+   "insElB" : function()
+   {
+         if ( arguments.length < 2 )
+         {
+            return false;
+         }
+         else
+         {
+            var referenceEl;
+            var parentEl;
+            switch ( typeof arguments[arguments.length-1] )
+            {
+               case 'object' :
+                              parentEl    = arguments[arguments.length-1].parentNode;
+                              referenceEl = arguments[arguments.length-1];
+               break;
+               case 'string' :
+                              referenceEl = document.getElementById(arguments[arguments.length-1]);
+                              parentEl    = referenceEl.parentNode;
+            }
+
+            for ( var i = 0; i < arguments.length-1; i++ )
+            {
+                  parentEl.insertBefore(arguments[i], referenceEl);
+            }
+         } /* else */
+         return true;
+   },
+
+   "isArray" : function(a)
+   {
+      return this.isObject(a) && a.constructor == Array;
+   },
+
+   "isFunction" : function(a)
+   {
+      return typeof a == 'function';
+   },
+
+   "isNumber" : function(a)
+   {
+      return typeof a == 'number' && isFinite(a);
+   },
+
+   "isNull" : function(a)
+   {
+      return a === null;
+   },
+
+   "isObject" : function(a)
+   {
+      return (a && typeof a == 'object') || this.isFunction(a);
+   },
+
+   "isString" : function(a)
+   {
+      return typeof a == 'string';
+   },
+
+   "isUndefined" : function(a)
+   {
+      return typeof a == 'undefined';
+   },
+
+   "newEl" : function(pElement)
+   {
+      if ( arguments.length == 1 )
+      {
+         switch ( typeof pElement)
+         {
+            case 'string' :
+                           return document.createElement(pElement);
+            break;
+            case 'object' :
+                           var retorno = new Array();
+                           if (this.isArray(pElement))
+                           {
+                              for (var i in pElement)
+                              {
+                                 retorno[i] = document.createElement(pElement[i]);
+                              }
+                              return retorno;
+                           }
+            break;
+         } /* switch */
+      } /* if */
+      else
+      {
+         var retorno = new Array();
+         for ( var i = 0; i < arguments.length; i++ )
+         {
+            retorno[i] = document.createElement(arguments[i]);
+         }
+         return retorno;
+      }
+   },
+
+   "trim" : function(pString)
+   {
+      return pString.replace(/^( )*|( )*$/g, '');
+   }
+}
Index: /trunk/instant_messenger/js/im_templates.js
===================================================================
--- /trunk/instant_messenger/js/im_templates.js	(revision 20)
+++ /trunk/instant_messenger/js/im_templates.js	(revision 20)
@@ -0,0 +1,352 @@
+/**
+* @AUTHOR: Alexandre Correia / Rodrigo Souza
+* @DATE: 2006/10/24 17:03:00
+* @LAST CHANGE: Seg 11 Dez 2006 10:21:34 BRST::
+* Instant Messenger
+* im_templates.js
+**/
+
+	function Templates(){
+
+		this.element 	= document.getElementById("im_expresso");
+		this.form 		= "";
+		this.time_set 	= "";
+		this.transfer	= 0;
+		this.arquivo 	= "";
+	}
+	
+   /*
+	* Conf forms
+	*/
+
+	Templates.prototype.conf_form = function(pName,pWidth,pHeight,pHTML,pTitle)
+	{
+	     var params = new Array();
+    	 params['body'] = pHTML;
+      	 params['height'] = pHeight;
+     	 params['id'] = pName;
+     	 params['maximize'] = false;
+     	 params['minimize'] = false;
+     	 params['title'] = pTitle;
+     	 params['width'] = pWidth;
+		 im_win.create_window(params);
+	}
+
+   /*
+	* Add Usuario
+	*/
+
+	Templates.prototype.add_user = function()
+	{
+
+		var _this = this;
+		var _td = "";
+
+		var form_add_user = "<span><b>Selecione uma Organização .: </b><select id='ImSelOrg' name='ImSelOrg' onchange='Preferences.SearchContacts();'></select>" +
+							"</span>"+
+							"<select size='10' id='ImSelAddContact' name='ImSelAddContact' class='add_user' onclick='Preferences.preenche();'></select><table border='0' cellpadding='1' cellspacing='2' align='center' width='100%'  >"+
+							"<tr><td><b>"+IM.get_lang('Jid Contact')+".:</b></td><td><input id='text0' type='text' size='40' maxlength='40'></td></tr>"+
+							"<tr><td><b>"+IM.get_lang('Nickname')+".:</b></td><td><input id='text1' type='text' size='20' maxlength='20'></td></tr>"+
+							"<tr><td><b>"+IM.get_lang('Group')+".:</b></td><td><input id='text2' type='text' size='20' maxlength='20'></td></tr>"+
+							"<tr><td colspan='2'><input type='button' value='"+IM.get_lang('Add')+"' onclick='Preferences.Add_user(\"divAddUser_im\")'></td></tr>"+
+							"</table>"
+		_this.conf_form("divAddUser",500,285,form_add_user,":: " + IM.get_lang('Add New Contact') + " - Expresso ::");
+	}
+
+   /*
+	* Del Usuario
+	*/
+
+	Templates.prototype.remove_user = function()
+	{
+		var _this = this;
+		var form_del_user = "<div style='margin-left:20px;margin-top:20px'>"+
+							"<span>"+IM.get_lang('Contact')+"&nbsp;.:&nbsp;</span>"+
+							"<span style='margin-left:20px'><select id='sel_contact'></select></span><br>"+
+							"<p><span><input type='button' value='"+IM.get_lang('Remove')+"' onclick='javascript:Preferences.Remove_user()'></span>"+
+							"</div>";
+
+		_this.conf_form("divDelUser",400,110,form_del_user,":: " + IM.get_lang('Remove Contact') + " - Expresso ::");
+	}
+
+   /*
+	* Update Usuario
+	*/
+
+	Templates.prototype.update_user = function()
+	{
+		if(document.getElementById("divChildrenFormAuthUser") != null){
+			im_win.windowClose("divFormAuthUser_im");	
+		}
+
+		var _this = this;
+		var form_update_user = "<table border='0' cellpadding='1' cellspacing='2' align='center' width='90%'>"+
+							   "<tr><td><input id='text0' type='hidden' size='40' maxlength='40'></td></tr>"+
+							   "<tr><td><b>Contato .:</b></td><td><span id='span0'></span></td></tr>"+
+							   "<tr><td><b>"+IM.get_lang('Nickname')+".:</b></td><td><input id='text1' type='text' size='20' maxlength='20'></td></tr>"+
+							   "<tr><td><b>"+IM.get_lang('Group')+".:</b></td><td><input id='text2' type='text' size='20' maxlength='20'></td></tr>"+
+							   "<tr><td colspan='2'><input type='button' value='"+IM.get_lang('Update')+"' onclick='Preferences.Add_user(\"divUpdateUser_im\")'></td></tr>"+
+							   "</table>";
+		_this.conf_form("divUpdateUser",300,110,form_update_user,":: Adicionar Contato - Expresso ::");
+	}
+
+	Templates.prototype.Users_Not_Auth = function ()
+	{
+		var _this = this;
+		var form_auth_user = "<div style='margin-left:10px;margin-top:5'>" +
+							 "<br>"+
+							 "<b>O(s) contato(s) abaixo aguarda(m) sua autorização." +
+							 "<br>Para adicionar este(s) novo(s) contato(s), basta dar um " +
+							 "<br>clique em cima do contato." +
+							 "<p>Contato(s) :" + 
+							 "</b><br>" +
+							 "<div id='divChildrenFormAuthUser'>" +		
+							 "<p>" + document.getElementById('not_aut').innerHTML + 
+							 "</div></div>";
+
+		_this.conf_form("divFormAuthUser",370,200,form_auth_user, ":: Contatos sem Cadastro - Expresso ::");
+	
+	}
+
+   /*
+	* Vcard Usuario
+	*/
+
+	Templates.prototype.information_user = function()
+	{
+		var _this = this;
+		var form_info_user = "<table border='0' cellpadding='1' cellspacing='2' width='90%' style='margin-top:10px'>"+
+							 "<tr><td width='30%' align='right'>"+IM.get_lang("Full Name")+"&nbsp;.:&nbsp;</td><td><input id='FN' type='text name='text0' size='40' maxlength='40'></td></tr>"+
+							 "<tr><td width='30%' align='right'>"+IM.get_lang("NickName")+"&nbsp;.:&nbsp;</td><td><input id='NICKNAME' type='text name='text1' size='20' maxlength='20'></td></tr>"+
+							 "<tr><td width='30%' align='right'>"+IM.get_lang("Orgname")+"&nbsp;.:&nbsp;</td><td><input id='ORGNAME' type='text name='text4' size='17' maxlength='17'></td></tr>"+							 
+							 "<tr><td width='30%' align='right'>"+IM.get_lang("Orgunit")+"&nbsp;.:&nbsp;</td><td><input id='ORGUNIT' type='text name='text5' size='10' maxlength='10'></td></tr>"+
+ 							 "<tr><td width='30%' align='right'>"+IM.get_lang("Role")+"&nbsp;.:&nbsp;</td><td><input id='ROLE' type='text name='text6' size='25' maxlength='25'></td></tr>"+
+							 "<tr><td width='30%' align='right'>"+IM.get_lang("Birthday")+"&nbsp;.:&nbsp;</td><td><input id='BDAY' type='text name='text7' size='10' maxlength='10'></td></tr>"+ 							 
+							 "<tr><td width='30%' align='right'>"+IM.get_lang("your message")+"&nbsp;.:&nbsp;</td><td><input id='DESC' type='text name='text8' size='40' maxlength='40'></td></tr>"+ 							 
+							 "</table>"+
+							 "<table border='0' cellpading='1' cellspacing='2' width='100%'>"+
+							 "<tr><input type='button' value='"+IM.get_lang('save')+"' onclick='javascript:Preferences.vCardAdd();'></tr>"+
+							 "</table>";
+		_this.conf_form("divInfoUser",400,220,form_info_user, ":: " + IM.get_lang('Information User') + " - Expresso ::");
+	}
+
+	Templates.prototype.information_Contact = function()
+	{
+		var _this = this;
+		var form_info_contact = '<table border="0" cellpading="1" cellspacing="2" width="90%" style="margin-top:10px">'+
+							 	'<tr><td width="30%" align="right">'+IM.get_lang('Full Name')+'&nbsp;.:&nbsp;</td><td width="70%" align="left"><label id="_lbl_FN"></label></td></tr>'+
+							 	'<tr><td width="30%" align="right">'+IM.get_lang('NickName')+'&nbsp;.:&nbsp;</td><td width="70%" align="left"><label id="_lbl_Nickname"></label></td></tr>'+
+							 	'<tr><td width="30%" align="right">'+IM.get_lang('Orgunit')+'&nbsp;.:&nbsp;</td><td width="70%" align="left"><label id="_lbl_Orgunit"></label></td></tr>'+
+							 	'<tr><td width="30%" align="right">'+IM.get_lang('Role')+'&nbsp;.:&nbsp;</td><td width="70%" align="left"><label id="_lbl_Role"></label></td></tr>'+
+							 	'<tr><td width="30%" align="right">'+IM.get_lang('Birthday')+'&nbsp;.:&nbsp;</td><td width="70%" align="left"><label id="_lbl_Birthday"></label></td></tr>'+							
+								'<table>';
+		_this.conf_form("divInfoContact",400,130,form_info_contact,":: Informações do Contato - Expresso ::");
+	
+	}
+
+   Templates.prototype.emotions = function()
+   {
+      grid = '';
+      grid += '<table cellpadding="0" cellspacing="0" border="0">';
+      grid += '    <tr>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':)\')" id="sendMessageMenuId"><img alt=":)" width="19" height="19" src="' + smile_1.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':d\')" id="sendMessageMenuId"><img alt=":d" width="19" height="19" src="' + smile_2.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\';)\')" id="sendMessageMenuId"><img alt=";)" width="19" height="19" src="' + smile_3.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':o\')" id="sendMessageMenuId"><img alt=":o" width="19" height="19" src="' + smile_4.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':p\')" id="sendMessageMenuId"><img alt=":p" width="19" height="19" src="' + smile_5.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(h)\')" id="sendMessageMenuId"><img alt="(h)" width="19" height="19" src="' + smile_6.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':@\')" id="sendMessageMenuId"><img alt=":@" width="19" height="19" src="' + smile_7.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':$\')" id="sendMessageMenuId"><img alt=":$" width="19" height="19" src="' + smile_8.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':s\')" id="sendMessageMenuId"><img alt=":s" width="19" height="19" src="' + smile_9.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':(\')" id="sendMessageMenuId"><img alt=":(" width="19" height="19" src="' + smile_10.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':\\\'\(\')" id="sendMessageMenuId"><img alt=":\'(" width="19" height="19" src="' + smile_11.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':|\')" id="sendMessageMenuId"><img alt=":|" width="19" height="19" src="' + smile_12.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(6)\')" id="sendMessageMenuId"><img alt="(6)" width="19" height="19" src="' + smile_13.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(a)\')" id="sendMessageMenuId"><img alt="(a)" width="19" height="19" src="' + smile_14.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(l)\')" id="sendMessageMenuId"><img alt="(l)" width="19" height="19" src="' + smile_15.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(u)\')" id="sendMessageMenuId"><img alt="(u)" width="19" height="19" src="' + smile_16.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(m)\')" id="sendMessageMenuId"><img alt="(m)" width="19" height="19" src="' + smile_17.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(@)\')" id="sendMessageMenuId"><img alt="(@)" width="19" height="19" src="' + smile_18.src + '" /></div></td>';
+      grid += '    </tr>';
+      grid += '    <tr>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(&)\')" id="sendMessageMenuId"><img alt="(&)" width="19" height="19" src="' + smile_19.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(S)\')" id="sendMessageMenuId"><img alt="(S)" width="19" height="19" src="' + smile_20.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(*)\')" id="sendMessageMenuId"><img alt="(*)" width="19" height="19" src="' + smile_21.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(~)\')" id="sendMessageMenuId"><img alt="(~)" width="19" height="19" src="' + smile_22.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(8)\')" id="sendMessageMenuId"><img alt="(8)" width="19" height="19" src="' + smile_23.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(e)\')" id="sendMessageMenuId"><img alt="(e)" width="19" height="19" src="' + smile_24.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(f)\')" id="sendMessageMenuId"><img alt="(f)" width="19" height="19" src="' + smile_25.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(w)\')" id="sendMessageMenuId"><img alt="(w)" width="19" height="19" src="' + smile_26.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(o)\')" id="sendMessageMenuId"><img alt="(o)" width="19" height="19" src="' + smile_27.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(k)\')" id="sendMessageMenuId"><img alt="(k)" width="19" height="19" src="' + smile_28.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(g)\')" id="sendMessageMenuId"><img alt="(g)" width="19" height="19" src="' + smile_29.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(^)\')" id="sendMessageMenuId"><img alt="(^)" width="19" height="19" src="' + smile_30.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(p)\')" id="sendMessageMenuId"><img alt="(p)" width="19" height="19" src="' + smile_31.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(i)\')" id="sendMessageMenuId"><img alt="(i)" width="19" height="19" src="' + smile_32.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(c)\')" id="sendMessageMenuId"><img alt="(c)" width="19" height="19" src="' + smile_33.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(t)\')" id="sendMessageMenuId"><img alt="(t)" width="19" height="19" src="' + smile_34.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'({)\')" id="sendMessageMenuId"><img alt="({)" width="19" height="19" src="' + smile_35.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(})\')" id="sendMessageMenuId"><img alt="(})" width="19" height="19" src="' + smile_36.src + '" /></div></td>';
+      grid += '    </tr>';
+      grid += '    <tr>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(b)\')" id="sendMessageMenuId"><img alt="(b)" width="19" height="19" src="' + smile_37.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(d)\')" id="sendMessageMenuId"><img alt="(d)" width="19" height="19" src="' + smile_38.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(z)\')" id="sendMessageMenuId"><img alt="(z)" width="19" height="19" src="' + smile_39.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(x)\')" id="sendMessageMenuId"><img alt="(x)" width="19" height="19" src="' + smile_40.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(y)\')" id="sendMessageMenuId"><img alt="(y)" width="19" height="19" src="' + smile_41.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(n)\')" id="sendMessageMenuId"><img alt="(n)" width="19" height="19" src="' + smile_42.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':[\')" id="sendMessageMenuId"><img alt=":["  width="19" height="19" src="' + smile_43.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(?)\')" id="sendMessageMenuId"><img alt="(?)" width="19" height="19" src="' + smile_44.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(%)\')" id="sendMessageMenuId"><img alt="(%)" width="19" height="19" src="' + smile_45.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(#)\')" id="sendMessageMenuId"><img alt="(#)" width="19" height="19" src="' + smile_46.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(r)\')" id="sendMessageMenuId"><img alt="(r)" width="19" height="19" src="' + smile_47.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':-#\')" id="sendMessageMenuId"><img alt=":-#" width="19" height="19" src="' + smile_48.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'8o|\')" id="sendMessageMenuId"><img alt="8o|" width="19" height="19" src="' + smile_49.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'8-|\')" id="sendMessageMenuId"><img alt="8-|" width="19" height="19" src="' + smile_50.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'^o)\')" id="sendMessageMenuId"><img alt="^o)" width="19" height="19" src="' + smile_51.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\':-*\')" id="sendMessageMenuId"><img alt=":-*" width="19" height="19" src="' + smile_52.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'+o(\')" id="sendMessageMenuId"><img alt="+o(" width="19" height="19" src="' + smile_53.src + '" /></div></td>';
+      grid += '      <td><div class="emotionItem" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.addEmotion(\'(sn)\')" id="sendMessageMenuId"><img alt=(sn)"" width="19" height="19" src="' + smile_54.src + '" /></div></td>';
+      grid += '    </tr>';
+      grid += '    <tr>';
+      grid += '      <td colspan="18"><div style="background:#cccccc;margin:1px"><img src="templates/default/images/img/blank.gif" height="1" width="1" border="0"/></div></td>';
+      grid += '    </tr>';
+      grid += '    <tr>';
+      grid += '    </tr>';
+      grid += '    <td colspan="18"><div class="emotionItem" !style="width:100%" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideEmotionSelection()" id="closeEmotionSelectionDiv">Close This Menu</div></td>';
+      grid += '   </tr>';
+      grid += '</table>';
+
+      return grid;
+   }
+
+   Templates.prototype.font_name = function()
+   {
+      grid = '';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFont(\'Arial\')" id="fontStyle1" style="width:120px;font-family:arial">Arial</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFont(\'Courier\')" id="fontStyle1" style="width:120px;font-family:Courier">Courier</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFont(\'Times\')" id="fontStyle1" style="width:120px;font-family:Times New Roman">Times New Roman</div>';
+      grid += '<div style="background:#cccccc;margin:1px"><img src="../images/blank.gif" height="1" width="1" border="0"/></div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontNameSelection()" id="fontStyle1" style="width:120px">Close This Menu</div>';
+
+      return grid;
+   }
+
+   Templates.prototype.font_size = function()
+   {
+      grid = '';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeSizeFont(\'9pt\');" id="fontStyle1" style="width:100px">9</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeSizeFont(\'10pt\');" id="fontStyle1" style="width:100px">10</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeSizeFont(\'11pt\');" id="fontStyle1" style="width:100px">11</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeSizeFont(\'12pt\');" id="fontStyle1" style="width:100px">12</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeSizeFont(\'14pt\');" id="fontStyle1" style="width:1!00px">14</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeSizeFont(\'16pt\');" id="fontStyle1" style="width:100px">16</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeSizeFont(\'18pt\');" id="fontStyle1" style="width:100px">18</div>';
+      grid += '<div style="background:#cccccc;margin:1px"><img src="../images/blank.gif" height="1" width="1" border="0"/></div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontSizeSelection()" id="fontStyle1" style="width:100px">Close This Menu</div>';
+
+      return grid;
+   }
+
+   Templates.prototype.font_color = function()
+   {
+      grid = '';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontColor(\'#000000\')" id="fontStyle1" style="width:100px">Black</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontColor(\'#c0c0c0\')" id="fontStyle1" style="width:100px">Silver</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontColor(\'#ffff00\')" id="fontStyle1" style="width:100px">Yellow</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontColor(\'#ff0000\')" id="fontStyle1" style="width:100px">Red</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontColor(\'#ff00ff\')" id="fontStyle1" style="width:100px">Pink</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontColor(\'#00ff00\')" id="fontStyle1" style="width:100px">Green</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontColor(\'#1111ff\')" id="fontStyle1" style="width:100px">Blue</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontColor(\'#800080\')" id="fontStyle1" style="width:100px">Magenta</div>';
+      grid += '<div style="background:#cccccc;margin:1px"><img src="../images/blank.gif" height="1" width="1" border="0"/></div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontColorSelection()" id="fontStyle1" style="width:100px">Close This Menu</div>';
+
+      return grid;
+   }
+
+   Templates.prototype.font_style = function()
+   {
+      grid = '';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontStyle(\'normal\')" id="fontStyle1" style="width:100px">Regular</div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontStyle(\'italic\')" id="fontStyle1" style="width:100px"><i>Italic</i></div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_conf_font.changeFontStyle(\'bold\')" id="fontStyle1" style="width:100px"><b>Bold</b></div>';
+      grid += '<div style="background:#cccccc;margin:1px"><img src="../images/blank.gif" height="1" width="1" border="0"/></div>';
+      grid += '<div class="menuitems" onMouseover="im_win.highlightie5(this)" onMouseout="im_win.lowlightie5(this)" onclick="im_win.hideFontStyleSelection()" id="fontStyle1" style="width:100px">Close This Menu</div>';
+
+      return grid;
+   }
+
+   /*
+   	* Send File
+   	*/
+
+   Templates.prototype.Send_file = function(pJid)
+   {
+		var _this = this;
+		var form_send_file = '<iframe style="display:none;" name="send_file"></iframe>'+
+							 '<div id="div_send_file_im" style="margin-left:5px;margin-top:10px;display:block;">'+
+		                     '<span>.: Enviar Arquivo :.</span><br>'+
+		                     '<form method="POST" target="send_file" action="'+im_path+'inc/class.upload.inc.php" enctype="multipart/form-data">'+
+							 '<input id="to_jid_im" type="hidden" value="' + pJid + '" name="to">'+
+							 '<input id="send_file_im" type="file" size="40" name="file">'+
+							 '<br><br><input type="submit" value="'+IM.get_lang('Send')+'" onclick="javascript:Templates.Wait_file(\'' + pJid + '\');return true;">'+
+							 '</form></div>'+
+							 '<div id="status_upload" style="margin-left:5px;margin-top:10px;display:none;">' +
+							 '<span>.: Status da Transferência :.</span>'+
+							 '<br><br>'+
+							 '<div id="progressbar_p" style="border:1px solid #C9D9E8;width:70%;height:12%">'+
+					 		 '<div id="progressbar_f" style="border:1px solid #000;width:0%;height:100%;background-color:#C9D9E8;text-align:right">'+
+							 '<font style="font-size:8pt"><span id="porcent_im">100%</span></font>'+
+							 '</div></div></div>';
+		_this.conf_form("divSendFile",360,110,form_send_file,":: Envio de Arquivo - Expresso ::");
+	}
+	
+	Templates.prototype.Wait_file = function(pJid)
+	{
+		if(document.getElementById("send_file_im").value != ""){
+			document.getElementById("div_send_file_im").style.display = "none";
+			document.getElementById("status_upload").style.display = "block";			
+			this.UpdateStatusSendFile(pJid);
+		}else{
+			alert("É necessário informar um arquivo para envio!");
+		}
+	}
+	
+	Templates.prototype.UpdateStatusSendFile = function(pJid)
+	{
+		var _this = this;
+		this.time_set = setTimeout("Templates.Wait_file('" + pJid + "')",80);
+		if(this.transfer == 100){
+			clearTimeout(this.time_set);
+			document.getElementById("div_send_file_im").style.display = "block";
+			document.getElementById("status_upload").style.display = "none";
+			document.getElementById("send_file_im").value = "";	
+			this.transfer = 0;
+			this.time_set = "";
+			// Envia a Mensagem para a baixa do arquivo;
+			var h_name_file = function(data){
+				//var pJID = "alexandrecorreia@im.pr.gov.br";
+				var pJID = pJid;				
+				var message_conf = '<iframe name="IM_down_file" style="display:none"></iframe>'+
+								   '<b>VOCÊ ACABA DE RECEBER UM ARQUIVO !!!!&nbsp;</b>'+
+								   '<a href="../instant_messenger/inc/class.download.inc.php?file=' + data + '" target="IM_down_file">Clique aqui</a>';
+				var Conf_send_file = function(data){		
+	         		if(!data)
+	               		alert(data);
+		         }
+	         	cIM.cExecute("$this.Ujabber.SendMessage",Conf_send_file,"to="+pJID+"&body="+url_encode(encodeURI(message_conf)));
+			}
+			cIM.cExecute("$this.upload.name_file",h_name_file);
+		}else{		
+			var h_size_file = function(data){
+				_this.transfer++;
+				document.getElementById("progressbar_f").style.width = _this.transfer + "%";
+				document.getElementById("porcent_im").innerHTML = _this.transfer + "%";
+			}
+			cIM.cExecute("$this.upload.size_file",h_size_file);
+		}
+	}		
+	
+	//Templates
+	var Templates = new Templates();
Index: /trunk/instant_messenger/js/im_menu_action.js
===================================================================
--- /trunk/instant_messenger/js/im_menu_action.js	(revision 20)
+++ /trunk/instant_messenger/js/im_menu_action.js	(revision 20)
@@ -0,0 +1,70 @@
+// Instant Messenger
+// im_menu_action.js
+
+	var im_menu_action = {
+      "delay_hide" : 500,
+      "delayhide" : false,
+
+      "menu" : function()
+      {
+         try
+         {
+            pElement = arguments[0];
+            delete arguments[0];
+            pMenu = ( func.isString(arguments[1]) ) ? arguments[1] : arguments;
+            if ( document.getElementById(pElement).innerHTML == "" )
+            {
+               func.confEl(pElement, 'style', 'display:block;');
+               var _this = this;
+               _this.layout(pMenu, pElement);
+            }
+            else
+            {
+               func.confEl(pElement, 'style', 'display:none;');
+               this.del_innerHTML(pElement);
+               this.clear_delayhide();
+            }
+         }
+         catch(e)
+         {
+         }
+      },
+
+	  "layout" : function(pHtml, pElement)
+      {
+			var _this = this;
+			var el_dest_ = ( func.isString(pElement) ) ? func.byId(pElement) : pElement;
+			var div_menu = func.newEl("div");
+			func.confEl(div_menu, 'id', 'div_pref');
+            func.confEl(div_menu, 'style', 'padding:0px;position:absolute;padding:0px;');
+			div_menu.style.Zindex = "150";
+			div_menu.onmouseover = function(){_this.clear_delayhide();};
+			div_menu.onmouseout = function(){_this.resetit(pElement);};
+			if ( func.isString(pHtml) )
+               div_menu.innerHTML = pHtml;
+            else
+            for ( i = 1; i < pHtml.length; i++ )
+               func.insEl(pHtml[i], div_menu);
+			
+			func.insEl(div_menu, el_dest_);
+			this.delayhide = setTimeout("im_menu_action.del_innerHTML('"+pElement+"')", 2000);
+		},
+
+	   "del_innerHTML": function(pElement)
+       {
+           func.confEl(pElement, 'style', 'display:none;');
+		   func.byId(pElement).innerHTML = "";
+		   document.oncontextmenu = new Function("return true");
+	   },
+
+	   "resetit": function(pElement)
+       {
+			this.delayhide = setTimeout("im_menu_action.del_innerHTML('"+pElement+"')",this.delay_hide);
+	   },
+		
+	   "clear_delayhide" : function()
+       {
+			if ( this.delayhide )
+				clearTimeout(this.delayhide);
+	   }
+	}
Index: /trunk/instant_messenger/js/im_preferences.js
===================================================================
--- /trunk/instant_messenger/js/im_preferences.js	(revision 20)
+++ /trunk/instant_messenger/js/im_preferences.js	(revision 20)
@@ -0,0 +1,348 @@
+// Instant Messenger
+// im_preferences.js
+
+	function Preferences()
+	{
+		this.save_vcard = "";	
+	}
+
+   /*
+	* Add
+	*/
+	
+	Preferences.prototype.Add_userLoad = function()
+	{
+		Templates.add_user();
+		this.SearchOrganizationsLdap();
+		var select_contact = document.getElementById('ImSelAddContact');
+		select_contact.innerHTML = "";
+	}
+	
+	Preferences.prototype.SearchOrganizationsLdap = function()
+	{
+		var handler_organizations = function(data){
+			var select_org = document.getElementById('ImSelOrg');
+			if(select_org.options.length > 0)
+				select_org.options.splice(0,select_org.options.length);
+			var options = new Option("--Selecione -- ", -1, false, true);
+			select_org[select_org.length] = options;
+			
+			for(var i in data){
+				var options = new Option(data[i].ou, data[i].ou, false, true);
+				select_org[select_org.length] = options;
+			}
+			select_org[0].selected = true;
+		}
+		cIM.cExecute("$this.ldap_im.list_organizations_ldap", handler_organizations);
+	}
+	
+	Preferences.prototype.SearchContacts = function()
+	{
+		var select_org = document.getElementById('ImSelOrg');
+		var organization = "";
+		for(var i=0; i < select_org.options.length; i++){
+			if(select_org.options[i].selected == true){
+				organization = select_org.options[i].value;
+			}
+		}
+		var handler_contacts = function(data){
+			var select_contact = document.getElementById('ImSelAddContact');
+			var text0 = document.getElementById('text0');
+			var text1 = document.getElementById('text1');
+			var content = "";
+			select_contact.innerHTML = "";
+			text0.value = "";
+			text1.value = "";
+			if(data){
+				for(var i in data){
+					var options =  new Option(data[i].cn + " ( "+ data[i].mail + " )", data[i].mail, false, false);
+					select_contact[select_contact.length] = options;
+				}
+			}
+		}
+		cIM.cExecute("$this.contacts_im.list_contacts", handler_contacts,"ou="+organization);
+	}
+
+	Preferences.prototype.preenche = function()
+	{
+		var select = document.getElementById('ImSelAddContact');
+		if(select.options.length > 0){
+			for(var i=0; i < select.options.length; i++){
+				if(select.options[i].selected == true){
+					document.getElementById('text0').value = select.options[i].value;
+					document.getElementById('text1').value = select.options[i].value.substr(0,select.options[i].value.indexOf('@'));	
+					document.getElementById('text2').focus(); 			
+				}
+			}
+		}
+	}
+	
+	Preferences.prototype.Add_user = function(pFunc)
+	{
+		var text0 = document.getElementById('text0');
+		var text1 = document.getElementById('text1');
+		var text2 = document.getElementById('text2');
+		var _this = this;
+		
+		if(pFunc != "divUpdateUser_im"){
+			var jid = text0.value.substr(0,text0.value.indexOf('@'));
+			for(var i=0; i < IM.user_not_aut.length; i++){
+				if(IM.user_not_aut[i].substr(0,IM.user_not_aut[i].indexOf('@')) == jid){
+					return;
+				}					
+			}
+		}
+			
+		if(IM.LTrim(text0.value) != "" && IM.LTrim(text1.value) != "" && IM.LTrim(text2.value) != ""){
+			var handler_add_contact = function(data){
+				if(data){
+					text0.value = "";
+					text1.value = "";
+					text2.value = "";	
+					if(pFunc != 'divAddUser_im')
+						im_win.windowClose(pFunc);
+					IM.UpdateContacts();
+					
+				}
+			}
+			if(pFunc == 'divAddUser_im')
+				cIM.cExecute("$this.Ujabber.AddNewContacts",handler_add_contact,"email="+text0.value+"&name="+text1.value+"&group="+text2.value+"&subscription=none");
+			else
+				cIM.cExecute("$this.Ujabber.AddNewContacts",handler_add_contact,"email="+text0.value+"&name="+text1.value+"&group="+text2.value+"&subscription=to");
+		}else{
+			alert("Informe todos os campos!");
+		}
+	}
+
+   /*
+	* Remove
+	*/
+	
+	Preferences.prototype.Remove_userLoad = function()
+	{
+		Templates.remove_user();
+		var sel_contact = document.getElementById('sel_contact');
+		if(sel_contact.options.length > 0)
+			sel_contact.options.splice(0,sel_contact.options.length);
+		var opt = new Option("-- "+IM.get_lang('Choice Contact')+" -- ","0",true,true);
+		sel_contact.options[sel_contact.length] = opt;
+
+		for(var i=1; i < IM.vcard_contacts.length; i++){
+			if(IM.vcard_contacts[i].name != ""){
+				opt = new Option(IM.vcard_contacts[i].name,IM.vcard_contacts[i].jid, false, false);
+				sel_contact.options[sel_contact.length] = opt;
+			}else{
+				name = IM.vcard_contacts[i].jid.substr(0,IM.vcard_contacts[i].jid.indexOf('@'));
+				opt = new Option(name,IM.vcard_contacts[i].jid, false, false);
+				sel_contact.options[sel_contact.length] = opt;
+			}
+		}
+	}
+	
+	Preferences.prototype.Remove_user = function()
+	{
+		var _this = this;
+		var sel_contact = document.getElementById('sel_contact');
+		for(var i=0; i < sel_contact.options.length; i++){
+			if(sel_contact[i].selected && sel_contact.options[i].value != 0){
+				if(confirm("Excluir o contato " + sel_contact.options[i].innerHTML + "?")){
+					var in_el = sel_contact.options[i].innerHTML;
+					for(var j=1 ; j < IM.vcard_contacts.length; j++){
+						var name = IM.vcard_contacts[j].jid.substr(0,IM.vcard_contacts[j].jid.indexOf('@'));
+						if(IM.vcard_contacts[j].name == in_el || name == in_el){
+							var handler_remove_contact = function(data){
+								if(!data){
+									alert(data);
+									return false;
+								}
+	  						    setTimeout("IM.UpdateContacts()",1000);
+							}
+							cIM.cExecute("$this.Ujabber.RosterRemoveUser",handler_remove_contact,"jid="+sel_contact.options[i].value);
+							IM.vcard_contacts.splice(j,1);
+							_this.ComboRemove();							
+							j--;
+						}
+					}
+				}
+			}
+		}
+	}
+	
+	Preferences.prototype.ComboRemove = function()
+	{
+		var sel_contact = document.getElementById('sel_contact');
+		if(sel_contact.length > 0 ){
+			for(var i=0; i < sel_contact.options.length; i++){
+				sel_contact.options[i] = null;
+				i--;
+			}
+		}
+
+		var opt = new Option("-- "+IM.get_lang('Choice Contact')+" -- ","0",true,true);
+		sel_contact.options[sel_contact.length] = opt;
+		for(var i=0; i < IM.vcard_contacts.length; i++){
+			opt = new Option(IM.vcard_contacts[i].name,IM.vcard_contacts[i].jid, false, false);
+			sel_contact.options[sel_contact.length] = opt;
+		}
+	}	
+
+	Preferences.prototype.Remove_Contact = function(pJid)
+	{
+		for(var i=0; i < IM.vcard_contacts.length; i++){
+			if(IM.vcard_contacts[i].jid == pJid){
+				if(confirm("Excluir o contato " + IM.vcard_contacts[i].name + "?")){
+					var handler_remove_contact = function(data){
+						if(!data){
+							alert(data);
+							return;
+						}else{
+  						    setTimeout("IM.UpdateContacts()",1000);
+						}
+					}
+					cIM.cExecute("$this.Ujabber.RosterRemoveUser",handler_remove_contact,"jid="+pJid);
+				}	
+				return;
+			}	
+		}
+	}
+
+   /*
+    * Update
+    */
+   
+   Preferences.prototype.updateLoad = function(i)
+   {
+   		Jid = IM.vcard_contacts[i].jid;
+   		Templates.update_user();   	
+   		document.getElementById('text0').value = Jid;
+   		document.getElementById('span0').innerHTML = Jid.substr(0,Jid.indexOf('@'));
+   }
+   
+   Preferences.prototype.Update_ = function(pJid,pType)
+   {
+		var name  = "";
+		var group = "";
+		var jid   = pJid;
+		
+		for(var i=1; i < IM.vcard_contacts.length; i++){
+			if(IM.vcard_contacts[i].jid == pJid){
+				name  = IM.vcard_contacts[i].name;
+				group = IM.vcard_contacts[i].group;
+			}
+		}
+		
+		if((name != "") && (group != "")){
+			if(pType){
+				var act = prompt("Digite um apelido para :" + pJid , name);
+				name = act;
+			}else{
+				var act = prompt("Digite um novo grupo para : " + name, group);
+				group = act;
+			}				
+			if((act != null) && (act != "")){
+				var handler_update_contacts = function(data){
+					if(data)
+						IM.UpdateContacts();
+					else
+						alert("erro");
+				}				
+				cIM.cExecute("$this.Ujabber.UpdateUser",handler_update_contacts,"jid="+jid+"&name="+name+"&group="+group);
+			}
+		}
+	}
+
+	Preferences.prototype.Update_Group = function(pJid)
+	{
+		this.Update_(pJid,false);		
+	}
+		
+	Preferences.prototype.Update_NickName = function(pJid)
+	{
+		this.Update_(pJid,true);   
+	}
+   
+   /*
+	* Vcard
+	*/
+		
+	Preferences.prototype.vCardLoad = function()
+	{
+		Templates.information_user();
+		document.getElementById('FN').value = IM.vcard_user['VCARD_FN'];
+		document.getElementById('NICKNAME').value = IM.vcard_user['VCARD_NICKNAME'];
+		document.getElementById('ORGNAME').value = IM.vcard_user['VCARD_ORGNAME'];
+		document.getElementById('ORGUNIT').value = IM.vcard_user['VCARD_ORGUNIT'];
+		document.getElementById('ROLE').value = IM.vcard_user['VCARD_ROLE'];
+		document.getElementById('BDAY').value = IM.vcard_user['VCARD_BDAY'];
+		document.getElementById('DESC').value = IM.vcard_user['VCARD_DESC'];
+	}
+	
+	Preferences.prototype.vCardAdd = function()
+	{
+		var _this = this;
+		IM.vcard_user['VCARD_FN'] = document.getElementById('FN').value;
+		_this.save_vcard = document.getElementById('FN').value + ";";
+		IM.vcard_user['VCARD_NICKNAME'] = document.getElementById('NICKNAME').value;
+		_this.save_vcard += document.getElementById('NICKNAME').value + ";";
+		var nickname = document.getElementById('span_nickname').innerHTML;
+		document.getElementById('span_nickname').innerHTML = (IM.vcard_user['VCARD_NICKNAME']) ? "<b>&nbsp;" + IM.vcard_user['VCARD_NICKNAME'].substring(0,30) + "</b>" : nickname;
+		IM.vcard_user['VCARD_ORGNAME'] = document.getElementById('ORGNAME').value;
+		_this.save_vcard += document.getElementById('ORGNAME').value + ";";
+		IM.vcard_user['VCARD_ORGUNIT'] = document.getElementById('ORGUNIT').value;
+		_this.save_vcard += document.getElementById('ORGUNIT').value + ";";
+		IM.vcard_user['VCARD_ROLE'] = document.getElementById('ROLE').value;
+		_this.save_vcard += document.getElementById('ROLE').value + ";";
+		IM.vcard_user['VCARD_BDAY'] = document.getElementById('BDAY').value;
+		_this.save_vcard += document.getElementById('BDAY').value + ";";		
+		IM.vcard_user['VCARD_DESC'] = document.getElementById('DESC').value;
+		_this.save_vcard += document.getElementById('DESC').value;		
+		var message_desc = document.getElementById('span_message').innerHTML;
+		document.getElementById('span_message').innerHTML = (IM.vcard_user['VCARD_DESC']) ? "<b>&nbsp;" + IM.vcard_user['VCARD_DESC'].substring(0,30) + "</b>" : message_desc ;
+
+		var handler_vcardAdd = function(data){
+			if(!data)
+				alert(data);
+			else
+				alert("Informações Cadastradas / Atualizadas !");
+		}
+		cIM.cExecute("$this.Ujabber.newVcard",handler_vcardAdd,"vcard="+_this.save_vcard);
+	}
+	
+	Preferences.prototype.vCardLoad_Contact = function(pJid)
+	{
+		Templates.information_Contact();
+		for(var i=0; i < IM.vcard_contacts.length; i++){
+			if(IM.vcard_contacts[i].jid == pJid){
+				document.getElementById('_lbl_FN').innerHTML = IM.vcard_contacts[i].VCARD_FN;
+				document.getElementById('_lbl_Nickname').innerHTML = IM.vcard_contacts[i].VCARD_NICKNAME;
+				document.getElementById('_lbl_Orgunit').innerHTML = IM.vcard_contacts[i].VCARD_ORGUNIT;
+				document.getElementById('_lbl_Role').innerHTML = IM.vcard_contacts[i].VCARD_ROLE;
+				document.getElementById('_lbl_Birthday').innerHTML = IM.vcard_contacts[i].VCARD_BDAY;																
+				return;
+			}	
+		}
+	}
+	
+   /*
+    * Envio de arquivo
+    */
+    
+    Preferences.prototype.SendFile = function(pJid)
+    {
+		if(im_send_file == 'true'){
+			Templates.Send_file(pJid);
+		}else{
+			alert('Funçao Indisponível!');
+		}
+    }
+    
+    Preferences.prototype.SizeFile = function()
+    {
+    	var h_SizeFile = function(data){
+    		alert(data);	
+    	}
+ 	   	cIM.cExecute("$this.upload.size_file",h_SizeFile);
+    }
+    
+// Build Object	
+	var Preferences = new Preferences();	
Index: /trunk/instant_messenger/js/im_dragdrop.js
===================================================================
--- /trunk/instant_messenger/js/im_dragdrop.js	(revision 20)
+++ /trunk/instant_messenger/js/im_dragdrop.js	(revision 20)
@@ -0,0 +1,1425 @@
+/* This notice must be untouched at all times.
+
+wz_dragdrop.js	v. 4.85
+The latest version is available at
+http://www.walterzorn.com
+or http://www.devira.com
+or http://www.walterzorn.de
+
+Copyright (c) 2002-2003 Walter Zorn. All rights reserved.
+Created 26. 8. 2002 by Walter Zorn (Web: http://www.walterzorn.com )
+Last modified: 3. 7. 2006
+
+This DHTML & Drag&Drop Library adds Drag&Drop functionality
+to the following types of html-elements:
+- images, even if not positioned via layers,
+  nor via stylesheets or any other kind of "hard-coding"
+- relatively and absolutely positioned layers (DIV elements).
+Moreover, it provides extended DHTML abilities.
+
+LICENSE: LGPL
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License (LGPL) as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+For more details on the GNU Lesser General Public License,
+see http://www.gnu.org/copyleft/lesser.html
+*/
+
+
+// PATH TO THE TRANSPARENT 1*1 PX IMAGE (required by NS 4 as spacer)
+var IM_spacer = 'transparentpixel.gif';
+
+
+
+
+//window.onerror = new Function('return true;');
+
+
+// Optional commands passed to SET_DHTML() on the html-page (g: may be applied globally, i: individually)
+var IM_CLONE			= 'C10nE';   // i  img	  clone image
+var IM_COPY			 = 'C0pY';	// i  img	  create copies
+var IM_DETACH_CHILDREN  = 'd37aCH';  // i  lyr	  detach images
+var IM_HORIZONTAL	   = 'H0r1Z';   // i  img,lyr  horizontally draggable only
+var IM_MAXHEIGHT		= 'm7x8I';   // i  img,lyr  maximum height limit, "
+var IM_MAXOFFBOTTOM	 = 'm7xd0wN'; // i  img,lyr  downward offset limit
+var IM_MAXOFFLEFT	   = 'm7x23Ft'; // i  img,lyr  leftward offset limit
+var IM_MAXOFFRIGHT	  = 'm7x0Ff8'; // i  img,lyr  rightward offset limit
+var IM_MAXOFFTOP		= 'm7xu9';   // i  img,lyr  upward offset limit
+var IM_MAXWIDTH		 = 'm7xW1';   // i  img,lyr  maximum width limit, use with resizable or scalable
+var IM_MINWIDTH		 = 'm1nw1';   // i  img,lyr  minimum width limit, "
+var IM_MINHEIGHT		= 'm1n8I';   // i  img,lyr  minimum height limit, "
+var IM_NO_ALT		   = 'no81T';   // gi img	  disable alt and title attributes
+var IM_NO_DRAG		  = 'N0d4Ag';  // i  img,lyr  disable draggability
+var IM_RESET_Z		  = 'r35E7z';  // gi img,lyr  reset z-index when dropped
+var IM_RESIZABLE		= 'r5IZbl';  // gi img,lyr  resizable if <ctrl> or <shift> pressed
+var IM_SCALABLE		 = 'SCLbl';   // gi img,lyr  scalable		   "
+var IM_SCROLL		   = 'sC8lL';   // gi img,lyr  enable auto scroll functionality
+var IM_TRANSPARENT	  = 'dIApHAn'; // gi img,lyr  translucent while dragged
+var IM_VERTICAL		 = 'V3Rt1C';  // i  img,lyr  vertically draggable only
+var IM_dd_cursors = new Array(
+	'im_c:default',
+	'im_c:crosshair',
+	'im_c:e-resize',
+	'im_c:hand',
+	'im_c:help',
+	'im_c:move',
+	'im_c:n-resize',
+	'im_c:ne-resize',
+	'im_c:nw-resize',
+	'im_c:s-resize',
+	'im_c:se-resize',
+	'im_c:sw-resize',
+	'im_c:text',
+	'im_c:w-resize',
+	'im_c:wait'
+);
+
+var IM_dd_i = IM_dd_cursors.length; while(IM_dd_i--)
+	eval('var IM_CURSOR_' + (IM_dd_cursors[IM_dd_i].substring(5).toUpperCase().replace('-', '_')) + ' = "' + IM_dd_cursors[IM_dd_i] + '";');
+var IM_dd_u = "undefined";
+function IM_WZDD()
+{
+	this.elements = new Array(0);
+	this.obj = null;
+	this.n = navigator.userAgent.toLowerCase();
+	this.db = (document.compatMode && document.compatMode.toLowerCase() != "backcompat")?
+		document.documentElement
+		: (document.body || null);
+	this.op = !!(window.opera && document.getElementById);
+	if(this.op) document.onmousedown = new Function('e',
+		'if(((e = e || window.event).target || e.srcElement).tagName == "IMAGE") return false;');
+	this.ie = !!(this.n.indexOf("msie") >= 0 && document.all && this.db && !this.op);
+	this.iemac = !!(this.ie && this.n.indexOf("mac") >= 0);
+	this.ie4 = !!(this.ie && !document.getElementById);
+	this.n4 = !!(document.layers && typeof document.classes != IM_dd_u);
+	this.n6 = !!(typeof window.getComputedStyle != IM_dd_u && typeof document.createRange != IM_dd_u);
+	this.w3c = !!(!this.op && !this.ie && !this.n6 && document.getElementById);
+	this.ce = !!(document.captureEvents && document.releaseEvents);
+	this.px = this.n4? '' : 'px';
+	this.tiv = this.w3c? 40 : 10;
+}
+var IM_dd = new IM_WZDD();
+
+IM_dd.Int = function(d_x, d_y)
+{
+	return isNaN(d_y = parseInt(d_x))? 0 : d_y;
+};
+IM_dd.getWndW = function()
+{
+	return IM_dd.Int(
+		(IM_dd.db && !IM_dd.op && !IM_dd.w3c && IM_dd.db.clientWidth)? IM_dd.db.clientWidth
+		: (window.innerWidth || 0)
+	);
+};
+IM_dd.getWndH = function()
+{
+	return IM_dd.Int(
+		(IM_dd.db && !IM_dd.op && !IM_dd.w3c && IM_dd.db.clientHeight)? IM_dd.db.clientHeight
+		: (window.innerHeight || 0)
+	);
+};
+IM_dd.getScrollX = function()
+{
+	return IM_dd.Int(window.pageXOffset || (IM_dd.db? IM_dd.db.scrollLeft : 0));
+};
+IM_dd.getScrollY = function()
+{
+	return IM_dd.Int(window.pageYOffset || (IM_dd.db? IM_dd.db.scrollTop : 0));
+};
+IM_dd.getPageXY = function(d_o)
+{
+	if(IM_dd.n4 && d_o)
+	{
+		IM_dd.x = d_o.pageX || 0;
+		IM_dd.y = d_o.pageY || 0;
+	}
+	else
+	{
+		IM_dd.x = IM_dd.y = 0; //global helper vars
+		while(d_o)
+		{
+			IM_dd.x += IM_dd.Int(d_o.offsetLeft);
+			IM_dd.y += IM_dd.Int(d_o.offsetTop);
+			d_o = d_o.offsetParent || null;
+		}
+	}
+};
+IM_dd.getCssXY = function(d_o)
+{
+	if(d_o.div)
+	{
+		if(IM_dd.n4)
+		{
+			d_o.cssx = d_o.div.x;
+			d_o.cssy = d_o.div.y;
+		}
+		else if(IM_dd.ie4)
+		{
+			d_o.cssx = d_o.css.pixelLeft;
+			d_o.cssy = d_o.css.pixelTop;
+		}
+		else
+		{
+			d_o.css.left = d_o.css.top = 0 + IM_dd.px;
+			IM_dd.getPageXY(d_o.div);
+			d_o.cssx = d_o.x - IM_dd.x;
+			d_o.cssy = d_o.y - IM_dd.y;
+			d_o.css.left = d_o.cssx + IM_dd.px;
+			d_o.css.top = d_o.cssy + IM_dd.px;
+		}
+	}
+	else
+	{
+		d_o.cssx = 0;
+		d_o.cssy = 0;
+	}
+};
+IM_dd.getImgW = function(d_o)
+{
+	return d_o? IM_dd.Int(d_o.width) : 0;
+};
+IM_dd.getImgH = function(d_o)
+{
+	return d_o? IM_dd.Int(d_o.height) : 0;
+};
+IM_dd.getDivW = function(d_o)
+{
+	return IM_dd.Int(
+		IM_dd.n4? (d_o.div? d_o.div.clip.width : 0)
+		: d_o.div? (d_o.div.offsetWidth || d_o.css.pixelWidth || d_o.css.width || 0)
+		: 0
+	);
+};
+IM_dd.getDivH = function(d_o)
+{
+	return IM_dd.Int(
+		IM_dd.n4? (d_o.div? d_o.div.clip.height : 0)
+		: d_o.div? (d_o.div.offsetHeight || d_o.css.pixelHeight || d_o.css.height || 0)
+		: 0
+	);
+};
+IM_dd.getWH = function(d_o)
+{
+	d_o.w = IM_dd.getDivW(d_o);
+	d_o.h = IM_dd.getDivH(d_o);
+	if(d_o.css)
+	{
+		d_o.css.width = d_o.w + IM_dd.px;
+		d_o.css.height = d_o.h + IM_dd.px;
+		d_o.dw = IM_dd.getDivW(d_o)-d_o.w;
+		d_o.dh = IM_dd.getDivH(d_o)-d_o.h;
+      /*
+       * by Rodrigo Souza
+       * acrescentado Math.abs para corrigir retorno
+       * negativo ou ainda NaN
+       */
+		d_o.css.width = Math.abs(d_o.w-d_o.dw) + IM_dd.px;
+		d_o.css.height = Math.abs(d_o.h-d_o.dh) + IM_dd.px;
+	}
+	else d_o.dw = d_o.dh = 0;
+};
+IM_dd.getCssProp = function(d_o, d_pn6, d_pstyle, d_pn4)
+{
+	if(d_o && IM_dd.n6) return ''+window.getComputedStyle(d_o, null).getPropertyValue(d_pn6);
+	if(d_o && d_o.currentStyle) return ''+eval('d_o.currentStyle.'+d_pstyle);
+	if(d_o && d_o.style) return ''+eval('d_o.style.'+d_pstyle);
+	if(d_o && IM_dd.n4) return ''+eval('d_o.'+d_pn4);
+	return '';
+};
+IM_dd.getDiv = function(d_x, d_d)
+{
+	d_d = d_d || document;
+	if(IM_dd.n4)
+	{
+		if(d_d.layers[d_x]) return d_d.layers[d_x];
+		for(var d_i = d_d.layers.length; d_i--;)
+		{
+			var d_y = IM_dd.getDiv(d_x, d_d.layers[d_i].document);
+			if(d_y) return d_y;
+		}
+	}
+	if(IM_dd.ie) return d_d.all[d_x] || null;
+	if(d_d.getElementById) return d_d.getElementById(d_x) || null;
+	return null;
+};
+IM_dd.getImg = function(d_o, d_nm, d_xy, d_w)
+{
+	d_w = d_w || window;
+	var d_img;
+	if(document.images && (d_img = d_w.document.images[d_nm]))
+	{
+		if(d_xy)
+		{
+			if(IM_dd.n4)
+			{
+				IM_dd.getPageXY(d_w);
+				d_o.defx = d_img.x + IM_dd.x;
+				d_o.defy = d_img.y + IM_dd.y;
+			}
+			else
+			{
+				IM_dd.getPageXY(d_img);
+				d_o.defx = IM_dd.x;
+				d_o.defy = IM_dd.y;
+			}
+		}
+		return d_img;
+	}
+	if(IM_dd.n4) for(var d_i = d_w.document.layers.length; d_i--;)
+	{
+		var d_y = IM_dd.getImg(d_o, d_nm, d_xy, d_w.document.layers[d_i]);
+		if(d_y) return d_y;
+	}
+	return null;
+};
+IM_dd.getParent = function(d_o, d_p)
+{
+	if(IM_dd.n4)
+	{
+		for(d_p, d_i = IM_dd.elements.length; d_i--;)
+		{
+			if(!((d_p = IM_dd.elements[d_i]).is_image) && d_p.div && (d_p.div.document.layers[d_o.name] || d_o.oimg && d_p.div.document.images[d_o.oimg.name]))
+				d_p.addChild(d_o, d_p.detach, 1);
+		}
+	}
+	else
+	{
+		d_p = d_o.is_image? IM_dd.getImg(d_o, d_o.oimg.name) : (d_o.div || null);
+		while(d_p && !!(d_p = d_p.offsetParent || d_p.parentNode || null))
+		{
+			if(d_p.ddObj)
+			{
+				d_p.ddObj.addChild(d_o, d_p.ddObj.detach, 1);
+				break;
+			}
+		}
+	}
+};
+IM_dd.getCmd = function(d_o, d_cmd, d_cmdStr)
+{
+	var d_i = d_o.id.indexOf(d_cmd), d_j,
+	d_y = (d_i >= 0)*1;
+	if(d_y)
+	{
+		d_j = d_i+d_cmd.length;
+		if(d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j);
+		d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);
+	}
+	return d_y;
+};
+IM_dd.getCmdVal = function(d_o, d_cmd, d_cmdStr, int0)
+{
+	var d_i = d_o.id.indexOf(d_cmd), d_j,
+	d_y = (d_o.id.indexOf(d_cmd) >= 0)? IM_dd.Int(d_o.id.substring(d_o.id.indexOf(d_cmd)+d_cmd.length)) : int0? -1 : 0;
+	if(!int0 && d_y || int0 && d_y >= 0)
+	{
+		d_j = d_i+d_cmd.length+(""+d_y).length;
+		if(d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j);
+		d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);
+	}
+	return d_y;
+};
+IM_dd.addElt = function(d_o, d_p)
+{
+	IM_dd.elements[d_o.name] = IM_dd.elements[d_o.index = IM_dd.elements.length] = d_o;
+	if(d_p) d_p.copies[d_o.name] = d_p.copies[d_p.copies.length] = d_o;
+};
+IM_dd.mkWzDom = function()
+{
+	var d_o, d_i = IM_dd.elements.length; while(d_i--) IM_dd.getParent(IM_dd.elements[d_i]);
+	d_i = IM_dd.elements.length; while(d_i--)
+	{
+		d_o = IM_dd.elements[d_i];
+		if(d_o.children && !d_o.parent)
+		{
+			var d_j = d_o.children.length; while(d_j--)
+				d_o.children[d_j].setZ(d_o.z+d_o.children[d_j].z, 1);
+		}
+	}
+};
+IM_dd.addProps = function(d_o)
+{
+	var d_i, d_c;
+	if(d_o.is_image)
+	{
+		d_o.div = IM_dd.getDiv(d_o.id);
+		d_o.css = (d_o.div && typeof d_o.div.style != IM_dd_u)? d_o.div.style : null;
+		d_o.nimg = (IM_dd.n4 && d_o.div)? d_o.div.document.images[0] : (document.images[d_o.id+"NI1m6G"] || null);
+		if(!d_o.noalt && !IM_dd.noalt && d_o.nimg && d_o.oimg)
+		{
+			d_o.nimg.alt = d_o.oimg.alt || '';
+			if(d_o.oimg.title) d_o.nimg.title = d_o.oimg.title;
+		}
+		d_o.bgColor = '';
+	}
+	else
+	{
+		d_o.bgColor = IM_dd.getCssProp(d_o.div, 'background-color','backgroundColor','bgColor').toLowerCase();
+		if(IM_dd.n6 && d_o.div)
+		{
+			if((d_c = d_o.bgColor).indexOf('rgb') >= 0)
+			{
+				d_c = d_c.substring(4, d_c.length-1).split(',');
+				d_o.bgColor = '#';
+				for(d_i = 0; d_i < d_c.length; d_i++) d_o.bgColor += parseInt(d_c[d_i]).toString(0x10);
+			}
+			else d_o.bgColor = d_c;
+		}
+	}
+	if(IM_dd.scalable) d_o.scalable = d_o.resizable^1;
+	else if(IM_dd.resizable) d_o.resizable = d_o.scalable^1;
+	d_o.setZ(d_o.defz);
+	d_o.cursor = d_o.cursor || IM_dd.cursor || 'auto';
+	d_o._setCrs(d_o.nodrag? 'auto' : d_o.cursor);
+	d_o.diaphan = d_o.diaphan || IM_dd.diaphan || 0;
+	d_o.opacity = 1.0;
+	d_o.visible = true;
+};
+IM_dd.initz = function()
+{
+	if(!(IM_dd && (IM_dd.n4 || IM_dd.n6 || IM_dd.ie || IM_dd.op || IM_dd.w3c))) return;
+	else if(IM_dd.n6 || IM_dd.ie || IM_dd.op || IM_dd.w3c) IM_dd.recalc(1);
+	var d_drag = (document.onmousemove == IM_DRAG),
+	d_resize = (document.onmousemove == IM_RESIZE);
+	if(IM_dd.loadFunc) IM_dd.loadFunc();
+	if(d_drag) IM_dd.setMovHdl(IM_DRAG);
+	else if(d_resize) IM_dd.setMovHdl(IM_RESIZE);
+	if(d_drag || d_resize) IM_dd.setUpHdl(IM_DROP);
+	IM_dd.setDwnHdl(IM_PICK);
+};
+IM_dd.finlz = function()
+{
+	if(IM_dd.ie && IM_dd.elements)
+	{
+		var d_i = IM_dd.elements.length; while(d_i--)
+			IM_dd.elements[d_i].del();
+	}
+	if(IM_dd.uloadFunc) IM_dd.uloadFunc();
+};
+IM_dd.setCe = function(d_e, d_fnc)
+{
+	d_fnc? document.captureEvents(d_e) : document.releaseEvents(d_e);
+};
+IM_dd.setDwnHdl = function(d_x)
+{
+	if(document.onmousedown != d_x)
+	{
+		//IM_dd.downFunc = document.onmousedown;
+		document.onmousedown = d_x;
+		if(IM_dd.ce) IM_dd.setCe(Event.MOUSEDOWN, d_x);
+	}
+};
+IM_dd.setMovHdl = function(d_x)
+{
+	if(document.onmousemove != d_x)
+	{
+		IM_dd.moveFunc = document.onmousemove;
+		document.onmousemove = d_x;
+		if(IM_dd.ce) IM_dd.setCe(Event.MOUSEMOVE, d_x);
+	}
+};
+IM_dd.setUpHdl = function(d_x)
+{
+	if(document.onmouseup != d_x)
+	{
+		IM_dd.upFunc = document.onmouseup;
+		document.onmouseup = d_x;
+		if(IM_dd.ce) IM_dd.setCe(Event.MOUSEUP, d_x);
+	}
+};
+IM_dd.evt = function(d_e)
+{
+	this.but = (this.e = d_e || window.event).which || this.e.button || 0;
+	this.button = (this.e.type == 'mousedown')? this.but
+		: (IM_dd.e && IM_dd.e.button)? IM_dd.e.button
+		: 0;
+	this.src = this.e.target || this.e.srcElement || null;
+	this.src.tag = ("" + (this.src.tagName || this.src)).toLowerCase();
+	this.x = IM_dd.Int(this.e.pageX || this.e.clientX || 0);
+	this.y = IM_dd.Int(this.e.pageY || this.e.clientY || 0);
+	if(IM_dd.ie)
+	{
+		this.x += IM_dd.getScrollX() - (IM_dd.ie && !IM_dd.iemac)*1;
+		this.y += IM_dd.getScrollY() - (IM_dd.ie && !IM_dd.iemac)*1;
+	}
+	this.modifKey = this.e.modifiers? this.e.modifiers&Event.SHIFT_MASK : (this.e.shiftKey || false);
+};
+IM_dd.getEventTarget = function(d_e, d_s, d_n)
+{
+	d_e = d_e || window.event;
+	if(d_e && (d_s = d_e.target || d_e.srcElement || null) != null)
+	{
+		if(null != (d_n = d_s.id || d_s.name || null))
+		{
+			if(d_n.indexOf("dIi15vNI1m6G") == d_n.length-12)
+				return IM_dd.elements[d_n.substring(0, d_n.length-12)] || null;
+			if(d_n.indexOf("dIi15v") == d_n.length-6)
+				return IM_dd.elements[d_n.substring(0, d_n.length-6)] || null;
+			return IM_dd.elements[d_n] || null;
+		}
+	}
+	return null;
+};
+IM_dd.recalc = function(d_x)
+{
+	var d_o, d_i = IM_dd.elements.length; while(d_i--)
+	{
+		if(!(d_o = IM_dd.elements[d_i]).is_image && d_o.div)
+		{
+			IM_dd.getWH(d_o);
+			if(d_o.div.pos_rel)
+			{
+				IM_dd.getPageXY(d_o.div);
+				var d_dx = IM_dd.x - d_o.x, d_dy = IM_dd.y - d_o.y;
+				d_o.defx += d_dx;
+				d_o.x += d_dx;
+				d_o.defy += d_dy;
+				d_o.y += d_dy;
+				var d_p, d_j = d_o.children.length; while(d_j--)
+				{
+					if(!(d_p = d_o.children[d_j]).detached && (d_o != d_p.defparent || !(d_p.is_image && IM_dd.getImg(d_p, d_p.oimg.name, 1))))
+					{
+						d_p.defx += d_dx;
+						d_p.defy += d_dy;
+						d_p.moveBy(d_dx, d_dy);
+					}
+				}
+			}
+		}
+		else if(d_o.is_image && !IM_dd.n4)
+		{
+			if(IM_dd.n6 && d_x && !d_o.defw) d_o.resizeTo(d_o.defw = IM_dd.getImgW(d_o.oimg), d_o.defh = IM_dd.getImgH(d_o.oimg));
+			var d_defx = d_o.defx, d_defy = d_o.defy;
+			if(!(d_o.parent && d_o.parent != d_o.defparent) && (d_x || !d_o.detached || d_o.horizontal || d_o.vertical) && IM_dd.getImg(d_o, d_o.oimg.name, 1))
+				d_o.moveBy(d_o.defx-d_defx, d_o.defy-d_defy);
+		}
+	}
+};
+function IM_WINSZ(d_x)
+{
+	if(d_x)
+	{
+		if(IM_dd.n4)
+		{
+			IM_dd.iW = innerWidth;
+			IM_dd.iH = innerHeight;
+		}
+		window.onresize = new Function('IM_WINSZ();');
+	}
+	else if(IM_dd.n4 && (innerWidth != IM_dd.iW || innerHeight != IM_dd.iH)) location.reload();
+	else if(!IM_dd.n4) setTimeout('IM_dd.recalc()', 0xa);
+}
+IM_WINSZ(1);
+
+function IM_DDObj(d_o, d_i)
+{
+	this.id = d_o;
+	this.cmd = '';
+	this.cpy_n = IM_dd.getCmdVal(this, IM_COPY);
+	this.maxoffb = IM_dd.getCmdVal(this, IM_MAXOFFBOTTOM, 0, 1);
+	this.maxoffl = IM_dd.getCmdVal(this, IM_MAXOFFLEFT, 0, 1);
+	this.maxoffr = IM_dd.getCmdVal(this, IM_MAXOFFRIGHT, 0, 1);
+	this.maxofft = IM_dd.getCmdVal(this, IM_MAXOFFTOP, 0, 1);
+	var d_j = IM_dd_cursors.length; while(d_j--)
+		if(IM_dd.getCmd(this, IM_dd_cursors[d_j], 1)) this.cursor = IM_dd_cursors[d_j].substring(2);
+	this.clone = IM_dd.getCmd(this, IM_CLONE, 1);
+	this.detach = IM_dd.getCmd(this, IM_DETACH_CHILDREN);
+	this.scalable = IM_dd.getCmd(this, IM_SCALABLE, 1);
+	this.horizontal = IM_dd.getCmd(this, IM_HORIZONTAL);
+	this.noalt = IM_dd.getCmd(this, IM_NO_ALT, 1);
+	this.nodrag = IM_dd.getCmd(this, IM_NO_DRAG);
+	this.scroll = IM_dd.getCmd(this, IM_SCROLL, 1);
+	this.resizable = IM_dd.getCmd(this, IM_RESIZABLE, 1);
+	this.re_z = IM_dd.getCmd(this, IM_RESET_Z, 1);
+	this.diaphan = IM_dd.getCmd(this, IM_TRANSPARENT, 1);
+	this.vertical = IM_dd.getCmd(this, IM_VERTICAL);
+	this.maxw = IM_dd.getCmdVal(this, IM_MAXWIDTH, 1, 1);
+	this.minw = Math.abs(IM_dd.getCmdVal(this, IM_MINWIDTH, 1, 1));
+	this.maxh = IM_dd.getCmdVal(this, IM_MAXHEIGHT, 1, 1);
+	this.minh = Math.abs(IM_dd.getCmdVal(this, IM_MINHEIGHT, 1, 1));
+	this.pickFunc = this.dragFunc = this.resizeFunc = this.dropFunc = null;
+
+	this.name = this.id + (d_i || '');
+	this.oimg = IM_dd.getImg(this, this.id, 1);
+	this.is_image = !!this.oimg;
+	this.copies = new Array();
+	this.children = new Array();
+	this.parent = this.original = null;
+	if(this.oimg)
+	{
+		this.id = this.name + "dIi15v";
+		this.w = IM_dd.getImgW(this.oimg);
+		this.h = IM_dd.getImgH(this.oimg);
+		this.dw = this.dh = 0;
+		this.defz = IM_dd.Int(IM_dd.getCssProp(this.oimg, 'z-index','zIndex','zIndex')) || 1;
+		this.defsrc = this.src = this.oimg.src;
+		this.htm = '<img name="' + this.id + 'NI1m6G"'+
+			' src="' + this.oimg.src + '" '+
+			'width="' + this.w + '" height="' + this.h + '">';
+		this.t_htm = '<div id="' + this.id +
+			'" style="position:absolute;'+
+			'left:' + (this.cssx = this.x = this.defx) + 'px;'+
+			'top:' + (this.cssy = this.y = this.defy) + 'px;'+
+			'width:' + this.w + 'px;'+
+			'height:' + this.h + 'px;">'+
+			this.htm + '</div>';
+	}
+	else
+	{
+		if(!!(this.div = IM_dd.getDiv(this.id)) && typeof this.div.style != IM_dd_u) this.css = this.div.style;
+		IM_dd.getWH(this);
+		if(this.div)
+		{
+			this.div.ddObj = this;
+			this.div.pos_rel = ("" + (this.div.parentNode? this.div.parentNode.tagName : this.div.parentElement? this.div.parentElement.tagName : '').toLowerCase().indexOf('body') < 0);
+		}
+		IM_dd.getPageXY(this.div);
+		this.defx = this.x = IM_dd.x;
+		this.defy = this.y = IM_dd.y;
+		IM_dd.getCssXY(this);
+		this.defz = IM_dd.Int(IM_dd.getCssProp(this.div, 'z-index','zIndex','zIndex'));
+	}
+	this.defw = this.w || 0;
+	this.defh = this.h || 0;
+}
+IM_DDObj.prototype.setPickFunc = function(d_x)
+{
+	this.pickFunc = d_x;
+};
+IM_DDObj.prototype.setDragFunc = function(d_x)
+{
+	this.dragFunc = d_x;
+};
+IM_DDObj.prototype.setResizeFunc = function(d_x)
+{
+	this.resizeFunc = d_x;
+};
+IM_DDObj.prototype.setDropFunc = function(d_x)
+{
+	this.dropFunc = d_x;
+};
+IM_DDObj.prototype.moveBy = function(d_x, d_y, d_kds, d_o)
+{
+	if(!this.div) return;
+	this.x += (d_x = IM_dd.Int(d_x));
+	this.y += (d_y = IM_dd.Int(d_y));
+	if(!d_kds || this.is_image || this.parent != this.defparent)
+	{
+		(d_o = this.css || this.div).left = (this.cssx += d_x) + IM_dd.px;
+		d_o.top = (this.cssy += d_y) + IM_dd.px;
+	}
+	var d_i = this.children.length; while(d_i--)
+	{
+		if(!(d_o = this.children[d_i]).detached) d_o.moveBy(d_x, d_y, 1);
+		d_o.defx += d_x;
+		d_o.defy += d_y;
+	}
+};
+IM_DDObj.prototype.moveTo = function(d_x, d_y)
+{
+	this.moveBy(IM_dd.Int(d_x)-this.x, IM_dd.Int(d_y)-this.y);
+};
+IM_DDObj.prototype.hide = function(d_m, d_o, d_p)
+{
+	if(this.div && this.visible)
+	{
+		d_p = this.css || this.div;
+		if(d_m && !IM_dd.n4)
+		{
+			this.display = IM_dd.getCssProp(this.div, "display", "display", "display");
+			if(this.oimg)
+			{
+				this.oimg.display = IM_dd.getCssProp(this.oimg, "display", "display", "display");
+				this.oimg.style.display = "none";
+			}
+			d_p.display = "none";
+			IM_dd.recalc();
+		}
+		else d_p.visibility = "hidden";
+	}
+	this.visible = false;
+	var d_i = this.children.length; while(d_i--)
+		if(!(d_o = this.children[d_i]).detached) d_o.hide(d_m);
+};
+IM_DDObj.prototype.show = function(d_o, d_p)
+{
+	if(this.div)
+	{
+		d_p = this.css || this.div;
+		if(d_p.display && d_p.display == "none")
+		{
+			d_p.display = this.display || "block";
+			if(this.oimg) this.oimg.style.display = this.oimg.display || "inline";
+			IM_dd.recalc();
+		}
+		else d_p.visibility = "visible";
+	}
+	this.visible = true;
+	var d_i = this.children.length; while(d_i--)
+		if(!(d_o = this.children[d_i]).detached) d_o.show();
+};
+IM_DDObj.prototype.resizeTo = function(d_w, d_h, d_o)
+{
+	if(!this.div) return;
+	d_w = (this.w = IM_dd.Int(d_w))-this.dw;
+	d_h = (this.h = IM_dd.Int(d_h))-this.dh;
+	if(IM_dd.n4)
+	{
+		this.div.resizeTo(d_w, d_h);
+		if(this.is_image)
+		{
+			this.write('<img src="' + this.src + '" width="' + d_w + '" height="' + d_h + '">');
+			(this.nimg = this.div.document.images[0]).src = this.src;
+		}
+	}
+	else if(typeof this.css.pixelWidth != IM_dd_u)
+	{
+		this.css.pixelWidth = d_w;
+		this.css.pixelHeight = d_h;
+		if(this.is_image)
+		{
+			(d_o = this.nimg.style).pixelWidth = d_w;
+			d_o.pixelHeight = d_h;
+		}
+	}
+	else
+	{
+      /*
+       * by Rodrigo Souza
+       * acrescentado Math.abs para corrigir retorno
+       * negativo ou ainda NaN
+       */
+		this.css.width = Math.abs(d_w) + IM_dd.px;
+		this.css.height = Math.abs(d_h) + IM_dd.px;
+		if(this.is_image)
+		{
+			(d_o = this.nimg).width = d_w;
+			d_o.height = d_h;
+			if(!d_o.complete) d_o.src = this.src;
+		}
+	}
+};
+IM_DDObj.prototype.resizeBy = function(d_dw, d_dh)
+{
+	this.resizeTo(this.w+IM_dd.Int(d_dw), this.h+IM_dd.Int(d_dh));
+};
+IM_DDObj.prototype.swapImage = function(d_x, d_cp)
+{
+	if(!this.nimg) return;
+	this.nimg.src = d_x;
+	this.src = this.nimg.src;
+	if(d_cp)
+	{
+		var d_i = this.copies.length; while(d_i--)
+			this.copies[d_i].src = this.copies[d_i].nimg.src = this.nimg.src;
+	}
+};
+IM_DDObj.prototype.setBgColor = function(d_x)
+{
+	if(IM_dd.n4 && this.div) this.div.bgColor = d_x;
+	else if(this.css) this.css.background = d_x;
+	this.bgColor = d_x;
+};
+IM_DDObj.prototype.write = function(d_x, d_o)
+{
+	this.text = d_x;
+	if(!this.div) return;
+	if(IM_dd.n4)
+	{
+		(d_o = this.div.document).open();
+		d_o.write(d_x);
+		d_o.close();
+		IM_dd.getWH(this);
+	}
+	else
+	{
+		this.css.height = 'auto';
+		this.div.innerHTML = d_x;
+		if(!IM_dd.ie4) IM_dd.recalc();
+		if(IM_dd.ie4 || IM_dd.n6) setTimeout('IM_dd.recalc();', 0); // n6.0: recalc twice
+	}
+};
+IM_DDObj.prototype.copy = function(d_n, d_p, d_b)
+{
+	if(!this.oimg) return;
+	d_b = (IM_dd.ie && document.all.tags('body'))? document.all.tags('body')[0] : document.getElementsByTagName? (document.getElementsByTagName('body')[0] || IM_dd.db) : IM_dd.db;
+	d_n = d_n || 1;
+	while(d_n--)
+	{
+		var d_l = this.copies.length,
+		d_o = new IM_DDObj(this.name+this.cmd, d_l+1);
+		if(IM_dd.n4)
+		{
+			d_o.id = (d_p = new Layer(d_o.w)).name;
+			d_p.clip.height = d_o.h;
+			d_p.visibility = 'show';
+			(d_p = d_p.document).open();
+			d_p.write(d_o.htm);
+			d_p.close();
+		}
+		else if(d_b && d_b.insertAdjacentHTML) d_b.insertAdjacentHTML("AfterBegin", d_o.t_htm);
+		else if(document.createElement && d_b && d_b.appendChild)
+		{
+			d_b.appendChild(d_p = document.createElement("dIi15v"));
+			d_p.innerHTML = d_o.htm;
+			d_p.id = d_o.id;
+			d_p.style.position = 'absolute';
+			d_p.style.width = d_o.w + 'px';
+			d_p.style.height = d_o.h + 'px';
+		}
+		else if(d_b && d_b.innerHTML) d_b.innerHTML += d_o.t_htm;
+		d_o.defz = this.defz+1+d_l;
+		IM_dd.addProps(d_o);
+		d_o.original = this;
+		IM_dd.addElt(d_o, this);
+		if(this.parent)
+		{
+			this.parent.addChild(d_o, this.detached);
+			d_o.defparent = this.defparent;
+		}
+		d_o.moveTo(d_o.defx = this.defx, d_o.defy = this.defy);
+		if(IM_dd.n4) d_o.defsrc = d_o.src = this.defsrc;
+		d_o.swapImage(this.src);
+	}
+};
+IM_DDObj.prototype.addChild = function(d_kd, detach, defp)
+{
+	if(typeof d_kd != "object") d_kd = IM_dd.elements[d_kd];
+	if(d_kd.parent && d_kd.parent == this || d_kd == this || !d_kd.is_image && d_kd.defparent && !defp) return;
+
+	this.children[this.children.length] = this.children[d_kd.name] = d_kd;
+	d_kd.detached = detach || 0;
+	if(defp) d_kd.defparent = this;
+	else if(this == d_kd.defparent && d_kd.is_image) IM_dd.getImg(this, d_kd.oimg.name, 1);
+	if(!d_kd.defparent || this != d_kd.defparent)
+	{
+		d_kd.defx = d_kd.x;
+		d_kd.defy = d_kd.y;
+	}
+	if(!detach)
+	{
+		d_kd.defz = d_kd.defz+this.defz-(d_kd.parent? d_kd.parent.defz : 0)+(!d_kd.is_image*1);
+		d_kd.setZ(d_kd.z+this.z-(d_kd.parent? d_kd.parent.z : 0)+(!d_kd.is_image*1), 1);
+	}
+	if(d_kd.parent) d_kd.parent._removeChild(d_kd, 1);
+	d_kd.parent = this;
+};
+IM_DDObj.prototype._removeChild = function(d_kd, d_newp)
+{
+	if(typeof d_kd != "object") d_kd = this.children[d_kd];
+	var d_oc = this.children, d_nc = new Array();
+	for(var d_i = 0; d_i < d_oc.length; d_i++)
+		if(d_oc[d_i] != d_kd) d_nc[d_nc.length] = d_oc[d_i];
+	this.children = d_nc;
+	d_kd.parent = null;
+	if(!d_newp)
+	{
+		d_kd.detached = d_kd.defp = 0;
+		if(d_kd.is_image) IM_dd.getImg(d_kd, d_kd.oimg.name, 1);
+	}
+};
+IM_DDObj.prototype.attachChild = function(d_kd)
+{
+	(d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 0;
+	d_kd.setZ(d_kd.defz + this.z-this.defz, 1);
+};
+IM_DDObj.prototype.detachChild = function(d_kd)
+{
+	(d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 1;
+};
+IM_DDObj.prototype.setZ = function(d_x, d_kds, d_o)
+{
+	if(d_kds)
+	{
+		var d_dz = d_x-this.z,
+		d_i = this.children.length; while(d_i--)
+			if(!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.z+d_dz, 1);
+	}
+	IM_dd.z = Math.max(IM_dd.z, this.z = this.div? ((this.css || this.div).zIndex = d_x) : 0);
+};
+IM_DDObj.prototype.maximizeZ = function()
+{
+	this.setZ(IM_dd.z+1, 1);
+};
+IM_DDObj.prototype._resetZ = function(d_o)
+{
+	if(this.re_z || IM_dd.re_z)
+	{
+		this.setZ(this.defz);
+		var d_i = this.children.length; while(d_i--)
+			if(!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.defz);
+	}
+};
+IM_DDObj.prototype.setOpacity = function(d_x)
+{
+	this.opacity = d_x;
+	this._setOpaRel(1.0, 1);
+};
+IM_DDObj.prototype._setOpaRel = function(d_x, d_kd, d_y, d_o)
+{
+	if(this.css && (this.diaphan || d_kd))
+	{
+		d_y = this.opacity*d_x;
+		if(typeof this.css.MozOpacity != IM_dd_u) this.css.MozOpacity = d_y;
+		else if(typeof this.css.filter != IM_dd_u)
+			this.css.filter = "Alpha(opacity="+parseInt(100*d_y)+")";
+		else this.css.opacity = d_y;
+		var d_i = this.children.length; while(d_i--)
+			if(!(d_o = this.children[d_i]).detached) d_o._setOpaRel(d_x, 1);
+	}
+};
+IM_DDObj.prototype.setCursor = function(d_x)
+{
+	this._setCrs(this.cursor = (d_x.indexOf('c:')+1)? d_x.substring(2) : d_x);
+};
+IM_DDObj.prototype._setCrs = function(d_x)
+{
+	if(this.css) this.css.cursor = ((!IM_dd.ie || IM_dd.iemac) && d_x == 'hand')? 'pointer' : d_x;
+};
+IM_DDObj.prototype.setDraggable = function(d_x)
+{
+	this.nodrag = !d_x*1;
+	this._setCrs(d_x? this.cursor : 'auto');
+};
+IM_DDObj.prototype.setResizable = function(d_x)
+{
+	this.resizable = d_x*1;
+	if(d_x) this.scalable = 0;
+};
+IM_DDObj.prototype.setScalable = function(d_x)
+{
+	this.scalable = d_x*1;
+	if(d_x) this.resizable = 0;
+};
+IM_DDObj.prototype.getEltBelow = function(d_ret, d_x, d_y)
+{
+	var d_o, d_cmp = -1, d_i = IM_dd.elements.length; while(d_i--)
+	{
+		d_o = IM_dd.elements[d_i];
+		d_x = d_o.x-this.w/2;
+		d_y = d_o.y-this.h/2;
+		if(d_o.visible && d_o.z < this.z && this.x >= d_x && this.x <= d_x+d_o.w && this.y >= d_y && this.y <= d_y+d_o.h)
+		{
+			if(d_o.z > d_cmp)
+			{
+				d_cmp = d_o.z;
+				d_ret = d_o;
+			}
+		}
+	}
+	return d_ret;
+};
+IM_DDObj.prototype.del = function(d_os, d_o)
+{
+	var d_i;
+	if(this.parent && this.parent._removeChild) this.parent._removeChild(this);
+	if(this.original)
+	{
+		this.hide();
+		if(this.original.copies)
+		{
+			d_os = new Array();
+			for(d_i = 0; d_i < this.original.copies.length; d_i++)
+				if((d_o = this.original.copies[d_i]) != this) d_os[d_o.name] = d_os[d_os.length] = d_o;
+			this.original.copies = d_os;
+		}
+	}
+	else if(this.is_image)
+	{
+		this.hide();
+		if(this.oimg)
+		{
+		  if(IM_dd.n4) this.oimg.src = this.defsrc;
+		  else this.oimg.style.visibility = 'visible';
+		}
+	}
+	else if(this.moveTo)
+	{
+		if(this.css) this.css.cursor = 'default';
+		this.moveTo(this.defx, this.defy);
+		this.resizeTo(this.defw, this.defh);
+	}
+	d_os = new Array();
+	for(d_i = 0; d_i < IM_dd.elements.length; d_i++)
+	{
+		if((d_o = IM_dd.elements[d_i]) != this) d_os[d_o.name] = d_os[d_o.index = d_os.length] = d_o;
+		else d_o._free();
+	}
+	IM_dd.elements = d_os;
+	if(!IM_dd.n4) IM_dd.recalc();
+};
+IM_DDObj.prototype._free = function()
+{
+	for(var d_i in this)
+		this[d_i] = null;
+	IM_dd.elements[this.name] = null;
+};
+IM_dd.n4RectVis = function(vis)
+{
+	for(var d_i = 4; d_i--;)
+	{
+		IM_dd.rectI[d_i].visibility = IM_dd.rectA[d_i].visibility = vis? 'show' : 'hide';
+		if(vis) IM_dd.rectI[d_i].zIndex = IM_dd.rectA[d_i].zIndex = IM_dd.z+2;
+	}
+};
+IM_dd.n4RectPos = function(d_o, d_x, d_y, d_w, d_h)
+{
+	d_o.x = d_x;
+	d_o.y = d_y;
+	d_o.clip.width = d_w;
+	d_o.clip.height = d_h;
+};
+// NN4: Draw img sizing rect
+IM_dd.n4Rect = function(d_w, d_h)
+{
+	var d_i;
+	if(!IM_dd.rectI)
+	{
+		IM_dd.rectI = new Array();
+		IM_dd.rectA = new Array();
+	}
+	if(!IM_dd.rectI[0])
+	{
+		for(d_i = 4; d_i--;)
+		{
+			(IM_dd.rectI[d_i] = new Layer(1)).bgColor = '#000000';
+			(IM_dd.rectA[d_i] = new Layer(1)).bgColor = '#ffffff';
+		}
+	}
+	if(!IM_dd.rectI[0].visibility || IM_dd.rectI[0].visibility == 'hide') IM_dd.n4RectVis(1);
+	IM_dd.obj.w = d_w;
+	IM_dd.obj.h = d_h;
+	for(d_i = 4; d_i--;)
+	{
+		IM_dd.n4RectPos(IM_dd.rectI[d_i], IM_dd.obj.x + (!(d_i-1)? (IM_dd.obj.w-1) : 0), IM_dd.obj.y + (!(d_i-2)? (IM_dd.obj.h-1) : 0), d_i&1 || IM_dd.obj.w, !(d_i&1) || IM_dd.obj.h);
+		IM_dd.n4RectPos(IM_dd.rectA[d_i], !(d_i-1)? IM_dd.rectI[1].x+1 : (IM_dd.obj.x-1), !(d_i-2)? IM_dd.rectI[2].y+1 : (IM_dd.obj.y-1), d_i&1 || IM_dd.obj.w+2, !(d_i&1) || IM_dd.obj.h+2);
+	}
+};
+IM_dd.reszTo = function(d_w, d_h)
+{
+	if(IM_dd.n4 && IM_dd.obj.is_image) IM_dd.n4Rect(d_w, d_h);
+	else IM_dd.obj.resizeTo(d_w, d_h);
+};
+IM_dd.embedVis = function(d_vis)
+{
+	var d_o = new Array('iframe', 'applet', 'embed', 'object');
+	var d_i = d_o.length; while(d_i--)
+	{
+		var d_p = IM_dd.ie? document.all.tags(d_o[d_i]) : document.getElementsByTagName? document.getElementsByTagName(d_o[d_i]) : null;
+		if(d_p)
+		{
+			var d_j = d_p.length; while(d_j--)
+			{
+				var d_q = d_p[d_j];
+				while(d_q.offsetParent || d_q.parentNode)
+				{
+					if((d_q = d_q.parentNode || d_q.offsetParent || null) == IM_dd.obj.div)
+					{
+						d_p[d_j].style.visibility = d_vis;
+						break;
+					}
+				}
+			}
+		}
+	}
+};
+IM_dd.maxOffX = function(d_x, d_y)
+{
+	return(
+		(IM_dd.obj.maxoffl+1 && (d_y = IM_dd.obj.defx-IM_dd.obj.maxoffl)-d_x > 0
+		|| IM_dd.obj.maxoffr+1 && (d_y = IM_dd.obj.defx+IM_dd.obj.maxoffr)-d_x < 0)? d_y
+		: d_x
+	);
+};
+IM_dd.maxOffY = function(d_x, d_y)
+{
+	return(
+		(IM_dd.obj.maxofft+1 && (d_y = IM_dd.obj.defy-IM_dd.obj.maxofft)-d_x > 0
+		|| IM_dd.obj.maxoffb+1 && (d_y = IM_dd.obj.defy+IM_dd.obj.maxoffb)-d_x < 0)? d_y
+		: d_x
+	);
+};
+IM_dd.inWndW = function(d_x, d_y)
+{
+	var d_wx = IM_dd.getScrollX(),
+	d_ww = IM_dd.getWndW();
+	return(
+		((d_y = d_wx+2)-d_x > 0) || ((d_y = d_wx+d_ww+IM_dd.obj.w-2)-d_x < 0)? d_y
+		: d_x
+	);
+};
+IM_dd.inWndH = function(d_x, d_y)
+{
+	var d_wy = IM_dd.getScrollY(),
+	d_wh = IM_dd.getWndH();
+	return(
+		((d_y = d_wy+2)-d_x > 0) || ((d_y = d_wy+d_wh+IM_dd.obj.h-2)-d_x < 0)? d_y
+		: d_x
+	);
+};
+// These two funcs limit the size of element when mouseresized.
+// Implemented 22.5.2003 by Gregor Ltolf, modified by Walter Zorn
+IM_dd.limW = function(d_w)
+{
+	return(
+		(IM_dd.obj.minw-d_w > 0)? IM_dd.obj.minw
+		: (IM_dd.obj.maxw > 0 && IM_dd.obj.maxw-d_w < 0)? IM_dd.obj.maxw
+		: d_w
+	);
+};
+IM_dd.limH = function(d_h)
+{
+	return(
+		(IM_dd.obj.minh-d_h > 0)? IM_dd.obj.minh
+		: (IM_dd.obj.maxh > 0 && IM_dd.obj.maxh-d_h < 0)? IM_dd.obj.maxh
+		: d_h
+	);
+};
+// Optional autoscroll-page functionality. Courtesy Cedric Savarese.
+// Modified by Walter Zorn.
+function IM_DDScroll()
+{
+	if(!IM_dd.obj || !IM_dd.obj.scroll && !IM_dd.scroll || IM_dd.ie4 || IM_dd.whratio)
+	{
+		IM_dd.scrx = IM_dd.scry = 0;
+		return;
+	}
+	var d_bnd = 0x1c,
+	d_wx = IM_dd.getScrollX(), d_wy = IM_dd.getScrollY();
+	if(IM_dd.msmoved)
+	{
+		var d_ww = IM_dd.getWndW(), d_wh = IM_dd.getWndH(), d_y;
+		IM_dd.scrx = ((d_y = IM_dd.e.x-d_ww-d_wx+d_bnd) > 0)? (d_y>>=2)*d_y
+			: ((d_y = d_wx+d_bnd-IM_dd.e.x) > 0)? -(d_y>>=2)*d_y
+			: 0;
+		IM_dd.scry = ((d_y = IM_dd.e.y-d_wh-d_wy+d_bnd) > 0)? (d_y>>=2)*d_y
+			: ((d_y = d_wy+d_bnd-IM_dd.e.y) > 0)? -(d_y>>=2)*d_y
+			: 0;
+	}
+	if(IM_dd.scrx || IM_dd.scry)
+	{
+		window.scrollTo(
+			d_wx + (IM_dd.scrx = IM_dd.obj.is_resized? IM_dd.limW(IM_dd.obj.w+IM_dd.scrx)-IM_dd.obj.w : IM_dd.obj.vertical? 0 : (IM_dd.maxOffX(IM_dd.obj.x+IM_dd.scrx)-IM_dd.obj.x)),
+			d_wy + (IM_dd.scry = IM_dd.obj.is_resized? IM_dd.limH(IM_dd.obj.h+IM_dd.scry)-IM_dd.obj.h : IM_dd.obj.horizontal? 0 : (IM_dd.maxOffY(IM_dd.obj.y+IM_dd.scry)-IM_dd.obj.y))
+		);
+		IM_dd.obj.is_dragged? IM_dd.obj.moveTo(IM_dd.obj.x+IM_dd.getScrollX()-d_wx, IM_dd.obj.y+IM_dd.getScrollY()-d_wy)
+			: IM_dd.reszTo(IM_dd.obj.w+IM_dd.getScrollX()-d_wx, IM_dd.obj.h+IM_dd.getScrollY()-d_wy);
+	}
+	IM_dd.msmoved = 0;
+	window.setTimeout('IM_DDScroll()', 0x33);
+}
+function IM_PICK(d_ev)
+{
+	IM_dd.e = new IM_dd.evt(d_ev);
+	if(IM_dd.e.x >= IM_dd.getWndW()+IM_dd.getScrollX() || IM_dd.e.y >= IM_dd.getWndH()+IM_dd.getScrollY()) return true; // on scrollbar
+	var d_o, d_t, d_cmp = -1, d_i = IM_dd.elements.length; while(d_i--)
+	{
+		d_o = IM_dd.elements[d_i];
+		if(IM_dd.n4 && IM_dd.e.but > 1 && IM_dd.e.src == d_o.oimg && !d_o.clone) return false;
+		if(d_o.visible && IM_dd.e.but <= 1 && IM_dd.e.x >= d_o.x && IM_dd.e.x <= d_o.x+d_o.w && IM_dd.e.y >= d_o.y && IM_dd.e.y <= d_o.y+d_o.h)
+		{
+			if(d_o.z > d_cmp && (d_t = IM_dd.e.src.tag).indexOf('inpu') < 0 && d_t.indexOf('texta') < 0 && d_t.indexOf('sele') < 0 && d_t.indexOf('opti') < 0 && d_t.indexOf('scrol') < 0)
+			{
+				d_cmp = d_o.z;
+				IM_dd.obj = d_o;
+			}
+		}
+	}
+	if(IM_dd.obj)
+	{
+		if(IM_dd.obj.nodrag) IM_dd.obj = null;
+		else
+		{
+			IM_dd.e.e.cancelBubble = true;
+			var d_rsz = IM_dd.e.modifKey && (IM_dd.obj.resizable || IM_dd.obj.scalable);
+			if(IM_dd.op)
+			{
+				(d_o = document.getElementById('OpBlUr')).style.pixelLeft = IM_dd.e.x;
+				d_o.style.pixelTop = IM_dd.e.y;
+				(d_o = d_o.children[0].children[0]).focus();
+				d_o.blur();
+			}
+			else if(IM_dd.ie && !IM_dd.ie4)
+			{
+				if(document.selection && document.selection.empty) document.selection.empty();
+				IM_dd.db.onselectstart = function()
+				{
+					event.returnValue = false;
+				};
+			}
+			if(d_rsz)
+			{
+				IM_dd.obj._setCrs('se-resize');
+				IM_dd.obj.is_resized = 1;
+				IM_dd.whratio = IM_dd.obj.scalable? IM_dd.obj.defw/IM_dd.obj.defh : 0;
+				if(IM_dd.ie)
+				{
+					if(IM_dd.ie4)
+					{
+						window.IM_dd_x = IM_dd.getScrollX();
+						window.IM_dd_y = IM_dd.getScrollY();
+					}
+					setTimeout(
+						'if(IM_dd.obj && document.selection && document.selection.empty)'+
+						'{'+
+							'document.selection.empty();'+
+							'if(IM_dd.ie4) window.scrollTo(window.IM_dd_x, window.IM_dd_y);'+
+						'}'
+					,0);
+				}
+				IM_dd.setMovHdl(IM_RESIZE);
+				IM_dd.reszTo(IM_dd.obj.w, IM_dd.obj.h);
+			}
+			else
+			{
+				IM_dd.obj.is_dragged = 1;
+				IM_dd.setMovHdl(IM_DRAG);
+			}
+			IM_dd.setUpHdl(IM_DROP);
+			IM_dd.embedVis('hidden');
+			IM_dd.obj._setOpaRel(0.7);
+			IM_dd.obj.maximizeZ();
+			IM_dd.ofx = IM_dd.obj.x+IM_dd.obj.w-IM_dd.e.x;
+			IM_dd.ofy = IM_dd.obj.y+IM_dd.obj.h-IM_dd.e.y;
+			if(window.IM_my_PickFunc) IM_my_PickFunc();
+			if(IM_dd.obj.pickFunc) IM_dd.obj.pickFunc();
+			IM_DDScroll();
+			return !(
+				IM_dd.obj.is_resized
+				|| IM_dd.n4 && IM_dd.obj.is_image
+				|| IM_dd.n6 || IM_dd.w3c
+			);
+		}
+	}
+	if(IM_dd.downFunc) return IM_dd.downFunc(d_ev);
+	return true;
+}
+function IM_DRAG(d_ev)
+{
+	if(!IM_dd.obj || !IM_dd.obj.visible) return true;
+	if(IM_dd.ie4 || IM_dd.w3c || IM_dd.n6 || IM_dd.obj.children.length > 0xf)
+	{
+		if(IM_dd.wait) return false;
+		IM_dd.wait = 1;
+		setTimeout('IM_dd.wait = 0;', IM_dd.tiv);
+	}
+	IM_dd.e = new IM_dd.evt(d_ev);
+	if(IM_dd.ie && !IM_dd.e.but)
+	{
+		IM_DROP(d_ev);
+		return true;
+	}
+	IM_dd.msmoved = 1;
+	IM_dd.obj.moveTo(
+		IM_dd.obj.vertical? IM_dd.obj.x : IM_dd.maxOffX(IM_dd.inWndW(IM_dd.ofx+IM_dd.e.x)-IM_dd.obj.w),
+		IM_dd.obj.horizontal? IM_dd.obj.y : IM_dd.maxOffY(IM_dd.inWndH(IM_dd.ofy+IM_dd.e.y)-IM_dd.obj.h)
+	);
+
+	if(window.IM_my_DragFunc) IM_my_DragFunc();
+	if(IM_dd.obj.dragFunc) IM_dd.obj.dragFunc();
+	if(IM_dd.moveFunc) return IM_dd.moveFunc(d_ev);
+	return false;
+}
+function IM_RESIZE(d_ev)
+{
+	if(!IM_dd.obj || !IM_dd.obj.visible) return true;
+	if(IM_dd.wait) return false;
+	IM_dd.wait = 1;
+	setTimeout('IM_dd.wait = 0;', IM_dd.tiv);
+	IM_dd.e = new IM_dd.evt(d_ev);
+	if(IM_dd.ie && !IM_dd.e.but)
+	{
+		IM_DROP(d_ev);
+		return true;
+	}
+	IM_dd.msmoved = 1;
+	var d_w = IM_dd.limW(IM_dd.inWndW(IM_dd.ofx+IM_dd.e.x)-IM_dd.obj.x), d_h;
+	if(!IM_dd.whratio) d_h = IM_dd.limH(IM_dd.inWndH(IM_dd.ofy+IM_dd.e.y)-IM_dd.obj.y);
+	else
+	{
+		d_h = IM_dd.limH(IM_dd.inWndH(Math.round(d_w/IM_dd.whratio)+IM_dd.obj.y)-IM_dd.obj.y);
+		d_w = Math.round(d_h*IM_dd.whratio);
+	}
+	IM_dd.reszTo(d_w, d_h);
+	if(window.IM_my_ResizeFunc) IM_my_ResizeFunc();
+	if(IM_dd.obj.resizeFunc) IM_dd.obj.resizeFunc();
+	if(IM_dd.moveFunc) return IM_dd.moveFunc(d_ev);
+	return false;
+}
+function IM_DROP(d_ev)
+{
+	if(IM_dd.obj)
+	{
+		if(IM_dd.obj.is_dragged)
+		{
+			if(!IM_dd.obj.is_image) IM_dd.getWH(IM_dd.obj);
+		}
+		else if(IM_dd.n4)
+		{
+			if(IM_dd.obj.is_image)
+			{
+				IM_dd.n4RectVis(0);
+				IM_dd.obj.resizeTo(IM_dd.obj.w, IM_dd.obj.h);
+			}
+		}
+		if(!IM_dd.n4 || !IM_dd.obj.is_image) IM_dd.recalc();
+		IM_dd.setMovHdl(IM_dd.moveFunc);
+		IM_dd.setUpHdl(IM_dd.upFunc);
+		if(IM_dd.db) IM_dd.db.onselectstart = null;
+		IM_dd.obj._setOpaRel(1.0);
+		IM_dd.obj._setCrs(IM_dd.obj.cursor);
+		IM_dd.embedVis('visible');
+		IM_dd.obj._resetZ();
+		IM_dd.e = new IM_dd.evt(d_ev);
+		if(window.IM_my_DropFunc) IM_my_DropFunc();
+		if(IM_dd.obj.dropFunc) IM_dd.obj.dropFunc();
+		IM_dd.msmoved = IM_dd.obj.is_dragged = IM_dd.obj.is_resized = IM_dd.whratio = 0;
+		IM_dd.obj = null;
+	}
+	IM_dd.setDwnHdl(IM_PICK);
+}
+function IM_SET_DHTML()
+{
+	var d_a = arguments, d_ai, d_htm = '', d_o, d_i = d_a.length;
+   while(d_i--)
+	{
+		if(!(d_ai = d_a[d_i]).indexOf('c:')) IM_dd.cursor = d_ai.substring(2);
+		else if(d_ai == IM_NO_ALT) IM_dd.noalt = 1;
+		else if(d_ai == IM_SCROLL) IM_dd.scroll = 1;
+		else if(d_ai == IM_RESET_Z) IM_dd.re_z = 1;
+		else if(d_ai == IM_RESIZABLE) IM_dd.resizable = 1;
+		else if(d_ai == IM_SCALABLE) IM_dd.scalable = 1;
+		else if(d_ai == IM_TRANSPARENT) IM_dd.diaphan = 1;
+		else
+		{
+			d_o = new IM_DDObj(d_ai);
+			IM_dd.addElt(d_o);
+			d_htm += d_o.t_htm || '';
+			if(d_o.oimg && d_o.cpy_n)
+			{
+				var d_j = 0; while(d_j < d_o.cpy_n)
+				{
+					var d_p = new IM_DDObj(d_o.name+d_o.cmd, ++d_j);
+					IM_dd.addElt(d_p, d_o);
+					d_p.defz = d_o.defz+d_j;
+					d_p.original = d_o;
+					d_htm += d_p.t_htm;
+				}
+			}
+		}
+	}
+	if (IM_dd.n4 || IM_dd.n6 || IM_dd.ie || IM_dd.op || IM_dd.w3c) document.write(
+		(IM_dd.n4? '<div style="position:absolute;"><\/div>\n'
+		: (IM_dd.op && !IM_dd.op6)? '<div id="OpBlUr" style="position:absolute;visibility:hidden;width:0px;height:0px;"><form><input type="text" style="width:0px;height:0px;"><\/form><\/div>'
+		: '') + d_htm
+	);
+	IM_dd.z = 0x33;
+	d_i = IM_dd.elements.length; while(d_i--)
+	{
+		IM_dd.addProps(d_o = IM_dd.elements[d_i]);
+		if(d_o.is_image && !d_o.original && !d_o.clone)
+			IM_dd.n4? d_o.oimg.src = IM_spacer : d_o.oimg.style.visibility = 'hidden';
+	}
+	IM_dd.mkWzDom();
+	if(window.onload) IM_dd.loadFunc = window.onload;
+	if(window.onunload) IM_dd.uloadFunc = window.onunload;
+	window.onload = IM_dd.initz;
+	window.onunload = IM_dd.finlz;
+	IM_dd.setDwnHdl(IM_PICK);
+}
+function IM_ADD_DHTML(d_o) // layers only!
+{
+	d_o = new IM_DDObj(d_o);
+	IM_dd.addElt(d_o);
+	IM_dd.addProps(d_o);
+	IM_dd.mkWzDom();
+}
+
+
+
+
+////////////////////////////////////////////////////////////
+// If not needed, all code below this line may be removed
+
+
+// For backward compatibility
+IM_dd.d = document;			// < v. 2.72
+var RESET_ZINDEX = IM_RESET_Z; // < 3.44
+var KEYDOWN_RESIZE = IM_RESIZABLE; // < 4.43
+var CURSOR_POINTER = IM_CURSOR_HAND; // < 4.44
+var NO_SCROLL = '';		 // < v. 4.49
+
+
+
+////////////////////////////////////////////////////////////
+// FUNCTIONS FOR EXTENDED SCRIPTING
+// Use these for your own extensions,
+// or to call functions defined elsewhere
+
+
+
+/* my_PickFunc IS AUTOMATICALLY CALLED WHEN AN ITEM STARTS TO BE DRAGGED.
+The following objects/properties are accessible from here:
+
+- dd.e: current mouse event
+- dd.e.property: access to a property of the current mouse event.
+  Mostly requested properties:
+  - dd.e.x: document-related x co-ordinate
+  - dd.e.y: document-related y co-ord
+  - dd.e.src: target of mouse event (not identical with the drag drop object itself).
+  - dd.e.button: currently pressed mouse button. Left button: dd.e.button <= 1
+
+- dd.obj: reference to currently dragged item.
+- dd.obj.property: access to any property of that item.
+- dd.obj.method(): for example dd.obj.resizeTo() or dd.obj.swapImage() .
+  Mostly requested properties:
+	- dd.obj.name: image name or layer ID passed to SET_DHTML();
+	- dd.obj.x and dd.obj.y: co-ordinates;
+	- dd.obj.w and dd.obj.h: size;
+	- dd.obj.is_dragged: 1 while item is dragged, else 0;
+	- dd.obj.is_resized: 1 while item is resized, i.e. if <ctrl> or <shift> is pressed, else 0
+
+For more properties and details, visit the API documentation
+at http://www.walterzorn.com/dragdrop/api_e.htm (english) or
+http://www.walterzorn.de/dragdrop/api.htm (german)	*/
+function IM_my_PickFunc()
+{
+}
+
+
+
+
+/* my_DragFunc IS CALLED WHILE AN ITEM IS DRAGGED
+See the description of my_PickFunc above for what's accessible from here. */
+function IM_my_DragFunc()
+{
+	//window.status = 'dd.elements.' + dd.obj.name + '.x  = ' + dd.obj.x + '	 dd.elements.' + dd.obj.name + '.y = ' + dd.obj.y;
+}
+
+
+
+
+/* my_ResizeFunc IS CALLED WHILE AN ITEM IS RESIZED
+See the description of my_PickFunc above for what's accessible from here. */
+function IM_my_ResizeFunc()
+{
+	//window.status = 'dd.elements.' + dd.obj.name + '.w  = ' + dd.obj.w + '	 dd.elements.' + dd.obj.name + '.h = ' + dd.obj.h;
+}
+
+
+
+
+/* THIS ONE IS CALLED ONCE AN ITEM IS DROPPED
+See the description of my_PickFunc for what's accessible from here.
+Here may be investigated, for example, what's the name (dd.obj.name)
+of the dropped item, and where (dd.obj.x, dd.obj.y) it has been dropped... */
+function IM_my_DropFunc()
+{
+}
Index: /trunk/instant_messenger/js/im_init.js
===================================================================
--- /trunk/instant_messenger/js/im_init.js	(revision 20)
+++ /trunk/instant_messenger/js/im_init.js	(revision 20)
@@ -0,0 +1,73 @@
+// Instant Messenger
+// im_init.js
+
+   function _init_jabber()
+   {
+      try
+      {
+         if ( window.IM )
+         {
+            setTimeout('IM.atalho()', 6000);
+            setTimeout('IM.load_im(true)', 6200);
+         }
+         else
+            setTimeout('_init_jabber()', 2000);
+      }
+      catch(e)
+      {
+            setTimeout('_init_jabber()', 2000);
+      }
+   }
+
+   var _date = new Date();                                                                    
+   var _time = '?' + _date.getTime();                                                         
+   var js_path = im_path + "js/";                                                                       
+   var css_path = im_path + "templates/default/";                                                                     
+   // conn = new cConnector();
+
+   function init_jabber()
+   {
+      //alert('inicio - im_path: ' + im_path);
+
+      /* CSS's */
+      new_css = new Array();
+      new_css[0] = css_path + 'css.css' + _time;
+      new_css[1] = css_path + 'messenger.css';
+      /* JS's
+       *
+       * escritos pelo arquivo index2.php para que
+       * seja sobrescrito o cache apenas quando há
+       * alteração no conteúdo dos scripts
+       *
+       */
+
+      for ( i = 0; i < new_css.length; i++ ) IM_loadCss(new_css[i]);
+      for ( i = 0; i < new_js.length; i++ ) setTimeout('IM_loadScript(\'' + (new_js[i] + _time) + '\')', (650 * (i+1)));
+
+      _init_jabber();
+   }
+
+   function add_head(pElement)                                                                
+   {                                                                                          
+      _head = document.getElementsByTagName('head').item(0);                                  
+      _head.appendChild(pElement);                                                            
+   }                                                                                          
+                                                                                               
+   function IM_loadCss(pName)                                                                   
+   {                                                                                          
+      _css = document.createElement('link');                                                    
+      _css.setAttribute('rel', 'stylesheet');                                                   
+      //_css.setAttribute('type', 'text/css'):                                                  
+      _css.setAttribute('href', pName + _time);                                                 
+      add_head(_css);                                                                           
+   }                                                                                          
+                                                                                               
+   function load_script(pName)                                                                
+   {                                                                                          
+      _script = document.createElement('script');
+      _script.setAttribute('src', pName);
+      _script.setAttribute('type', 'text/javascript');
+      add_head(_script);/**/
+   }                                                                                          
+//im_win.load();
+setTimeout('init_jabber()', 5000)
Index: /trunk/instant_messenger/js/im_images.js
===================================================================
--- /trunk/instant_messenger/js/im_images.js	(revision 20)
+++ /trunk/instant_messenger/js/im_images.js	(revision 20)
@@ -0,0 +1,148 @@
+// Instant Messenger
+// Images.js
+
+	var img_group_close = new Image();
+	img_group_close.src = im_path + "templates/default/images/group_close.gif";
+	var img_group_open = new Image();
+	img_group_open.src = im_path + "templates/default/images/group_open.gif";
+	var blank = new Image();
+	blank.src = im_path + "templates/default/images/blank.gif";
+	var img_down = new Image();
+	img_down.src = im_path + "templates/default/images/down.gif";
+	var img_up = new Image();
+	img_up.src = im_path + "templates/default/images/up.gif";
+	var img_online = new Image();
+	img_online.src = im_path + "templates/default/images/online.gif";
+	var img_offline = new Image();
+	img_offline.src = im_path + "templates/default/images/offline.gif";
+	var img_idle = new Image();
+	img_idle.src = im_path + "templates/default/images/idle.gif";
+	var img_busy = new Image();
+	img_busy.src = im_path + "templates/default/images/busy.gif";
+	var img_not_authorized  = new Image();
+	img_not_authorized.src = im_path + "templates/default/images/not_authorized.gif";
+	var img_chat = new Image();
+	img_chat.src = im_path + "templates/default/images/chat.gif";
+	var img_open_box = new Image();
+	img_open_box.src = im_path + "templates/default/images/open_box.gif";
+	var img_close_box = new Image();
+	img_close_box.src = im_path + "templates/default/images/close_box.gif";
+	var img_photo = new Image();
+	img_photo.src = im_path + "templates/default/images/photo.png";
+	var img_menu = new Image();
+	img_menu.src = im_path + "templates/default/images/menu.gif";
+	var img_wait = new Image();
+	img_wait.src = im_path + "templates/default/images/wait.gif";
+	var img_chat_bubble = new Image();
+	img_chat_bubble.src = im_path + "templates/default/images/chat_bubble.gif";
+
+
+
+	var smile_1 = new Image();
+   smile_1.src = im_path + "templates/default/images/img/smiles/1.gif"
+   var smile_2 = new Image();
+   smile_2.src = im_path + "templates/default/images/img/smiles/2.gif"
+   var smile_3 = new Image();
+   smile_3.src = im_path + "templates/default/images/img/smiles/3.gif"
+   var smile_4 = new Image();
+   smile_4.src = im_path + "templates/default/images/img/smiles/4.gif"
+   var smile_5 = new Image();
+   smile_5.src = im_path + "templates/default/images/img/smiles/5.gif"
+   var smile_6 = new Image();
+   smile_6.src = im_path + "templates/default/images/img/smiles/6.gif"
+   var smile_7 = new Image();
+   smile_7.src = im_path + "templates/default/images/img/smiles/7.gif"
+   var smile_8 = new Image();
+   smile_8.src = im_path + "templates/default/images/img/smiles/8.gif"
+   var smile_9 = new Image();
+   smile_9.src = im_path + "templates/default/images/img/smiles/9.gif"
+   var smile_10 = new Image();
+   smile_10.src = im_path + "templates/default/images/img/smiles/10.gif"
+   var smile_11 = new Image();
+   smile_11.src = im_path + "templates/default/images/img/smiles/11.gif"
+   var smile_12 = new Image();
+   smile_12.src = im_path + "templates/default/images/img/smiles/12.gif"
+   var smile_13 = new Image();
+   smile_13.src = im_path + "templates/default/images/img/smiles/13.gif"
+   var smile_14 = new Image();
+   smile_14.src = im_path + "templates/default/images/img/smiles/14.gif"
+   var smile_15 = new Image();
+   smile_15.src = im_path + "templates/default/images/img/smiles/15.gif"
+   var smile_16 = new Image();
+   smile_16.src = im_path + "templates/default/images/img/smiles/16.gif"
+   var smile_17 = new Image();
+   smile_17.src = im_path + "templates/default/images/img/smiles/17.gif"
+   var smile_18 = new Image();
+   smile_18.src = im_path + "templates/default/images/img/smiles/18.gif"
+   var smile_19 = new Image();
+   smile_19.src = im_path + "templates/default/images/img/smiles/19.gif"
+   var smile_20 = new Image();
+   smile_20.src = im_path + "templates/default/images/img/smiles/20.gif"
+   var smile_21 = new Image();
+   smile_21.src = im_path + "templates/default/images/img/smiles/21.gif"
+   var smile_22 = new Image();
+   smile_22.src = im_path + "templates/default/images/img/smiles/22.gif"
+   var smile_23 = new Image();
+   smile_23.src = im_path + "templates/default/images/img/smiles/23.gif"
+   var smile_24 = new Image();
+   smile_24.src = im_path + "templates/default/images/img/smiles/24.gif"
+   var smile_25 = new Image();
+   smile_25.src = im_path + "templates/default/images/img/smiles/25.gif"
+   var smile_26 = new Image();
+   smile_26.src = im_path + "templates/default/images/img/smiles/26.gif"
+   var smile_27 = new Image();
+   smile_27.src = im_path + "templates/default/images/img/smiles/27.gif"
+   var smile_28 = new Image();
+   smile_28.src = im_path + "templates/default/images/img/smiles/28.gif"
+   var smile_29 = new Image();
+   smile_29.src = im_path + "templates/default/images/img/smiles/29.gif"
+   var smile_30 = new Image();
+   smile_30.src = im_path + "templates/default/images/img/smiles/30.gif"
+   var smile_31 = new Image();
+   smile_31.src = im_path + "templates/default/images/img/smiles/31.gif"
+   var smile_32 = new Image();
+   smile_32.src = im_path + "templates/default/images/img/smiles/32.gif"
+   var smile_33 = new Image();
+   smile_33.src = im_path + "templates/default/images/img/smiles/33.gif"
+   var smile_34 = new Image();
+   smile_34.src = im_path + "templates/default/images/img/smiles/34.gif"
+   var smile_35 = new Image();
+   smile_35.src = im_path + "templates/default/images/img/smiles/35.gif"
+   var smile_36 = new Image();
+   smile_36.src = im_path + "templates/default/images/img/smiles/36.gif"
+   var smile_37 = new Image();
+   smile_37.src = im_path + "templates/default/images/img/smiles/37.gif"
+   var smile_38 = new Image();
+   smile_38.src = im_path + "templates/default/images/img/smiles/38.gif"
+   var smile_39 = new Image();
+   smile_39.src = im_path + "templates/default/images/img/smiles/39.gif"
+   var smile_40 = new Image();
+   smile_40.src = im_path + "templates/default/images/img/smiles/40.gif"
+   var smile_41 = new Image();
+   smile_41.src = im_path + "templates/default/images/img/smiles/41.gif"
+   var smile_42 = new Image();
+   smile_42.src = im_path + "templates/default/images/img/smiles/42.gif"
+   var smile_43 = new Image();
+   smile_43.src = im_path + "templates/default/images/img/smiles/43.gif"
+   var smile_44 = new Image();
+   smile_44.src = im_path + "templates/default/images/img/smiles/44.gif"
+   var smile_45 = new Image();
+   smile_45.src = im_path + "templates/default/images/img/smiles/45.gif"
+   var smile_46 = new Image();
+   smile_46.src = im_path + "templates/default/images/img/smiles/46.gif"
+   var smile_47 = new Image();
+   smile_47.src = im_path + "templates/default/images/img/smiles/47.gif"
+   var smile_48 = new Image();
+   smile_48.src = im_path + "templates/default/images/img/smiles/48.gif"
+   var smile_49 = new Image();
+   smile_49.src = im_path + "templates/default/images/img/smiles/49.gif"
+   var smile_50 = new Image();
+   smile_50.src = im_path + "templates/default/images/img/smiles/50.gif"
+   var smile_51 = new Image();
+   smile_51.src = im_path + "templates/default/images/img/smiles/51.gif"
+   var smile_52 = new Image();
+   smile_52.src = im_path + "templates/default/images/img/smiles/52.gif"
+   var smile_53 = new Image();
+   smile_53.src = im_path + "templates/default/images/img/smiles/53.gif"
+   var smile_54 = new Image();
+   smile_54.src = im_path + "templates/default/images/img/smiles/54.gif"
Index: /trunk/instant_messenger/js/im_functions.js
===================================================================
--- /trunk/instant_messenger/js/im_functions.js	(revision 20)
+++ /trunk/instant_messenger/js/im_functions.js	(revision 20)
@@ -0,0 +1,705 @@
+// Instant Messenger
+// im_functions.js
+
+   function IM()
+   {
+      this.array_lang_im  = [];
+      this.user_not_aut   = [];
+      this.vcard_contacts = [];
+      this.vcard_user     = [];
+      this.load_photo	  = false;
+   }
+
+   /*
+    * Load Contatos
+    */
+
+   IM.prototype.load_im = function()
+   {
+	   var force = ( arguments.length ) ? true : false;
+      var _this = this;
+      Sincro.count = 0;
+
+      var handler_contacts = function(data)
+      {
+         if ( data[1] )
+         {
+            _this.vcard_contacts.splice(0,_this.vcard_contacts.length);
+            _this.vcard_user.splice(0,_this.vcard_user.length);
+            _this.user_not_aut.splice(0,_this.user_not_aut.length);
+            _this.mount_list(data);
+
+         }
+         _this.conf_VcardUser(data[0]);
+      }
+
+      if ( force || this.getWinContactsState() )
+         cIM.cExecute("$this.Ujabber.list_user",handler_contacts);
+   }
+	
+   /*
+    * Update Contatos
+    */
+
+   IM.prototype.UpdateContacts = function()
+   {
+      var _this = this;
+      _this.load_im();
+   }
+
+   IM.prototype.showContacts = function()
+   {
+      if ( this.getWinContactsState() )
+         im_win.windowClose('contacts_im');
+      else
+      {
+         im_win.windowMaximizeRestore('contacts_im');
+         this.load_im();
+      }
+   }
+
+   IM.prototype.getWinContactsState = function()
+   {
+      try
+      {
+         var win_state = false;
+             win_state = ( windowItems['contacts'].state == WINDOW_STATE_REGULAR ) ? true : false;
+             win_state = ( win_state ) ? win_state : ( windowItems['contacts'].state == WINDOW_STATE_MAXIMIZED ) ? true : false;
+         return win_state;
+      }
+      catch(e)
+      {
+         return false;
+      }
+   }
+	/*
+	 * Monta Lista de Contatos
+	 */
+	
+	IM.prototype.mount_list = function(pList)
+	{
+		var _this = this;
+		var div = document.getElementById("div_contacts");
+			div.innerHTML = "";
+		var groups = "<b>"+_this.get_lang("list of contacts")+" - 0 </b><br>";
+	
+		if(pList.length > 0){
+			var name_group = "";
+			groups = "<img id='img_all_groups' src=" + img_group_open.src + " onclick=javascript:IM.visible_group('all_groups')>" +
+			         "<b>"+_this.get_lang("list of contacts")+" - " + ( pList.length - 1 ) + "</b><br>"+
+			         "<div id='all_groups'>";
+			for(var i=1; i < pList.length; i++){
+				if( i == 1 ){
+					if(pList[i].group != "" && pList[i].name != ""){
+						name_group = pList[i].group;
+						groups += '<img id="img_' + pList[i].group.rm_space() + '" src="' + img_group_open.src + '" onclick="javascript:IM.visible_group(\'' + pList[i].group.rm_space() + '\')" style="margin-left:16px;">';
+						groups += "<b>" + pList[i].group + "</b><br>";
+						groups += "<div id='" + pList[i].group.rm_space() + "'>";
+						if(pList[i].subscription == "both"){
+							groups += '<div id="' + pList[i].jid + '" nuncontact="'+ i +'" onmouseover="this.className=\'contato_hover\'" onmouseout="this.className=\'\'" onmousedown="javascript:IM.action_button(event, \''+pList[i].online + '\', \'' + pList[i].jid + '\');" style="cursor:pointer;padding-left:32px;"><img src="' + ((pList[i].online) == parseInt(1) ? img_online.src : img_offline.src) + '">' + pList[i].name + '</div><span id="_span_' + pList[i].jid + '" class="menu_im"></span>';
+						}else{
+							groups += _this.FromToNone(pList[i].jid,pList[i].subscription,pList[i].group,pList[i].name);
+						}
+					}else
+						_this.user_not_aut[_this.user_not_aut.length] = pList[i].jid + ";" + i;
+				}else{
+					if(pList[i].group != "" && pList[i].name != ""){
+						if(pList[i].group == name_group){
+							if(pList[i].subscription == "both"){
+								groups += '<div id="' + pList[i].jid + '" nuncontact="'+ i +'" onmouseover="this.className=\'contato_hover\'" onmouseout="this.className=\'\'" onmousedown="javascript:IM.action_button(event, \''+pList[i].online + '\', \'' + pList[i].jid + '\');" style="cursor:pointer;padding-left:32px;"><img src="' + ((pList[i].online) == parseInt(1) ? img_online.src : img_offline.src) + '">' + pList[i].name + '</div><span id="_span_' + pList[i].jid + '" class="menu_im"></span>';
+							}else{
+								groups += _this.FromToNone(pList[i].jid,pList[i].subscription,pList[i].group,pList[i].name);
+							}
+							name_group = pList[i].group;
+						}else{
+							groups += "</div>";
+							groups += '<img id="img_' + pList[i].group.rm_space() + '" src="' + img_group_open.src + '" onclick="javascript:IM.visible_group(\'' + pList[i].group.rm_space() + '\')" style="margin-left:16px;">';
+							groups += "<b>" + pList[i].group + "</b><br>";
+							groups += "<div id='" + pList[i].group.rm_space() + "'>";
+							if(pList[i].subscription == "both"){
+								groups += '<div id="' + pList[i].jid + '" nuncontact="'+ i +'" onmouseover="this.className=\'contato_hover\'" onmouseout="this.className=\'\'" onmousedown="javascript:IM.action_button(event, \''+pList[i].online + '\', \'' + pList[i].jid + '\');" style="cursor:pointer;padding-left:32px;"><img src="' + ((pList[i].online) == parseInt(1) ? img_online.src : img_offline.src) + '">' + pList[i].name + '</div><span id="_span_' + pList[i].jid + '" class="menu_im"></span>';
+							}else{
+								groups += _this.FromToNone(pList[i].jid,pList[i].subscription,pList[i].group,pList[i].name);
+							}
+							name_group = pList[i].group;
+						}
+					}else{
+						_this.user_not_aut[_this.user_not_aut.length] = pList[i].jid + ";" + i;
+					}
+				}
+			}
+			groups += "</div><div id='out_list'></div></div>";
+		}
+		
+		// Vcard Contato;
+		if(pList.length > 0)
+			_this.vcard_contacts =  pList;
+
+		// Imprime valor de groups;
+		div.innerHTML = groups;
+
+		// Usuários sem grupo e nome;
+		if(_this.user_not_aut.length > 0)
+			_this.Group_Name(document.getElementById('out_list'));
+	}
+
+	/*
+	 * Define se From - To - None
+	 */
+
+	IM.prototype.FromToNone = function(pJid,pSubscription,pGroup,pName)
+	{
+		var n_groups = "";
+		var _this = this;
+		if(pSubscription == "from")
+			n_groups += "<div id='" + pJid + "' nucontact="+ i +" style='cursor:pointer;padding-left:32px;' onclick=javascript:IM.Authorization(\'"+pJid+"\',\'"+pSubscription+"\')><img src="+img_not_authorized.src+" title='Aguardando/Enviar Autorização'>"+pName+"</div>";
+		else if(pSubscription == "to")
+			n_groups += "<div id='" + pJid + "' nucontact="+ i +" style='cursor:pointer;padding-left:32px;' onclick=javascript:IM.Authorization(\'"+pJid+"\',\'"+pSubscription+"\')><img src="+img_not_authorized.src+" title='Enviar Autorização'>"+pName+"</div>";																			
+		else if(pSubscription == "none"){
+			n_groups += "<div id='" + pJid + "' nucontact="+ i +" style='cursor:pointer;padding-left:32px;' onclick=javascript:IM.Authorization(\'"+pJid+"\',\'"+pSubscription+"\')><img src="+img_not_authorized.src+" title='Pedir Autorização'>"+pName+"</div>";																			
+		}	
+		return n_groups;
+	}
+
+	/*
+	 *  Usuário sem grupo e nome
+	 */
+
+	IM.prototype.Group_Name = function(el)
+	{
+		var _this = this;
+		var group_nt = "";
+		
+		group_nt += '<img	id="img_not_aut" src="' + img_group_open.src + '" onclick="javascript:IM.visible_group(\'not_aut\')" style="margin-left:16px;">';
+		group_nt += "<b>" + _this.get_lang("Sem Cadastro") + "</b><br>";
+		group_nt += "<div id='not_aut'>";
+		for(var i=0; i < _this.user_not_aut.length; i++){
+			var pos = _this.user_not_aut[i].indexOf("@");
+			var ind = _this.user_not_aut[i].substr((_this.user_not_aut[i].indexOf(";")+1),1);
+			group_nt += '<div id="'+_this.user_not_aut[i]+'" onclick=Preferences.updateLoad("'+ind+'") style="cursor:pointer;padding-left:32px;">'+
+						'<img src="'+img_not_authorized.src+'">'+_this.user_not_aut[i].substr(0,pos)+'</div>';
+		}
+		group_nt += "</div>";
+		el.innerHTML = group_nt;
+		setTimeout("Templates.Users_Not_Auth()",2500);
+	}
+
+   /*	
+	*  Requisitar autorização;
+	*/
+
+	IM.prototype.Authorization = function(pJid,pSubscription)
+	{
+		if(confirm("Enviar pedido?")){
+			var handler_accept_request = function(data){
+				if(!data)
+					alert("Pedido já foi enviado!");
+			}
+			cIM.cExecute("$this.Ujabber.AcceptRequest",handler_accept_request,"jid="+pJid+"&subscription="+pSubscription);
+		}
+	}
+
+   /*	
+	*  Grupos dos Contatos;
+	*/
+
+	IM.prototype.visible_group = function(el)
+	{
+		var _this = this;
+		el = el.rm_space();
+		var div = document.getElementById(el);
+		div.style.display = "none";
+		var img = document.getElementById("img_" + el);
+		img.onclick = function(){_this.unvisible_group(el)};
+		img.src = img_group_close.src;
+	
+	}
+	
+	IM.prototype.unvisible_group = function(el)
+	{
+		var _this = this;
+		el = el.rm_space();
+		var div = document.getElementById(el);
+		div.style.display = "";
+		var img = document.getElementById("img_" + el);
+		img.onclick = function(){_this.visible_group(el)};
+		img.src = img_group_open.src;
+	
+	}
+
+	/*
+	 *  Conf. Vcard
+	 */
+	
+	IM.prototype.conf_VcardUser = function(data)
+	{
+		var _this = this;
+
+		// Vcard pessoal;
+
+		if ( !_this.load_photo ){
+
+			_this.vcard_user['VCARD_FN'] = data.VCARD_FN;
+			_this.vcard_user['VCARD_NICKNAME'] = data.VCARD_NICKNAME;
+			_this.vcard_user['VCARD_ORGNAME']  = data.VCARD_ORGNAME;
+			_this.vcard_user['VCARD_ORGUNIT']  = data.VCARD_ORGUNIT;
+			_this.vcard_user['VCARD_ROLE'] = data.VCARD_ROLE;
+			_this.vcard_user['VCARD_BDAY'] = data.VCARD_BDAY;
+			_this.vcard_user['VCARD_DESC'] = data.VCARD_DESC;
+			_this.vcard_user['VCARD_JID']  = data.VCARD_JID;
+
+			im_win.get_photo_ldap(_this.vcard_user['VCARD_JID']);
+			_this.load_photo = true;
+		}
+	
+		// NickName;
+		if(_this.vcard_user['VCARD_NICKNAME'] != "")
+			document.getElementById('span_nickname').innerHTML = "<b>&nbsp;" + _this.vcard_user['VCARD_NICKNAME'].substring(0,30) + "</b>";
+		else
+			document.getElementById('span_nickname').innerHTML = "<b>&nbsp;" + IM.get_lang('your nickname') + "</b>";
+		
+		// Custom Message;
+		if(_this.vcard_user['VCARD_DESC'] != "")
+			document.getElementById('span_message').innerHTML = "<b>&nbsp;" + _this.vcard_user['VCARD_DESC'].substring(0,30) + "</b>";
+		else
+			document.getElementById('span_message').innerHTML = "<b>&nbsp;" + IM.get_lang('your message') + "</b>";			
+	
+	}
+
+   /*	
+	*  Menu
+	*/
+
+	IM.prototype.visible_box = function()
+	{
+		var _this = this;
+		document.getElementById('list_users').style.display = "";
+		var img = document.getElementById('box_menu');
+		img.onclick = function(){_this.unvisible_box()};
+		img.src = img_open_box.src;
+	}
+
+	IM.prototype.unvisible_box = function()
+	{
+		var _this = this;
+		document.getElementById('list_users').style.display = "none";
+		var img = document.getElementById('box_menu');
+		img.onclick = function(){_this.visible_box()};
+		img.src = img_close_box.src;
+	}
+
+   /*	
+	*  Traduções
+	*/
+
+	// Translate words and phrases using user language from eGroupware.
+	IM.prototype.get_lang = function(_key,_arg1,_arg2,_arg3,_arg4)
+	{
+		var _this = this;
+		if(!_this.array_lang_im[0]){		
+			return _key+"*";
+		}
+		_value = "";	
+		for(i = 0; i < _this.array_lang_im[0].length;i++){
+			if(_this.array_lang_im[0][i] == _key.toLowerCase()) {
+				_value = _this.array_lang_im[1][i];					
+				break;
+			}
+		}	
+		
+		if(!_value)
+			return _key+"*";
+				
+		if(_arg1 || _arg2 ||_arg3 || _arg4) {
+			for(j = 1; j <= 4; j++){
+				if(eval("_arg"+j)) {
+					var regExp = new RegExp("%"+j+"");		
+					_value = _value.replace(regExp,eval("_arg"+j));
+				}
+			}
+		}
+		
+		return _value;
+	}
+
+	/*
+	 *  Pega Mensagens
+	 */
+
+	IM.prototype.getMessage = function()
+	{
+		_this = this;
+		var handler_message = function(data)
+        {
+			if(data.length > 0)
+            {
+				var aux = "";
+                var hora = new Date();
+				for(var i=0; i < data.length; i++)
+	            {
+	                mensagens = document.getElementById(data[i].from.substr(0, data[i].from.indexOf('/')) + '_chatMessages');
+	         	    var nickname = data[i].from.substr(0, data[i].from.indexOf('/'));
+    	            for(var j=1 ; j < _this.vcard_contacts.length ; j++)
+                    {
+			          if(data[i].from.substr(0, data[i].from.indexOf('/')) == _this.vcard_contacts[j].VCARD_JID)
+			             if(_this.vcard_contacts[j].VCARD_NICKNAME != "")
+				             nickname = _this.vcard_contacts[j].VCARD_NICKNAME;	
+	                }
+                    
+                    minuto = ( hora.getMinutes() > 9 ) ? hora.getMinutes() : '0' + hora.getMinutes();
+                    _hora = '[' + hora.getHours() + ':' + minuto + '] ';
+                    data[i].body = decodeURI(data[i].body).replace(/\\\'/g, '\'');
+	                
+	                if ( mensagens )
+	                {
+	                   mensagens.innerHTML += '<strong>' + _hora + nickname + ' fala:</strong><br/> ' + _this.emotions_icons(data[i].body) + '<br/>';
+                       if ( windowItems[data[i].from.substr(0, data[i].from.indexOf('/'))].state != WINDOW_STATE_REGULAR && windowItems[data[i].from.substr(0, data[i].from.indexOf('/'))].state != WINDOW_STATE_MAXIMIZED )
+                          im_win.showWindowItem(data[i].from.substr(0, data[i].from.indexOf('/')));
+	                }
+	                else
+	                {
+	                   im_win.open_chat(data[i].from.substr(0, data[i].from.indexOf('/')));
+	                   mensagens = document.getElementById(data[i].from.substr(0, data[i].from.indexOf('/')) + '_chatMessages');
+	                   mensagens.innerHTML += '<strong>' + _hora + nickname + ' fala:</strong><br/> ' + _this.emotions_icons(data[i].body) + '<br/>';
+	                }
+				}
+				mensagens.scrollTop = mensagens.scrollHeight;
+				im_win.newMessageNotification();
+			}
+		}
+		cIM.cExecute("$this.Ujabber.getMessages", handler_message);			
+	}
+
+	/*
+	 * Envia Mensagens
+	 */
+
+   IM.prototype.sendMessage = function (pJID)
+   {
+      var _this = this;
+      var name_document = document.getElementById(pJID + '_edita');
+      var envio = name_document.contentWindow.document.getElementsByTagName('body').item(0);
+
+      envio.innerHTML = func.trim(envio.innerHTML.replace(/^(&nbsp;|<br>| )*|(&nbsp;|<br>| )*$/g, ''));
+
+      if ( envio.innerHTML != "" )
+      {
+         var message_text  = "<div style='";
+         message_text += (envio.style.fontFamily != "") ? "font-family:"+envio.style.fontFamily+";" : "";
+         message_text += (envio.style.fontSize != "") ? "font-size:"+envio.style.fontSize+";" : "" ;
+         message_text += (envio.style.fontWeight != "") ? "font-weight:"+envio.style.fontWeight+";": "";
+         message_text += (envio.style.fontStyle != "" ) ? "font-style:"+envio.style.fontStyle+";" : "";
+         message_text += (envio.style.color != "") ? "color:"+envio.style.color+";" : "color:black";
+         message_text += "'>";
+         message_text += envio.innerHTML + "</div>";
+
+         envio.innerHTML = '';
+
+         var message_element = document.getElementById(pJID + '_chatMessages');
+         message_element.innerHTML += '<strong>' + ((_this.vcard_user['VCARD_NICKNAME'] != "") ? _this.vcard_user['VCARD_NICKNAME'] : _this.vcard_user['VCARD_JID'] );
+         message_element.innerHTML += ' ' + _this.get_lang('speak') + ':</strong><br/>';
+         message_element.innerHTML += _this.emotions_icons(message_text.replace(/^(&nbsp;|<br>| )*|(&nbsp;|<br>| )*$/g, '')) + '<br/>';
+
+         message_element.scrollTop = message_element.scrollHeight;
+
+         var handler_sendMessage = function(data)
+         {
+            if(!data)
+               alert(data);
+         }
+         cIM.cExecute("$this.Ujabber.SendMessage",handler_sendMessage,"to="+pJID+"&body="+url_encode(encodeURI(message_text)));
+      }
+   }
+	
+	/*
+	 *  Smiles
+	 */
+
+   IM.prototype.emotions_icons = function(pMessage)
+   {
+      for ( i = 1; i < cod_emotions.length; i++ )
+      {
+         var image = eval('smile_' + i + '.src.substr(smile_' + i + '.src.indexOf(im_path))')
+         pMessage  = pMessage.replace(cod_emotions[i], '<img src="' + image + '">');
+      }
+      return pMessage;
+   }
+
+   IM.prototype.atalho = function()
+   {
+      if ( local = func.byId('user_info') )
+      {
+         var aux  = new Array();
+         var _mix = func.newEl('a', 'a', 'img', 'img', 'dl');
+
+         var fast_menu_link  = _mix[0];
+         var contacts_link   = _mix[1];
+         var fast_menu_image = _mix[2];
+         var contacts_image  = _mix[3];
+         var im_fast_menu    = _mix[4];
+
+         fast_menu_link.onclick = function(){IM.showFastMenu();};
+         contacts_link.onclick  = function(){IM.showContacts();};
+
+         aux['fast_menu_image'] = new Array();
+         aux['fast_menu_image']['element'] = fast_menu_image;
+         aux['fast_menu_image']['style']   = 'width:9px;height:9px';
+         aux['fast_menu_image']['src']     = im_path + 'templates/default/images/menuarwopen.gif';
+
+         aux['im_fast_menu'] = new Array();
+         aux['im_fast_menu']['element'] = im_fast_menu;
+         aux['im_fast_menu']['id']      = 'fast_menu_im';
+         aux['im_fast_menu']['class']   = 'menu_im';
+
+         aux['contacts_image'] = new Array();
+         aux['contacts_image']['element'] = contacts_image;
+         aux['contacts_image']['id']      = 'chat_bubble';
+         aux['contacts_image']['src']     = im_path + 'templates/default/images/navbar.png';
+         aux['contacts_image']['style']   = 'width:15px;height:15px';
+         func.confEl(aux);
+
+         func.insEl(fast_menu_image, fast_menu_link);
+         func.insEl(contacts_image, contacts_link);
+         func.insElB(fast_menu_link, contacts_link, im_fast_menu, document.createTextNode(' '), local.firstChild);
+      }
+      else
+         setTimeout('IM.atalho()', 5000);
+   }
+
+   IM.prototype.showFastMenu = function()
+   {
+      if ( !messages_timeout )
+      {
+         var option       = func.newEl('dt');
+         var option_link  = func.newEl('a');
+         var option_image = func.newEl('img');
+
+         option_link.onclick = function(){IM.login();};
+
+         func.confEl(option_image, 'src', img_online.src);
+         func.confEl(option_image, 'style', 'width:16px;height:16px;');
+
+         func.insEl(option_image, IM.get_lang('login'), option_link);
+         func.insEl(option_link, option);
+
+         im_menu_action.menu('fast_menu_im', option);
+      }
+      else
+      {
+         var _dt = func.newEl('dt', 'dt', 'dt', 'dt', 'dt');
+         var _a  = func.newEl('a', 'a', 'a', 'a', 'a');
+
+         for ( var i in _dt )
+         {
+            if ( typeof _dt[i] == 'function' )
+               continue;
+            eval('var option' + (parseInt(i)+1) + ' = _dt[' + i + '];');
+            eval('var option' + (parseInt(i)+1) + '_link = _a[' + i + '];');
+         }
+
+         var _img = func.newEl('img', 'img', 'img', 'img');
+
+         for ( var i in _img )
+         {
+            if ( typeof _dt[i] == 'function' )
+               continue;
+            eval('var option' + (parseInt(i)+1) + '_image = _img[' + i + '];');
+         }
+
+         option1_link.onclick = function(){IM.setStatus('online');};
+         option2_link.onclick = function(){IM.setStatus('idle');};
+         option3_link.onclick = function(){IM.setStatus('busy');};
+         option4_link.onclick = function(){IM.logout();};
+         option5_link.onclick = function(){IM.setStatus('custom')};
+
+         func.confEl(option1_image, 'src', img_online.src);
+         func.confEl(option1_image, 'style', 'width:16px;height:16px;');
+         func.confEl(option2_image, 'src', img_idle.src);
+         func.confEl(option2_image, 'style', 'width:16px;height:16px;');
+         func.confEl(option3_image, 'src', img_busy.src);
+         func.confEl(option3_image, 'style', 'width:16px;height:16px;');
+         func.confEl(option4_image, 'src', img_offline.src);
+         func.confEl(option4_image, 'style', 'width:16px;height:16px;');
+
+         func.insEl(option1_image, IM.get_lang('online'), option1_link);
+         func.insEl(option1_link, option1);
+         func.insEl(option2_image, IM.get_lang('????'), option2_link);
+         func.insEl(option2_link, option2);
+         func.insEl(option3_image, IM.get_lang('busy'), option3_link);
+         func.insEl(option3_link, option3);
+         func.insEl(option4_image, IM.get_lang('offline'), option4_link);
+         func.insEl(option4_link, option4);
+         func.insEl(IM.get_lang('Custom message...'), option5_link);
+         func.insEl(option5_link, option5);
+
+         im_menu_action.menu('fast_menu_im', option1, option2, option3, option4, option5);
+      }
+   }
+
+   IM.prototype.setStatus = function(pStatus)
+   {
+      im_menu_action.menu('fast_menu_im', null);
+   }
+
+   IM.prototype.getStatus = function()
+   {
+   }
+
+   IM.prototype.login = function()
+   {
+      try
+      {
+         im_menu_action.menu('fast_menu_im', null);
+         Sincro.get_list();
+         Sincro.get_Message();
+         var contacts_image = func.byId('chat_bubble');
+         contacts_image.parentNode.onclick = function(){IM.showContacts()};
+         func.confEl(contacts_image, 'src', im_path + 'templates/default/images/navbar.png');
+      }
+      catch (e)
+      {
+      }
+   }
+
+   IM.prototype.logout = function()
+   {
+      im_menu_action.menu('fast_menu_im', null);
+      clearTimeout(messages_timeout);
+      clearTimeout(contacts_timeout);
+      messages_timeout = false;
+      contacts_timeout = false;
+      var contacts_image = func.byId('chat_bubble');
+      contacts_image.parentNode.onclick = function(){IM.showFastMenu()};
+      func.confEl(contacts_image, 'src', img_chat_bubble.src);
+   }
+
+   IM.prototype.menu_preferences = function(pElement)
+   { 
+      if ( document.getElementById(pElement).innerHTML == "" )
+      {
+         var form_pref  = "<dl>";
+            form_pref += "<dt><a href='javascript:void(0)' onclick='javascript:Preferences.Add_userLoad()'>";
+            form_pref += "<img src="+img_menu.src+">&nbsp;"+IM.get_lang('Add Contact')+"</a></dt>";
+            form_pref += "<dt><a href='javascript:void(0)' onclick='javascript:Preferences.Remove_userLoad()'>";
+            form_pref += "<img src="+img_menu.src+">&nbsp;"+IM.get_lang('Remove Contact')+"</a></dt>";
+            form_pref += "<dt><a href='javascript:void(0)' onclick='javascript:Preferences.vCardLoad()'>";
+            form_pref += "<img src="+img_menu.src+">&nbsp;"+IM.get_lang('Information')+"</a></dt>";
+            form_pref += "</dl>";
+         im_menu_action.menu(pElement, form_pref);
+      }
+   }
+
+   IM.prototype.menu_button_right = function(pElement)
+   {
+      var form_menu_button_right = '<dl>'+
+                                   '<dt><a href="javascript:void(0);" onclick="javascript:Preferences.Update_NickName(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Nick') + '</a>'+
+                                   '<dt><a href="javascript:void(0);" onclick="javascript:Preferences.SendFile(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Send File') + '</a>'+
+                                   '<dt><a href="javascript:void(0);" onclick="javascript:Preferences.Update_Group(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Group') + '</a>'+
+                                   '<dt><a href="javascript:void(0);" onclick="javascript:Preferences.Remove_Contact(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('Delete') + '</a>'+
+                                   '<dt><a href="javascript:void(0);" onclick="javascript:Preferences.vCardLoad_Contact(\''+pElement+'\');"><img src="'+img_group_close.src+'">' + IM.get_lang('See Info') + '</a>'+
+                                   '</dl>';
+      im_menu_action.menu("_span_" + pElement, form_menu_button_right);
+   }
+
+	/*
+	 * url_encode
+	 */
+	
+	function url_encode(str)
+   { 
+	    var hex_chars = "0123456789ABCDEF"; 
+	    var noEncode = /^([a-zA-Z0-9\_\-\.])$/; 
+	    var n, strCode, hex1, hex2, strEncode = ""; 
+	
+	    for( n = 0; n < str.length; n++ )
+       { 
+	        if ( noEncode.test(str.charAt(n)) )
+           { 
+	            strEncode += str.charAt(n); 
+	        }
+           else
+           { 
+	            strCode = str.charCodeAt(n); 
+	            hex1 = hex_chars.charAt(Math.floor(strCode / 16)); 
+	            hex2 = hex_chars.charAt(strCode % 16); 
+	            strEncode += "%" + (hex1 + hex2); 
+	        } 
+	    } 
+	    return strEncode; 
+	}  
+
+	/*
+	 *  Ação do botão onclick da lista de contatos;
+	 */
+
+	IM.prototype.action_button = function(pEv,pStatus,pJid)
+	{
+		var _this = this;
+		if(pEv.button > 1){
+			_this.menu_button_right(pJid);
+			document.oncontextmenu = new Function("return false");
+		}else{
+			if(pStatus == parseInt(1))
+				_this.open_chat(pJid);
+		}
+	}
+	
+	/*
+	 * Abre Conversa
+	 */
+
+	IM.prototype.open_chat = function(pJID)
+	{
+      func.byId(pJID).firstChild.src = img_chat_bubble.src;
+      im_win.open_chat(pJID);
+	}
+
+
+	String.prototype.rm_space = function()
+	{
+    	return this.replace(/( *)/g,"");
+	}
+
+	IM.prototype.LTrim = function(value)
+	{
+		var w_space = String.fromCharCode(32);
+		var strTemp = "";
+		var iTemp = 0;
+
+		if(v_length < 1) return "";
+
+		var v_length = value ? value.length : 0;
+
+		while ( iTemp < v_length )
+		{
+			if ( value && value.charAt(iTemp) != w_space )
+			{
+				strTemp = value.substring(iTemp,v_length);
+				break;
+			}
+			iTemp++;
+		}	
+		return strTemp;
+	}
+
+	function teste(pJID)
+	{
+		document.getElementById(pJID + '_edita').onkeydown = function (e){
+			if (is_ie)
+			{
+				if ((window.event.keyCode) == 13)
+					send(pJID);
+			}
+			else
+			{
+				if ((e.keyCode) == 13)
+				{
+					send(pJID);
+					return false;
+				}
+			}
+		}
+	}
+
+// Build Object	
+	var IM = new IM();
Index: /trunk/instant_messenger/js/im_conf_font.js
===================================================================
--- /trunk/instant_messenger/js/im_conf_font.js	(revision 20)
+++ /trunk/instant_messenger/js/im_conf_font.js	(revision 20)
@@ -0,0 +1,55 @@
+var im_conf_font = {
+    
+    content   : null,
+	
+	"get_element" : function()
+	{
+		var _document = document.getElementById(im_win.chat_pJid + '_edita');
+		this.content = _document.contentWindow.document.getElementsByTagName('body').item(0);
+
+	},
+
+	"changeFont" : function(nameFont)
+	{
+  	    this.get_element();
+	    this.content.style.fontFamily = nameFont;
+	    this.content.innerHTML = this.content.innerHTML;
+	    im_win.hideFontNameSelection();
+	},
+	
+	"changeSizeFont" : function(SizeFont)
+	{
+		this.get_element();
+		this.content.style.fontSize = SizeFont;
+		this.content.innerHTML = this.content.innerHTML;
+		im_win.hideFontSizeSelection();
+	},
+	
+	"changeFontColor" : function(ColorFont)
+	{
+		this.get_element();
+		this.content.style.color = ColorFont;
+		this.content.innerHTML = this.content.innerHTML;
+		im_win.hideFontColorSelection();
+	},
+	
+	"changeFontStyle" : function(StyleFont)
+	{
+		this.get_element();
+		if(StyleFont == "bold")
+			this.content.style.fontWeight = "bold";
+		else{
+			this.content.style.fontWeight = "normal";
+			this.content.style.fontStyle = StyleFont;
+		}
+		this.content.innerHTML = this.content.innerHTML;
+		im_win.hideFontStyleSelection();
+	},
+	
+	"defaultOptions" : function()
+	{
+		this.content.style.fontStyle = "normal"	;
+		this.content.style.color = "000000";
+		this.content.style.fontStyle = "10pt";
+	}
+}
Index: /trunk/instant_messenger/js/xml.js
===================================================================
--- /trunk/instant_messenger/js/xml.js	(revision 20)
+++ /trunk/instant_messenger/js/xml.js	(revision 20)
@@ -0,0 +1,150 @@
+var XMLTools = {
+	"_defaultUrl" : im_path + 'controller.php?action=',
+   "_debug" : false,
+	"_http" : null,
+	"mode" : 'X',
+   "threads" : [],
+	"http" : function()
+	{
+		try
+		{
+			this._http = new XMLHttpRequest();
+		}
+		catch (e)
+		{
+			try
+			{
+				this._http = new ActiveXObject('Msxml2.XMLHTTP');
+			}
+			catch (e1)
+			{
+				try
+				{
+					this._http = new ActiveXObject('Microsoft.XMLHTTP');
+				}
+				catch (e2)
+				{
+					this._http = null;
+				}
+			}
+		}
+	},
+	"load" : function(pFile)
+	{
+		var data = null;
+		if ( document.implementation.createDocument )
+			data = document.implementation.createDocument("", "", null);
+		else
+			data = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
+
+		data.async = false;
+		data.load(pFile);
+		return data;
+	},
+	"request" : function(pId, pTarget, pMethod, pHandler, pData)
+	{
+		if ( typeof pHandler != 'function' )
+			return false;
+
+      if ( this.threads[pId] )
+         return false;
+      else
+         this.threads[pId] = pHandler;
+
+		var _pTarget = pId;
+
+		var _this = this;
+		this.http();
+		var _http = this._http;
+		var _handler = function ()
+		{
+			try
+			{
+				switch( _http.readyState )
+				{
+					case 1 :
+					break;
+					case 2 :
+					break;
+					case 3 :
+					break;
+					case 4 :
+							switch ( _http.status )
+							{
+								case 200:
+										var data = ( _this.mode == 'X' ) ?
+										               _http.responseXML :
+                                             _http.responseText;
+
+										pHandler(data, _pTarget);
+                              _this.threads[_pTarget] = false;
+                              delete _this.threads[_pTarget];
+								break;
+								case 404:
+										alert('Page Not Found!');
+								break;
+								default:
+							}
+					break;
+					default:
+				}
+			}
+			catch(e)
+			{
+				if ( this._debug ) alert(e)
+			}
+		}
+		
+		try
+		{
+			var target = pTarget;
+			if ( pMethod == 'POST' )
+			{
+				_http.open("POST", target, true);
+				_http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
+				_http.setRequestHeader('Cache-Control',  'no-store, no-cache, must-revalidate');
+				_http.setRequestHeader('Cache-Control', 'post-check=0, pre-check=0');
+				_http.setRequestHeader('Pragma', 'no-cache');
+				_http.onreadystatechange = _handler;
+				_http.send(pData);
+			}
+			else
+			{
+				_http.open("GET", target, true);
+				_http.onreadystatechange = _handler;
+				_http.send(null);
+			}
+		}
+		catch(e)
+		{}
+		return true;
+	},
+	"transform" : function(pXML, pXSL)
+	{
+		var fragment = null;
+		if ( window.XSLTProcessor )
+		{
+			var xslProc = new XSLTProcessor();
+			xslProc.importStylesheet(pXSL);
+			fragment = xslProc.transformToFragment(pXML, document);
+			
+			// para retornar valor igual ao ie.
+			var aux = document.createElement("div");
+			aux.appendChild(fragment);
+			fragment = aux.innerHTML;
+		}
+		else
+		{
+			var xslTemplate = new ActiveXObject("Msxml2.XSLTemplate");
+			xslTemplate.stylesheet = pXSL;
+
+			var myXslProc = xslTemplate.createProcessor();
+			myXslProc.input = pXML;
+
+			myXslProc.transform();
+			fragment = myXslProc.output;
+			
+		}
+		return fragment;
+	}
+}
Index: /trunk/instant_messenger/index.php
===================================================================
--- /trunk/instant_messenger/index.php	(revision 20)
+++ /trunk/instant_messenger/index.php	(revision 20)
@@ -0,0 +1,48 @@
+<?php
+	/****************************************************\
+	 *													*
+	 * 	 			Im - Instant Messenger				*
+	 *													*
+	\****************************************************/
+	
+	$GLOBALS['phpgw_info']['flags'] = array(
+		'currentapp' => 'instant_messenger',
+		'im_version'	=> '0.001'
+	);
+	
+	include("../header.inc.php");
+    $im_version = $GLOBALS['phpgw_info']['flags']['im_version'];
+
+	// Template  
+	$template_1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+	$template_1->set_file(Array('instant_messenger' => 'index.tpl'));
+	$template_1->set_block('instant_messenger','index');
+	$template_1->pfp('out','index');
+	
+	// Session
+	$_SESSION['phpgw_info']['instant_messenger']['user'] 			      = $GLOBALS['phpgw_info']['user']['account_lid'];
+	$_SESSION['phpgw_info']['instant_messenger']['passwd'] 			      = $GLOBALS['phpgw_info']['user']['passwd'];
+	$_SESSION['phpgw_info']['instant_messenger']['name_jabber'] 	      = $GLOBALS['phpgw_info']['server']['name_jabber'];
+	$_SESSION['phpgw_info']['instant_messenger']['port_jabber'] 	      = $GLOBALS['phpgw_info']['server']['port_jabber'];
+	$_SESSION['phpgw_info']['instant_messenger']['resource_jabber']       = $GLOBALS['phpgw_info']['server']['resource_jabber'];
+	$_SESSION['phpgw_info']['instant_messenger']['send_file_jabber']      = $GLOBALS['phpgw_info']['server']['send_file_jabber'];
+	// Conf. Ldap
+	$_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']    = $GLOBALS['phpgw_info']['server']['server_ldap_jabber'];
+	$_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']   = $GLOBALS['phpgw_info']['server']['context_ldap_jabber'];
+	$_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']      = $GLOBALS['phpgw_info']['server']['user_ldap_jabber'];
+	$_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber']  = $GLOBALS['phpgw_info']['server']['password_ldap_jabber'];	
+	$_SESSION['phpgw_info']['instant_messenger']['size_file_jabber']  	  = $GLOBALS['phpgw_info']['server']['size_file_jabber'];	
+	
+	$_SESSION['phpgw_info']['instant_messenger']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name'];
+	$_SESSION['phpgw_info']['instant_messenger']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host'];
+	$_SESSION['phpgw_info']['instant_messenger']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port'];
+	$_SESSION['phpgw_info']['instant_messenger']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user'];
+	$_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass'];	
+	$_SESSION['phpgw_info']['instant_messenger']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type'];
+
+	// Footer
+	$GLOBALS['phpgw']->common->phpgw_footer();
+     
+	// Language
+	echo "<script src='/instant_messenger/inc/load_lang.php?".$im_version."' type='text/javascript'></script>";
+?>
Index: /trunk/instant_messenger/templates/default/css.css
===================================================================
--- /trunk/instant_messenger/templates/default/css.css	(revision 20)
+++ /trunk/instant_messenger/templates/default/css.css	(revision 20)
@@ -0,0 +1,408 @@
+b.rnd
+{
+   background:	#fff;
+   display:	block;
+   font-size:	1px;
+}
+b.rnd b
+{
+   display:	block;
+   height:		1px;
+   overflow:	hidden;
+}
+b.rnd1
+{
+   border-color:     #809aa9;
+   border-width:     1px 1px 0px 1px;
+   border-style:     solid;
+   background:						#cbdae4;
+   margin:							0px 2px;
+}
+b.rnd2
+{
+      border-color:     #809aa9;
+      border-width:     0px 1px 0px 1px;
+      border-style:     solid;
+      background:					   #cbdae4;
+	  margin:							0px 1px;
+}
+
+/* IM:WINDOW - ADD USER */
+
+select.add_user
+{
+   font-family:   Tahoma, Verdana, sans-serif;
+   font-size:     8pt;
+   font-weight:   normal;
+   border-color:  #809aa9;
+   border-width:  1px 1px;
+   border-style:  solid;
+   margin:        2px 2px 2px 2px;
+   width:    	  493px;
+
+
+}
+
+/* IM:WINDOW */
+
+.im_window_fantom
+{
+	position: absolute;
+	padding: 0px;
+	border-style: dashed;
+	border-width: 1px 1px 1px 1px;
+	border-color: #000000;
+	background-color: #ffffff;
+	overflow: hidden;
+}
+
+.im-windowfantom-des
+{
+	position: absolute;
+	padding: 0px;
+	overflow: hidden;
+}
+
+.im-window
+{
+    background: transparent;
+	position:   absolute;
+}
+
+.im-window-resizehandle
+{
+	position: absolute;
+	overflow: hidden;
+	width: 15px;
+	height: 15px;
+    background-image: url(images/img/winresize2.gif);
+}
+
+.im-window-sel {
+	z-index: 100;
+}
+
+.im-window-des {
+	z-index: 50;
+}
+
+/* IM:WINDOWHEAD */
+
+.im_window_head
+{
+   background:    #cbdae4;
+   border-color:  #809aa9;
+   border-width:  0px 1px;
+   border-style:  solid;
+   height:        24px;
+	margin:        0px;
+	overflow:      hidden;
+	width:         258px;
+}
+
+.im-window-sel .im-windowhead {
+	background-position: 0 0;
+}
+
+.im-window-des .im-windowhead {
+	background-position: 0 -25px;
+}
+
+.im-window-flash .im-windowhead {
+	background-position: 0 0px;
+        background-image: url(images/img/flash_win_top_left2.gif);
+}
+
+.im-windowhead-right{
+	padding-right: 5px;
+	margin: 0;
+	background: 100% 0 transparent no-repeat;
+        background-image: url(images/img/win_top_right.gif);
+	overflow: hidden;
+}
+
+.im-window-sel .im-windowhead-right{
+	background-position: 100% 0;
+}
+
+.im-window-des .im-windowhead-right{
+	background-position: 100% -25px;
+}
+
+.im-window-flash .im-windowhead-right{
+	background-position: 100% 0;
+        background-image: url(images/img/flash_win_top_right2.gif);
+}
+
+.im-windowhead-mid {
+	position: relative;
+	background-position: 0 0;
+        background-image: url(images/img/win_top_mid.gif);
+	background-repeat: repeat-x;
+	overflow: hidden;
+	line-height: 25px;
+	height: 25px;
+	cursor: auto;
+	font-weight: bold;
+	padding-left: 24px;
+}
+
+.im-window-sel .im-windowhead-mid {
+	background-position: 0 0;
+	color: #000000;
+}
+
+.im-window-des .im-windowhead-mid {
+	background-position: 0 -25px;
+	color: #aaaaaa;
+}
+
+.im-window-flash .im-windowhead-mid {
+	background-position: 0 0;
+        background-image: url(images/img/flash_win_top_mid2.gif);
+	color: #aaaaaa;
+}
+
+.im_window_title
+{
+   cursor:        move;
+   float:         left;
+   font-weight:   bolder;
+   height:        16px;
+   left:          8px;
+   overflow:      hidden;
+   position:   	  relative;
+   top:           3px;
+   width:         166px;
+}
+.im_window_icon
+{
+    background: url(images/img/favicon.ico) 0 0 no-repeat;
+    float:      left;
+	height:     16px;
+    left:       4px;
+	overflow:   hidden;
+    position:   relative;
+    top:        3px;
+	width:      16px;
+}
+
+
+/* IM:WINDOWBODY */
+
+
+.im_window_body
+{
+	background-color: #cbdae4;
+	border-color:     #809aa9;
+	border-style:     solid;
+	border-width:     0px 1px 1px 1px;
+}
+
+.im_window_body_inner
+{
+	background: #fff;
+    border:     1px solid #809aa9;
+    margin:  0px 3px;
+	overflow: auto;
+}
+
+.im-window-des .im-windowbody {
+	border-color: #d0dfe5;
+	background-color: #f0f5f8;
+
+}
+
+.im-window-flash .im-windowbody {
+	border-color: #d0dfe5;
+	background-color: #f0f5f8;
+    background-image: url(images/img/flash_window_background.gif);
+}
+
+.im-window-des .im-windowbody-inner {
+	border-color: #b9cfd8;
+}
+
+.edit_message
+{
+	background-color: #fff;
+   border:           2px solid #c9d9e8;
+	color:            #000;
+	font-family:      Tahoma, Verdana, sans-serif;
+	font-size:        10pt;
+	font-weight:      normal;
+   padding:          0px;
+}
+
+/* WINDOWBUTTONS */
+
+.im_window_head_buttons
+{
+    display:       block;
+    float:         left;
+	height:        15px;
+    padding-top:   6px;
+	position:      relative;
+	right:         0px;
+	width:         53px;
+}
+
+.im-window-sel .im-windowbutton-container {
+	background-position: 0 0;
+}
+
+.im-window-des .im-windowbutton-container {
+	background-position: 0 -25px;
+}
+
+.im-window-button {
+	margin: 1px 0px 0 2px;
+	/*float: left;*/
+   /*float: right;*/
+   /*clear: both;*/
+	height: 13px;
+	width: 13px;
+   position: absolute;
+	cursor: pointer;
+   top: 3px;
+   /*left: 20px;
+   /*right: 10px;*/
+}
+
+.im-window-sel .im-window-button {
+	background-position: 0 0;
+}
+
+.im-window-sel .im-window-button-hov {
+	background-position: 0 -13px;
+}
+
+.im-window-sel .im-window-button-pres {
+	background-position: 0 -26px;
+}
+
+.im-window-des .im-window-button {
+	background-position: 0 -39px;
+}
+
+.im-window-des .im-window-button-hov {
+	background-position: 0 -52px;
+}
+
+.im-window-des .im-window-button-pres {
+	background-position: 0 -65px;
+}
+
+.im-window-closebutton {
+   background-image: url(images/img/close.gif);
+}
+
+.im-window-maximizerestorebutton {
+   background-image: url(images/img/max.gif);
+}
+
+.im-window-minimizebutton {
+   background-image: url(images/img/min.gif);
+}
+
+/* IM:TASKBAR */
+
+.im-taskbar
+{
+	position: absolute;
+	width: 100%;
+	height: 27px;
+	z-index: 101; 
+	background-position: 0 0;
+	background-repeat: repeat;
+    overflow: hidden;
+}
+
+/* IM:TASKBARITEM */
+
+.im-taskbaritem-des {
+	position: absolute;
+	top: 0;
+	right: 0;
+	width: 150px;
+	height: 22px;
+    border-style: solid;
+	border-width: 1px 1px 1px 1px;
+	border-color: #B9CFD8;
+    background-position: 0 -4px;
+    background-image: url(images/img/win_top_mid.gif);
+    padding: 3px 10px;
+    color: #555555;
+    -moz-box-sizing: border-box;
+    cursor:pointer ;
+}
+
+.im-taskbaritem-flash {
+	position: absolute;
+	top: 0;
+	right: 0;
+	width: 150px;
+	height: 22px;
+        border-style: solid;
+        border-color: #B9CFD8;
+	border-width: 1px 1px 1px 1px;
+        background-position: 0 0;
+        background-image: url(images/img/flash_window_background.gif);
+        background-repeat: repeat;
+        padding: 3px 10px;
+        color: #555555;
+        -moz-box-sizing: border-box;
+        cursor:pointer ;
+}
+
+.im-taskbaritem {
+    position: absolute;
+	top: 0;
+	right: 0;
+	width: 150px;
+	height: 22px;
+    border-style: solid;
+	border-width: 1px 1px 1px 1px;
+	border-color: #B9CFD8;
+        background-position: 0 -26px;
+        background-image: url(images/img/win_top_mid.gif);
+        padding: 3px 10px;
+        color: #999999;
+        -moz-box-sizing: border-box;
+        cursor:pointer;
+}
+
+.menu_im
+{
+   /*border-bottom: 1px solid #ccc;*/
+   display:       none;
+   /*float:         left;*/
+   list-style:    none;
+   margin:        0px;
+   padding:       0px;
+   position:      absolute;
+   width:         150px; /* Width of Menu Items */
+	z-index:       1000;
+}
+
+.menu_im dt a
+{
+   background:      #cbdae4;
+   border:          1px solid #b9cfd8;
+   border-bottom:   0px;
+   color:           #000;
+   display:         block;
+   padding:         2px;
+   text-decoration: none;
+}
+
+.menu_im dt a:hover
+{
+   color:      #e2144a;
+   background: #f9f9f9;
+}
+
+.contato_hover
+{
+   background-color: #cbdae4;
+}
Index: /trunk/instant_messenger/templates/default/messenger.css
===================================================================
--- /trunk/instant_messenger/templates/default/messenger.css	(revision 20)
+++ /trunk/instant_messenger/templates/default/messenger.css	(revision 20)
@@ -0,0 +1,365 @@
+div.border
+{
+   margin-top: 0px;
+   border: 2px solid #C9D9E8;
+   padding: 0px;
+   float: left;
+}
+
+div.popupChecker
+{
+   position : absolute;
+   left : 15px;
+   top : 100px;
+   background : #FFFFFF;
+   width : 200px;
+   height : 100px;
+   text-align : center;
+   visibility : hidden;
+}
+
+div.deleteContact
+{
+    position : absolute;
+    left : 20px;
+    top : 100px;
+    background : #FFFFFF;
+    width : 250px;
+    height : 150px;
+    text-align : center;
+    visibility : hidden;
+}
+
+div.flyMenu
+{
+    position : absolute;
+    left : 75px;
+    top : 100px;
+    border: 2px solid #C9D9E8;
+    background : #DFEFFE;
+    width : 150px;
+    height : 60px;
+    text-align : left;
+    visibility : hidden;
+}
+
+div.statusMenu
+{
+    position : absolute;
+    border: 1px solid #C9D9E8;
+    background : #DFEFFE;
+    text-align : left;
+    visibility : hidden;
+}
+
+.flyMenuClass
+{
+    position:absolute;
+    width:150px;
+    border:2px solid #C9D9E8;
+    background-color:#DFEFFE;
+    line-height:20px;
+    cursor:default;
+    font-size:11px;
+    z-index:100;
+    visibility:hidden;
+}
+
+.menuitems
+{
+    padding-left:10px;
+    padding-right:10px;
+    font-size:11px;
+    border: 1px solid #DFEFFE;
+    cursor:pointer ;
+}
+
+.padding
+{
+    padding-left:10px;
+    padding-right:10px;
+    font-size:11px;
+}
+
+.contactItem
+{
+    font-size:11px;
+}
+
+table.border
+{
+    margin-top: 0px;
+    border: 2px solid #C9D9E8;
+    padding: 0px;
+    float: left;
+}
+
+p.small
+{
+	font-family : Tahoma, Verdana, Arial, sans-serif ;
+	font-size : 8pt;
+
+}
+
+span.small
+{
+	font-family : Tahoma, Verdana, Arial, sans-serif ;
+	font-size : 8pt;
+}
+
+p.small-red
+{
+	font-family : Tahoma, Verdana, Arial, sans-serif ;
+	font-size : 8pt;
+    color: #FF0000;
+}
+
+font.small
+{
+	font-family : Tahoma, Verdana, Arial, sans-serif ;
+	font-size : 8pt;
+}
+
+font.small-grey
+{
+	font-family : Tahoma, Verdana, Arial, sans-serif ;
+	font-size : 8pt;
+}
+
+font.large
+{
+	font-family : Tahoma, Verdana, Arial, sans-serif ;
+	font-size : 12pt;
+}
+
+table.window
+{
+	font-family : Tahoma, Verdana, Arial, sans-serif ;
+	font-size : 10pt;
+	border : 1px solid Black;
+}
+
+table.excel
+{
+	font-family : Tahoma, Verdana, Arial, sans-serif ;
+	font-size : 8pt;
+	border : 0px dashed Black;
+}
+
+div.sel
+{
+  	position: absolute;
+  	padding: 0px 4px 2px;
+  	border: solid 1px;
+  	border-color: #C9D9E8;
+  	background: #ffffff;
+}
+
+div.des
+{
+  	position: absolute;
+  	border: 0px;
+  	padding: 1px 5px 3px;
+}
+
+div.sel-small
+{
+  	position: relative;
+  	padding: 1px 6px 1px 6px;
+  	border: solid 1px;
+  	border-color: #C9D9E8;
+  	background: #DFEFFF;
+  	cursor:pointer;
+  	-moz-box-sizing: border-box;
+}
+
+div.des-small
+{
+  	position: relative;
+  	border: 0px;
+  	padding: 2px 7px 2px 7px;
+  	cursor:pointer ;
+  	-moz-box-sizing: border-box;
+}
+
+span.sel-small
+{
+  	position: relative;
+  	padding: 0px 2px;
+  	border: solid 1px;
+  	border-color: #C9D9E8;
+  	background: #DFEFFF;
+  	cursor:pointer;
+  	-moz-box-sizing: border-box;
+}
+
+span.des-small
+{
+  	position: relative;
+  	border: 0px;
+  	padding: 1px 3px;
+  	cursor:pointer ;
+  	-moz-box-sizing: border-box;
+}
+
+div.menuitems
+{
+    padding: 2px;
+    padding-left:10px;
+    padding-right:10px;
+    font-size:11px;
+    border: 1px solid #DFEFFE;
+    background : #DFEFFE;
+    cursor:pointer ;
+}
+
+div.menuitems-sel
+{
+    padding: 2px;
+    padding-left:10px;
+    padding-right:10px;
+    font-size:11px;
+    border: 1px solid #C9D9E8;
+    background: #ffffff;
+    cursor:pointer ;
+}
+
+div.emotionFrame 
+{
+    position: absolute;
+    border: 1px solid #A9B9C8;
+    background: #DFEFFE;
+}
+
+div.emotionItem
+{
+    padding: 2px;
+    font-size:11px;
+    background: #ffffff;
+    border: 1px solid #DFEFFE;
+    cursor:pointer ;
+}
+
+div.emotionItem-sel
+{
+    padding: 1px;
+    font-size:11px;
+    background: #FFFFFF;
+    border: 2px solid #99a9b8;
+    cursor: pointer;
+}
+
+div.myAvatar
+{
+    background: #fff;
+    border:     1px solid #b9cfd8;
+    float:      left;
+    height:     65px;
+    padding:    2px;
+    position:   relative;
+    cursor:     pointer;
+    width:      49px;
+}
+
+div.avatarSelection
+{
+    position: relative;
+    border-style: solid;
+	border-width: 1px 1px 1px 1px;
+	border-color: #B9CFD8;
+    background-color: #ffffff;
+    padding: 2px;
+    cursor:pointer ;
+    -moz-box-sizing: border-box;
+}
+
+dl
+{
+    margin: 0px;
+    padding: 0px;
+}
+dd
+{
+    margin: 0px;
+    padding: 0px;
+   display: inline;   
+}
+
+   .master
+   {
+      /*border:1px solid red;*/
+      height:     250px;
+      margin:     0px;
+      padding:    0px;
+	   position:   absolute;
+      overflow:   hidden;
+      width:      350px;
+      z-index:    1;
+   }
+   .pai
+   {
+      background: #cbdae4 url(templates/default/images/icone.png) 4px 2px no-repeat;
+      border:     1px solid #809aa9;
+      border-top: 0px;
+      height:     242px;
+      margin:     0px 0px 0px 0px;
+      padding:    3px 2px 0px 0px;
+	   position:   relative;
+      z-index:    1;
+   }
+   .filho
+   {
+      background: #fff;
+      border:     1px solid #809aa9;
+      height:     208px;
+      left:       4px;
+      margin:     0px 0px 15px 0px;
+      overflow:   auto;
+      position:   absolute;
+      top: 23px;
+      width:      338px;
+      z-index:    2;
+   }
+   .header
+   {
+      margin:     0px 0px 3px 3px;
+      padding:    0px 0px 0px 20px;
+      height:     20px;
+   }
+   .but
+   {
+      border:  1px solid #809aa9;
+      /*float:   right*/;
+	   height:  13px;
+	   width:   13px;
+      margin:  3px 58px 3px -3px;
+      padding: 0px;
+   }
+   .tit
+   {
+      /*border:  1px solid #f00;
+      float:   left;
+      width: 80%;*/
+      height: 13px;
+      margin:  0px 0px 0px 22px;
+      padding: 0px;
+      overflow: hidden;
+   }
+   /*
+   .tit:before
+   {
+      content:"meu novo texto";
+      overflow: hidden;
+   }
+   */
+._rtop{display:block;}
+._rtop *{display:block;height: 1px;overflow: hidden}
+._r1{margin: 0 4px;height: 0px}
+._r2{margin: 0 3px}
+._r3{margin: 0 2px}
+._r4{margin: 0 1px}
+
+._rs1{margin: 0 2px}
+._rs2{margin: 0 1px}
+._rtop *{border-width: 0px 1px;border-style: solid; border-color: #809aa9}
+._rtop ._r1{border-top: 1px solid #809aa9;}
Index: /trunk/instant_messenger/templates/default/config.tpl
===================================================================
--- /trunk/instant_messenger/templates/default/config.tpl	(revision 20)
+++ /trunk/instant_messenger/templates/default/config.tpl	(revision 20)
@@ -0,0 +1,76 @@
+<!-- BEGIN header -->
+<form method="POST" action="{action_url}">
+<table border="0" align="center">
+   <tr bgcolor="{th_bg}">
+    <td colspan="2"><font color="{th_text}">&nbsp;<b>{title} - Jabber</b></font></td>
+   </tr>
+<!-- END header -->
+<!-- BEGIN body -->
+   <tr bgcolor="{row_on}">
+    <td colspan="2">&nbsp;</td>
+   </tr>
+
+   <tr bgcolor="{row_off}">
+    <td colspan="2">&nbsp;<b>Configuração do Servidor Jabber</b></td>
+   </tr>
+
+   <tr bgcolor="{row_on}">
+    <td>Digite o nome da máquina Servidor Jabber:</td>
+    <td><input name="newsettings[name_jabber]" value="{value_name_jabber}"></td>
+   </tr>
+
+   <tr bgcolor="{row_off}">
+    <td>Digite Nome da Conexão:</td>
+    <td><input name="newsettings[resource_jabber]" value="{value_resource_jabber}"></td>
+   </tr>
+
+   <tr bgcolor="{row_on}">
+    <td>Digite a porta do Servidor Jabber:</td>
+    <td><input name="newsettings[port_jabber]" value="{value_port_jabber}"></td>
+   </tr>
+
+   <tr bgcolor="{row_off}">
+    <td>Servidor Ldap:</td>
+    <td><input name="newsettings[server_ldap_jabber]" value="{value_server_ldap_jabber}"></td>
+   </tr>
+
+   <tr bgcolor="{row_on}">
+    <td>Contexto:</td>
+    <td><input name="newsettings[context_ldap_jabber]" value="{value_context_ldap_jabber}" size="30"></td>
+   </tr>
+
+   <tr bgcolor="{row_off}">
+    <td>Usuário Ldap:</td>
+    <td><input name="newsettings[user_ldap_jabber]" value="{value_user_ldap_jabber}" size="30"></td>
+   </tr>
+
+   <tr bgcolor="{row_on}">
+    <td>Password:</td>
+    <td><input type="password" name="newsettings[password_ldap_jabber]" value="{value_password_ldap_jabber}"></td>
+   </tr>
+
+   <tr bgcolor="{row_off}">
+    <td>Permitir Transferência de Arquivo:</td>
+    <td><select name="newsettings[send_file_jabber]">
+    	<option value="false" {selected_send_file_jabber_false}>Não</option>
+    	<option value="true" {selected_send_file_jabber_true}>Sim</option>
+    	</select>    	
+    </td>
+   </tr>
+
+<!-- END body -->
+<!-- BEGIN footer -->
+  <tr bgcolor="{th_bg}">
+    <td colspan="2">
+&nbsp;
+    </td>
+  </tr>
+  <tr>
+    <td colspan="2" align="center">
+      <input type="submit" name="submit" value="{lang_submit}">
+      <input type="submit" name="cancel" value="{lang_cancel}">
+    </td>
+  </tr>
+</table>
+</form>
+<!-- END footer -->
Index: /trunk/instant_messenger/templates/default/index.tpl
===================================================================
--- /trunk/instant_messenger/templates/default/index.tpl	(revision 20)
+++ /trunk/instant_messenger/templates/default/index.tpl	(revision 20)
@@ -0,0 +1,132 @@
+<!-- BEGIN index -->
+    <h1>Como Utilizar o Mensageiro Instantâneo</h1>
+    <h2><a name="toc">Conteúdo</a></h2>
+    <ol>
+      <li><a href="#intro">Introdução</a>
+      <li><a href="#supported">Browsers Suportados</a>
+	  <li><a href="#prefe">Menu Preferências</a>
+      <li><a href="#contact_list">Lista de Contatos</a>
+        <ol>
+          <li><a href="#status">Indicador de Status</a>
+          <li><a href="#useradd">Adicionando um novo contato</a>
+          <li><a href="#userdel">Removendo um contato</a>          
+        </ol>
+      <li><a href="#menu_right">Preferências Avançadas</a>
+      <li><a href="#info_ad">Informações Adicionais</a>
+	  <li><a href="#troca_mens">Troca de Mensagens</a>
+	  <li><a href="#troca_status">Troca de Status</a>      
+    </ol>
+
+    <h2><a name="intro">1. Introdução</h2></a>
+    
+    O Mensageiro Instantâneo do Expresso é uma aplicação que permite o envio e recebimento de mensagens instantaneamente. Através da sua lista de contatos, você pode trocar mensagens e arquivos com seus contatos. Através da lista também é possível saber se seus contatos estão Online ou Offline. Para a troca de mensagens basta clicar em cima do nome do seu contato, se o mesmo estiver online ( verifique a sessão <a href="#status">Indicador de Status</a> ) abrirá uma janela onde você poderá enviar/receber as mensagens. O Mensageiro Instantâneo do Expresso está associado
+    a um serviço de mensagens instantâneas Jabber, este serviço é responsável pelo armazenamento dos seus contatos, preferências e mensagens.
+	
+	<br clear="all">
+	<br>
+	( figura 1 )
+    <img src="templates/default/images/lista_contatos.png" width="256" height="371" alt="Im Screenshot" align="left" style="padding-right:4px;"> 
+	
+    <br clear="all">
+
+    <h2><a name="supported">2. Browsers Suportados</a></h2>
+
+    <p>
+      <b>Windows XP/2000/ME/98/95:</b>
+	  <ul>
+	    <li>MS Internet Explorer desde a versão 6.0</li>
+	    <li>Mozilla Firefox desde a versão 1.5</li>
+	  </ul>
+	  
+    <p>
+      <b>Linux:</b>
+      <ul>
+	    <li>Mozilla Firefox desde a versão 1.5</li>
+      </ul>
+    </p>
+
+    <h2><a name="prefe">3. Menu Preferências</a></h2>
+	( figura 2 )
+    <img src="templates/default/images/menu_preferencias.png" width="259" height="188" alt="Menu Preferências" align="left">
+    <br clear="all">
+    <br>
+
+	Para acessar suas "Preferências" ( conforme figura 2 ), basta dar um clique com o mouse e abrirá uma menu com as opções de Adicionar Contato ( <b>veja <a href="#useradd">Adicionando um novo contato</a></b> ), Remover Contato ( <b>veja <a href="#userdel">Removendo um contato</a></b> ) e
+	Informações Adicionais ( <b>veja <a href="#info_ad">Informações Adicionais</a></b> ).
+    
+    <h2><a name="contact_list">4. Lista de Contatos</a></h2>
+	( figura 3 )
+    <img src="templates/default/images/lista_contatos1.png" width="230" height="248" alt="Lista de Contatos" align="left">
+    <br clear="all">
+    <br>
+    
+    Na lista de contato ( conforme figura 3 ), você visualizará seus contatos. 
+    <h3><a name="status">1. Status dos Usuários</a></h3>
+    
+    <img src="templates/default/images/online.gif" align="top"> - Contato Online<br>
+    <img src="templates/default/images/offline.gif" align="top"> - Contato Offline<br>
+    <img src="templates/default/images/not_authorized.gif" align="top"> - Contato aguardando autorização ou não autorizado<br>
+    <img src="templates/default/images/chat.gif" align="top"> - Existe uma janela aberta para a troca de mensagens<br>
+
+    <h3><a name="useradd">2. Adicionando um novo contato </a></h3>
+	( figura 3.1 )
+    <img src="templates/default/images/adicionar_contato.png" width="510" height="337" alt="Adicionar Contato" align="left">
+    <br clear="all">
+    <br>
+
+	Para adicionar um novo contato ( conforme figura 3.1 ), selecione uma organização e automaticamente carregará os usuários que tem permissão para usar o Mensageiro Instantâneo Expresso. Para escolher
+	seu novo contato basta apenas dar um clique em cima do nome desejado. Logo abaixo, três campos são necessários para adicionar o novo contato, sendo que o campo "Email Expresso" e
+	"Nickname" são preenchidos no momento da escolha do novo contato e o campo grupo terá que ser definido. Tendo os três campos preenchidos basta clicar no Botão Adicionar ( <input type="button" value="Adicionar"> ) .
+
+	<h3><a name="userdel">3. Removendo um contato </a></h3>
+	( figura 3.2 )
+    <img src="templates/default/images/remover_contato.png" width="410" height="164" alt="Remover Contato" align="left">
+    <br clear="all">
+    <br>
+
+	Para remover um contato da sua lista ( conforme figura 3.2 ), selecione na lista e clique no botao Botão Remover ( <input type="button" value="Remover"> ) .
+    
+    <h2><a name="menu_right">5. Preferências Avançadas</a></h2>
+	( figura 3.3 )
+    <img src="templates/default/images/menu_right.png" width="259" height="359" alt="Preferências Avançadas" align="left">
+    <br clear="all">
+    <br>
+
+    Clicando com o botão direito do mouse, você tera acesso a um menu ( conforme figura 3.3 ), com as seguintes funcionalidades :
+
+    <ul>
+      <li>Apelido: Renomeia o Apelido(Nickanem) do seu contato
+      <!--<li>Envio Arquivo: Troca de arquivos entre você e seus contatos-->
+      <li>Grupo: Muda seu contato para um novo grupo
+      <li>Remover: Exclui o contato
+      <li>Ver Info: Visualize as informações dos seus contatos
+    </ul>
+
+    <h2><a name="info_ad">6. Informações Adicionais</a></h2>
+	( figura 4 )
+    <img src="templates/default/images/info_adicionais.png" width="410" height="274" alt="Informações Adicionais" align="left">
+    <br clear="all">
+    <br>
+
+	Efetuando o cadastro ( conforme figura 4 ) com seus dados, os contatos que você adicionou em sua lista poderão ver essas informações. Cada contato cadastrado em sua lista
+	também possui esta opção ( <b>veja <a href="#menu_right">Preferências Avançadas</a></b>, opção Ver Info).
+
+    <h2><a name="troca_mens">7. Troca de Mensagens</a></h2>
+	( figura 5 )
+    <img src="templates/default/images/troca_mensagem.png" width="485" height="270" alt="Troca de Mensagens" align="left">
+    <br clear="all">
+    <br>
+
+	Clicando com o mouse em cima do nome do contato escolhido, abrirá uma janela ( conforme figura 5 ), para a troca de mensagens. Nessa mesma janela existe um menu, o qual é possível
+	configurar o formato da : Fonte, Tamanho, Cor e o Estilo. Você também pode enviar os Smiles, clicando nessa figura <img src="templates/default/images/img/1.gif">.
+
+    <h2><a name="troca_status">8. Troca de Status</a></h2>
+	( figura 6 )
+    <img src="templates/default/images/troca_status.png" width="391" height="250" alt="Troca de Status" align="left">
+    <br clear="all">
+    <br>
+
+	Já está disponível o recurso de mudar o status para "online/offline".
+
+    <hr noshade>
+<!-- END index -->
