/**
 * show_admin_head
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 */
function show_admin_head($site_title, $page_title = '', $theme = 'desktop')
{
    $css_href = WW_WEB_ROOT . '/ww_edit/themes/' . $theme . '/';
    $meta_title = !empty($page_title) ? $page_title . ' - ' . $site_title . ' edit room' : $site_title . ' - edit room';
    // doctype
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<title>' . $meta_title . '</title>
		<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
	';
    // jquery & miscellaneous javascript functions
    echo '
	<script type="text/javascript" src="' . WW_WEB_ROOT . '/ww_edit/_js/jquery.js"></script>
	<script type="text/javascript" src="' . WW_WEB_ROOT . '/ww_edit/_js/jquery-ui.js"></script>
	<script type="text/javascript" src="' . WW_WEB_ROOT . '/ww_edit/_functions/misc_functions.js"></script>
	';
    // include tiny mce script and configuration
    if (isset($_GET['page_name']) && $_GET['page_name'] == 'write') {
        echo '
		<script type="text/javascript" src="' . WW_WEB_ROOT . '/ww_edit/_js/tiny_mce/tiny_mce.js"></script>';
        // configuration options for tinyMCE
        include '_snippets/tinymce_config.php';
    }
    // grab specific js for any other pages
    // prevents a 'not defined' error on the front admin page
    $_GET['page_name'] = !isset($_GET['page_name']) ? 'front' : $_GET['page_name'];
    if (file_exists(WW_ROOT . '/ww_edit/_js/' . $_GET['page_name'] . '.js')) {
        echo '
		<script type="text/javascript" src="' . WW_WEB_ROOT . '/ww_edit/_js/' . $_GET['page_name'] . '.js"></script>
		';
    }
    // include css files
    echo '
	<link href="' . $css_href . 'structure.css" rel="stylesheet" media="screen" type="text/css" />
	<link href="' . $css_href . 'style.css" rel="stylesheet" media="screen" type="text/css" />
	<!--[if IE 7]>
	<link href="' . $css_href . 'ie7.css" rel="stylesheet" media="screen" type="text/css" />
	<![endif]-->
	<!--[if lt IE 7]>
	<link href="' . $css_href . 'ie6.css" rel="stylesheet" media="screen" type="text/css" />
	<![endif]-->
	';
    // smartphone user
    if (detect_smartphone() == true) {
        echo '
	<link href="' . $css_href . 'iphone.css" rel="stylesheet" media="screen" type="text/css" />
	';
    }
    echo '
	</head>';
}
    $menu_links = isset($menu_links['site_menu']) ? $menu_links['site_menu'] : '';
    $aside_snippet['main_menu'] = build_snippet('Menu', $menu_links);
}
// get content for blogroll / links aside
$aside_snippet['blogroll'] = '';
$blogroll_links = get_links();
if (!empty($blogroll_links)) {
    $blogroll_snip = array();
    foreach ($blogroll_links as $bl_cat => $bl_links) {
        $links_list = show_links($bl_links);
        $blogroll_snip[] = build_snippet($bl_cat, $links_list);
    }
    $aside_snippet['blogroll'] = implode('', $blogroll_snip);
}
// now we start formatting the above data into snippet-style html using the build_snippet function
if (detect_smartphone() == true) {
    // if the user is using a mobile we'll only show the dropdown lists
    // first we define each snippet and store in a variable
    // here we build the actual html for each snippet
    $aside_snippet['search'] = build_snippet('Search', $search_form);
    $aside_snippet['categories_select'] = build_snippet('Categories', $categories_select_form);
    $aside_snippet['months_select'] = build_snippet('Months', $months_select_form);
    $aside_snippet['authors_select'] = build_snippet('Authors', $authors_select_form);
    $aside_snippet['tags_select'] = build_snippet('Tags', $tags_select_form);
    // then we insert each snippet variable into an array
    // upper/inner/outer/lower correlates to the divs within the aside section of the html page
    $aside_content['upper'] = array($aside_snippet['search']);
    $aside_content['inner'] = array($aside_snippet['categories_select'], $aside_snippet['months_select'], $aside_snippet['authors_select'], $aside_snippet['tags_select']);
    $aside_content['outer'] = array();
    // nothing to go in the aside_outer div
    $aside_content['lower'] = array();
/**
 * insert_css
 * 
 * 
 * 
 * 
 * 
 * 
 */
function insert_css($theme = 'default')
{
    // set paths
    $theme_folder = "/ww_view/themes" . $theme;
    $css = '
	<!-- css -->';
    // use structure.css if provided, otherwise use dynamic structure
    if (file_exists(WW_ROOT . $theme_folder . '/structure.css')) {
        $css .= '
	<link rel="stylesheet" type="text/css" href="' . WW_REAL_WEB_ROOT . $theme_folder . '/structure.css" />' . "\n";
    } else {
        $css .= '
	<link rel="stylesheet" type="text/css" href="' . WW_REAL_WEB_ROOT . '/ww_view/themes/structure_css.php" />' . "\n";
    }
    // styles
    if (file_exists(WW_ROOT . $theme_folder . '/style.css')) {
        $css .= '
	<link rel="stylesheet" type="text/css" href="' . WW_REAL_WEB_ROOT . $theme_folder . '/style.css" />' . "\n";
    }
    // page name specific styles
    if (file_exists(WW_ROOT . $theme_folder . '/' . $_GET['page_name'] . '.css')) {
        $css .= '
	<link rel="stylesheet" type="text/css" href="' . WW_REAL_WEB_ROOT . $theme_folder . '/' . $_GET['page_name'] . '.css" />' . "\n";
    }
    // category specific styles
    if (isset($_GET['category_url'])) {
        if (file_exists(WW_ROOT . $theme_folder . '/' . $_GET['category_url'] . '.css')) {
            $css .= '
		<link rel="stylesheet" type="text/css" href="' . WW_REAL_WEB_ROOT . $theme_folder . '/' . $_GET['category_url'] . '.css" />' . "\n";
        }
    }
    // IE 7 fixes
    if (file_exists(WW_ROOT . $theme_folder . '/ie7.css')) {
        $css .= '
	<!--[if IE 7]>
	<link rel="stylesheet" type="text/css" href="' . WW_REAL_WEB_ROOT . $theme_folder . '/ie7.css" />
	<![endif]-->' . "\n";
    }
    // other IE fixes
    if (file_exists(WW_ROOT . $theme_folder . '/ie6.css')) {
        $css .= '
	<!--[if lt IE 7]>
	<link rel="stylesheet" type="text/css" href="' . WW_REAL_WEB_ROOT . $theme_folder . '/ie6.css" />
	<![endif]-->' . "\n";
    }
    // print
    if (file_exists(WW_ROOT . $theme_folder . '/print.css')) {
        $css .= '
	<link rel="stylesheet" media="print" type="text/css" href="' . WW_REAL_WEB_ROOT . $theme_folder . '/print.css" />' . "\n";
    }
    // pda
    if (file_exists(WW_ROOT . $theme_folder . '/pda.css')) {
        $css .= '
	<link rel="stylesheet" media="handheld" type="text/css" href="' . WW_REAL_WEB_ROOT . $theme_folder . '/pda.css" />' . "\n";
    }
    // smartphone user
    if (detect_smartphone() == true) {
        if (file_exists(WW_ROOT . $theme_folder . '/iphone.css')) {
            $css .= '
		<link rel="stylesheet" media="screen" type="text/css" href="' . WW_REAL_WEB_ROOT . $theme_folder . '/iphone.css" />
		<meta name="viewport" content="width=device-width" />' . "\n";
        }
    }
    return $css;
}