<?php
header('Content-type: text/html; charset=utf8');
?><!doctype html>
<html lang="ja">
<head>
	<meta charset="utf-8">
	<title><?php if (!empty($title)) echo $title.' | ';?><?php echo TITLE; ?></title>
<?php
	if(! empty($meta_description)) {
		echo '
	<meta name="description" content="'.h($meta_description).'">';
	}
	if(! empty($meta_keyword)) {
		echo '
	<meta name="keyword" content="'.h($meta_keyword).'">';
	}
?>

	<link id="skin" href="<?php echo CSS_URL.Setting::Get('skin');?>/jquery-ui-1.9.2.custom.css" rel="stylesheet">
	<link href="<?php echo CSS_URL;?>main.css" rel="stylesheet">
<?php
	if (! empty($css_links)) {
		foreach ($css_links as $css_link) {
			if (strpos($css_link, 'http://') === 0 || strpos($css_link, '/') === 0) {
				echo '<link href="'.$css_link.'" rel="stylesheet">';
			} else {
				echo '<link href="'.CSS_URL.$css_link.'" rel="stylesheet">';
			}
		}
	}
	if (! empty($css)) {
		echo '
	<style>
'.$css.'
	</style>
';
	}
?>
	<script src="<?php echo JS_URL; ?>base.php?<?php echo time();?>" type="text/javascript"></script>
	<script src="<?php echo JS_URL; ?>jquery-1.8.3.js"></script>
	<script src="<?php echo JS_URL; ?>jquery-ui-1.9.2.custom.js"></script>
	<script src="<?php echo JS_URL; ?>spin.min.js"></script>
	<script src="<?php echo JS_URL; ?>theme.js"></script>
<?php
	if (can_action('operation')) {
?>
		<script src="<?php echo JS_URL; ?>operator.js"></script>
<?php
	}
	if (! empty($script_links)) {
		foreach ($script_links as $script_link) {
			if (strpos($script_link, 'http://') === 0 || strpos($script_link, '/') === 0) {
				echo '<script src="'.$script_link.'"></script>';
			} else {
				echo '<script src="'.JS_URL.$script_link.'"></script>';
			}
		}
	}
?>
<?php
	if (!empty($script)) {
		echo '<script type="text/javascript">'.$script.'</script>';
	}
?>
</head>
<body>
<div class="title ui-widget-header ui-corner-all">
	<table class="page-header"><tbody><tr>
	<td id="app-header">
<?php
if (!empty($title)) {
	echo '<h1><a href="'.BASE_URL.'">'.TITLE.'</a></h1>';
} else {
	echo '<h1 style="margin-top:16px">'.TITLE.'</h1>';
}
?>
<?php
if (!empty($title)) {
	echo '<h2>'.h($title).'</h2>';
}
?>
	</td>
	<td id="user-header">
<?php
	if (is_login()) {
		echo '<div><a href="'.BASE_URL.'my" class="name">'.h($_SESSION['user']['display_name']).'</a>';
		if (can_action('admin') || can_action('operation')) {
			echo ' <a href="'.BASE_URL.'admin" class="name">(管理)</a>';
		}
		echo '</div>';
		echo '<div><a href="'.BASE_URL.'logout" class="name">ログアウト</a></div>';
	} else if (LOGIN_MENU) {
		echo '<div><a href="'.BASE_URL.'login" class="name">ログイン</a></div>';
	}
?>
		<div>
		<?php
			if (@$_SESSION['uid'])
				echo 'ID: <a class="name" href="'.BASE_URL.'name/'.(@$_SESSION['uid']).'">'.@$_SESSION['uid'].'</a>';
		?>
		</div>
	</td>
	</tr></tbody></table>
</div>
<?php
if (empty($no_main)) {
?><div id="main-container" class="ui-widget"><?php }?>
