Index: /trunk/calendar_new/setup/phpgw_pt-br.lang
===================================================================
--- /trunk/calendar_new/setup/phpgw_pt-br.lang	(revision 420)
+++ /trunk/calendar_new/setup/phpgw_pt-br.lang	(revision 420)
@@ -0,0 +1,34 @@
+loading	calendar	pt-br	carregando
+remove	calendar	pt-br	remover
+details	caelndar	pt-br	detalhes
+event were deleted	calendar	pt-br	Evento foi apagado
+event were added successfully!	calendar	pt-br	Evento foi adicionado com sucesso!
+Daily View	calendar	pt-br	Visão Diária
+Weekly View	calendar	pt-br	Visão Semanal
+Monthly View	calendar	pt-br	Visão Mensal
+Year View	calendar	pt-br	Visão Anual
+Add this event	calendar	pt-br	Adicionar este evento
+Sunday	calendar	pt-br	Domingo
+Monday	calendar	pt-br	Segunda-feira
+Tuesday	calendar	pt-br	Terça-feira
+Wednesday	calendar	pt-br	Quarta-feira
+Thursday	calendar	pt-br	Quinta-feira
+Friday	calendar	pt-br	Sexta-feira
+Saturday	calendar	pt-br	Sábado
+January	calendar	pt-br	Janeiro
+February	calendar	pt-br	Fevereiro
+March	calendar	pt-br	Março
+April	calendar	pt-br	Abril
+May	calendar	pt-br	Maio
+June	calendar	pt-br	Junho
+July	calendar	pt-br	Julho
+August	calendar	pt-br	Agosto
+September	calendar	pt-br	Setembro
+October	calendar	pt-br	Outubro
+November	calendar	pt-br	Novembro
+December	calendar	pt-br	Dezembro
+of	calendar	pt-br	de
+Change the end of this event to %1	calendar	pt-br	Mudar o horário final deste evento para %1
+Error	calendar	pt-br	Erro
+Empty field	calendar	pt-br	Campo em branco
+Week Number %1 of %2	calendar	pt-br	Semana número %1 de %2
Index: /trunk/calendar_new/setup/setup.inc.php
===================================================================
--- /trunk/calendar_new/setup/setup.inc.php	(revision 420)
+++ /trunk/calendar_new/setup/setup.inc.php	(revision 420)
@@ -0,0 +1,31 @@
+<?php
+	/******************************************************\
+	 * Calendar 2.0						*
+	 * Alexandre Felipe Muller de Souza			*
+	 * Nilton Neto						*
+	\******************************************************/
+	
+	$setup_info['calendar_new']['name']      	= 'calendar_new';
+	$setup_info['calendar_new']['title']     	= 'Calendar 2.0';
+	$setup_info['calendar_new']['version']   	= '2.0';
+	$setup_info['calendar_new']['app_order'] 	= 9;
+	$setup_info['calendar_new']['enable']    	= 1;
+	
+	/* Conf Table */
+	
+	$setup_info['calendar_new']['author'] = 'Celepar Companhia de Informatica do Parana';
+	$setup_info['calendar_new']['maintainer']	=  'CELEPAR';
+	$setup_info['calendar_new']['maintainer_email']= '';
+
+	$setup_info['calendar_new']['license']  	= 'GPL';
+	$setup_info['calendar_new']['description'] = 'Calendar Ajax';
+
+	/* The hooks this app includes, needed for hooks registration */
+	$setup_info['calendar_new']['hooks'][] = 'admin';
+		
+	/* Dependencies for this app to work */
+	$setup_info['calendar_new']['depends'][] = array(
+		'appname' => 'phpgwapi',
+		'versions' => Array('0.9.14','0.9.15','1.0.0')
+	);
+?>
Index: /trunk/calendar_new/.project
===================================================================
--- /trunk/calendar_new/.project	(revision 420)
+++ /trunk/calendar_new/.project	(revision 420)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>calendar</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>net.sourceforge.phpeclipse.parserbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>net.sourceforge.phpeclipse.phpnature</nature>
+	</natures>
+</projectDescription>
Index: /trunk/calendar_new/xsl/viewMonth.xsl
===================================================================
--- /trunk/calendar_new/xsl/viewMonth.xsl	(revision 420)
+++ /trunk/calendar_new/xsl/viewMonth.xsl	(revision 420)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/retorno">
+<xsl:variable name="today" select="today" />
+<div id="day">
+        <div id="{$today}"></div>
+</div>
+<div width="100%" class="title" align="left" ><label id="l_date"></label><br/><br/>
+<table class="table_common" width="100%" cellpadding="0" cellspacing="0" border="0">
+	<tr class="td_common" height="100%" width="1%">
+
+			<table class="table_common" height="100%" width="100%" cellpadding="0" cellspacing="0">
+				<tr id="tr_week">
+					<xsl:for-each select="dayofweek">
+						<xsl:variable name="dayName" select="dayname" />
+						<td id="weekHeader_{$dayName}" class="td_header" height="1%">
+							<xsl:value-of select='$dayName' />
+						</td>
+					</xsl:for-each>
+				</tr>
+				<xsl:for-each select="/retorno/workWeek">
+						<tr>
+							<xsl:for-each select="workday">
+								<xsl:variable name="day" select="id" />
+								<td class="td_day" id="{$day}">
+								</td>
+							</xsl:for-each>
+						</tr>
+				</xsl:for-each>
+
+			</table>	
+	</tr>
+</table>	
+</div>
+<div id="returnEvents">
+	<xsl:for-each select="calEvent">
+		<xsl:variable name="event_id" select="id" />
+		<xsl:variable name="datetime" select="datetime" />
+		<xsl:variable name="edatetime" select="edatetime" />
+		<xsl:if test="id > 0">
+			<div id="event_{$event_id}">
+				<xsl:value-of select='title' />
+				<div id="{$datetime}"></div>
+				<div id="{$edatetime}"></div>
+			</div>
+		</xsl:if>
+	</xsl:for-each>
+</div>
+</xsl:template>
+</xsl:stylesheet>
Index: /trunk/calendar_new/xsl/viewWeek.xsl
===================================================================
--- /trunk/calendar_new/xsl/viewWeek.xsl	(revision 420)
+++ /trunk/calendar_new/xsl/viewWeek.xsl	(revision 420)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/retorno">
+<xsl:variable name="today" select="today" />
+<div id="day">
+	<div id="{$today}"></div>
+</div>
+<div width="100%" class="title" align="left" ><label id="l_date"></label><br/><br/>
+<table class="table_common" width="100%" cellpadding="0" cellspacing="0" border="0">
+	<tr>
+		<td class="td_common" height="100%" width="1%">
+		
+			<table class="table_common" height="100%" width="100%" cellpadding="0" cellspacing="0">
+				<tr id="tr_week">
+					<td class="td_header" width="10%"></td>
+					<xsl:for-each select="workweek">
+						<xsl:variable name="dayIndex" select="dayid" />
+						<td id="weekHeader_{$dayIndex}" class="td_header" height="1%">
+							<xsl:value-of select='dayofweek' />
+						</td>
+					</xsl:for-each>
+				</tr>
+				<xsl:for-each select="/retorno/workday">
+				<tr>
+					<xsl:variable name="time" select="timeid" />
+					<xsl:variable name="event_id" select="id" />
+					<td width="1%"  id="header_{$today}{$time}" class="td_header">
+						<xsl:value-of select="hour" /></td>
+					<xsl:for-each select="/retorno/workweek">
+						<xsl:variable name="day" select="dayid" />
+						<td class="td_common" id="{$day}{$time}">
+						</td>
+					</xsl:for-each>
+				</tr>
+				</xsl:for-each>				
+			</table>	
+		</td>
+	</tr>
+</table>	
+</div>
+<div id="returnEvents">
+	<xsl:for-each select="calEvent">
+		<xsl:variable name="event_id" select="id" />
+		<xsl:variable name="datetime" select="datetime" />
+		<xsl:variable name="edatetime" select="edatetime" />
+		<xsl:if test="id > 0">
+			<div id="event_{$event_id}">
+				<xsl:value-of select='title' />
+				<div id="{$datetime}"></div>
+				<div id="{$edatetime}"></div>
+			</div>
+		</xsl:if>
+	</xsl:for-each>
+</div>
+</xsl:template>
+</xsl:stylesheet>
Index: /trunk/calendar_new/xsl/addDialog.xsl
===================================================================
--- /trunk/calendar_new/xsl/addDialog.xsl	(revision 420)
+++ /trunk/calendar_new/xsl/addDialog.xsl	(revision 420)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/text">
+<div style="position:absolute;left: 0px; top: 0px;" id="infowindow">
+<table style="position: absolute; width: 350px; height: 150px;" border="0" cellpadding="0" cellspacing="0">
+<tbody>
+<tr style="height: 24px;">
+	<td background="templates/default/images/iw_nw.png">
+	</td>
+	<td background="templates/default/images/iw_lu.png">
+	</td>
+	<td background="templates/default/images/iw_ne.png">
+	</td>
+</tr>
+<tr>
+	<td style="width: 24px;" background="templates/default/images/iw_ll.png">
+	</td>
+	<td> 
+	<div style="overflow: hidden; height: 110; background-color: #ffffff; z-index: 183; cursor: default">
+	<br/>
+	<font size="-1"><xsl:value-of select="date" /></font>
+	<br/>
+	<table class="" style="width: auto;"><tbody>
+	<tr><td><font size="-1"><label>Horário:</label></font></td>
+		<td style="text-align:center"><font color="black" id="intervalId" size="-1"><xsl:value-of select="time" /></font></td>
+	</tr>
+	<tr>
+		<td><font size="-1"><label forid="b_subject">Título:</label></font></td>
+		<td class="" id="bubble_input">
+		<input style="height:18px" id="dragEventSubject" size="35" name="b_subject"/>
+		</td>
+	</tr>
+	</tbody></table>
+	<br/>
+	<div id="addEventLink" class="buttontype" onclick="quickAddEvent(document.getElementById('dragEventSubject').value,_dragArea.initEvent,_dragArea.endEvent);">Add event</div>
+	<img onclick="calendar.dialog()" width="14" height="13" src="templates/default/images/close.gif" style="position: absolute; z-index: 184; cursor: pointer; left: 320px; top: 25px;"/>
+	</div>
+	</td>
+	<td style="width: 24px;" background="templates/default/images/iw_lr.png"></td>
+</tr>
+<tr style="height: 24px;">
+	<td background="templates/default/images/iw_sw.png">
+	</td>
+	<td background="templates/default/images/iw_ld.png">
+	</td>
+	<td background="templates/default/images/iw_se.png">
+	</td>
+</tr>
+</tbody>
+</table>
+</div>
+</xsl:template>
+</xsl:stylesheet>
Index: /trunk/calendar_new/xsl/viewDay.xsl
===================================================================
--- /trunk/calendar_new/xsl/viewDay.xsl	(revision 420)
+++ /trunk/calendar_new/xsl/viewDay.xsl	(revision 420)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:template match="/retorno">
+<xsl:variable name="today" select="today" />
+<div id="day">
+	<div id="{$today}"></div>
+</div>
+<div width="100%" class="title" align="left" ><label id="l_date"></label><br/><br/>
+<table class="table_common" height="50%" width="800" cellpadding="0" cellspacing="0">
+<xsl:for-each select="workday">
+	<tr>
+		<xsl:variable name="time" select="timeid" />
+		<td width="65px" class="td_header" id="header_{$today}{$time}">
+		<xsl:value-of select="hour" /></td>
+		<td class="td_common" id="{$today}{$time}">
+		</td>
+	</tr>
+</xsl:for-each>
+</table>
+</div>
+<div id="returnEvents">
+<xsl:for-each select="calEvent">
+	<xsl:variable name="event_id" select="id" />
+	<xsl:variable name="datetime" select="datetime" />
+	<xsl:variable name="edatetime" select="edatetime" />
+		<xsl:if test="id > 0">
+			<div id="event_{$event_id}">
+				<xsl:value-of select='title' />
+				<div id="{$datetime}"></div>
+				<div id="{$edatetime}"></div>
+			</div>
+		</xsl:if>
+</xsl:for-each>
+</div>
+</xsl:template>
+</xsl:stylesheet>
Index: /trunk/calendar_new/inc/class.db_functions.inc.php
===================================================================
--- /trunk/calendar_new/inc/class.db_functions.inc.php	(revision 420)
+++ /trunk/calendar_new/inc/class.db_functions.inc.php	(revision 420)
@@ -0,0 +1,250 @@
+<?php
+define('PHPGW_INCLUDE_ROOT','../');	
+define('PHPGW_API_INC','../phpgwapi/inc');	
+include_once(PHPGW_API_INC.'/class.db.inc.php');
+	
+class db_functions
+{
+	var $db;
+	var $user_id;
+	
+	function db_functions(){
+		$this->db = new db();		
+		$this->db->Halt_On_Error = 'no';
+	}
+
+	// BEGIN of functions.
+	function get_cc_contacts()
+	{				
+		$result = array();
+		$stringDropDownContacts = '';
+		// Pesquisa no CC os nomes e email dos contatos.
+ 		$query = 'select A.names_ordered, C.connection_value from phpgw_cc_contact A,'.
+  		'phpgw_cc_contact_conns B, phpgw_cc_connections C where '.
+     	'A.id_contact = B.id_contact and B.id_connection = C.id_connection '.
+        'and B.id_typeof_contact_connection = 1 and '.
+        'A.id_owner ='.$this -> user_id.' order by A.names_ordered';
+				
+        if (!$this->db->query($query))
+        	return null;
+				
+		
+		while($this->db->next_record())
+			$result[] = $this->db->row();
+
+		if (count($result) != 0) 
+		{
+			// Monta string				
+			foreach($result as $contact)
+				$stringDropDownContacts = $stringDropDownContacts . $contact['names_ordered']. ';' . $contact['connection_value'] . ',';
+			//Retira ultima virgula.
+			$stringDropDownContacts = substr($stringDropDownContacts,0,(strlen($stringDropDownContacts) - 1));
+		}
+		else 
+			return null;
+
+		return $stringDropDownContacts;
+	}
+	
+	function get_cc_groups() 
+	{
+		// Pesquisa no CC os Grupos Pessoais.
+		$stringDropDownContacts = '';			
+		$result = array();
+		$query = 'select title, short_name from phpgw_cc_groups where owner ='.$this -> user_id.' order by title';
+		// Executa a query 
+		if (!$this->db->query($query))
+        	return null;
+		// Retorna cada resultado            	
+		while($this->db->next_record())
+			$result[] = $this->db->row();
+		// Se houver grupos ....
+		if (count($result) != 0) 
+		{	
+			foreach($result as $group)
+				$stringDropDownContacts .=  $group['title']. ';' . $group['short_name'] . ',';
+			//Retira ultima virgula.
+			$stringDropDownContacts = substr($stringDropDownContacts,0,(strlen($stringDropDownContacts) - 1));
+		}
+		else
+			return null;
+			
+		return $stringDropDownContacts;
+	}
+	
+	function getContactsByGroupAlias($alias)
+	{
+		
+		$query = "select C.id_connection, A.names_ordered, C.connection_value from phpgw_cc_contact A, ".
+		"phpgw_cc_contact_conns B, phpgw_cc_connections C,phpgw_cc_contact_grps D,phpgw_cc_groups E where ".
+		"A.id_contact = B.id_contact and B.id_connection = C.id_connection ".
+		"and B.id_typeof_contact_connection = 1 and ".
+		"A.id_owner =".$this -> user_id." and ".			
+		"D.id_group = E.id_group and ".
+		"D.id_connection = C.id_connection and E.short_name = '".$alias.
+		"' order by A.names_ordered";
+
+		if (!$this->db->query($query))
+		{
+			exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
+		}
+
+		$return = false;
+
+		while($this->db->next_record())
+		{
+			$return[] = $this->db->row(); 
+		}
+
+		return $return;
+	}
+
+	function getAddrs($array_addrs) {
+		$array_addrs_final = array();				
+
+		for($i = 0; $i < count($array_addrs); $i++){
+			$j = count($array_addrs_final);
+
+			if(!strchr($array_addrs[$i],'@') 
+					&& strchr($array_addrs[$i],'<')
+					 && strchr($array_addrs[$i],'>')) {		
+
+				$alias = substr($array_addrs[$i], strpos($array_addrs[$i],'<'), strpos($array_addrs[$i],'>'));				
+		 		$alias = str_replace('<','', str_replace('>','',$alias));		 		        	           		
+		 		$arrayContacts = $this -> getContactsByGroupAlias($alias);
+
+				if($arrayContacts) {
+					foreach($arrayContacts as $index => $contact){
+						if($contact['names_ordered']) {
+							$array_addrs_final[$j] = '"'.$contact['names_ordered'].'" <'.$contact['connection_value'].'>';
+						}
+						else 
+							$array_addrs_final[$j] = $contact['connection_value'];
+
+						$j++;
+					}
+				}
+	   		}
+	   		else
+	   			$array_addrs_final[$j++] = $array_addrs[$i]; 							
+		}
+		return $array_addrs_final;
+	}
+
+	function get_dropdown_contacts(){
+		
+		$contacts = $this -> get_cc_contacts();
+		$groups = $this -> get_cc_groups();
+		
+		if(($contacts) && ($groups))
+			$stringDropDownContacts = $contacts . ',' . $groups;
+		elseif ((!$contacts) && (!$groups))
+			$stringDropDownContacts = '';
+		elseif (($contacts) && (!$groups))
+			$stringDropDownContacts = $contacts;
+		elseif ((!$contacts) && ($groups))
+			$stringDropDownContacts = $groups;
+					
+		return $stringDropDownContacts;	
+	}
+	/*
+	function update_preferences($params){
+		
+		$aux = explode("##",$params['prefe_string']);
+		$new_prefe = array();
+		
+		foreach($aux as $key=>$tmp){
+			if($key == 0){
+				$new_prefe['max_email_per_page'] = $tmp;
+			}
+			if($key == 1){
+				$new_prefe['save_deleted_msg'] = $tmp;
+			}
+			if($key == 2){
+				$new_prefe['delete_trash_messages_after_n_days'] = $tmp;
+			}
+			if($key == 3){
+				$new_prefe['delete_and_show_previous_message'] = $tmp;
+			}
+			if($key == 4){
+				$new_prefe['alert_new_msg'] = $tmp;
+			}
+			if($key == 5){
+				$new_prefe['mainscreen_showmail'] = $tmp;
+			}
+			if($key == 10){
+				$new_prefe['signature'] = $tmp;
+			}
+			if($key == 7){
+				$new_prefe['hide_folders'] = $tmp;
+			}
+			if($key == 6){
+				$new_prefe['save_in_folder'] = $tmp;
+			}
+			if($key == 8){
+				$new_prefe['line_height'] = $tmp;
+			}
+			if($key == 9){
+				$new_prefe['font_size'] = $tmp;
+			}
+			if($key == 11){
+				$new_prefe['use_shortcuts'] = $tmp;
+			}
+		}
+		
+		$string_serial =  serialize($new_prefe);
+		$string_serial = get_magic_quotes_gpc() ? $string_serial : addslashes($string_serial);
+		$query = "update phpgw_preferences set preference_value = '".$string_serial."' where preference_app = 'expressoMail'".
+				 " and preference_owner = '".$this->user_id."'";
+		
+		if (!$this->db->query($query))
+        	return "Failed!";
+		else
+			return "OK!";
+	}
+	*/
+	function update_preferences($params){
+		$string_serial = urldecode($params['prefe_string']);				
+		$string_serial = get_magic_quotes_gpc() ? $string_serial : addslashes($string_serial);
+		$query = "update phpgw_preferences set preference_value = '".$string_serial."' where preference_app = 'expressoMail'".
+				 " and preference_owner = '".$this->user_id."'";
+		
+		if (!$this->db->query($query))
+        	return $this->db->error;
+		else
+			return array("success" => true);
+	}
+	function getUserByEmail($params){	
+		// Follow the referral
+		$email = $params['email'];
+		$query = 'select A.names_ordered, C.connection_name, C.connection_value, A.photo'. 
+				' from phpgw_cc_contact A, phpgw_cc_contact_conns B, '.
+				'phpgw_cc_connections C where A.id_contact = B.id_contact'. 
+ 				' and B.id_connection = C.id_connection and A.id_contact ='. 
+				'(select A.id_contact from phpgw_cc_contact A, phpgw_cc_contact_conns B,'. 
+				'phpgw_cc_connections C where A.id_contact = B.id_contact'. 
+				' and B.id_connection = C.id_connection and A.id_owner = '.$this -> user_id.
+				' and C.connection_value = \''.$email.'\') and '.
+				'C.connection_is_default = true and B.id_typeof_contact_connection = 2';
+
+        if (!$this->db->query($query))
+        	return null;
+
+
+		if($this->db->next_record()) {
+			$result = $this->db->row();
+
+			$obj =  array("cn" => $result['names_ordered'],
+					  "email" => $email,
+					  "type" => "personal",
+					  "telefone" =>  $result['connection_value']);
+
+			if($result['photo'])
+				$_SESSION['phpgw_info']['expressomail']['contact_photo'] =  array($result['photo']);				
+
+			return $obj;
+		}
+		return $result;
+	}
+}
+?>
Index: /trunk/calendar_new/inc/hook_admin.inc.php
===================================================================
--- /trunk/calendar_new/inc/hook_admin.inc.php	(revision 420)
+++ /trunk/calendar_new/inc/hook_admin.inc.php	(revision 420)
@@ -0,0 +1,21 @@
+<?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 = 'Calendar 2.0';
+	$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/calendar_new/inc/load_lang.php
===================================================================
--- /trunk/calendar_new/inc/load_lang.php	(revision 420)
+++ /trunk/calendar_new/inc/load_lang.php	(revision 420)
@@ -0,0 +1,25 @@
+<?
+// Load the lang of the module.
+	if(!$_SESSION['phpgw_info']['calendar']['lang']) 
+	{
+		$array_keys = array();
+		$fn = '../setup/phpgw_'.$_SESSION['calendar']['user']['preferences']['common']['lang'].'.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']['calendar']['lang'][$message_id] =  $content;
+			}
+			fclose($fp);
+		}
+	}
+	$script  = "array_lang[0] = new Array();";
+	$script .= "array_lang[1] = new Array();";		
+	$i = 0;
+	foreach($_SESSION['phpgw_info']['calendar']['lang'] as $key => $value) {		
+		$script .= "array_lang[0][".$i."] = '".str_replace("'","\'",strtolower($key))."';";		
+		$script .= "array_lang[1][".$i."] = '".str_replace("'","\'",$value)."';";
+		$i++;					
+	}
+	echo $script;
+?>
Index: /trunk/calendar_new/inc/class.uicalendar.inc.php
===================================================================
--- /trunk/calendar_new/inc/class.uicalendar.inc.php	(revision 420)
+++ /trunk/calendar_new/inc/class.uicalendar.inc.php	(revision 420)
@@ -0,0 +1,171 @@
+<?php
+
+include_once("class.bocalendar.inc.php");
+
+class uicalendar
+{
+	function uicalendar() {
+		$this -> daysofweek     = array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
+		$this -> workweekstarts = 0;
+		$this -> workweekends   = 6;
+		$this -> workdaystarts  = 7;
+		$this -> workdayends    = 20;
+		$this -> weekDate = array();
+		$this -> db_obj = new bocalendar();
+	}
+
+	var $public_functions = array(
+			'quickAdd' => True,
+			'getViewDay' => true
+			);
+
+	function quickAdd () {
+		$start = isset ($_REQUEST["start"]) ? $_REQUEST["start"] : NULL;
+		$end = isset ($_REQUEST["end"]) ? $_REQUEST["end"] : NULL;
+		$description = isset ($_REQUEST["desc"]) ? $_REQUEST["desc"] : NULL;
+		if ($start == NULL || $end == NULL || $description == NULL)
+			return "false;Empty field";
+		if (!eregi("^[a-zA-Z_.0-9-]*",$description))
+			return "false;Invalid char in description";
+		if (!eregi("^[0-9]*",$start))
+			return "false;Wrong formed text";
+		if (!eregi("^[0-9]*",$end))
+			return "false;Wrong formed text";
+
+		return $this->db_obj->insertEvent($start, $end, $description, $description);
+	}
+
+	function changeEvent()
+	{
+		$calId = isset ($_REQUEST["cal_id"]) ? $_REQUEST["cal_id"] : NULL;
+		$field = isset ($_REQUEST["field"]) ? $_REQUEST["field"] : NULL;
+		$value = isset ($_REQUEST["value"]) ? $_REQUEST["value"] : NULL;
+		if ($calId == NULL || $field == NULL || $value == NULL)
+			return false;
+		if (!eregi("^[a-zA-Z_.]*",$field))
+			return "<false>Wrong formed text</false>";
+		if (!eregi("^[a-zA-Z_.0-9-]*",$value))
+			return "<false>Wrong formed text</false>";
+		if (!eregi("^[0-9]*",$calId))
+			return "<false>Wrong formed text</false>";
+
+		return $this->db_obj->changeEvent($calId, $field, $value);
+	}
+
+	function removeEvent () {
+		$id = isset ($_REQUEST["id"]) ? $_REQUEST["id"] : NULL;
+		if ($id == NULL)
+			return "false;Internal Problem";
+
+		return $this->db_obj->removeEventById($id);
+
+	}
+
+	function getViewDay () {
+		$dayViewTime = isset ($_REQUEST["time"]) ?  strtotime(substr($_REQUEST["time"],0,4)."-".substr($_REQUEST["time"],6,2)."-".substr($_REQUEST["time"],4,2)) : strtotime(date('Y-m-d', time()));
+
+		$retorno = "<today>".date('Ydm',$dayViewTime)."</today>";
+		include_once("class.bocalendar.inc.php");
+		$obj = new bocalendar();
+
+		$fromBo = $obj->requestDayCal($dayViewTime);
+
+
+		// Printing results in XML
+		for($i = $this->workdaystarts; $i <= $this->workdayends; $i = $i + 0.5){
+			if($i == intval($i))
+				$retorno.= "<workday><timeid>".($i < 10 ? "0" : "").intval($i)."00</timeid><hour>".($i < 10 ? "0" : "").intval($i).":00</hour>";
+			else
+				$retorno.= "<workday><timeid>".($i < 10 ? "0" : "").intval($i)."30</timeid><hour>".($i < 10 ? "0" : "").intval($i).":30</hour>";
+		
+		$retorno .= "</workday>";
+		}
+			if (is_array($fromBo))
+				foreach ($fromBo as $line){
+					$retorno .= "<calEvent>";
+					$retorno .= "<id>".$line['cal_id']."</id>";
+					$retorno .= "<title>".$line['description']."</title>";
+					$retorno .= "<edatetime>".($line['edatetime']*1000)."</edatetime>";
+					$retorno .= "<datetime>".($line['datetime']*1000)."</datetime>";       
+					$retorno .= "</calEvent>";
+				}
+		
+		return $retorno;
+	}
+	function getViewWeek () {
+		$dayViewTime = isset ($_REQUEST["time"]) ?  strtotime(substr($_REQUEST["time"],0,4)."-".substr($_REQUEST["time"],6,2)."-".substr($_REQUEST["time"],4,2)) : strtotime(date('Y-m-d', time()));
+		$dayViewTime -= date('N', time())*86400;
+		$retorno = "<today>".date('Ydm', $dayViewTime)."</today>";
+
+		$fromBo = $this->db_obj->requestWeekCal($dayViewTime);
+
+		for($i = $this->workdaystarts; $i <= $this->workdayends; $i = $i + 0.5){
+			if($i == intval($i))
+				$retorno.= "<workday><timeid>".($i < 10 ? "0" : "").intval($i)."00</timeid><hour>".($i < 10 ? "0" : "").intval($i).":00</hour>";
+			else
+				$retorno.= "<workday><timeid>".($i < 10 ? "0" : "").intval($i)."30</timeid><hour>".($i < 10 ? "0" : "").intval($i).":30</hour>";
+			$retorno .= "</workday>";
+		}
+		$currentWeekDay = date('w', mktime());
+
+		for($i = $this->workweekstarts; $i <= $this->workweekends; $i++){
+			$retorno.= "<workweek><dayid>".date("Ydm", time() - (($currentWeekDay-$i)*60*60*24))."</dayid><dayofweek>".$this->daysofweek[$i]."</dayofweek></workweek>";
+		 }
+
+
+		// Printing results in XML
+		if (is_array($fromBo))
+			foreach ($fromBo as $line) {
+				if ($line['datetime'] > 0){
+					$retorno .= "<calEvent>";
+					$retorno .= "<id>".$line['cal_id']."</id>";
+					$retorno .= "<title>".$line['description']."</title>";
+					$retorno .= "<edatetime>".($line['edatetime']*1000)."</edatetime>";
+					$retorno .= "<datetime>".($line['datetime']*1000)."</datetime>";
+					$retorno .= "</calEvent>";
+				}
+			}
+		return $retorno;
+	}
+	function getViewMonth () {
+		$todayTime = strtotime(date('Y-m-d', time()));
+		$retorno = "<today>".date('Ydm', time())."</today>";
+
+		$fromBo = $this->db_obj->requestMonthCal($todayTime);
+		
+		for ($i=1;$i<=date('t');$i+=7){
+			$retorno.= "<workWeek>";
+			$retorno.= "<workday><id>".date('Y').$i.date('m')."0000</id></workday>";
+			$retorno.= "<workday><id>".date('Y').($i+1).date('m')."0000</id></workday>";
+			$retorno.= "<workday><id>".date('Y').($i+2).date('m')."0000</id></workday>";
+			$retorno.= "<workday><id>".date('Y').($i+3).date('m')."0000</id></workday>";
+			$retorno.= "<workday><id>".date('Y').($i+4).date('m')."0000</id></workday>";
+			$retorno.= "<workday><id>".date('Y').($i+5).date('m')."0000</id></workday>";
+			$retorno.= "<workday><id>".(date('Y').$i+6).date('m')."0000</id></workday>";
+			$retorno.= "</workWeek>";
+		}
+		
+		for($i = $this->workweekstarts; $i <= $this->workweekends; $i++){
+			// Dayid is year+month+dayofMonth (currentDay-(dayofWeek+$i))
+			$retorno.= "<dayofweek><dayname>".$this->daysofweek[$i]."</dayname></dayofweek>";
+		 }
+
+
+		// Printing results in XML
+		if (is_array($fromBo))
+		foreach ($fromBo as $line) {
+			if ($line['datetime'] > 0){
+				$retorno .= "<calEvent>";
+				$retorno .= "<id>".$line['cal_id']."</id>";
+				$retorno .= "<title>".$line['description']."</title>";
+				$retorno .= "<edatetime>".($line['edatetime']*1000)."</edatetime>";
+				$retorno .= "<datetime>".($line['datetime']*1000)."</datetime>";
+				$retorno .= "</calEvent>";
+			}
+		}
+		return $retorno;
+	}
+
+};
+
+?>
Index: /trunk/calendar_new/inc/controller.php
===================================================================
--- /trunk/calendar_new/inc/controller.php	(revision 420)
+++ /trunk/calendar_new/inc/controller.php	(revision 420)
@@ -0,0 +1,103 @@
+<?php
+	//	Explode action from cExecuteForm function
+	$cExecuteFormReturn = false;
+//echo "lalal";
+   $returnMode = $_REQUEST['returnMode'];
+ 	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'])
+   {
+      unset($_GET['returnMode']);
+		list($app,$class,$method) = explode('.',@$_GET['action']);
+   }
+	// NO ACTION
+	else
+		return $_SESSION['response'] = 'false';
+
+	// Load dinamically class file.
+	if($app == '$this')
+		$filename = 'class.'.$class.'.inc.php';
+	else
+		$filename = '../'.$app.'/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)
+   {
+      $dom = new DOMDocument;//('1.0', 'UTF-8');
+
+      if ( $returnMode == 'JSON')
+      {
+         $root = $dom->appendChild(new DOMElement('retorno'));
+         encode($result, 'encode');
+         $result = ( !is_object($result) && !is_array($result) ) ? $result : json_encode($result);
+
+         $root->appendChild($dom->createCDATASection($result));
+      }
+      else
+		{
+			$dom->loadXML('<retorno>' . utf8_encode($result) . '</retorno>');
+		}
+
+      $dom->normalizeDocument();
+		$retorno = $dom->saveXML();
+      header('Pragma: anytextexeptno-cache', true);
+      header('Content-type: text/xml, charset=UTF-8');
+		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/calendar_new/inc/class.uixmlcalendar.inc.php
===================================================================
--- /trunk/calendar_new/inc/class.uixmlcalendar.inc.php	(revision 420)
+++ /trunk/calendar_new/inc/class.uixmlcalendar.inc.php	(revision 420)
@@ -0,0 +1,112 @@
+<?php
+
+
+ class UIXMLCalendar{
+ 	
+ 	function UIXMLCalendar(){
+ 		// Domingo = 0 -> Sabado = 6 		
+ 		$this -> daysofweek 	= array ("Dom ", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado");
+ 		$this -> workweekstarts = 0;
+ 		$this -> workweekends   = 6;
+ 		$this -> workdaystarts 	= 8;
+ 		$this -> workdayends   	= 19;
+ 		$this -> weekDate = array();
+ 		
+ 		
+ 	}
+ 	function getUserCalendar($type,$date, $userId){ 		
+ 		$calendarUser = array  (
+			"20071008" => array( 
+				"0900" => "Cafe da Manha",
+ 				"1100" => "Lanche da Manhã",
+ 				"1600" => "Almoco Executivo",
+ 				"1500" => "Cafe da Tarde" 				
+ 			),
+ 			"20071009" => array(),
+			"20071126" => array( 
+				"0800" => "Cafe da Manha",
+ 				"1000" => "Lanche da Manhã",
+ 				"1200" => "Almoco Executivo",
+ 				"1530" => "Cafe da Tarde",
+ 				"1800" => "Hora de ir embora" 				
+ 			),		
+ 			"20071011" => array(),
+ 			"20071012" => array(),
+			"20071013" => array( 
+				"1000" => "Cafe da Manha", 				
+ 				"1400" => "Almoco Executivo",
+ 				"1700" => "Cafe da Tarde",
+ 			),
+ 			"20071014" => array()	
+ 		);
+ 		if($type == 'week') 		   		
+   			return $calendarUser;
+   		elseif($type == 'day')
+   			return $calendarUser[$date];
+ 	}
+ 		 	 	 	
+ 	function getWorkDay($date){	
+ 		$workday = ''; 		
+ 		for($i = $this->workdaystarts; $i <= $this->workdayends; $i = $i + 0.5){
+ 			if($i == intval($i)) 			
+ 				$workday.= "<workday><timeid>".($i < 10 ? "0" : "").intval($i)."00</timeid><hour>".($i < 10 ? "0" : "").intval($i).":00</hour></workday>";
+ 			else	
+ 				$workday.= "<workday><timeid>".($i < 10 ? "0" : "").intval($i)."30</timeid><hour>".($i < 10 ? "0" : "").intval($i).":30</hour></workday>";
+ 		} 		
+ 		return $workday;
+ 	}
+ 	
+	function getWorkWeek(){ 		 		 		
+ 		$workweek = '';
+ 		for($i = $this->workweekstarts; $i <= $this->workweekends; $i++){ 			
+ 			$workweek.= "<workweek><dayid>".$this -> weekDate[$i]."</dayid><dayofweek>".$this->daysofweek[$i]."</dayofweek></workweek>";
+ 		} 		
+ 		return $workweek;
+ 	} 	
+ 	
+	function getViewDay($params){
+ 		$userId = $params['userId'];
+ 		$date = $params['date'];
+		$calendarUser = $this->getUserCalendar('day',$date, $userId); 		   		
+   		$return = "<today>$date</today>";
+   		
+   		if($calendarUser) {
+   			foreach($calendarUser as $time => $title) {
+   				$return.= "<hourofday><timeid>$date$time</timeid><title>$title</title></hourofday>";
+   			} 			
+ 		}   
+ 				
+   		return $return.$this->getWorkDay($date);
+ 	} 	
+ 	
+ 	function getViewWeek($params){
+ 		$userId = $params['userId'];
+ 		$date = $params['date']; 		 	
+ 		$tstamp=mktime(0,0,0,substr($date,4,2),substr($date,6,2),substr($date,0,4));
+   	    $Tdate = getdate($tstamp);
+ 		$calendarUser = $this->getUserCalendar('week',$date, $userId);
+ 		$return = "<today>$date</today>";  		 		
+   	       	    
+   	    for ($dayofweek = 0; $dayofweek < 7; $dayofweek++){   	    	
+			$offset = $Tdate['wday'] - $dayofweek;
+			$weekday = getdate($tstamp - ($offset*86400));
+			$this -> weekDate[$dayofweek] = $weekday['year'].($weekday['mon'] < 10 ? "0" : "" ).$weekday['mon'].($weekday['mday'] < 10 ? "0" : "" ).$weekday['mday'];
+	   		if($calendarUser[$this -> weekDate[$dayofweek]]) {
+	   			foreach($calendarUser[$this -> weekDate[$dayofweek]] as $time => $title) {
+	   				$return.= "<hourofday><datetime>".$this -> weekDate[$dayofweek]."$time</datetime><title>$title</title></hourofday>";
+	   			} 			
+	 		}        	    		
+   	    }
+   		return $return.$this->getWorkDay($date).$this->getWorkWeek($date);
+ 	} 	
+ 	
+ 	function getViewMonth($params){
+ 		$userId = $params['userId']; 		
+   		return '';
+ 	}
+ 	function getViewYear($params){
+ 		$userId = $params['userId']; 		 	
+   		return '';
+ 	}
+ }
+?>
Index: /trunk/calendar_new/inc/class.bocalendar.inc.php
===================================================================
--- /trunk/calendar_new/inc/class.bocalendar.inc.php	(revision 420)
+++ /trunk/calendar_new/inc/class.bocalendar.inc.php	(revision 420)
@@ -0,0 +1,133 @@
+<?php
+define('PHPGW_API_INC','../../phpgwapi/inc');
+include_once(PHPGW_API_INC.'/class.db.inc.php');
+
+class bocalendar
+{
+	var $db;
+	function bocalendar()
+	{
+		$this->db = new db();           
+		$this->db->Halt_On_Error = 'no';
+		$this->db->connect(
+			$_SESSION['calendar']['server']['db_name'],
+			$_SESSION['calendar']['server']['db_host'],
+			$_SESSION['calendar']['server']['db_port'],
+			$_SESSION['calendar']['server']['db_user'],
+			$_SESSION['calendar']['server']['db_pass'],
+			$_SESSION['calendar']['server']['db_type']
+		);
+		$this -> user_id = $_SESSION['calendar']['user']['account_id']; 
+	}
+
+
+	var $public_functions = array(
+			'requestTodayCal' => True
+			);
+
+
+	// Return the events of current Day
+	function requestDayCal ($dayTime) {
+		$query = ("SELECT * FROM phpgw_cal where (owner = '".$this->user_id."') and ((datetime > ".$dayTime." and datetime < ".($dayTime+86400).") or (edatetime > ".$dayTime." and edatetime < ".($dayTime+86400)."))");
+
+		if (!$this->db->query($query))
+			return false;
+
+		while($this->db->next_record())
+			$result[] = $this->db->row();
+
+		return $result;
+	}
+
+	function changeEvent ($calId,$field,$value) {
+		$query = ("UPDATE phpgw_cal SET ".$field."=".$value." WHERE cal_id = ".$calId.";");
+
+		if (!$this->db->query($query))
+			return "<false>DB out of service or internal error</false>";
+
+		return "<true ></true >";
+	}
+
+	// Return the events of current Day
+	function requestWeekCal ($dayTime) {
+		// Performing SQL query
+		$query = "SELECT cal_id, title, description, datetime, edatetime FROM phpgw_cal where (owner = '".$this->user_id."') and ((datetime > ".$dayTime." and datetime < ".($dayTime+604800).") or (edatetime > ".$dayTime." and edatetime < ".($dayTime+604800)."))";
+		if (!$this->db->query($query))
+			return false;
+
+		while($this->db->next_record())
+			$result[] = $this->db->row();
+
+		return $result;
+	}
+
+	// Return the events of current Day
+	function requestMonthCal ($dayTime) {
+		// Performing SQL query
+		$query = "SELECT cal_id, title, description, datetime, edatetime FROM phpgw_cal where (owner = '".$this->user_id."') and ((datetime > ".$dayTime." and datetime < ".($dayTime+2592000).") or (edatetime > ".$dayTime." and edatetime < ".($dayTime+2592000)."))";
+		if (!$this->db->query($query))
+			return false;
+
+		while($this->db->next_record())
+			$result[] = $this->db->row();
+
+		return $result;
+	}
+
+	function insertEvent ($datetime, $edatetime, $title, $description)
+	{
+		//Discover the event id
+		$query = "SELECT max(cal_id) FROM phpgw_cal";
+		if (!$this->db->query($query))
+			return false;
+
+		while($this->db->next_record())
+			$id = $this->db->row();
+
+
+		// Performing SQL insert query
+		$query = "INSERT INTO phpgw_cal VALUES (".($id['max']+1).", '".$_SESSION['calendar']['user']['email']."', ".$this->user_id.", null, null, ".$datetime.", ".time().",".$edatetime.", 2, 'E', 0, '".$title."', '".$description."', null, 0, null, null, null )";
+
+		if ($this->db->query($query)){
+			$query = "INSERT INTO phpgw_cal_user VALUES (".($id['max']+1).", ".$this->user_id.", 'A', 'u')";
+			if ($this->db->query($query)){
+				$return = "true ";
+				$return .= ";".($id['max']+1);
+			} else {
+				$return = "false";
+				$return .= ";Query failed: " . pg_last_error();
+			}
+
+		}
+		else{
+			$return = "false";
+			$return .= ";Query failed: " . pg_last_error();
+		}
+
+		return $return;
+
+	}
+	function removeEventById($id){
+		$query = "DELETE from phpgw_cal where cal_id = ".$id;
+
+		if ($this->db->query($query)){
+			$query = "DELETE from phpgw_cal_user where cal_id = ".$id;
+			if ($this->db->query($query))
+				$return = "true ";
+			else
+			{
+				$return = "false";
+				$return .= ";Query failed: " . pg_last_error();
+			}
+		}
+		else{
+			$return = "false";
+			$return .= ";Query failed: " . pg_last_error();
+		}
+
+		return $return;
+
+	}
+}
+
+?>
Index: /trunk/calendar_new/inc/class.socalendar.inc.php
===================================================================
--- /trunk/calendar_new/inc/class.socalendar.inc.php	(revision 420)
+++ /trunk/calendar_new/inc/class.socalendar.inc.php	(revision 420)
@@ -0,0 +1,10 @@
+<?php class socalendar
+{
+
+	var $public_functions = array(
+			false			);
+
+}
+
+
+?>
Index: /trunk/calendar_new/js/drag_area.js
===================================================================
--- /trunk/calendar_new/js/drag_area.js	(revision 420)
+++ /trunk/calendar_new/js/drag_area.js	(revision 420)
@@ -0,0 +1,97 @@
+var agt=navigator.userAgent.toLowerCase();
+var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
+
+function DragArea(){
+	this.pressed = 0;
+	this.resizing = 0;
+	this.initEvent;
+	this.endEvent;
+	this.currentEvent;
+}
+
+DragArea.prototype.loadMouseDown = function(e) {
+	var	_event  = is_ie ? window.event : e;
+	var	_target = is_ie ? window.event.srcElement : e.target;
+	var _button = is_ie ? _event.button : _event.which;
+	
+	if (typeof _event.preventDefault != 'undefined') {
+		_event.preventDefault();
+	}
+
+	this.pressed = 1;	
+
+	if(_button != 2 && _button != 3) {
+		if(_target.id && _target.id.length == 12){
+			if (parseInt(_target.id) > 0)
+				this.initEvent = _target.id;
+		}	
+	}	
+};
+
+DragArea.prototype.loadMouseMove = function(e) {
+	if(!this.pressed) {
+		return true;
+	}
+	var id = is_ie ? window.event.srcElement.id : e.target.id;
+	var colorCell = function (id,style){
+		try {
+			document.getElementById(id).style.background = style;
+		}
+		catch(e)
+		{ document.style.background = "#000;"; };
+	};
+
+	var incHour = function (hour,op){
+	if (op == '+')
+		(hour%100 >= 30)?hour+=70:hour+=30;
+	else
+		(hour%100 == 30)?hour-=30:hour-=70;
+	return hour;
+	};
+
+	if((parseInt(id) > 0) && (id.length == 12)){
+		if (this.endEvent < this.initEvent)
+			if (id <= this.endEvent)
+				for (var hour = parseInt(this.initEvent); hour >= parseInt(id);hour=incHour(hour,'-')) 
+					colorCell(hour,"#EEE;");
+			else
+				for (var hour = parseInt(id); hour >= parseInt(this.endEvent);hour=incHour(hour,'-')) 
+					colorCell(hour,"");
+		else
+			if (id < this.endEvent)
+				for (var hour = parseInt(id); hour <= parseInt(this.endEvent);hour=incHour(hour,'+'))
+					colorCell(hour,"");
+			else
+				for (var hour = parseInt(this.initEvent); hour <= parseInt(id);hour=incHour(hour,'+'))
+					colorCell(hour,"#EEE;");
+		this.endEvent=id;
+		return true;
+	}
+};
+
+document.onmousemove = function(event) {_dragArea.loadMouseMove(event);};
+document.onmousedown = function(event) {_dragArea.loadMouseDown(event);};
+document.onmouseup = function(event) {_dragArea.loadMouseUp(event);};
+
+DragArea.prototype.loadMouseUp = function(e) {
+	this.pressed = 0;
+	var _event  = is_ie ? window.event : e;
+	var id = is_ie ? window.event.srcElement.id : e.target.id;
+	var _button = is_ie ? _event.button : _event.which;
+	
+	if(_button != 2 && _button != 3) {
+		if (this.resizing == 0){
+			if((parseInt(id) > 0) && (id.length == 12))
+				calendar.dialog();
+		}else{
+			if (confirm(get_lang('Change the end of this event to %1',calendar.parseDate(id2timeStamp(id)))+' ('+id.substr(8,2)+':'+id.substr(10,2)+') ?')){
+				changeEvent(this.currentEvent,'edatetime',parseInt((id2timeStamp(id)+1800000)/1000));
+			}
+			for (var hour = parseInt(_dragArea.initEvent); hour <= parseInt(_dragArea.endEvent);(hour%100 == 30)?hour+=70:hour+=30)
+				document.getElementById(hour).style.background = "";
+			this.resizing = 0;
+		}
+	}
+}
+
+var _dragArea = new DragArea();
Index: /trunk/calendar_new/js/MOFX.js
===================================================================
--- /trunk/calendar_new/js/MOFX.js	(revision 420)
+++ /trunk/calendar_new/js/MOFX.js	(revision 420)
@@ -0,0 +1,183 @@
+/*
+moo.fx, simple effects library built with prototype.js (http://prototype.conio.net).
+by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE.
+for more info (http://moofx.mad4milk.net).
+10/24/2005
+v(1.0.2)
+*/
+var Class = {
+  create: function() {
+    return function() { 
+      this.initialize.apply(this, arguments);
+    }
+  }
+}
+
+Object.extend = function(destination, source) {
+  for (property in source) {
+    destination[property] = source[property];
+  }
+  return destination;
+}
+
+Function.prototype.bind = function(object) {
+  var __method = this;
+  return function() {
+    return __method.apply(object, arguments);
+  }
+}
+
+function $() {
+  var elements = new Array();
+
+  for (var i = 0; i < arguments.length; i++) {
+    var element = arguments[i];
+    if (typeof element == 'string')
+      element = document.getElementById(element);
+
+    if (arguments.length == 1) 
+      return element;
+
+    elements.push(element);
+  }
+
+  return elements;
+}
+
+
+if (!window.Element) {
+  var Element = new Object();
+}
+
+Object.extend(Element, {
+  remove: function(element) {
+    element = $(element);
+    element.parentNode.removeChild(element);
+  },
+
+  hasClassName: function(element, className) {
+    element = $(element);
+    if (!element)
+      return;
+    var a = element.className.split(' ');
+    for (var i = 0; i < a.length; i++) {
+      if (a[i] == className)
+        return true;
+    }
+    return false;
+  },
+
+  addClassName: function(element, className) {
+    element = $(element);
+    Element.removeClassName(element, className);
+    element.className += ' ' + className;
+  },
+  
+  removeClassName: function(element, className) {
+    element = $(element);
+    if (!element)
+      return;
+    var newClassName = '';
+    var a = element.className.split(' ');
+    for (var i = 0; i < a.length; i++) {
+      if (a[i] != className) {
+        if (i > 0)
+          newClassName += ' ';
+        newClassName += a[i];
+      }
+    }
+    element.className = newClassName;
+  },
+  
+  // removes whitespace-only text node children
+  cleanWhitespace: function(element) {
+    element = $(element);
+    for (var i = 0; i < element.childNodes.length; i++) {
+      var node = element.childNodes[i];
+      if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) 
+        Element.remove(node);
+    }
+  }
+});
+//base
+var fx = new Object();
+fx.Base = function(){};
+fx.Base.prototype = {
+	setOptions: function(options) {
+	this.options = {
+		duration: 500,
+		onComplete: ''
+	}
+	Object.extend(this.options, options || {});
+	},
+
+	go: function() {
+		this.duration = this.options.duration;
+		this.startTime = (new Date).getTime();
+		this.timer = setInterval (this.step.bind(this), 13);
+	},
+
+	step: function() {
+		var time  = (new Date).getTime();
+		var Tpos   = (time - this.startTime) / (this.duration);
+		if (time >= this.duration+this.startTime) {
+			this.now = this.to;
+			clearInterval (this.timer);
+			this.timer = null;
+			if (this.options.onComplete) setTimeout(this.options.onComplete.bind(this), 10);
+		}
+		else {
+			this.now = ((-Math.cos(Tpos*Math.PI)/2) + 0.5) * (this.to-this.from) + this.from;
+			//this time-position, sinoidal transition thing is from script.aculo.us
+		}
+		this.increase();
+	},
+
+	custom: function(from, to) {
+		if (this.timer != null) return;
+		this.from = from;
+		this.to = to;
+		this.go();
+	},
+
+	hide: function() {
+		this.now = 0;
+		this.increase();
+	},
+
+	clearTimer: function() {
+		clearInterval(this.timer);
+		this.timer = null;
+	}
+}
+//fader
+fx.Opacity = Class.create();
+fx.Opacity.prototype = Object.extend(new fx.Base(), {
+	initialize: function(el, options) {
+		this.el = $(el);
+		this.now = 1;
+		this.increase();
+		this.setOptions(options);
+	},
+
+	increase: function() {
+		if (this.now == 1) this.now = 0.9999;
+		if (this.now > 0 && this.el.style.visibility == "hidden") this.el.style.visibility = "visible";
+		if (this.now == 0) this.el.style.visibility = "hidden";
+		if (window.ActiveXObject) this.el.style.filter = "alpha(opacity=" + this.now*100 + ")";
+		this.el.style.opacity = this.now;
+	},
+
+	toggle: function() {
+		if (this.now > 0) this.custom(1, 0);
+		else this.custom(0, 1);
+	}
+});
+
+function fadeinMsg(_div) {
+	myOpacity = new fx.Opacity(_div.id, {duration: 600});
+	_div.style.visibility = "hidden";
+	_div.style.display = "";
+	myOpacity.now = 0;
+	setTimeout("myOpacity.toggle()",1);
+}
Index: /trunk/calendar_new/js/connector.js
===================================================================
--- /trunk/calendar_new/js/connector.js	(revision 420)
+++ /trunk/calendar_new/js/connector.js	(revision 420)
@@ -0,0 +1,284 @@
+var progressBar;
+
+if (document.all)
+{
+	navigator.userAgent.toLowerCase().indexOf('msie 5') != -1 ? is_ie5 = true : is_ie5 = false;
+	is_ie = true;
+	is_moz1_6 = false;
+	is_mozilla = false;
+	is_ns4 = false;
+}
+else if (document.getElementById)
+{
+	navigator.userAgent.toLowerCase().match('mozilla.*rv[:]1\.6.*gecko') ? is_moz1_6 = true : is_moz1_6 = false;
+	is_ie = false;
+	is_ie5 = false;
+	is_mozilla = true;
+	is_ns4 = false;
+}
+else if (document.layers)
+{
+	is_ie = false;
+	is_ie5 = false
+		is_moz1_6 = false;
+	is_mozilla = false;
+	is_ns4 = true;
+}	
+
+/****************************************** Connector Class *************************************************/
+// Constructor
+function cConnector()
+{
+	this.requests = new Array();
+	this.oxmlhttp = null;
+	this.isVisibleBar = false;
+	this.tid = 0;
+	this.progressBar = null;
+	this.oldX = 0;
+	this.oldY = 0;
+	this.updateVersion = "";
+}
+cConnector.prototype.buildBar = function()
+{
+	var div = document.getElementById('divProgressBar');
+
+	if(! div) {                                                                                           
+		div = document.createElement("DIV");
+		div.style.visibility    = "hidden";
+		div.style.width = "103px";
+		div.id = 'divProgressBar';
+		div.align = "center";
+		div.innerHTML = '&nbsp;&nbsp;<font face="Verdana" size="2" color="WHITE">'+get_lang('loading')+'...</font>&nbsp;';
+		div.style.background = "#cc4444";
+		div.style.position = 'fixed';
+		div.style.top = '0px';
+		div.style.right = '0px';
+		document.body.appendChild(div);                                                               
+
+		if(is_ie) {
+			var elem = document.all[div.id];
+			elem.style.position="absolute";
+			var root = document.body;
+			var posX = elem.offsetLeft-root.scrollLeft;
+			var posY = elem.offsetTop-root.scrollTop;
+			root.onscroll = function() {
+				elem.style.right = '0px';
+				elem.style.top = (posY + root.scrollTop) + "px";
+			};
+		}
+	}
+}
+
+cConnector.prototype.hideProgressBar = function ()
+{
+	var div = document.getElementById('divProgressBar');
+	div.style.visibility = 'hidden';
+	this.isVisibleBar = false;
+}
+
+cConnector.prototype.showProgressBar = function(){
+	var div = document.getElementById('divProgressBar');
+	if (! div){
+		connector.buildBar();
+		connector.showProgressBar();
+		return;
+	}
+
+	div.style.visibility = 'visible';
+
+	this.isVisibleBar = true;
+}
+
+	function XMLTools()
+	{
+		this.path = "";
+	}
+var connector = new cConnector();
+
+	XMLTools.prototype = {
+		"__DEBUG__" : false,
+		"__DEFAULT_URI__" : 'inc/controller.php?action=',
+		"__HTTP__" : null,
+		"__MODE__" : 'X',
+		"__RETURN_MODE_DEFAULT__" : 'JSON',
+		"__RETURN_MODE__" : false,
+		"__THREADS__" : [],
+		"http" : function()
+		{
+			try
+			{
+				this.__HTTP__ = new XMLHttpRequest();
+				this.__HTTP__.overrideMimeType('text/xml');
+			}
+			catch (e)
+			{
+				try
+				{
+					this.__HTTP__ = new ActiveXObject('Msxml2.XMLHTTP');
+				}
+				catch (e1)
+				{
+					try
+					{
+						this.__HTTP__ = new ActiveXObject('Microsoft.XMLHTTP');
+					}
+					catch (e2)
+					{
+						this.__HTTP__ = null;
+					}
+				}
+			}
+		},
+		"request" : function(pTarget, pMethod, pHandler, pData)
+		{
+			if ( typeof pHandler != 'function' || this.__THREADS__[pTarget] )
+				return false;
+			connector.showProgressBar();
+
+			var __this = this;
+			var __pTarget = pTarget
+				this.http();
+			var __HTTP__ = this.__HTTP__;
+			this.__THREADS__[pTarget] = pHandler;
+
+			var __handler = function ()
+			{
+				try
+				{
+					if ( __HTTP__.readyState == 4 )
+					{
+						switch ( __HTTP__.status )
+						{
+							case 200:
+								var data = ( __this.__MODE__ == 'X' ) ?
+									__HTTP__.responseXML :
+									__HTTP__.responseText;
+
+								var handler = __this.__THREADS__[__pTarget];
+								delete __this.__THREADS__[__pTarget];
+								handler(data, __pTarget);
+								break; /* [case : status 200] */
+							case 404:
+								alert('Page Not Found!');
+								break; /* [case : status 404] */
+							default:
+						}
+					}
+				}
+				catch(e)
+				{
+					if ( __this.__DEBUG__ ) alert("request : #2\n\n" + e)
+				}
+			}
+
+			try
+			{
+				var target = this.__DEFAULT_URI__ + pTarget;
+				if ( this.__RETURN_MODE__ )
+				{
+					target += '&returnMode=' + this.__RETURN_MODE__;
+					this.__RETURN_MODE__ = false;
+				}
+				else
+					target += '&returnMode=' + this.__RETURN_MODE_DEFAULT__;
+
+				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;
+					pData = ( pData ) ? pData : null ;
+				}
+				else
+				{
+					__HTTP__.open("GET", target, true);
+					__HTTP__.onreadystatechange = __handler;
+					pData = null;
+				}
+				__HTTP__.send(pData);
+			}
+			catch(e)
+			{
+				if ( this.__DEBUG__ ) alert("request : #1\n\n" + e)
+			}
+			setTimeout('connector.hideProgressBar()',100);
+			return true;
+		},
+		"load" : function( pFile )
+		{
+			connector.showProgressBar();
+			var data = null;
+			if ( document.implementation.createDocument )
+				data = document.implementation.createDocument("", "", null);
+			else
+				data = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
+
+			data.async = false;
+			data.load(pFile);
+			setTimeout('connector.hideProgressBar()',100);
+			return data;
+		},
+
+		"ParseXmlXsl" : function( _xmlDoc, xslForm )
+		{
+			var xslWin = false	
+
+				//if( !xslWin ) xslWin = this.load(this.path + 'xsl/' + xslForm + '?' + Date.parse(new Date));
+
+				var 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 = this.transform(xmlDoc,xslForm );
+
+			return a;
+		},
+
+		"transform" : function( pXML, pXSL )
+		{
+			try
+			{
+				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;
+			}catch(e)
+			{
+				alert("transform\n\n" + e + "\n\n" + e.description);
+			}
+		}	
+	};
+
+	var XMLTools = new XMLTools();
Index: /trunk/calendar_new/js/common_functions.js
===================================================================
--- /trunk/calendar_new/js/common_functions.js	(revision 420)
+++ /trunk/calendar_new/js/common_functions.js	(revision 420)
@@ -0,0 +1,269 @@
+var headerMsgLock = false;
+function write_msg (message){
+	if (headerMsgLock){
+		setTimeout('write_msg("'+message+'");', 300);
+		return;
+	}
+	headerMsgLock = true;
+	headerDiv = document.getElementById("divAppboxHeader");
+	var labelBefore = headerDiv.innerHTML;
+	headerDiv.innerHTML = '<table width=100% cellspacing="0" cellpadding="0" border="0"><tbody><tr><th width="40%"></th><th noWrap class="action_info_th">'+message+'</th><th width="40%"></th></tr></tbody></table>';
+	setTimeout('headerMsgLock = false; document.getElementById("divAppboxHeader").innerHTML = \"'+labelBefore+'\";', 2000);
+}
+
+// This array stores the events in table to avoid conflict in screen
+var screenTable = new Array();
+var today = new Date();
+var weekDay = today.getDay();
+function createEventDiv(eventDiv){
+	eventDiv.className = "event_div";
+	eventDiv.style.height = parseInt(eventDiv.childNodes[2].id-eventDiv.childNodes[1].id)/120000+"px";
+	var end_ = timeStamp2id(eventDiv.childNodes[2].id).substr(8);
+	var start_ = parseInt(timeStamp2id(eventDiv.childNodes[1].id).substr(8),10);
+	if (viewType == "Day"){
+		if (!screenTable[weekDay])
+			screenTable[weekDay] = new Array();
+		eventDiv.style.width = "190px";
+
+		currentPos = 1;
+		for (var hour = parseInt(start_,10); hour < parseInt(end_,10);(hour%100 == 30)?hour+=70:hour+=30){
+			if (!screenTable[weekDay][hour])
+				screenTable[weekDay][hour] = 0;
+
+			if (currentPos <= screenTable[weekDay][hour])
+				currentPos = screenTable[weekDay][hour]+1;
+		}
+		for (var hour = parseInt(start_,10); hour < parseInt(end_,10);(hour%100 == 30)?hour+=70:hour+=30)
+			screenTable[weekDay][hour] = currentPos;
+		eventDiv.style.left  = 90+(205*(currentPos-1)) + "px" ;
+		eventDiv.onmouseover = function(){ createButtons(eventDiv); };
+		eventDiv.onmouseout = function(){ removeButtons(eventDiv); };
+		var resizeDiv = document.createElement('DIV');
+		resizeDiv.id = "resize_" + eventDiv.id;
+		resizeDiv.className = 'resize_div';
+		resizeDiv.style.right = (parseInt(eventDiv.style.width)-10)*-1+"px;";
+		resizeDiv.style.bottom = ((parseInt(eventDiv.style.height)-24)*-1)+"px;";
+		resizeDiv.onmousedown = function() { resizeEvent(eventDiv); };
+		eventDiv.appendChild(resizeDiv);
+	}
+	if (viewType == "Week"){
+		var tempDate = new Date;
+		tempDate.setTime(eventDiv.childNodes[2].id);
+		if (!screenTable[tempDate.getDay()])
+			screenTable[tempDate.getDay()] = new Array();
+		currentPos = 1;	
+		if (!screenTable[tempDate.getDay()][start_])
+			screenTable[tempDate.getDay()][start_] = 0;
+
+		if (currentPos <= screenTable[tempDate.getDay()][start_])
+			currentPos = screenTable[tempDate.getDay()][start_]+1;
+		screenTable[tempDate.getDay()][start_] = currentPos;
+
+		var widthValue = 100;
+		eventDiv.style.width = widthValue+"px";
+
+		var headerElement = document.getElementById('weekHeader_'+timeStamp2id(eventDiv.childNodes[2].id).substr(0,8));
+		if (currentPos > 1)
+			eventDiv.style.left = (10+(tempDate.getDay()*122)+(widthValue*currentPos))+"px";
+		headerElement.style.width = (widthValue*currentPos)+"px";
+		eventDiv.style.height = "20px";
+		eventDiv.style.cursor = "pointer";
+		eventDiv.onmouseover = function () { this.style.height = (parseInt(this.style.height)+40)+"px"; };
+		eventDiv.onmouseout = function () { this.style.height = (parseInt(this.style.height)-40)+"px"; };
+		eventDiv.onclick = function () { calendar.getView('div_main','Day','&time='+timeStamp2id(eventDiv.childNodes[2].id).substr(0,8)); };
+	}
+	var tdElement = document.getElementById(timeStamp2id(eventDiv.childNodes[1].id));
+
+	if (viewType == "Month"){
+		eventDiv.style.width = "90px";
+		eventDiv.style.heigth = "20px";
+		var tdElement = document.getElementById(timeStamp2id(eventDiv.childNodes[1].id).substr(0,8)+'0000');
+	}
+
+	eventDiv.style.top  =  (tdElement.offsetTop + 145) + "px" ;
+	tdElement.appendChild(eventDiv);
+}
+
+function createButtons(eventDiv) {
+	var lnk = document.getElementById('remove_'+eventDiv.id);
+	var lnk2 = document.getElementById('details_'+eventDiv.id);
+	if (!lnk){
+		var removeLink = document.createElement('a');
+		removeLink.id = "remove_" + eventDiv.id;
+		removeLink.href = "javascript:removeEvent("+eventDiv.id.substr(6)+");";
+		removeLink.innerHTML = '<img onmouseover="this.setAttribute(\'width\', \'15\');"'+
+			'onmouseout="this.setAttribute(\'width\', \'10\');"'+
+			' title="'+get_lang('remove')+'" alt="'+get_lang('remove')+'"'+
+			' src="templates/default/images/min.png"></img>';
+		removeLink.style.position = "absolute";
+		removeLink.style.top = "0px";
+		removeLink.style.left = "175px";
+		var showDetailLink = document.createElement('a');
+		showDetailLink.id = "details_" + eventDiv.id;
+		showDetailLink.href = "javascript:alert('show details');";
+		showDetailLink.innerHTML = '<img onmouseover="this.setAttribute(\'width\', \'15\');"'+
+			'onmouseout="this.setAttribute(\'width\', \'10\');"'+
+			' title="'+get_lang('details')+'" alt="'+get_lang('details')+'"'+ 
+			' src="templates/default/images/plus.png"></img>';
+		showDetailLink.style.position = "absolute";
+		showDetailLink.style.top = "0px";
+		showDetailLink.style.left = "160px";
+
+		eventDiv.appendChild(showDetailLink);
+		eventDiv.appendChild(removeLink);
+	}
+	else{
+		lnk.style.visibility="visible";
+		lnk2.style.visibility="visible";
+	}
+}
+function removeButtons(eventDiv){
+	var lnk = document.getElementById('remove_'+eventDiv.id);
+	var lnk2 = document.getElementById('details_'+eventDiv.id);
+	if (lnk){
+		lnk.style.visibility="hidden";
+		lnk2.style.visibility="hidden";
+	}
+}
+
+function removeEvent (id) {
+	var handler_removeEvent = function (data) {
+		var serverRet = data.firstChild.childNodes[0];
+		var retStatus = serverRet.substringData(0,4);
+		if (retStatus == "false")
+			write_msg(get_lang("Error") + ": " + serverRet.data)
+		else{
+			var eventDiv = document.getElementById("event_"+id);
+			if (viewType == "Day"){
+				init_ = timeStamp2id(eventDiv.childNodes[1].id).substr(8);
+				end_ = timeStamp2id(eventDiv.childNodes[2].id).substr(8);
+				for (var hour = parseInt(init_,10); hour < parseInt(end_,10);(hour%100 == 30)?hour+=70:hour+=30)
+					screenTable[weekDay][hour]--;
+			}
+			eventDiv.parentNode.removeChild(eventDiv);
+			write_msg(get_lang("Event were deleted"));
+		}
+	}
+	XMLTools.request('$this.uicalendar.removeEvent&id='+id, 'GET', handler_removeEvent);
+}
+
+function quickAddEvent (description, startTime, endTime)
+{
+	var endDate = new Date();
+	endDate.setTime(id2timeStamp(endTime)+1800000);
+
+	var handler_quickAdd = function (data) {
+		calendar.dialog('infowindow');
+
+		var serverRet = data.firstChild.childNodes[0];
+		var retStatus = serverRet.substringData(0,5);
+
+		if (retStatus == "false")
+			write_msg(get_lang("Error") + ": " + get_lang(serverRet.data.substr(6)));
+		else{
+			var tdElement = document.getElementById(startTime);
+			var eventDiv = document.createElement('DIV');
+			eventDiv.id = "event_" + serverRet.substringData(6,serverRet.data.length);
+			eventDiv.innerHTML = description;
+			var endDateDiv = document.createElement('DIV');
+			var startDateDiv = document.createElement('DIV');
+			endDateDiv.id = endDate.getTime();
+			startDateDiv.id = id2timeStamp(startTime);
+			eventDiv.appendChild(startDateDiv);
+			eventDiv.appendChild(endDateDiv);
+
+			createEventDiv(eventDiv);
+			write_msg(get_lang("Event were added successfully!"));
+		}
+
+	}
+	XMLTools.request('$this.uicalendar.quickAdd&start='+parseInt(id2timeStamp(startTime)/1000)+'&end='+parseInt(endDate.getTime()/1000)+'&desc='+description, 'GET', handler_quickAdd);
+}
+
+function changeEvent(objEvent,field,value){
+	init_ = timeStamp2id(objEvent.childNodes[1].id).substr(8);
+	end_ = timeStamp2id(objEvent.childNodes[2].id).substr(8);
+
+	var handler_changeEvent = function (data){
+		var serverRet = data.firstChild.childNodes[0];
+		var retStatus = serverRet.substringData(1,5);
+		if (retStatus == "false")
+			write_msg(get_lang("Error") + ": " + serverRet.data)
+		else
+			switch (field) {
+				case 'edatetime':
+					for (var hour = parseInt(init_,10); hour < parseInt(end_,10);(hour%100 == 30)?hour+=70:hour+=30)
+						screenTable[weekDay][hour]--;
+
+					objEvent.childNodes[2].id = value*1000;
+					var resizeIcon = document.getElementById("resize_"+objEvent.id);
+					resizeIcon.parentNode.removeChild(resizeIcon);
+
+					createEventDiv(objEvent);
+					break;
+				default:
+					alert('not implemented');
+			}
+	}
+	XMLTools.request('$this.uicalendar.changeEvent&cal_id='+objEvent.id.substr(6)+'&field='+field+'&value='+value, 'GET', handler_changeEvent);
+}
+
+// Convert Unix Time Stamp to Div Id used in calendar
+function timeStamp2id(timeStamp){
+	var tmpDate = new Date();
+	tmpDate.setTime(timeStamp);
+	return (tmpDate.getYear()+1900)+""+
+		(tmpDate.getDate()<10?"0"+tmpDate.getDate():tmpDate.getDate())+
+		(tmpDate.getMonth()<9?"0"+(tmpDate.getMonth()+1):(tmpDate.getMonth()+1))+
+		(tmpDate.getHours()<10?"0"+tmpDate.getHours():tmpDate.getHours())+
+		(tmpDate.getMinutes()<10?"0"+tmpDate.getMinutes():tmpDate.getMinutes());
+}
+
+// Convert the opposite of function above
+function id2timeStamp(id){
+	objDate = new Date();
+	objDate.setYear(id.substr(0,4));
+	objDate.setMonth(id.substr(6,2)-1);
+	objDate.setDate(id.substr(4,2));
+	objDate.setHours(id.substr(8,2));
+	objDate.setMinutes(id.substr(10,2));
+	return objDate.getTime();
+}
+
+
+function get_lang(_key,_arg1,_arg2,_arg3,_arg4){
+	if (_key.length == 0)
+		return '';
+	if(!array_lang[0]){
+		return _key+"*";
+	}
+	_value = "";
+	for(i = 0; i < array_lang[0].length;i++){
+		if(array_lang[0][i] == _key.toLowerCase()) {
+			_value = array_lang[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;
+}
+
+function resizeEvent (eventDiv) {
+	_dragArea.pressed = 1;
+	_dragArea.initEvent = eventDiv.parentNode.id;
+	_dragArea.resizing = 1;
+	_dragArea.currentEvent = eventDiv;
+}
+
+refreshLang();
Index: /trunk/calendar_new/js/calendar_functions.js
===================================================================
--- /trunk/calendar_new/js/calendar_functions.js	(revision 420)
+++ /trunk/calendar_new/js/calendar_functions.js	(revision 420)
@@ -0,0 +1,199 @@
+var viewType;
+var todayDate = new Date();
+
+function Calendar()
+{
+	this.idEl;
+	this.lastId;
+	this.colorCellSelected = "LIGHTYELLOW";
+	this.nextView;
+	this.previousView;
+}
+
+Calendar.prototype.dialog = function() {
+	var divAddDialog = document.getElementById("divAddDialog");
+	if (_dragArea.initEvent > _dragArea.endEvent){
+		var temp = _dragArea.initEvent;
+		_dragArea.initEvent = _dragArea.endEvent;
+		_dragArea.endEvent = temp;
+	}
+
+
+	if(divAddDialog && divAddDialog.style.display != "none"){
+		divAddDialog.style.display = "none";
+		for (var hour = parseInt(_dragArea.initEvent); hour <= parseInt(_dragArea.endEvent);(hour%100 == 30)?hour+=70:hour+=30)
+			document.getElementById(hour).style.background = "";
+		_dragArea.initEvent = null;
+		_dragArea.endEvent = null;
+		try {
+			document.getElementById("div_main").style.opacity = 1;
+			document.getElementById("div_main").filters.alpha.opacity=100;
+		} catch (e) {  }
+	return true;
+	}
+
+	var cell = document.getElementById(_dragArea.endEvent);
+	try {
+		document.getElementById("div_main").style.opacity = 0.5;
+		document.getElementById("div_main").filters.alpha.opacity=50;
+	} catch (e) {};
+	
+	var data = '<text><date>'+calendar.parseDate(id2timeStamp(_dragArea.initEvent))+'</date><time>'+ calendar.parseTime(_dragArea.initEvent,_dragArea.endEvent)+'</time></text>';
+	var xsl = XMLTools.load('xsl/addDialog.xsl?'+ Date.parse(new Date));
+
+	if(!divAddDialog) {
+		divAddDialog = document.createElement("DIV");
+		divAddDialog.id = 'divAddDialog';
+		divAddDialog.style.zIndex = "10";
+		divAddDialog.style.position = "absolute";
+		divAddDialog.style.display = "none";
+		document.body.appendChild(divAddDialog);
+	}
+	divAddDialog.style.left = "300px"; //cell.offsetLeft + document.body.scrollLeft;
+	divAddDialog.style.top 	= "200px"; //cell.offsetTop - 100 + document.getElementById('div_main').offsetTop;
+	var elData = XMLTools.ParseXmlXsl(data, xsl);
+	divAddDialog.style.display = "block";
+	divAddDialog.innerHTML = elData.innerHTML;
+	document.getElementById('dragEventSubject').focus();
+	document.getElementById('addEventLink').innerHTML = get_lang("Add this event");
+
+	this.lastId = _dragArea.endEvent;
+
+}
+Calendar.prototype.getView = function(idEl, type, data)
+{
+	this.idEl = idEl;
+	var _this = this;
+	this.lastId = null;
+
+	var handler_getView = function(XMLdata)
+	{
+
+		try {
+			_this.parseView(XMLdata,type);
+
+			if (viewType == "Week"){
+				this.previousView = document.getElementById('day').firstChild.id;
+				this.nextView = document.getElementById('day').firstChild.id;
+				var dayInt = parseInt(this.nextView.substr(4,2),10)+7;
+				this.nextView = this.nextView.substr(0,4)+(dayInt+7)+this.nextView.substr(6,2);
+				}
+			if (viewType == "Day"){
+				this.nextView = document.getElementById('day').firstChild.id;
+				this.previousView = document.getElementById('day').firstChild.id;
+				var dayInt = parseInt(this.nextView.substr(4,2),10);
+				this.nextView = this.nextView.substr(0,4)+(dayInt+1)+this.nextView.substr(6,2);
+				var dayInt = parseInt(this.previousView.substr(4,2),10);   
+				this.previousView = this.previousView.substr(0,4)+(dayInt-1)+this.previousView.substr(6,2);
+			}
+			document.getElementById("l_date").innerHTML =  "<a href=\"javascript:calendar.getView('div_main','"+viewType+"','&time='+this.previousView);\">\<\<&nbsp;</a>";
+			if (viewType == "Week")
+				document.getElementById("l_date").innerHTML += calendar.parseWeek(id2timeStamp(document.getElementById('day').firstChild.id));
+			else
+				document.getElementById("l_date").innerHTML += calendar.parseDate(id2timeStamp(document.getElementById('day').firstChild.id));
+			document.getElementById("l_date").innerHTML += "<a href=\"javascript:calendar.getView('div_main','"+viewType+"','&time='+this.nextView);\">&nbsp;\>\></a>";
+
+		}catch(e){ alert(e); }
+		var events = document.getElementById('returnEvents');
+		while(typeof(events.firstChild.id) == 'string'){	
+			createEventDiv(events.firstChild);
+		}
+
+	};
+
+	XMLTools.__RETURN_MODE__ = 'XML';
+	viewType = type;
+	screenTable = new Array();
+	XMLTools.request('$this.uicalendar.getView'+type+(data?data:''), 'GET', handler_getView);  
+};
+
+
+Calendar.prototype.parseView = function(data,type)
+{
+	var _this = this;
+	try {
+	    var xsl = XMLTools.load('xsl/view'+type+'.xsl?'+ Date.parse(new Date));
+	    var div = document.getElementById(this.idEl);
+	    div.innerHTML = XMLTools.transform(data, xsl);
+	}
+	catch(e){
+		alert(e);
+	}
+
+	if (type == 'Week' || type == 'Month'){
+		var trWeek = document.getElementById('tr_week');
+		for (var i=0; i < trWeek.childNodes.length; i++)
+			trWeek.childNodes[i].innerHTML = get_lang(trWeek.childNodes[i].innerHTML);
+	}
+};
+
+
+Calendar.prototype.parseTime = function (first, last) {
+
+	var hour	= first.substring(8,10);
+	var minute 	= first.substring(10,12);
+	var startHour = hour+":"+minute;
+	
+	if(last && first != last) {
+		hour	= last.substring(8,10);
+		minute 	= last.substring(10,12);
+	}
+	
+	if(minute == "30") {
+		hour	= parseInt(hour,10);
+		hour	= (hour < 9 ? "0" : "")+(hour+1);		
+		minute 	= "00";
+	}
+	else {
+		minute	= "30";		
+	}
+		
+	return startHour+ " - "+ hour+":"+minute;
+}
+Calendar.prototype.parseWeek = function (timeStamp) {
+	dateObj=new Date();
+	dateObj.setTime(timeStamp);
+	Year=dateObj.getYear();
+	if (Year < 70) { Year=Year*1+2000; }
+	if (Year < 1900) { Year=Year*1+1900; }
+	Then=new Date(Year, 0, 1);
+	Then_Day=Then.getDay();
+	Diff=dateObj*1-Then*1;
+	Days=Math.floor(Diff/(1000*60*60*24)+(1/24));
+	Week=Math.floor((Days+Then_Day)/7)+1;
+	return get_lang("Week Number %1 of %2",Week,Year);
+}
+Calendar.prototype.parseDate = function (timeStamp) {
+	var obj = new Date();
+	obj.setTime(timeStamp);
+
+	switch(obj.getDay()) {  
+		case 0: day = "Sunday"; break;  
+		case 1: day = "Monday"; break;  
+		case 2: day = "Tuesday"; break;  
+		case 3: day = "Wednesday"; break;  
+		case 4: day = "Thursday"; break;  
+		case 5: day = "Friday"; break;  
+		case 6: day = "Saturday"; break;  
+		default: day = ""; break;
+	}     	
+   
+	switch(obj.getMonth()) {  
+		case 0: month = "January"; break;  
+		case 1: month = "February"; break;  
+		case 2: month = "March"; break;  
+		case 3: month = "April"; break;  
+		case 4: month = "May"; break;  
+		case 5: month = "June"; break;  
+		case 6: month = "July"; break;  
+		case 7: month = "August"; break;  
+		case 8: month = "September"; break;  
+		case 9: month = "October"; break;  
+		case 10: month = "November"; break;  
+		case 11: month = "December"; break;  
+		default: month = ""; break;
+	}	
+	year = parseInt(obj.getYear())+1900;
+	return get_lang(day)+", "+obj.getDate()+" "+get_lang("of")+" "+get_lang(month)+" "+get_lang("of")+" "+year; // FIXME USE FORMAT DATE AS PREFERENCE
+}
+var calendar = new Calendar();
Index: /trunk/calendar_new/js/globals.js
===================================================================
--- /trunk/calendar_new/js/globals.js	(revision 420)
+++ /trunk/calendar_new/js/globals.js	(revision 420)
@@ -0,0 +1,12 @@
+var array_lang = new Array();
+function refreshLang(){
+	document.getElementById('dayLinkView').title = get_lang('Daily View');
+	document.getElementById('dayLinkView').alt = get_lang('Daily View');
+	document.getElementById('weekLinkView').title = get_lang('Weekly View');
+	document.getElementById('weekLinkView').alt = get_lang('Weekly View');
+	document.getElementById('monthLinkView').title = get_lang('Monthly View');
+	document.getElementById('monthLinkView').alt = get_lang('Monthly View');
+	document.getElementById('yearLinkView').title = get_lang('Year View');
+	document.getElementById('yearLinkView').alt = get_lang('Year View');
+}
+
Index: /trunk/calendar_new/index.php
===================================================================
--- /trunk/calendar_new/index.php	(revision 420)
+++ /trunk/calendar_new/index.php	(revision 420)
@@ -0,0 +1,59 @@
+<?php
+/**************************************************************************\
+ * Expresso Livre - Calendar                                                *
+ * http://www.expressolivre.org                                             *
+ * Based on Webcalendar by Craig Knudsen <cknudsen@radix.net>               *
+ * Modified by Mark Peters <skeeter@phpgroupware.org>                       *
+ * And than Modified by Alexandre Muller <amuller@celepar.pr.gov.br>        *
+ * --------------------------------------------                             *
+ *  This program is free software; you can redistribute it and/or modify it *
+ *  under the terms of the GNU General Public License as published by the   *
+ *  Free Software Foundation; either version 2 of the License, or (at your  *
+ *  option) any later version.                                              *
+ \**************************************************************************/
+
+
+$phpgw_flags = Array(
+		'currentapp'	=>	'calendar_new',
+		'noappheader'   =>      True,
+		'noappfooter'   =>      True,
+		'nofooter'      =>      false
+		);
+
+
+$GLOBALS['phpgw_info']['flags'] = $phpgw_flags;
+include('../header.inc.php');
+$_SESSION['calendar']['user'] = $GLOBALS['phpgw_info']['user'];
+$_SESSION['calendar']['server'] = $GLOBALS['phpgw_info']['server'];
+
+$template_1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+$template_1->set_file(Array('calendar_new' => 'index.tpl'));
+$template_1->set_block('calendar_new','index');
+$template_1->pfp('out','index');
+
+
+if(!is_object($GLOBALS['phpgw']->datetime))
+{
+	$GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.date_time');
+}
+
+$parms = Array(
+		'date'		=> date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime)
+	      );
+
+// Footer
+$GLOBALS['phpgw']->common->phpgw_footer();
+echo "<link rel='stylesheet' href='templates/default/main.css' />"
+."<script language='JavaScript' type='text/javascript' src='js/globals.js'></script>"
+."<script src='inc/load_lang.php?".$GLOBALS['phpgw_info']['flags']['update_version']."' type='text/javascript'></script>"
+."<script language='JavaScript' type='text/javascript' src='js/connector.js'></script>"
+."<script language='JavaScript' type='text/javascript' src='js/calendar_functions.js'></script>"
+."<script language='JavaScript' type='text/javascript' src='js/drag_area.js'></script>"
+."<script language='JavaScript' type='text/javascript' src='js/MOFX.js'></script>"
+."<script language='JavaScript' type='text/javascript' src='js/common_functions.js'></script>";
+
+$GLOBALS['phpgw']->common->phpgw_exit();
+
+?>
+
+
Index: /trunk/calendar_new/templates/default/index.tpl
===================================================================
--- /trunk/calendar_new/templates/default/index.tpl	(revision 420)
+++ /trunk/calendar_new/templates/default/index.tpl	(revision 420)
@@ -0,0 +1,13 @@
+<!-- BEGIN index -->
+<a href="javascript:void(0)" onclick="calendar.getView('div_main','Day')">
+<img id="dayLinkView" src="templates/default/images/today.png"></img></a>
+<a href="javascript:void(0)" onclick="calendar.getView('div_main','Week')">
+<img id="weekLinkView" src="templates/default/images/week.png"></img></a>
+<a href="javascript:void(0)" onclick="calendar.getView('div_main','Month')">
+<img id="monthLinkView" src="templates/default/images/month.png"></img></a>
+<a href="javascript:void(0)" onclick="calendar.getView('div_main','Year')">
+<img id="yearLinkView" src="templates/default/images/year.png"></img></a>
+<br>
+<div style="width:100%;height:100%" id="div_main"></div>";
+
+<!-- END index -->
Index: /trunk/calendar_new/templates/default/main.css
===================================================================
--- /trunk/calendar_new/templates/default/main.css	(revision 420)
+++ /trunk/calendar_new/templates/default/main.css	(revision 420)
@@ -0,0 +1,89 @@
+.table_common {
+	border:0px solid black; 
+	border-collapse: collapse;	
+	background: rgb(195, 217, 255) none repeat scroll 0% 50%; 
+}
+.td_header {
+	background: rgb(195, 217, 255) none repeat scroll 0% 50%; 
+	border: 1px solid lightgray;
+	border-collapse: collapse;	
+	color: darkblue;
+	font-size: 0.8em; 	
+	font-family:arial, verdana;
+	text-align:center;
+ }
+
+ .td_common {
+	 background: white none repeat scroll 0% 50%; 
+	 border: 1px solid lightgray;
+	 border-collapse: collapse;
+	 color: darkblue;
+	 text-align:left;
+	 font-size: 0.8em; 	
+	 font-family:arial, verdana;
+ }
+
+ .td_day {
+	 background: white none repeat scroll 0% 50%;
+	 border: 1px solid lightgray;
+/*	 height: 15px;*/
+	 color: darkblue;
+	 text-align:center;
+	 font-size: 0.8em;
+	 font-family:arial, verdana;
+	  }
+
+ .a_common {
+	color: darkblue;
+ 	font-size: 0.7em; 	
+	font-family:arial, verdana;
+}
+
+ .input_common { 
+     font-family: Verdana;
+     font-size: 9px;
+     color: #576f8b;
+     text-decoration: none;
+     background-color: #FFFFFF;
+     border: 1px #576f8b solid;
+}
+.action_info_th {
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	border-width: 0px 0px 0px 0px;
+padding: 1px 10px 0px 10px;
+	 border-style: inset inset inset inset;
+	 border-color: gray gray gray gray;
+	 background-color: rgb(250, 209, 99);
+	 -moz-border-radius: 6px 6px 6px 6px;
+}
+
+.resize_div {
+	position: relative;
+	background: url(./images/resize.png);
+	width: 11px;
+	height: 11px;
+	cursor: se-resize;
+}
+
+.buttontype {
+	background-color: rgb(239, 239, 231);
+	-moz-border-radius: 5px 5px 5px 5px;
+	width: 100px;
+	border: 2px #AAA solid;
+	color:	#1111AA;
+	text-decoration: none; 
+}
+
+.event_div {
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+	position: absolute;
+	font-size: 11.5px;
+	/*width: 35%;*/
+	display: block;
+	overflow: hidden;
+	border: 1px solid gray; /* lightgray;*/
+	background-color: #FFFFCC; /* CCFFFF */
+	-moz-border-radius: 6px 6px 6px 6px;
+
+}
