<?php
        
    $renderCSS = false;
	$renderPaletteCSS = false;
	
	if (key_exists('renderCSS', $_REQUEST)) {
		$renderCSS = true;
		header('Content-type: text/css; charset=utf-8');	
	} else if (key_exists('renderPaletteCSS', $_REQUEST)) {
		$renderPaletteCSS = true;
		header('Content-type: text/css; charset=utf-8');	
	} else {
                session_start();
                header('Content-type: text/html; charset=utf-8');	
        }


        require_once('classes'. DIRECTORY_SEPARATOR . 'commons' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'Common.inc.php');
        require_once(_PAGE_SMARTYINIT);
        
        
	$styleName = $systemProperties['system']['template']['name'];
	

	if ($renderCSS) {
		foreach ($masterComponentList as &$component) {
			if ($_REQUEST['renderCSS'] == $component->getComponentProperty('id')) {			
				$component->renderCSS();
				break;
			}
		}

	} else if ($renderPaletteCSS){		
		$smarty->display('templates/' . $styleName . '/style.css');
	} else {            
            //Simple password protection
            if (_SYSTEM_MODE != 'DESIGN' && $systemProperties['system']['page']['protected'] == 'true') {                
                if (!isset($_SESSION['validAuth']) || $_SESSION['validAuth'] != $systemProperties['system']['site']['auth']['key']) {
                    require_once('classes'. DIRECTORY_SEPARATOR . 'commons' . DIRECTORY_SEPARATOR . 'protection' . DIRECTORY_SEPARATOR . 'PasswordProtection.inc.php');
                }
            }

            $smarty->display('templates/' . $styleName . '/style.html');
	}
	
?>