Index: /trunk/phpgwapi/templates/news_old/login.css
===================================================================
--- /trunk/phpgwapi/templates/news_old/login.css	(revision 7836)
+++ /trunk/phpgwapi/templates/news_old/login.css	(revision 7836)
@@ -0,0 +1,223 @@
+body{
+	margin-top: 0;
+	margin-bottom: 0;
+	margin-left: 0;
+	margin-right: 0; 
+	padding-top: 0;
+	padding-bottom: 0;
+	padding-left: 0;
+	padding-right: 0;
+}
+
+a:link,a:visited
+{
+	cursor:pointer;
+	color: #006699; 
+	text-decoration: none;
+}
+
+a:hover,a:active
+{
+	cursor:pointer;
+	color: #ff9933;
+	text-decoration: underline;
+}
+#conteudo {
+        background:url(../../../phpgwapi/templates/news/images/back_pagina.jpg) repeat-x #fff;
+}
+
+#conteudo_corpo{
+        margin:auto 0; width:770px;
+}
+
+#superior {
+        background: url(../../../phpgwapi/templates/news/images/fundo3.jpg) no-repeat top left;
+        height:340px;
+}
+
+#login {
+        text-align:left;
+        position: relative;
+        top: 49px;
+        left: -186px;
+}
+
+#login td {
+        text-align:left;
+}
+
+.login_label {
+        font-family:  Arial, Verdana,Helvetica, sans-serif;
+        font-size: 12px;
+        color: #003366;
+        font-weight: bold;
+}
+
+
+.button {
+        background:url(../../../phpgwapi/templates/news/images/back_botao.jpg) #1F4F7E no-repeat scroll left top;
+        color:#fff;
+        font-family: Arial,Verdana, Helvetica, sans-serif;
+        font-size:12px;
+        padding-top:2px 4px 2px 4px;
+        margin:2px 1px 0pt;
+        border: medium none;
+        font-weight: bold;
+        height:31px;
+        width:83px;
+}
+
+#caixa_login {
+	width: 262px; 
+	left: 30px;
+	position: relative;
+	float: left;
+	background: url("../../../phpgwapi/templates/news/images/corpo.jpg") repeat-y; 
+}
+
+#reflexo {
+	background:url(../../../phpgwapi/templates/news/images/topo_reflexo.jpg) no-repeat center top;	
+}
+
+.button:hover {
+        background:url(../../../phpgwapi/templates/news/images/back_botao_over.jpg) #FD9C0E no-repeat top left;
+        color:#1F4F7E;
+}
+
+#inferior {
+        background: url(../../../phpgwapi/templates/news/images/fundo4.jpg) no-repeat top left;
+        height:146px;
+}
+
+#rodape {
+        text-align:left;
+        width:100%;
+        position: relative;
+        margin:0;
+}
+
+#rodape_login {
+	background: #FFF url("../../../phpgwapi/templates/news/images/rodape.jpg") no-repeat; 
+	height: 41px;
+	clear: both; 
+}
+
+#rodape table {
+        width:250px;
+        font-family:  Arial, Verdana,Helvetica, sans-serif;
+        font-size:11px;
+        color: #666666;
+        text-align:right;
+        margin-left:108px;
+}
+
+#alterna_login {
+	clear: both;
+	text-align: left;
+	padding-left: 11px;
+	padding-top: 5px;
+}
+
+#alterna_login img {
+	margin-right: 5px;
+	vertical-align: middle;
+}
+
+#alterna_login a {
+	color: #fff;
+	font-family: Arial, Verdana, Helvetica, sans-serif;
+	font-size: 11px;
+	font-weight: bold;
+	text-decoration: none;
+	margin: 0px;
+	padding: 0px;
+}
+
+#alterna_login a:hover {
+	color: #fff !important;
+	text-decoration: underline !important;
+}
+
+.ajuda {
+	text-align: left;
+	padding-left: 11px;
+	padding-top: 9px;
+}
+
+.ajuda img {
+	vertical-align: middle;
+}
+
+.ajuda a {
+	font-family: Arial, Verdana, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #FFF !important;
+	margin-top: 10px;
+	margin-left: 11px;
+	font-weight: bold;
+	text-decoration: none;
+}
+
+.ajuda a:hover {
+	text-decoration:underline;
+}
+
+.login_Label {
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000066;
+	padding-top: 0px;
+	padding-bottom: 3px;
+}
+
+.msgInicial {
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+	height: 15px;
+	font-size: 12px;
+	color: #000066;
+	font-weight: bold;
+	padding-bottom: 13px;
+	padding-left: 0px;
+}
+
+.titulo_login {
+	font-family:  Arial, Verdana,Helvetica, sans-serif;
+	font-size: 14px;
+	color: #85A9CF;
+	font-weight: bold;
+	width:250px;
+	text-transform:uppercase;
+	line-height:22px;
+	padding:2px;
+}
+#news {
+	position:relative;
+	float:left;	
+	left:400px;	
+	top:95px;		
+	width:250px;	
+}
+#news_block {
+	overflow: hidden;
+	width:250px;
+	height:115px;	
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px; 
+	text-align:justify;	
+	background: #fff;
+	border:2px solid #71a8eb;		
+}
+#news_subject{
+	margin:7px 0px 0px 7px;	
+}
+#news_content{
+	margin:7px 7px 0px 7px;
+}
+.news_button_over{
+	cursor:pointer;
+	border:1px solid white;
+		
+}
+.news_button{		
+	border:1px solid transparent;
+}
Index: /trunk/phpgwapi/templates/news_old/login.tpl
===================================================================
--- /trunk/phpgwapi/templates/news_old/login.tpl	(revision 7836)
+++ /trunk/phpgwapi/templates/news_old/login.tpl	(revision 7836)
@@ -0,0 +1,220 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<HTML>
+<!-- BEGIN login_form -->
+<HEAD>
+<META http-equiv="Content-Type" content="text/html; charset={charset}">
+<META name="AUTHOR" content="dGroupWare http://www.eGroupWare.org">
+<META NAME="description" CONTENT="{website_title} login screen, working environment powered by eGroupWare">
+<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
+<META NAME="keywords" CONTENT="{website_title} login screen, eGroupWare, groupware, groupware suite">
+{login_css}
+<TITLE>{website_title} - {lang_login}</TITLE>
+<script src="./phpgwapi/templates/{template}/js/hash.js" type="text/javascript"></script>
+<script src="./phpgwapi/templates/{template}/js/news.js" type="text/javascript"></script>
+<script language="Javascript">
+<!--
+
+	function setLogin(){
+		if( document.flogin.organization != null)
+			document.flogin.login.value = document.flogin.organization.value+'-'+document.flogin.user.value;
+		else
+			document.flogin.login.value = document.flogin.user.value;			
+	}
+	
+	function getLogin(){
+		var cookie = '{cookie}';
+		if( document.flogin.organization != null)
+			document.flogin.user.value= cookie.substring(cookie.indexOf('-')+1,cookie.length);
+		else	
+			document.flogin.user.value= cookie;
+
+		if(document.flogin.user.value == '') {
+			if(document.flogin.organization != null)
+				document.flogin.organization.focus();
+			else
+				document.flogin.user.focus();
+		}
+		else
+			document.flogin.passwd.focus();
+	}
+	
+ 	function openWindow(newWidth,newHeight,link) {					
+		newScreenX  = screen.width - newWidth;	
+		newScreenY  = 0;		
+		Window1=window.open('{dir_root}'+link,'',"width="+newWidth+",height="+newHeight+",screenX="+newScreenX+",left="+newScreenX+",screenY="+newScreenY+",top="+newScreenY+",toolbar=no,scrollbars=yes,resizable=no");
+	}
+        var opened = false, vkb = null, text = null; 
+        var userstr = navigator.userAgent.toLowerCase(); 
+        var safari = (userstr.indexOf('applewebkit') != -1); 
+        var gecko  = (userstr.indexOf('gecko') != -1) && !safari; 
+        function loadvkbd(){ 
+                if(typeof(VKeyboard) == 'function') 
+                        keyb_change(); 
+                else 
+                { 
+                        vkbdscript=document.createElement('SCRIPT'); 
+                        vkbdscript.src="phpgwapi/js/jscode/vkboards.js"; 
+                        vkbdscript.onload = keyb_change; 
+                        if(gecko || window.opera || safari) 
+                                vkbdscript.onload = keyb_change; 
+                        else 
+                                setTimeout('keyb_change()',3000);  
+                        document.body.appendChild(vkbdscript); 
+                } 
+        } 
+ 
+   var opened = false, vkb = null, text = null; 
+ 
+   function keyb_change() 
+   { 
+     opened = !opened; 
+ 
+     if(opened && !vkb) 
+     { 
+       vkb = new VKeyboard("keyboard",    // container's id 
+                           keyb_callback, // reference to the callback function 
+                           false,          // create the arrow keys or not? (this and the following params are optional) 
+                           false,          // create up and down arrow keys?  
+                           false,         // reserved 
+                           false,          // create the numpad or not? 
+                           "",            // font name ("" == system default) 
+                           "14px",        // font size in px 
+                           "#FFF",        // font color 
+                           "#F00",        // font color for the dead keys 
+                           "#83a6ce",        // keyboard base background color 
+                           "#28599e",        // keys' background color 
+                           "#DDD",        // background color of switched/selected item 
+                           "#777",        // border color 
+                           "#CCC",        // border/font color of "inactive" key (key with no value/disabled) 
+                           "#83a6ce",        // background color of "inactive" key (key with no value/disabled) 
+                           "#F77",        // border color of the language selector's cell 
+                           true,          // show key flash on click? (false by default) 
+                           "#CC3300",     // font color during flash 
+                           "#FF9966",     // key background color during flash 
+                           "#CC3300",     // key border color during flash 
+                           false,         // embed VKeyboard into the page? 
+                           true,          // use 1-pixel gap between the keys? 
+                           0);            // index(0-based) of the initial layout 
+     } 
+     else 
+       vkb.Show(opened); 
+ 
+     text = document.getElementById("passwd"); 
+     text.focus(); 
+     if (!(gecko || window.opera || safari)) 
+     { 
+        document.getElementById('keyboard').style.left = "0px"; 
+        document.getElementById('rodape').style.zIndex="-100"; 
+     } 
+ 
+   } 
+   // Callback function: 
+   function keyb_callback(ch) 
+   { 
+     var val = text.value; 
+ 
+     switch(ch) 
+     { 
+       case "BackSpace": 
+         var min = (val.charCodeAt(val.length - 1) == 10) ? 2 : 1; 
+         text.value = val.substr(0, val.length - min); 
+         break; 
+ 
+       case "Enter": 
+         document.getElementById('loginForm').submit(); 
+         break; 
+ 
+       default: 
+         text.value += ch; 
+     } 
+   } 
+ function setRange(ctrl, start, end){ 
+ } 	
+ var news = new News({public_news});
+	-->
+</script>
+</HEAD>
+<body scroll="no"  style="overflow:hidden" onLoad="javascript:getLogin();news.start(4000)" bgcolor="#ffffff">
+<form id="loginForm" name="flogin" method="post" action="{login_url}" {autocomplete}>
+<div id="conteudo">
+<div style="position: absolute; top:0px; right: 10px;"><span class="login_label">{lang_language}&nbsp;&nbsp;</span>{select_language}</div>
+<div align="center">
+	<div id="conteudo_corpo">
+		<div id="superior">
+			<div id="news">
+				<div id="news_block">				
+					<b><div id="news_subject"></div></b><div id="news_content"></div>
+				</div>
+				<img onmouseover="this.className='news_button_over'" onmouseout="this.className='news_button'" class="news_button" onclick="javascript:news.update('previous')" title="{lang_previous}" src="./phpgwapi/templates/{template}/images/player-previous.png"/>
+        	 	<img onmouseover="this.className='news_button_over'" onmouseout="this.className='news_button'" class="news_button" onclick="javascript:news.pause()" title="{lang_pause}" src="./phpgwapi/templates/{template}/images/player-pause.png" id="img_player_pause" />
+        	 	<img onmouseover="this.className='news_button_over'" onmouseout="this.className='news_button'" style="display:none" class="news_button" onclick="javascript:news.pause()" title="{lang_resume}" src="./phpgwapi/templates/{template}/images/player-resume.png" id="img_player_resume" />
+			 	<img onmouseover="this.className='news_button_over'" onmouseout="this.className='news_button'" class="news_button"  onclick="javascript:news.update('next')" title="{lang_next}" src="./phpgwapi/templates/{template}/images/player-next.png"/>			 			
+			</div>
+		<div id="login">
+      <div align="center">
+<input type="hidden" name="passwd_type" value="text">
+<input type="hidden" name="account type" value="u">
+<input type="hidden" name="login">
+<div id="caixa_login">
+          <div id="reflexo">
+           <div class="titulo_login">Expresso Livre</div>
+           <div id="mensagem" class="msgInicial" >{cd}<br>{lang_message}</div>
+	   {action}
+            <div id="conteudo_login" style="display:{show};">{select_organization}
+              <div class="login_label">
+                <label for="usuario">{lang_username}</label>
+                <br />
+                <input class="input" type="text" maxlength="70" size="20" name="user" id="user" value="">
+              </div>
+
+              <div class="login_label">
+                <label for="senha">{lang_password}</label>
+                <br />
+                <input class="input" type="password" maxlength="50" size="20" name="passwd" id="passwd" value="">
+		<div id="keyboard"></div>
+              </div>
+		{captcha}
+      
+              <input value="{lang_login}" name="submitit" class="button" onclick="javascript:setLogin()" type="submit" style="margin-top:10px"/>
+	      <img style="display:{show_kbd};" src="phpgwapi/templates/default/images/keyboard.png" alt="virtualkeyboard" title="virtualkeyboard" onclick="loadvkbd()" /> 
+            </div> 
+			<div id="alterna_login">
+			 {link_alterna_login}
+			</div>
+          </div>
+          <div id="rodape_login">
+	    	<div class="ajuda" style="display:{display_help}">
+				<img src="./phpgwapi/templates/{template}/images/help.png"/>
+				<a title="{lang_help}" target="help" href="./help.php?lang={lang}">{lang_help}</a>
+			</div>
+          </div>
+        </div>
+</form>
+</div>
+</div>
+</div>
+<div id="inferior"><br />
+<div id="rodape">
+<table align="center" cellspacing="0" cellpadding="0" border="0">
+	<tr>
+		<td>
+			<table border="0" cellpadding="0" cellspacing="0" width="300px">
+          		<tbody>
+          			<tr> 
+            			<td>{logo_config}
+				<br><a title="Projeto Expresso Livre" target="_blank" href="http://www.expressolivre.org/">Expresso Livre</a> {version}
+                                {ultima_rev}
+				<br><a title="eGroupWare" target="_blank" href="http://www.egroupware.org/"> Powered by eGroupWare </a></div></td>
+          			</tr>
+        		</tbody>
+        	</table>
+        </td>
+	</tr>
+</table>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div>{applet}</div>
+</body></html>
Index: /trunk/phpgwapi/templates/news_old/login_news.php
===================================================================
--- /trunk/phpgwapi/templates/news_old/login_news.php	(revision 7836)
+++ /trunk/phpgwapi/templates/news_old/login_news.php	(revision 7836)
@@ -0,0 +1,606 @@
+<?php
+	/**************************************************************************\
+	* eGroupWare login                                                         *
+	* http://www.egroupware.org                                                *
+	* Originaly written by Dan Kuykendall <seek3r@phpgroupware.org>            *
+	*                      Joseph Engo    <jengo@phpgroupware.org>             *
+	* Updated by Nilton Emilio Buhrer Neto <niltonneto@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.                                              *
+	\**************************************************************************/
+
+	function check_logoutcode($code)
+	{
+		switch($code)
+		{
+			case 1:
+				return lang('You have been successfully logged out');
+				
+			case 2:
+				return lang('Sorry, your login has expired');
+				
+			case 4:
+				return lang('Cookies are required to login to this site.');
+				
+			case 5:
+				return '<font color="FF0000">' . lang('Bad login or password') . '</font>';
+
+			case 6:
+				return '<font color="FF0000">' . lang('Your password has expired, and you do not have access to change it') . '</font>';
+				
+			case 98:
+				return '<font color="FF0000">' . lang('Account is expired') . '</font>';
+				
+			case 99:
+				return '<font color="FF0000">' . lang('Blocked, too many attempts(%1)! Retry in %2 minute(s)',$GLOBALS['phpgw_info']['server']['num_unsuccessful_id'],$GLOBALS['phpgw_info']['server']['block_time']) . '</font>';
+			case 200:
+                            //return '<font color="FF0000">' . lang('Invalid code') . '</font>';
+                return '<font color="FF0000">' . lang('Bad login or password') . '</font>';
+			    break;
+			case 10:
+				$GLOBALS['phpgw']->session->phpgw_setcookie('sessionid');
+				$GLOBALS['phpgw']->session->phpgw_setcookie('kp3');
+				$GLOBALS['phpgw']->session->phpgw_setcookie('domain');
+
+				//fix for bug php4 expired sessions bug
+				if($GLOBALS['phpgw_info']['server']['sessions_type'] == 'php4')
+				{
+					$GLOBALS['phpgw']->session->phpgw_setcookie(PHPGW_PHPSESSID);
+				}
+
+				return '<font color="#FF0000">' . lang('Your session could not be verified.') . '</font>';
+				
+			default:
+				return '';
+		}
+	}
+	
+	$ifMobile = false;
+	$browser = CreateObject('phpgwapi.browser');
+	switch ( $browser->get_platform() )
+	{
+		case browser::PLATFORM_IPHONE:
+		case browser::PLATFORM_IPOD:
+		case browser::PLATFORM_IPAD:
+		case browser::PLATFORM_BLACKBERRY:
+		case browser::PLATFORM_NOKIA:
+		case browser::PLATFORM_ANDROID:
+			$ifMobile = true;						
+			break;
+	}
+	
+	if( $ifMobile && $_GET['dont_redirect_if_moble'] != 1 ) 
+	{
+		$GLOBALS['phpgw']->redirect_link('/mobile/login.php');
+	}
+	else
+	{
+	/* Program starts here */
+	if($GLOBALS['phpgw_info']['server']['auth_type'] == 'http' && isset($_SERVER['PHP_AUTH_USER']))
+	{
+		$submit = True;
+		$login  = $_SERVER['PHP_AUTH_USER'];
+		$passwd = $_SERVER['PHP_AUTH_PW'];
+		$passwd_type = 'text';
+	}
+	else
+	{
+		$passwd = $_POST['passwd'];
+		$passwd_type = $_POST['passwd_type'];
+	}
+
+	# Apache + mod_ssl style SSL certificate authentication
+	# Certificate (chain) verification occurs inside mod_ssl
+	if($GLOBALS['phpgw_info']['server']['auth_type'] == 'sqlssl' && isset($_SERVER['SSL_CLIENT_S_DN']) && !isset($_GET['cd']))
+	{
+		# an X.509 subject looks like:
+		# /CN=john.doe/OU=Department/O=Company/C=xx/Email=john@comapy.tld/L=City/
+		# the username is deliberately lowercase, to ease LDAP integration
+		$sslattribs = explode('/',$_SERVER['SSL_CLIENT_S_DN']);
+		# skip the part in front of the first '/' (nothing)
+		while($sslattrib = next($sslattribs))
+		{
+			list($key,$val) = explode('=',$sslattrib);
+			$sslattributes[$key] = $val;
+		}
+
+		if(isset($sslattributes['Email']))
+		{
+			$submit = True;
+
+			# login will be set here if the user logged out and uses a different username with
+			# the same SSL-certificate.
+			if(!isset($_POST['login'])&&isset($sslattributes['Email']))
+			{
+				$login = $sslattributes['Email'];
+				# not checked against the database, but delivered to authentication module
+				$passwd = $_SERVER['SSL_CLIENT_S_DN'];
+			}
+		}
+		unset($key);
+		unset($val);
+		unset($sslattributes);
+	}
+
+    if( isset( $_GET[ 'cd' ] ) && ( $_GET['cd']=='1' || $_GET['cd'] == 10 ) )
+	{
+            $_SESSION['contador'] = 0;
+	}
+
+	if(isset($passwd_type) || $_POST['submitit_x'] || $_POST['submitit_y'] || $submit)
+	{
+        
+	    // Primeiro testa o captcha....se houver......
+            if($GLOBALS['phpgw_info']['server']['captcha']==1)
+              {
+                if($_SESSION['contador'] > $GLOBALS['phpgw_info']['server']['num_badlogin'])
+                    {
+                        if ($_SESSION['CAPTCHAString'] != trim(strtoupper($_POST['codigo'])))
+                                {
+                                        if(!$_GET['cd'])
+                                        {
+                                            $_GET['cd'] = '200';
+                                        }
+                                }
+                        unset($_SESSION['CAPTCHAString']);
+                    }
+              }
+		if($_POST['user']) {
+			if($GLOBALS['phpgw_info']['server']['use_prefix_organization']) {
+				$common = CreateObject('phpgwapi.common');
+				$ldap_conn = $common->ldapConnect();
+				$justthese = array("uid");
+				$filter="(&(phpgwAccountType=u)(uid=".$_POST['user']."))";
+				$ldap_search = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese);
+				$ldap_info 	 = ldap_get_entries($ldap_conn, $ldap_search);
+				ldap_close($ldap_conn);
+				if ($ldap_info['count'] != 0) {
+					$_POST['login'] = $_POST['user'];
+				}
+			}
+			else
+				$_POST['login'] = $_POST['user'];
+		}
+		if(getenv('REQUEST_METHOD') != 'POST' && $_SERVER['REQUEST_METHOD'] != 'POST' &&
+			!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['SSL_CLIENT_S_DN']))
+		{
+                        if(!$_GET['cd'])
+                            {
+                                $_GET['cd'] = '5';
+                            }
+		}
+		
+		// don't get login data again when $submit is true
+		if($submit == false)
+		{
+			$login = $_POST['login'];
+		}
+		
+		if(strstr($login,'@') === False && isset($_POST['logindomain']))
+		{
+			$login .= '@' . $_POST['logindomain'];
+		}
+		elseif(!isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]))
+		{
+			$login .= '@'.$GLOBALS['phpgw_info']['server']['default_domain'];
+		}
+		
+		If(!$_GET['cd'])
+			$GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create(strtolower($login),$passwd,$passwd_type,'u');
+
+		if(!isset($GLOBALS['sessionid']) || ! $GLOBALS['sessionid'])
+		{
+			If(!$_GET['cd']) $_GET['cd'] = $GLOBALS['phpgw']->session->cd_reason;
+		}
+		else
+		{
+			if ($_POST['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2}){0,1}$/',$_POST['lang']) &&
+			    $_POST['lang'] != $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'])
+			{
+				$GLOBALS['phpgw']->preferences->add('common','lang',$_POST['lang'],'session');
+			}
+
+			if(!$GLOBALS['phpgw_info']['server']['disable_autoload_langfiles'])
+			{
+				$GLOBALS['phpgw']->translation->autoload_changed_langfiles();
+			}
+			$forward = isset($_GET['phpgw_forward']) ? urldecode($_GET['phpgw_forward']) : @$_POST['phpgw_forward'];
+			if (!$forward)
+			{
+				$extra_vars['cd'] = 'yes';
+				$forward = '/home.php';
+			}
+			else
+			{
+				list($forward,$extra_vars) = explode('?',$forward,2);
+			}
+		if ($GLOBALS['phpgw_info']['server']['use_https'] != 2)
+			{
+			//Modificacao feita para que o Expresso redirecione para o primeiro proxy caso haja um encadeamento de mais de um proxy.
+			//$forward = 'http://'.$_SERVER['HTTP_HOST'].($GLOBALS['phpgw']->link($forward.'?cd=yes'));
+			$forward = 'http://' . nearest_to_me() . $GLOBALS['phpgw']->link($forward.'?cd=yes');
+			echo "<script language='Javascript1.3'>location.href='".$forward."'</script>";
+			}
+		else
+			{
+			$GLOBALS['phpgw']->redirect_link($forward,$extra_vars);
+			}
+		}
+	}
+	//else   // =================================================================================
+	//{
+            $valor_contador = $_SESSION['contador'];
+            $valor_contador = $valor_contador + 1;
+            $_SESSION['contador'] = $valor_contador;
+		// !!! DONT CHANGE THESE LINES !!!
+		// If there is something wrong with this code TELL ME!
+		// Commenting out the code will not fix it. (jengo)
+		if(isset($_COOKIE['last_loginid']))
+		{
+			$accounts = CreateObject('phpgwapi.accounts');
+			$prefs = CreateObject('phpgwapi.preferences', $accounts->name2id($_COOKIE['last_loginid']));
+
+			if($prefs->account_id)
+			{
+				$GLOBALS['phpgw_info']['user']['preferences'] = $prefs->read_repository();
+			}
+		}
+		
+		$_GET['lang'] = addslashes($_GET['lang']);
+		if ($_GET['lang'])
+		{
+			$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $_GET['lang'];
+		}
+		elseif(!isset($_COOKIE['last_loginid']) || !$prefs->account_id)
+		{
+			// If the lastloginid cookies isn't set, we will default to the first language,
+			// the users browser accepts.
+			list($lang) = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
+			/*
+			if(strlen($lang) > 2)
+			{
+				$lang = substr($lang,0,2);
+			}
+			*/
+			$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $lang;
+		}
+		#print 'LANG:' . $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] . '<br>';
+
+		$GLOBALS['phpgw']->translation->init();	// this will set the language according to the (new) set prefs
+		$GLOBALS['phpgw']->translation->add_app('login');
+		$GLOBALS['phpgw']->translation->add_app('loginscreen');
+		if(lang('loginscreen_message') == 'loginscreen_message*')
+		{
+			$GLOBALS['phpgw']->translation->add_app('loginscreen','en');	// trying the en one
+		}
+		if(lang('loginscreen_message') != 'loginscreen_message*')
+		{
+			$tmpl->set_var('lang_message',stripslashes(lang('loginscreen_message')));
+		}
+	//}
+
+	if($GLOBALS['phpgw_info']['server']['use_prefix_organization'])
+	{
+		$obj_organization = CreateObject('phpgwapi.sector_search_ldap');
+		$organizations = $obj_organization->organization_search($GLOBALS['phpgw_info']['server']['ldap_context']);
+
+        $organizations_count = count($organizations);
+		for ($i=0; $i<$organizations_count; ++$i)
+		{
+			$tmp_array[strtolower($organizations[$i])] = $organizations[$i];	
+		}
+		
+		$arrayOrganization = $tmp_array;		
+		ksort($arrayOrganization);
+		
+		foreach($arrayOrganization
+			 as $organization_name => $organization_vars)
+		{
+			$organization_select .= '<option value="' . $organization_name . '"';
+
+			if($organization_name == $_COOKIE['last_organization'])
+			{
+				$organization_select .= ' selected';
+			}
+			$organization_select .= '>' . $organization_vars . "</option>\n";
+		}
+		$organization_select =  '<div class="login_label"><label>'.lang("organization")
+							.'</label><br><select name="organization">'
+							.$organization_select.'</select></div>';
+		$tmpl->set_var('select_organization',$organization_select);
+	}
+		
+	$domain_select = '&nbsp;';
+	$last_loginid = $_COOKIE['last_loginid'];
+	if($GLOBALS['phpgw_info']['server']['show_domain_selectbox'])
+	{
+		$domain_select = "<select name=\"logindomain\">\n";
+		foreach($GLOBALS['phpgw_domain'] as $domain_name => $domain_vars)
+		{
+			$domain_select .= '<option value="' . $domain_name . '"';
+
+			if($domain_name == $_COOKIE['last_domain'])
+			{
+				$domain_select .= ' selected';
+			}
+			$domain_select .= '>' . $domain_name . "</option>\n";
+		}
+		$domain_select .= "</select>\n";
+	}
+	elseif($last_loginid !== '')
+	{
+		reset($GLOBALS['phpgw_domain']);
+		list($default_domain) = each($GLOBALS['phpgw_domain']);
+
+		if($_COOKIE['last_domain'] != $default_domain && !empty($_COOKIE['last_domain']))
+		{
+			$last_loginid .= '@' . $_COOKIE['last_domain'];
+		}
+	}
+	$tmpl->set_var('select_domain',$domain_select);
+
+	foreach($_GET as $name => $value)
+	{
+		if(preg_match('/phpgw_/',$name))
+		{
+			$extra_vars .= '&' . $name . '=' . urlencode($value);
+		}
+	}
+
+	if ( is_string( $extra_vars ) )
+	{
+		$extra_vars = '?' . substr($extra_vars,1);
+	}
+
+	/********************************************************\
+	* Check is the registration app is installed, activated  *
+	* And if the register link must be placed                *
+	\********************************************************/
+	
+	$cnf_reg = createobject('phpgwapi.config','registration');
+	$cnf_reg->read_repository();
+	$config_reg = $cnf_reg->config_data;
+
+	if($config_reg['enable_registration']=='True' && $config_reg['register_link']=='True')
+	{
+		$reg_link='&nbsp;<a href="registration/">'.lang('Not a user yet? Register now').'</a><br/>';
+	}
+
+	$template = $GLOBALS['phpgw_info']['login_template_set'];
+	$GLOBALS['phpgw_info']['server']['template_set'] = $template;
+
+	$tmpl->set_var('register_link',$reg_link);
+	$tmpl->set_var('charset',$GLOBALS['phpgw']->translation->charset());
+	$tmpl->set_var('login_url', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/login.php' . $extra_vars);
+	$tmpl->set_var('registration_url',$GLOBALS['phpgw_info']['server']['webserver_url'] . '/registration/');
+	$tmpl->set_var('version',$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']);
+	$tmpl->set_var('cd',check_logoutcode($_GET['cd']));
+	$tmpl->set_var('cookie',$last_loginid);
+
+	$tmpl->set_var('lang_username',lang('username'));
+	$tmpl->set_var('lang_password',lang('password'));
+	$tmpl->set_var('lang_login',lang('login'));
+
+	$tmpl->set_var('website_title', $GLOBALS['phpgw_info']['server']['site_title']);
+	$tmpl->set_var('template_set', $template);
+
+	// loads the template's login.css
+	// and then the theme's login.css (if any)
+	$template_dir = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/' . $template;
+	$login_dir = $template_dir . '/login.css';
+	$login_css = "<link href='" . $login_dir . "' rel='stylesheet' type='text/css' />";
+	$login_dir = $template_dir . '/themes/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . '/login.css';
+	if(file_exists('./'.$login_dir))
+	{
+		$login_css .= "<link href='" . $login_dir . "' rel='stylesheet' type='text/css' />";
+	}
+	$tmpl->set_var('login_css',$login_css);
+
+	$GLOBALS['phpgw']->translation->add_app('loginhelp',$_GET['lang']);
+
+	if(lang('loginhelp_message') != 'loginhelp_message*' && trim(lang('loginhelp_message')) != ""){					
+		$tmpl->set_var('lang_help',lang("Help"));	
+	}
+	else 
+		$tmpl->set_var('display_help','none');
+
+	$tmpl->set_var('bg_color',($GLOBALS['phpgw_info']['server']['login_bg_color']?$GLOBALS['phpgw_info']['server']['login_bg_color']:'FFFFFF'));
+	$tmpl->set_var('bg_color_title',($GLOBALS['phpgw_info']['server']['login_bg_color_title']?$GLOBALS['phpgw_info']['server']['login_bg_color_title']:'486591'));
+
+	if($GLOBALS['phpgw_info']['server']['use_frontend_name'])
+		$tmpl->set_var('frontend_name', " - ".$GLOBALS['phpgw_info']['server']['use_frontend_name']);
+
+	if (substr($GLOBALS['phpgw_info']['server']['login_logo_file'],0,4) == 'http')
+	{
+		$var['logo_file'] = $GLOBALS['phpgw_info']['server']['login_logo_file'];
+	}
+	else
+	{
+		$var['logo_file'] = $GLOBALS['phpgw']->common->image('phpgwapi',$GLOBALS['phpgw_info']['server']['login_logo_file']?$GLOBALS['phpgw_info']['server']['login_logo_file']:'logo');
+	}
+	$var['logo_url'] = $GLOBALS['phpgw_info']['server']['login_logo_url']?$GLOBALS['phpgw_info']['server']['login_logo_url']:'http://www.eGroupWare.org';
+	if (substr($var['logo_url'],0,4) != 'http')
+	{
+		$var['logo_url'] = 'http://'.$var['logo_url'];
+	}
+	$var['logo_title'] = $GLOBALS['phpgw_info']['server']['login_logo_title']?$GLOBALS['phpgw_info']['server']['login_logo_title']:'www.eGroupWare.org';
+	$tmpl->set_var($var);
+
+	if (!@$GLOBALS['phpgw_info']['server']['login_virtual_keyboard']) 
+		$tmpl->set_var('show_kbd','none'); 
+
+	if (@$GLOBALS['phpgw_info']['server']['login_show_language_selection'])
+	{
+		$select_lang = '<select name="lang" onchange="'."location.href=location.href+(location.search?'&':'?')+'lang='+this.value".'">';
+		$langs = $GLOBALS['phpgw']->translation->get_installed_langs();
+		uasort($langs,'strcasecmp');
+		foreach ($langs as $key => $name)	// if we have a translation use it
+		{
+			$select_lang .= "\n\t".'<option value="'.$key.'"'.($key == $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] ? ' selected="1"' : '').'>'.$name.'</option>';
+		}
+		$select_lang .= "\n</select>\n";
+		$tmpl->set_var(array(
+			'lang_language' => lang('Language'),
+			'select_language' => $select_lang,
+		));
+	}
+	else
+	{
+		$tmpl->set_block('login_form','language_select');
+		$tmpl->set_var('language_select','');
+	}
+
+	$tmpl->set_var('autocomplete', ($GLOBALS['phpgw_info']['server']['autocomplete_login'] ? 'autocomplete="off"' : ''));
+
+	// soh mostra o captcha se for login sem certificado....
+	if($GLOBALS['phpgw_info']['server']['captcha'] && $_GET['cd']!='300' )
+	{
+		$aux_captcha = '<input type="hidden" name="' . session_name() . '"  value="' . session_id() . '" >';
+	//        setcookie(session_name(),base64_encode(session_convert($key_convert . session_id(),$key_convert)),0);
+		if($valor_contador > $GLOBALS['phpgw_info']['server']['num_badlogin'])
+		{
+			$aux_captcha = '<div class="login_label" >
+			   <img id="id_captcha" src="./security/captcha.php?' . session_name() . '=' . session_id() . '" title="'.lang('Security code').'" alt="'.lang('Security code').'" style="position:static;">
+			   <input class="input" type="text" maxlength="50" size="20" name="codigo" id="codigo" value="" >
+			   <input type="hidden" name="' . session_name() . '"  value="' . session_id() . '" >
+			   </div>';
+		}
+	}
+	$tmpl->set_var('captcha',$aux_captcha);
+
+	// Testa se deve incluir applet para login com certificado......
+	if ($_GET['cd']=='300' && $GLOBALS['phpgw_info']['server']['certificado']==1)
+	{
+		//Zera o Cookie contador, responsavel pelo captcha
+		$_SESSION['contador'] = 0;
+		$valor_contador = 0;
+		$link_alterna_login = '<img src="phpgwapi/templates/news/images/warning.gif"/><a href="login.php">' . lang('Access without Digital Certificate') . '</a>';
+		$tmpl->set_var('show','none');
+		$tmpl->set_var('action','<div id="action"><img style="border:0px;margin:31px 0px 58px 0px;" src="phpgwapi/templates/news/images/acao.gif" /></div>');
+		// gera parametro com tokens suportados ....
+		$var_tokens = '';
+		for($ii = 1; $ii < 11; ++$ii)
+		{
+			if($GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'])
+				$var_tokens .= $GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'] . ',';
+		}
+
+		if(!$var_tokens)
+		{
+			$var_tokens = 'ePass2000Lx;/usr/lib/libepsng_p11.so,ePass2000Win;c:/windows/system32/ngp11v211.dll';
+		}
+		$param1 = "
+											'<param name=\"token\" value=\"" . substr($var_tokens,0,strlen($var_tokens)) . "\"> ' +
+										   ";
+		$param2 = "
+											'token=\"" . substr($var_tokens,0,strlen($var_tokens)) . "\" ' +
+										   ";
+
+		$cod_applet =
+
+/*    // com debug ativado
+            '<script type="text/javascript">
+					if (navigator.userAgent.match(\'MSIE\')){
+						document.write(\'<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" \' +
+						\'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"> \' +
+						\'<param name="type" value="application/x-java-applet;version=1.5"> \' +
+						\'<param name="code" value="LoginApplet.class"> \' +
+						\'<param name="locale" value="' . $lang . '"> \' +
+						\'<param name="mayscript" value="true"> \' + '
+						. $param1
+						. ' \'<param name="archive" value="ExpressoCertLogin.jar,ExpressoCert.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar"> \' +
+                        \'<param name="debug" value="true"> \' +
+						\'</object>\');
+					}
+					else {
+						document.write(\'<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" code="LoginApplet.class" locale="' . $lang . '"\' +
+						\'archive="ExpressoCertLogin.jar,ExpressoCert.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar" \' + '
+						. $param2
+						. ' \'type="application/x-java-applet;version=1.5" debug= "true" mayscript > \' +
+						\'<noembed> \' +
+						\'No Java Support. \' +
+						\'</noembed> \' +
+						\'</embed> \');
+					}
+				</script>';
+*/
+            // sem debug ativado
+            '<script type="text/javascript">
+					if (navigator.userAgent.match(\'MSIE\')){
+						document.write(\'<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" \' +
+						\'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"> \' +
+						\'<param name="type" value="application/x-java-applet;version=1.5"> \' + 
+                                                \'<param name="codebase" value="/security/">\' +
+						\'<param name="code" value="LoginApplet.class"> \' +
+						\'<param name="locale" value="' . $lang . '"> \' +
+						\'<param name="mayscript" value="true"> \' + ' 
+						. $param1 
+						. ' \'<param name="archive" value="ExpressoCertLogin.jar,ExpressoCert.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar"> \' +
+						\'</object>\');
+					}
+					else {
+						document.write(\'<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" codebase="/security/" code="LoginApplet.class" locale="' . $lang . '"\' +
+						\'archive="ExpressoCertLogin.jar,ExpressoCert.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar" \' + '
+						. $param2  
+						. ' \'type="application/x-java-applet;version=1.5" mayscript > \' +
+						\'<noembed> \' +
+						\'No Java Support. \' +
+						\'</noembed> \' +
+						\'</embed> \');
+					}
+				</script>';
+
+
+	}
+
+	else
+	{
+		if($GLOBALS['phpgw_info']['server']['certificado']==1)
+		{
+			$tmpl->set_var('show','yes');
+			$link_alterna_login = '<img src="phpgwapi/templates/news/images/lock1_icon.gif"/><a title="' . lang('Link to use digital certificate') . '" href="login.php?cd=300">' . lang('Logon with my digital certificate') . '</a>';
+		}
+		$tmpl->set_var('lang_username',lang('username'));
+		$tmpl->set_var('action','');
+		$cod_applet = '';
+
+	}
+
+	$tmpl->set_var('applet',$cod_applet);
+	$tmpl->set_var('link_alterna_login',$link_alterna_login);
+		
+	// Load News from NewsAdmin module - BEGIN
+	define('PHPGW_TEMPLATE_DIR','./phpgwapi/templates/'.$GLOBALS['phpgw_info']['login_template_set']);
+	$news = CreateObject('news_admin.uinews');
+	$public_news = $news->bo->get_all_public_news();
+	rsort($public_news);	
+	$newslist = array();
+	foreach($public_news as $i => $news){
+		$newslist[] = array_map('utf8_encode', $news);
+	}
+	$tmpl->set_var('public_news',json_encode($newslist));
+	$tmpl->set_var('lang_previous',lang('Previous'));
+	$tmpl->set_var('lang_next',lang('Next'));
+	$tmpl->set_var('lang_pause',lang('Pause'));
+	$tmpl->set_var('lang_resume',lang('Resume'));
+	
+	// Load News from NewsAdmin module - END
+	
+	$tmpl->set_var('dir_root', 'http://' . nearest_to_me() . '/');
+	if(is_file(dirname( __FILE__ ) . '/../../../infodist/ultima-revisao-svn.php'))
+	include_once(dirname( __FILE__ ) . '/../../../infodist/ultima-revisao-svn.php');
+	if(isset($ultima_revisao)) $tmpl->set_var('ultima_rev','<br>' . $ultima_revisao);
+
+	// Adiciona código personalizado de outro template
+	// que esteja utilizando o login_default.php
+	if(is_file('.'.$template_dir.'/login.inc.php')) {
+		include_once('.'.$template_dir.'/login.inc.php');
+	}
+
+	$tmpl->pfp('loginout','login_form');
+	}
+
+?>
+
Index: /trunk/phpgwapi/templates/news_old/js/news.js
===================================================================
--- /trunk/phpgwapi/templates/news_old/js/news.js	(revision 7836)
+++ /trunk/phpgwapi/templates/news_old/js/news.js	(revision 7836)
@@ -0,0 +1,40 @@
+/****************************************************************************************\
+|************************ 	LOAD NEWS FROM NEWSADMIN MODULE		*************************|
+\****************************************************************************************/
+function News(data){	
+	this.data = new Hash(data);
+	this.delay = 5000;
+	this.timeout = 0;
+}
+
+News.prototype.update = function(direction) {	
+	if(this.data.size() == 0) {
+		document.getElementById("news").style.visibility ="hidden";
+		return true;
+	}	
+	var item = this.data.seek(direction);	
+	document.getElementById("news_subject").innerHTML = item.subject;
+	document.getElementById("news_content").innerHTML = item.content;
+}
+
+News.prototype.start = function(delay){
+	if(delay)
+		this.delay = delay;
+	
+	this.update('next');
+	this.timeout = setTimeout("news.start()",this.delay);
+}
+
+News.prototype.pause = function(){	
+	if(this.timeout){
+		document.getElementById("img_player_pause").style.display = 'none';
+		document.getElementById("img_player_resume").style.display = '';
+		clearTimeout(this.timeout);
+		this.timeout = 0;
+	}
+	else{
+		document.getElementById("img_player_pause").style.display = '';
+		document.getElementById("img_player_resume").style.display = 'none';
+		this.start();
+	}
+}
Index: /trunk/phpgwapi/templates/news_old/js/hash.js
===================================================================
--- /trunk/phpgwapi/templates/news_old/js/hash.js	(revision 7836)
+++ /trunk/phpgwapi/templates/news_old/js/hash.js	(revision 7836)
@@ -0,0 +1,20 @@
+/*********************** HASH PROTOTYPE **************************/
+function Hash(data)	{
+	this.last_item = 0;
+	this.data = data;
+}
+Hash.prototype.size = function(){
+	var _thisObject = this;		
+	var size = 0;
+	for (var i in _thisObject.data)
+       	if(_thisObject.data[i] != null)
+           	size++;    	
+   	return size;	
+}	
+Hash.prototype.seek = function(direction){
+	var _thisObject = this;	
+	_thisObject.last_item = (direction == "previous" ? 
+			(_thisObject.last_item == 0 ? _thisObject.size() - 1 : _thisObject.last_item - 1) : 
+			(_thisObject.last_item == _thisObject.size() -1 ? 0	 : _thisObject.last_item + 1));	
+	return _thisObject.data[_thisObject.last_item];		
+}
