<?php		

	// Explicitly set the MIME type. Netscape 7 doesn't recognise it otherwise	

	header ("Content-type: text/css");

	

	/* --------- Initialise variables and configuration info  --------- */

	// Process the config.xml files - along the path of the HTML page

	// that called this stylesheet.

	

	// Check the location GET variable.

	// If it is empty then we want to check the root level of the site

	// in case there is a config.xml with the theme defined.

	// Passed in from calling HTML file

	$filepath = $_GET["location"];

	if ( $filepath == "") { // If empty, default to the home page

		$filepath= "/index.html";

	}

	// Hard code the $_SERVER["PHP_SELF"] superglobal

	// This will make init.php think that it is processing the

	// HTML file rather than this stylesheet.css file.

	$_SERVER["PHP_SELF"] = $filepath ;

//	include $HTTP_SERVER_VARS["DOCUMENT_ROOT"] . "/esp/init.php";

	if ( isset($_SERVER["OS"] ) && preg_match('/window/i', $_SERVER["OS"] ) ) {

		// Microsoft IIS does not set "DOCUMENT_ROOT" so create our own.

		$_SERVER["DOCUMENT_ROOT"] = str_replace ('\\\\', '/', $_SERVER['PATH_TRANSLATED']);

		$_SERVER["DOCUMENT_ROOT"] = substr($_SERVER["DOCUMENT_ROOT"], 0, strlen($_SERVER['SCRIPT_NAME']) * - 1); 

		$_SERVER["DOCUMENT_ROOT"]= stripslashes ($_SERVER["DOCUMENT_ROOT"]);

	}

	include $_SERVER["DOCUMENT_ROOT"] . "/esp/init.php";



	/* ---------------------------------------------------------------- */



/*

	1. Templates should call the stylesheet.css as follows:

	     <link href="/stylesheet.css?location=<? echo urlencode(getenv("SCRIPT_NAME"))?>" rel="stylesheet" type="text/css">

		Note that /stylesheet.css will retrieve the stylesheet at the root level of the web site

		This is good for programs such as Contribute as a stylesheet will be used to help

		content editors see styles when they are editing. 

		To do: fix so that lower level themes can be seen by Contribute.

	  

	2.  _config.xml should declare the theme as follows 

	    within the <directory> element

	     <parameter name="theme" value="subsilver" />

	     Note that any subdirectory can override the theme by declaring

	     it's own theme name eg. metal	



    3. Note that  

*/



// Process the config.xml files along the filepath	

//ProcessDirectoryConfigFiles($filepath);



// --- Set some predefined globals.

// Note that this needs to be done again so that the above config.xml 

// variables are used. eg. See $contentBackgroundColour

// COuld set it in this script.

//SetGlobals();



// Check that a theme has been defined.

// If not set it to 'default'. Note there must be

// a default.css available at /styles/default.css

if (!isset($Directory['theme'])) {

	$Directory['theme']= "default";

}

/* --------- Grab the stylesheet for the appropriate theme --------- */

	$stylesheet_path = $Site['site-sub-directory'] . "/styles/". $Directory['theme'] . ".css";

	echo "/*".$stylesheet_path."*/";

    include $_SERVER["DOCUMENT_ROOT"] . $stylesheet_path

  // include $HTTP_SERVER_VARS["DOCUMENT_ROOT"] ."/scc/styles/subsilver.css";

/* ----------------------------------------------------------------- */

?>


