<?php

/*  Alternate WebKit
(C) 2010 by Alternate Tools
-----------------------------------------------------

File:         index.php
Description:  Main switching page

*/

    include "modules/mod_site.php";
    include "modules/class_textfile.php";
    include "modules/class_pagelist.php";

    if ($SITE_SHOWCONSTRUCTION == true)
    {
        header ("location: " . $SITE_CONSTRUCTION_SITE);
    }
    else
    {
        if ($SITE_SHOWSPLASHPAGE == true)
        {
            header ("location: " . $SITE_SPLASHPAGE_SITE);
            return;
        }
        if ($SITE_SHOWSURVEY == true)
            header ("location: " . $SITE_SURVEY_SITE);
        else
        {
            // Determine main page
            $pageList = new cPageList;
            $page = new cPage;
            $pageList->SetFolder(retrieve_absolute_path($PAGES_FOLDER));
            $page->SetFolder(retrieve_absolute_path($PAGES_FOLDER));
            $pageList->LoadPageList(1); // Nnlocked
            $pageList->SortPageList(4); // Nav pos
            $list = $pageList->GetPageList();
            $mainPage = "";
            foreach ($list as $value)
            {
                $page->LoadPageFromId($value);
                if ($mainPage == "" || $page->IsMainPage() == true)
                    $mainPage = $page->GetId();
            }
            // No main page -> construction
            if ($mainPage == "")
                header ("location: " . $SITE_CONSTRUCTION_SITE);
            else
                header ("location: " . $SITE_MAIN_SITE . '?page=' . $mainPage);
        }
    }
?>