<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html<?php echo $direction ?>>
<head>
    <?php echo $meta ?>
    <meta name="keywords" content="moodle, <?php echo $title ?> " />
    <title><?php echo $title ?></title>
    <link rel="shortcut icon" href="<?php echo $CFG->httpsthemewww .'/'. current_theme() ?>/favicon.ico" />

    <?php 
        include("$CFG->javascript");
        include($CFG->themedir.'/custom_corners/js/js.php');
        
        // check if page is opened within a popup window
        if (function_exists('is_in_popup')) {
            $inpopup = is_in_popup();
        } else {
            $inpopup = false;
        }
        
        // get class list
        preg_match('/class="([^"]*)"/i', $bodytags, $classes);
        $classlist = explode (' ', $classes[1]);
        
        
        // add "inpopup" or "notinpopup" to class list
        if ($inpopup) {
            array_push($classlist, 'inpopup');
        } else {
            array_push($classlist, 'notinpopup');
        }
        
        //replace classlist with new one
        $bodytags = str_replace($classes[0], 'class="'.implode(' ', $classlist).'"', $bodytags);
    ?>
</head>

<body<?php
    echo " $bodytags";
    if ($focus) {
        echo " onload=\"setfocus()\"";
    };
    ?>>

    <?php if(!empty($infooutput)) { ?>
        <div id="infowrapper"><div id="infooverlay"><?php echo $infooutput; ?></div></div>
    <?php } ?>
<div id="page">

<?php if (!$inpopup) { 
    if ($home) {  // This is what gets printed on the home page only
?>
    <?php print_container_start(true, '', 'header-home'); ?>
        <h1 class="headermain"><?php echo $heading ?></h1>
        <div class="headermenu"><?php echo $menu ?></div>
    <?php print_container_end(); ?>
<?php } else if ($heading) {  // This is what gets printed on any other page with a heading
?>
    <?php print_container_start(true, '', 'header'); ?>
        <h1 class="headermain"><?php echo $heading ?></h1>
        <div class="headermenu"><?php echo $menu ?></div>
        <div class="navbar clearfix">
            <?php if ($navigation) { // This is the navigation table with breadcrumbs
            ?>
            <div class="breadcrumb"><?php print_navigation($navigation); ?></div>
            <div class="navbutton"><?php echo $button; ?></div>
            <?php } ?>
        </div>
    <?php print_container_end(); ?>
<?php }
    }
?>
    <!-- END OF HEADER -->
<?php print_container_start(false, '', 'content'); ?>
