Index: /trunk/phpgwapi/templates/default/login_default.php
===================================================================
--- /trunk/phpgwapi/templates/default/login_default.php	(revision 5036)
+++ /trunk/phpgwapi/templates/default/login_default.php	(revision 5042)
@@ -57,16 +57,26 @@
 		}
 	}
-        function troca_espaco_por_mais($pem_data)
-        {
-            $begin = "CERTIFICATE-----";
-            $end   = "-----END";
-            $aux = substr($pem_data, strpos($pem_data, $begin)+strlen($begin));
-            $aux = substr($aux, 0, strpos($aux, $end));
-            $aux = strtr($aux,' ','+');
-            $aux = '-----BEGIN CERTIFICATE-----'.$aux.'-----END CERTIFICATE-----';
-            return $aux;
-        }
-        /* Program starts here */
-        
+	
+	$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']))
 	{
@@ -114,9 +124,6 @@
 		unset($sslattributes);
 	}
-        if(isset($_POST['certificado']) && $_POST['certificado'])
-        {
-            $_SESSION['login_certificate'] = troca_espaco_por_mais(str_replace(chr(0x0D).chr(0x0A),chr(0x0A),str_replace(chr(0x0A).chr(0x0A),chr(0x0A),$_POST['certificado'])));
-        }
-        if( isset( $_GET[ 'cd' ] ) && ( $_GET['cd']=='1' || $_GET['cd'] == 10 ) )
+
+    if( isset( $_GET[ 'cd' ] ) && ( $_GET['cd']=='1' || $_GET['cd'] == 10 ) )
 	{
             $_SESSION['contador'] = 0;
@@ -210,5 +217,4 @@
 				list($forward,$extra_vars) = explode('?',$forward,2);
 			}
-
 		if ($GLOBALS['phpgw_info']['server']['use_https'] != 2)
 			{
@@ -260,11 +266,4 @@
 			*/
 			$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $lang;
-
-			if (!isset($GLOBALS['phpgw_info']['user']['preferences']['common']['theme']))
-			{
-				$prefs2 = CreateObject('phpgwapi.preferences');
-				$temp_pref = $prefs2->read_repository();
-				$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = $temp_pref['common']['theme'];
-			}
 		}
 		#print 'LANG:' . $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] . '<br>';
@@ -386,5 +385,4 @@
 	$tmpl->set_var('website_title', $GLOBALS['phpgw_info']['server']['site_title']);
 	$tmpl->set_var('template_set', $template);
-        $tmpl->set_var('compatIE8',lang("The compatibility mode for internet explorer 8 is active. Turn it of if you want to use the local mail functionality."));
 
 	// loads the template's login.css
Index: /trunk/login.php
===================================================================
--- /trunk/login.php	(revision 4417)
+++ /trunk/login.php	(revision 5042)
@@ -27,41 +27,23 @@
 		// Force location to home, while logged in.
 		$GLOBALS['sessionid'] = @$_GET['sessionid'] ? $_GET['sessionid'] : @$_COOKIE['sessionid'];
+		
 		if(isset($GLOBALS['sessionid']) && $_GET['cd'] != 10)
-			$GLOBALS['phpgw']->redirect_link('/home.php');
+		{
+			if( $_GET['cd'] != '66' )
+			{
+				$GLOBALS['phpgw']->redirect_link('/home.php');
+			}
+		}
+		
 		if ($GLOBALS['phpgw_info']['server']['use_https'] > 0)
 		{
 			if ($_SERVER['HTTPS'] != 'on')
 			{
-        			Header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+        		Header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
 				exit;
 			}
 		}
 			
-		if(function_exists('CreateObject'))
-		{
-			if($_GET['dont_redirect_if_moble'] != 1) {
-				//detect if the user has a compatible browser, if don't have send him to expresso mini
-				$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:
-							$GLOBALS['phpgw']->redirect_link('/mobile/');
-						break;
-					default:
-						break;
-				}
-			}
-			$GLOBALS['phpgw']->session = CreateObject('phpgwapi.sessions');
-		}
-		else
-		{
-			Header('Location: setup/index.php');
-			exit;
-		}
+		$GLOBALS['phpgw']->session = CreateObject('phpgwapi.sessions');
 	}
 	else
@@ -70,58 +52,78 @@
 		exit;
 	}
+	
+	//detect if the user has a compatible browser, if don't have send him to expresso mini
+	$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;
+	}
 
-	$GLOBALS['phpgw_info']['server']['template_dir'] = PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info']['login_template_set'];
-	$tmpl = CreateObject('phpgwapi.Template', $GLOBALS['phpgw_info']['server']['template_dir']);
-
-	// read the images from the login-template-set, not the (maybe not even set) users template-set
-	$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'] = $GLOBALS['phpgw_info']['login_template_set'];
-
-	// This is used for system downtime, to prevent new logins.
-	if($GLOBALS['phpgw_info']['server']['deny_all_logins'])
+	if( $ifMobile && $_GET['dont_redirect_if_moble'] != 1 ) 
 	{
-		$deny_msg=lang('Oops! You caught us in the middle of system maintainance.<br/>
-		Please, check back with us shortly.');
-
-		$tmpl->set_file(array
-		(
-			'login_form' => 'login_denylogin.tpl'
-		));
-
-		$tmpl->set_var('template_set','default');
-		$tmpl->set_var('deny_msg',$deny_msg);
-		$tmpl->pfp('loginout','login_form');
-		exit;
+		$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = preg_replace("/\,.*/","",$GLOBALS['_SERVER']['HTTP_ACCEPT_LANGUAGE']);
+		if( $_GET['cd'] == '66' )
+			$GLOBALS['phpgw']->redirect_link('/mobile/login.php?cd=66');
+		else
+			$GLOBALS['phpgw']->redirect_link('/mobile/login.php');
 	}
-	$tmpl->set_file(array('login_form' => 'login.tpl'));
-
-	$tmpl->set_var('template',$GLOBALS['phpgw_info']['login_template_set']);
-	$tmpl->set_var('lang',$_GET['lang']?$_GET['lang']:preg_replace("/\,.*/","",$GLOBALS['_SERVER']['HTTP_ACCEPT_LANGUAGE']));
-
-	if (count($GLOBALS['phpgw_info']['server']['login_logo_file']) > 0)
-		$tmpl->set_var('logo_config',$GLOBALS['phpgw_info']['server']['login_logo_file']);
 	else
-		$tmpl->set_var('logo_config','<a title="Governo do Paran&aacute" href="http://www.pr.gov.br" target="_blank"><img src="phpgwapi/templates/'.$GLOBALS['phpgw_info']['login_template_set'].'/images/logo_governo.gif" border="0"></a></td>
-		<td><div align="center"><font color="#9a9a9a" face="Verdana, Arial, Helvetica, sans-serif" size="1">
-<a title="Celepar Inform&aacute;tica do Paran&aacute;" target="_blank" href="http://www.celepar.pr.gov.br/">
-<img src="phpgwapi/templates/'.$GLOBALS['phpgw_info']['login_template_set'].'/images/logo_celepar.gif" border="0"></a>');
-	// !! NOTE !!
-	// Do NOT and I repeat, do NOT touch ANYTHING to do with lang in this file.
-	// If there is a problem, tell me and I will fix it. (jengo)
-
-	// whoooo scaring
-
-	// ServerID => Identify the Apache Frontend.
-	if($GLOBALS['phpgw_info']['server']['usecookies'] == True && $GLOBALS['phpgw_info']['server']['use_frontend_id'])
 	{
-		$GLOBALS['phpgw']->session->phpgw_setcookie('serverID', $GLOBALS['phpgw_info']['server']['use_frontend_id']);
+		$GLOBALS['phpgw_info']['server']['template_dir'] = PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info']['login_template_set'];
+		$tmpl = CreateObject('phpgwapi.Template', $GLOBALS['phpgw_info']['server']['template_dir']);
+	
+		// read the images from the login-template-set, not the (maybe not even set) users template-set
+		$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'] = $GLOBALS['phpgw_info']['login_template_set'];
+	
+		// This is used for system downtime, to prevent new logins.
+		if($GLOBALS['phpgw_info']['server']['deny_all_logins'])
+		{
+			$deny_msg=lang('Oops! You caught us in the middle of system maintainance.<br/>
+			Please, check back with us shortly.');
+	
+			$tmpl->set_file(array('login_form' => 'login_denylogin.tpl'));
+	
+			$tmpl->set_var('template_set','default');
+			$tmpl->set_var('deny_msg',$deny_msg);
+			$tmpl->pfp('loginout','login_form');
+			exit;
+		}
+		$tmpl->set_file(array('login_form' => 'login.tpl'));
+	
+		$tmpl->set_var('template',$GLOBALS['phpgw_info']['login_template_set']);
+		$tmpl->set_var('lang',$_GET['lang']?$_GET['lang']:preg_replace("/\,.*/","",$GLOBALS['_SERVER']['HTTP_ACCEPT_LANGUAGE']));
+	
+		if (count($GLOBALS['phpgw_info']['server']['login_logo_file']) > 0)
+			$tmpl->set_var('logo_config',$GLOBALS['phpgw_info']['server']['login_logo_file']);
+		else
+			$tmpl->set_var('logo_config','<a title="Governo do Paran&aacute" href="http://www.pr.gov.br" target="_blank"><img src="phpgwapi/templates/'.$GLOBALS['phpgw_info']['login_template_set'].'/images/logo_governo.gif" border="0"></a></td>
+			<td><div align="center"><font color="#9a9a9a" face="Verdana, Arial, Helvetica, sans-serif" size="1">
+	<a title="Celepar Inform&aacute;tica do Paran&aacute;" target="_blank" href="http://www.celepar.pr.gov.br/">
+	<img src="phpgwapi/templates/'.$GLOBALS['phpgw_info']['login_template_set'].'/images/logo_celepar.gif" border="0"></a>');
+		// !! NOTE !!
+		// Do NOT and I repeat, do NOT touch ANYTHING to do with lang in this file.
+		// If there is a problem, tell me and I will fix it. (jengo)
+	
+		// whoooo scaring
+	
+		// ServerID => Identify the Apache Frontend.
+		if($GLOBALS['phpgw_info']['server']['usecookies'] == True && $GLOBALS['phpgw_info']['server']['use_frontend_id'])
+		{
+			$GLOBALS['phpgw']->session->phpgw_setcookie('serverID', $GLOBALS['phpgw_info']['server']['use_frontend_id']);
+		}
+		if($GLOBALS['phpgw_info']['server']['captcha']==1)
+	  	{
+			session_start();
+	  	}
+	  	
+		include(personalize_include_path('phpgwapi','login'));
 	}
-	if($GLOBALS['phpgw_info']['server']['captcha']==1)
-  {
-     session_start();
-  }
-
-        $_SESSION['rootPath'] = realpath( './');
-  
-	include(personalize_include_path('phpgwapi','login'));
 ?>
-
Index: /trunk/index.php
===================================================================
--- /trunk/index.php	(revision 3435)
+++ /trunk/index.php	(revision 5042)
@@ -69,5 +69,8 @@
 	if($app == 'home' && !$api_requested)
 	{
-		Header('Location: ' . $GLOBALS['phpgw']->link('/home.php'));
+		if( $_GET['dont_redirect_if_moble'] == 1 )
+			Header('Location: ' . $GLOBALS['phpgw']->link('/home.php?dont_redirect_if_moble=1'));
+		else
+			Header('Location: ' . $GLOBALS['phpgw']->link('/home.php'));
 	}
 
@@ -125,5 +128,10 @@
 		}
 
-		$GLOBALS['phpgw']->redirect_link('/home.php');
+		if( $_GET['dont_redirect_if_moble'] == 1 )
+			Header('Location: ' . $GLOBALS['phpgw']->link('/home.php?dont_redirect_if_moble=1'));
+		else
+			Header('Location: ' . $GLOBALS['phpgw']->link('/home.php'));
+				
+		//$GLOBALS['phpgw']->redirect_link('/home.php');
 	}
 
Index: /trunk/home.php
===================================================================
--- /trunk/home.php	(revision 3435)
+++ /trunk/home.php	(revision 5042)
@@ -36,4 +36,33 @@
 	);
 	include('header.inc.php');
+	
+	//detect browser
+	require_once('phpgwapi/inc/class.browser.inc.php');
+	
+	$ifMobile	= false;
+	$browser	= new browser();
+	
+	
+	switch( $browser->get_platform() )
+	{
+		case browser::PLATFORM_IPHONE:
+		case browser::PLATFORM_IPOD:
+		case browser::PLATFORM_IPAD:
+		case browser::PLATFORM_BLACKBERRY:
+		case browser::PLATFORM_ANDROID:						
+			$ifMobile = false;
+			break;			
+	}
+	
+	if( $ifMobile )
+	{
+		if( $_GET['dont_redirect_if_moble'] != 1 )
+		{
+			$GLOBALS['phpgw']->redirect('/mobile/index.php');
+			exit;			
+		}
+	} 
+	
+	
 	$GLOBALS['phpgw_info']['flags']['app_header']=lang('home');
 
