<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>PHProjekt</title>
    <link rel="shortcut icon" href="<?php echo $this->webpath; ?>img/favicon.ico" type="image/x-icon" />
    <style type="text/css">
        @import "<?php echo $this->webpath; ?>css/themes/phprojekt/phprojektCssCompiler.php";
    </style>
    <script type="text/javascript">
        var djConfig = {isDebug: false, parseOnLoad: false, bindEncoding: "utf-8",
                        locale: '<?php echo $this->language; ?>'};
    </script>
    <?php
    if (true === $this->isLoggedIn) {
        if ($this->compressedDojo) {
    ?>
    <script type="text/javascript" src="<?php echo $this->webpath; ?>dojo/dojo/dojo.js"></script>
    <script type="text/javascript" src="<?php echo $this->webpath; ?>dojo/dojo/mydojo.js"></script>
    <?php
        } else {
    ?>
    <script type="text/javascript" src="<?php echo $this->webpath; ?>dojo/dojo/dojo.js.uncompressed.js"></script>
    <?php
        }
    ?>
    <script type="text/javascript" src="<?php echo $this->webpath; ?>index.php/js/index/csrfToken/<?php
        echo Phprojekt::createCsrfToken(); ?>">
    </script>
    <?php
    } else {
    ?>
    <script type="text/javascript" src="<?php echo $this->webpath; ?>dojo/dojo/dojo.js"></script>
    <script type="text/javascript" src="<?php echo $this->webpath; ?>dojo/dojo/mydojo.js"></script>
    <script type="text/javascript">
    dojo.require("dojo.parser");
    dojo.require("dijit.layout.BorderContainer");
    dojo.require("dijit.layout.ContentPane");
    dojo.require("dijit.Toolbar");
    dojo.require("dijit.form.Form");
    dojo.require("dijit.form.TextBox");
    dojo.require("dijit.form.CheckBox");
    </script>
    <?php
    }
    ?>
    <script type="text/javascript">
        function getMaxHeight() {
            var availHeight = 0;

            if (document.layers) {
                availHeight = window.innerHeight + window.pageYOffset;
            } else if (document.all) {
                availHeight = document.documentElement.clientHeight + document.documentElement.scrollTop;
            } else if (document.getElementById) {
                availHeight = window.innerHeight + window.pageYOffset;
            }

            return availHeight;
        }

        function init() {
            availHeight = getMaxHeight();

            if (dijit.byId('completeContent')) {
                dojo.style(dojo.byId('completeContent'), "height", availHeight + "px");
                dijit.byId('completeContent').resize();
            }

            if (dojo.byId('completeCenterContent')) {
                dojo.style(dojo.byId('completeCenterContent'), "height", (availHeight - 60) + "px");
                if (dijit.byId('completeCenterContent')) {
                    dijit.byId('completeCenterContent').resize();
                }
            }
        }

        // This variable is needed to be able to clear an existing interval.
        var interval;

        function getFrontendMessage() {
            <?php
            if ($this->frontendMsg) {
            ?>
                var pollingLoop = <?php echo $this->pollingLoop; ?>;
                interval = setInterval(dojo.hitch(this, function() {
                    phpr.frontendMessage.getFrontendMessage();
                }), pollingLoop);
            <?php
            } else {
            ?>
                return;
            <?php
            }
            ?>
        }

        dojo.addOnLoad(function() {
            <?php
            if (true === $this->isLoggedIn) {
            ?>
            if (!window.location.hash) {
                // If current hash if empty,
                // try to fetch one from browser cookies
                // or use the default
                var hash = dojo.cookie('location.hash');
                if (hash != undefined) {
                    window.location.hash = hash;
                } else {
                    window.location.hash = "Project";
                }
            }
            recentHash = window.location.hash;
            setInterval(initialiseStateFromUrl, 500);
            // Add shortcut icon
            var link  = document.createElement("link");
            link.type = "image/x-icon";
            link.rel  = "shortcut icon";
            link.href = "<?php echo $this->webpath; ?>img/favicon.ico";
            document.getElementsByTagName("head")[0].appendChild(link);
            <?php
            } else {
            ?>
                dojo.parser.parse();
                dojo.byId('hash').value = <?php
                if ($this->hash) {
                    echo '"' . $this->hash . '"';
                } else {
                    echo 'window.location.hash';
                }
                ?>;
            <?php
            }
            ?>
            init();
            <?php
            if (true !== $this->isLoggedIn) {
            ?>
                dojo.byId('username').focus();
                dojo.byId('username').select();
            <?php
            } else {
            ?>
                getFrontendMessage();
            <?php
            }
            ?>
        });

        window.onresize = function() {
            init();
        };
    </script>
</head>
<body class="phprojekt">
    <?php
    if (true === $this->isLoggedIn) {
    ?>
    <script type="text/javascript">
        phpr.Url   = new phpr.Url();
        var module = phpr.Url.getModule();
        var main   = new phpr.Main("<?php echo $this->webpath; ?>", module, 1, '<?php echo $this->language; ?>');
    </script>
    <?php
    } else {
        include ("login.phtml");
    }
    ?>
</body>
</html>
<!-- template: index.phml -->
