<?php
//+--------------------------------------------------------+
//     CSS importer
//     Charset=UTF-8
//+--------------------------------------------------------+
//
//     2008.03.19 ver 1.0.1 - フォントCSSを外部化
//     2007.12.18 ver 1.0.0
//     
//     [ 使用方法 ]
//     CSSとして読み込む
//
//     [ 説明 ]
//
//+--------------------------------------------------------+
//     [ 拡張予定 ]
//   

//---------------------------------------------------------
//    Make style sheet
//---------------------------------------------------------
header ("Content-type: text/css\n\n");


//---------------------------------------------------------
//    Set vars
//---------------------------------------------------------
$ua = preg_replace ("/\s/", "", $_SERVER["HTTP_USER_AGENT"]);
$addition = "";
$styles = array ();


//---------------------------------------------------------
//    Set stylesheet
//---------------------------------------------------------
$type = set_type($ua);
$styles = array ();
if ($type == "full") {
	$styles[] = "font.css";
	$styles[] = "basic.css";
	$styles[] = "layout.css";
	$styles[] = "common.css";
	$styles[] = "detail.css";
	$styles = array_merge ($styles, set_addition($ua));
} else {
	$styles[] = "basic.css";
	$styles[] = "small.css";
}


//---------------------------------------------------------
//    Output
//---------------------------------------------------------
foreach ($styles as $style) {
	if (!$style) { continue;}
	print ("@import \"$style\";\n");
}


//---------------------------------------------------------
//    Set type
//---------------------------------------------------------
function set_type($_ua) {

	//  Set default
	$type = "full";

	//  Yahoo
	if (preg_match ("/Yahoo!Slurp/i", $_ua)) {
		$type = "small";
	}
	//  Mac IE
	if ((preg_match ("/MSIE([0-9|\.]*)/i", $_ua, $match)) and (preg_match ("/mac/i", $_ua))){
		$type = "small";
	}

	//  Result
	return $type;
}


//---------------------------------------------------------
//    Set addition
//---------------------------------------------------------
function set_addition($_ua) {

	//  WinIE
	$addition = array ();
	if (preg_match ("/MSIE([0-9|\.]*)/i", $_ua, $match)) {

		if ((preg_match ("/win|windows/i", $_ua)) and (!preg_match ("/Opera/i", $_ua))) {
			$version = (int)$match[1];
			if (($version >= 5) and ($version < 7)) {
				$addition[] = "addition/winie5-6.css";
			}
		}
	}
	return $addition;
}



?>