<?php
// $Id: page.tpl.php,v 1.28 2008/01/24 09:42:52 goba Exp $
?><!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="<?php print $language->language ?>" xml:lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">

<head>
  <title><?php print $head_title ?></title>
  <?php print $head ?>
  <?php print $styles ?>
  <?php print $scripts ?>
  <script type="text/javascript"><?php /* Needed to avoid Flash of Unstyle Content in IE */ ?> </script>
  <script language="javascript" type="text/javascript" src="<?php print base_path() . $directory ?>/scripts/inc.js"></script>
<!--[if lt IE 7]>
  <script language="javascript" type="text/javascript" src="<?php print base_path() . $directory ?>/scripts/IE7.js"></script>
<![endif]-->
  <script type="text/javascript">
    if (navigator.appCodeName == "Mozilla") {
      document.write("<style>ol li {list-style-type:-moz-thai;}</style>");
    }
  </script>


  <?php

  // CODE FROM http://www.javascriptkit.com/javatutors/externalphp2.shtml
  //  Header("content-type: application/x-javascript");

  function returnimages() {
    global $base_url, $this_dir, $gal_dir;
    $dirname=realpath('.')."/".$this_dir.$gal_dir;
    // ***** URL OF IMAGE
    $url=$base_url."/".$this_dir.$gal_dir;
    $pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)"; //valid image extensions
    $files = array();
    $curimage=0;
    if($handle = opendir($dirname)) {
      while(false !== ($file = readdir($handle))) {
        if(eregi($pattern, $file)) { //if this file is a valid image
                                     //Output it as a JavaScript array element
          echo 'image_list['.$curimage.'] = new imageItem("'.$url.'/'.$file.'");';
          $curimage++;
        }
      }
      closedir($handle);
    }
    return ($files);
  }

  ?>
  <!--[if lt IE 7]>
    <style type="text/css">.wmain { width: 960px };</style>
  <![endif]-->
</head>
<body>
<?php global $base_url, $this_dir, $gal_dir;?>
<?php $this_dir=$directory; ?>
<!-- ***** CHANGE SOURCE OF IMAGE HERE, DEFAULT IS (THEME_NAME)/gal -->
<?php $gal_dir="/gal"; ?>

<script language="JavaScript">
<!-- Original:  Robert Bui (astrogate@hotmail.com) -->
<!-- Web Site:  http://astrogate.virtualave.net -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
// ***** CHANGE TIMING HERE
var site=document.URL;
var interval = 15;
if ( site.match("q=") ) { // TEST FOR FIRSTPAGE
  interval = 60;
} else {
  interval = 15; // delay between rotating images (in seconds)
}
var random_display = 1; // 0 = no, 1 = yes
interval *= 1000;       //speed of display
var image_index = 0;
image_list = new Array();
<?php returnimages() ?>
var number_of_image = image_list.length;
//  End -->
</script>


<div class="topbg"><div class="tophead"><div class="wmain">
  <div id="header">
    <div class="menu_wrap">
      <?php if ($search_box); { ?><div id="search"><?php print $search_box ?></div><?php } ?>
      <div id="menu">
        <div id="primary_link">
          <?php if (isset($primary_links)) { ?><?php print theme('links', $primary_links, array('class' => 'links', 'id' => 'navlist')) ?><?php } ?>
        </div>
      </div>
      <div id="submenu">
        <div class="clear">&nbsp;</div>
        <?php if (isset($secondary_links)) { ?><?php print theme('links', $secondary_links, array('class' => 'links', 'id' => 'subnavlist')) ?><?php } ?>
        <?php if (isset($secondary_links)) { ?><?php print theme('links', $menu_secondary_links_source, array('class' => 'links', 'id' => 'subnavlist')) ?><?php } ?>
      </div>
    </div>
    <div id="logo">
      <?php if ($logo) { ?><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><img src="<?php print $logo ?>" alt="<?php print t('Home') ?>" /></a><?php } ?>
      <?php if ($site_name) { ?><h1 class='site-name'><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><?php print $site_name ?></a></h1><?php } ?>
      <?php if ($site_slogan) { ?><div class='site-slogan'><?php print $site_slogan ?></div><?php } ?>
    </div>
    <div class="clear"> </div>
    <?php if ($header) { ?>
      <div><?php print $header ?></div>
      <div class="clear"> </div>
    <?php } ?>
  </div></div>
</div></div>
  <?php if ($mission) { ?>
    <div id="mission" onclick="rotateImage('rImage');">
      <div class="rimage-wrap">
        <div class="rimage-top">&nbsp;</div>
        <div id="imagebackground"><img name="rImage" src="<?php print $base_url.'/'.$directory ?>/images/loading.gif" alt="Random image" title="Random image" id="blendimage" /></div>
        <div class="rimage-bottom">&nbsp;</div>
      </div>
      <div class="mission-text"><?php print $mission ?></div>
      <span class="clear"> </span>
    </div>
  <?php } ?>
  <div class="mainbg"><div class="wmain"><div id="content">
    <?php if ($left) { ?><div class="sbl_wrap"><div id="sidebar-left">
      <?php print $left ?>
    </div></div><?php } ?>
    <div id="main"><div class="main_wrap">
      <?php print $breadcrumb ?>
        <h1 class="title"><?php print $title ?></h1>
        <div class="tabs"><?php print $tabs ?></div>
        <?php if ($show_messages) { print $messages; } ?>
        <?php print $help ?>
        <?php print $content; ?>
        <?php print $feed_icons; ?>
    </div></div>
    <div class="clear">&nbsp;</div>
  </div></div></div>
  <div class="midbg"><div class="midbg-bottom"><div class="wmain"><div id="pre_footer">
    <?php if ($right) { ?><div id="sidebar-right">
      <?php print $right ?>
    </div><?php } ?>
    <div class="clear">&nbsp;</div>
  </div></div></div></div>
  <div class="bottombg"><div class="bottombg-bottom"><div class="wmain"><div id="footer">
    <?php print $footer_message ?>
    <?php print $footer ?>
  </div></div></div></div>
  <?php print $closure ?>
  <script>
    rotateImage('rImage');
  </script>

</body>
</html>
