Index: /branches/2.1/phpgwapi/inc/class.common.inc.php
===================================================================
--- /branches/2.1/phpgwapi/inc/class.common.inc.php	(revision 1576)
+++ /branches/2.1/phpgwapi/inc/class.common.inc.php	(revision 2385)
@@ -1243,5 +1243,5 @@
 		* @author Dave Hall (*based* on verdilak? css inclusion code)
 		*/
-		function get_css()
+		function get_css( )
 		{
 			$tpl = createObject('phpgwapi.Template', $this->get_tpl_dir('phpgwapi'));
@@ -1265,28 +1265,42 @@
 
 			// search for app specific css file
-			if(@isset($GLOBALS['phpgw_info']['flags']['currentapp']))
-			{
-				$appname = $GLOBALS['phpgw_info']['flags']['currentapp'];
-
-				if(file_exists(PHPGW_SERVER_ROOT . SEP . $appname . SEP
-					. 'templates' . SEP . $GLOBALS['phpgw_info']['server']['template_set']
-					. SEP . 'app.css')
-				)
-				{
-					$tpl->set_var('css_file', '<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url']
-						. "/$appname/templates/".$GLOBALS['phpgw_info']['server']['template_set']
-						. "/app.css".'" type=text/css rel=StyleSheet>');
-				}
-				elseif(file_exists(PHPGW_SERVER_ROOT . SEP . $appname . SEP
-					. 'templates' . SEP . 'default'
-					. SEP . 'app.css')
-				)
-				{
-					$tpl->set_var('css_file', '<LINK href="'.$GLOBALS['phpgw_info']['server']['webserver_url']
-					."/$appname/templates/default/app.css".'" type=text/css rel=StyleSheet>');
-				}
-			}
-
-			return $tpl->subst('css');
+			if ( @ isset( $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] ) )
+			{
+				$css = "/%s/templates/%s/%s.css";
+
+				global $path, $link, $template;
+
+				$path = PHPGW_SERVER_ROOT . str_replace( '/', SEP, $css );
+
+				$link = '<LINK href="%s" type="text/css" rel="StyleSheet">';
+				$link = sprintf( $link,
+					"{$GLOBALS[ 'phpgw_info' ][ 'server' ][ 'webserver_url' ]}{$css}"
+				);
+
+				$template = $GLOBALS[ 'phpgw_info' ][ 'server' ][ 'template_set' ];
+
+				function _css( $module, $css )
+				{
+					global $link, $path, $template;
+
+					if ( file_exists( sprintf( $path, $module, $template, str_replace( '/', SEP, $css ) ) ) )
+						return sprintf( $link, $module, $template, $css );
+
+					if ( file_exists( sprintf( $path, $module, 'default', str_replace( '/', SEP, $css ) ) ) )
+						return sprintf( $link, $module, 'default', $css );
+
+					return '';
+				}
+
+				$css = _css( 'phpgwapi', 'css/base' );
+				$css .= _css( 'phpgwapi', "css/{$GLOBALS[ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ]}" );
+				$css .= _css( $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'currentapp' ], "css/{$GLOBALS[ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ]}" );
+				$css .= _css( $GLOBALS[ 'phpgw_info' ][ 'flags' ][ 'currentapp' ], 'app' );
+
+				if ( $css )
+					$tpl -> set_var( 'css_file', $css );
+			}
+
+			return $tpl -> subst('css');
 		}
 
Index: /branches/2.1/phpgwapi/templates/classic/head.tpl
===================================================================
--- /branches/2.1/phpgwapi/templates/classic/head.tpl	(revision 1151)
+++ /branches/2.1/phpgwapi/templates/classic/head.tpl	(revision 2385)
@@ -13,5 +13,4 @@
 		<link rel="icon" href="{img_icon}" type="image/x-ico" />
 		<link rel="shortcut icon" href="{img_shortcut}" />
-		<link href="{theme_css}" title="eGroupWareStyle" type="text/css" rel="StyleSheet"/>
 		<META http-equiv="Default-Style" content="eGroupWareStyle">
 		{slider_effects}
Index: /branches/2.1/phpgwapi/templates/default/head.inc.php
===================================================================
--- /branches/2.1/phpgwapi/templates/default/head.inc.php	(revision 890)
+++ /branches/2.1/phpgwapi/templates/default/head.inc.php	(revision 2385)
@@ -33,9 +33,4 @@
 
 	#_debug_array($GLOBALS['phpgw_info']['user']['preferences']['common']);
-	$theme_css = ".".$GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/css/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'].'.css';
-	if(!file_exists($theme_css))
-	{
-		$theme_css = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/css/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'].'.css';
-	}
 
 	//pngfix defaults to yes
@@ -94,5 +89,4 @@
 		'website_title' => $GLOBALS['phpgw_info']['server']['site_title'].$app,
 		'body_tags'     => $bodyheader .' '. $GLOBALS['phpgw']->common->get_body_attribs(),
-		'theme_css'     => $theme_css,
 		'css'           => $GLOBALS['phpgw']->common->get_css(),
 		'java_script'   => $GLOBALS['phpgw']->common->get_java_script(),
Index: /branches/2.1/phpgwapi/templates/default/head.tpl
===================================================================
--- /branches/2.1/phpgwapi/templates/default/head.tpl	(revision 1247)
+++ /branches/2.1/phpgwapi/templates/default/head.tpl	(revision 2385)
@@ -13,5 +13,4 @@
 		<link rel="icon" href="{img_icon}" type="image/x-ico" />
 		<link rel="shortcut icon" href="{img_shortcut}" />
-		<link href="{theme_css}" title="eGroupWareStyle" type="text/css" rel="StyleSheet"/>
 		<META http-equiv="Default-Style" content="eGroupWareStyle">
 		{slider_effects}
