<?php
  function TitleTemplate($Caption=null,$Logo=null,$MenuFile=null,$Title=null,$Home=null,$Image=null,$Quote=null,$ImageCap=null,$TitleSize=null,$CaptionSize=null,$Link=null,$LetterHead=null)
  { global  $Session;
    global  $Site;
    global  $SRoot;
    global  $URL;
    global  $DisclaimerLink;
    global  $Target;
    global  $RTarget;
    global  $HelpMenu;
    global  $Quote;
    global  $Debugger;
    global  $NoContact;
    global  $FAQ;
    global  $Donate;
    global  $Comment;
    global  $Contact;

    if (empty($Title)) $Title = $Session->PT->Record[PageTitle];
?>
    <!--Header-->
    <div id='header' class='header'>
      <div class='header-top'>

<!--Header Logo-->

        <div class='header-logo-box'>
<?php
    if (isset($Home) && empty($Session->PT->PageOption(PageOptionNoHomeLink)))
      echo "          <a href='",iPageLink($Home),"'>\r\n";
    if (isset($Logo))
    { echo "            <img class='header-logo' title='Click on the ",$Caption," Logo to take you to the website&apos;s home page' src='",$Logo,"' alt='Logo'>\r\n";
    }
    else if (isset($Caption))
      echo "          ",$Caption,"\r\n";
    if (isset($Home) && empty($Session->PT->PageOption(PageOptionNoHomeLink)))
      echo "          </a>\r\n";
?>
        </div>
<!--End Header Logo-->

<!--Header Left Box-->

        <div class='header-left-box'>
<!--Site Info-->
<?php
    if (empty($Session->PT->PageOption(PageOptionNoPublicHdr)))
    { if (empty($Session->PT->PageOption(PageOptionNoUser)) && $Session->ST->Record[SessionUserName])
      { if (empty($Session->PT->PageOption(PageOptionNoMobileTest)) && $Session->Mobile)
        { if (empty($Session->PT->PageOption(PageOptionNoBotTest)) && $Session->Browser->Robot)
            echo "          <div id='TitleSessionTest'>Mobile Bot<br></div>";
          else
            echo "          <div id='TitleSessionTest'>Mobile<br></div>";
        }
        else if (empty($Session->PT->PageOption(PageOptionNoBotTest)) && $Session->Browser->Robot)
          echo "          <div id='TitleSessionTest'>Bot<br></div>";
        else
        { echo "          <div id='TitleSessionTest'><br></div>";
        }
        if (!empty($Session->MemberActingType))
          echo '          ',$Session->MT->MemberTypeStr($Session->MemberActingType), "<br><b>",$Session->ST->Record[SessionUserName];
        else
          echo '          <br><b>',$Session->ST->Record[SessionUserName];
        if ($Session->Admin && $Session->ID)
          echo "&nbsp;&nbsp;<span style='font-size:1vw;'>(",$Session->ST->Record[SessionID],")</span><br>";
        echo "</b>\r\n";
      }
    }
?>
<!--End Site Info-->
        </div>
<!--End Header Left Box-->

<!--Header Center Box-->
        <div class='header-center-box'>
          <div class='header-center-image'>
<?php

    if (isset($Image))
    { echo "<!--Site Image-->\r\n";
      echo "            <img class='header-center-image' alt='' ";
      if (isset($ImageCap))
        echo "title='",$ImageCap,"'";
      echo " src='",$Image,"'>\r\n";
    }
    else if (isset($ImageCap))
      echo  $ImageCap, "\r\n";
    echo "          </div>\r\n";
    echo "<!--End Site Image-->\r\n";

    echo "<!--Site Caption-->\r\n";
    echo "          <div id='header_title' class='header_title_title_caption'  style='font-size:2.5vw; font-weight:bold; white-space:nowrap; color: rgb(128, 128, 255); padding:0px; margin:0px;'>\r\n";
    if (isset($Caption))
    { echo "          ",$Caption,"\r\n";
    }
?>
          </div>
<!--End Site Caption-->
        </div>
<!--End Header Center Box-->

<!--Header Right Box-->

        <div class='header-right-box'>

<?php
    if (empty($PublicHdr))
    { echo "          <div class='header_title_timeout' style='display:none;'>\r\n";
      echo "          </div>\r\n";
    }
    if ($Session->MemberType >= MemberTypeAdmin)
    { echo "          <div title='Alerts'>\r\n";
      if ($Session->AT->RawRecord[1])  echo "            <img title='There are ",$Session->AT->RawRecord[1]," New Messages' alt='' src='/Host/Images/Msg.gif'>\r\n";
      if ($Session->AT->RawRecord[2])  echo "            <img title='There are ",$Session->AT->RawRecord[2]," New Members'  alt='' src='/Host/Images/Member.gif'>\r\n";
      if ($Session->AT->RawRecord[3])  echo "            <img title='There are ",$Session->AT->RawRecord[3]," New Guests'   alt='' src='/Host/Images/Guest.gif'>\r\n";
      if ($Session->AT->RawRecord[4])  echo "            <img title='There are ",$Session->AT->RawRecord[4]," New Sessions Started' alt='' src='/Host/Images/Session.gif'>\r\n";
      if ($Session->AT->RawRecord[5])  echo "            <img title='There are ",$Session->AT->RawRecord[5]," Replies Pending' alt='' src='/Host/Images/Reply.gif'>\r\n";
      if ($Session->AT->RawRecord[6])  echo "            <img title='There have been ",$Session->AT->RawRecord[6]," Attempted Bot Accesses' alt='' src='/Host/Images/Bot.gif'>\r\n";
      if ($Session->AT->RawRecord[7])  echo "            <img title='There have been ",$Session->AT->RawRecord[7]," Attempted hacker Attacks' alt='' src='/Host/Images/Hacker.gif'>\r\n";
      echo "          </div>\r\n";
      if (empty($Session->PT->PageOption(PageOptionNoACP)))
      { echo "          <a title='A Link to the Administrator Control Panel (ACP)' href='",iPageLink('/Admin/iACP.php'),"' style='color: rgb(128, 128, 255); font-size:1.25vw;'>ACP</a><br>\r\n";
      }
    }
?>
        </div>
<!--End Header Right Box-->

<!--Header Link Box-->

        <div class='header-link-box'>

<?php

    if (empty($Session->PT->PageOption(PageOptionNoLogin)))
    { if ($Session->MemberActingType > 2)
      { if (empty($RTarget))
          echo "          <a class='header-link' title='Log out when finished' href='",iPageLink('iLogout.php'),"&session=",$Session->ST->Record[SessionID],"'>Logout</a><br>\r\n";
        else
          echo "          <a class='header-link' title='Log out when finished' href='",iPageLink('iLogout.php'),"&target=",$RTarget,"&session=",$Session->ST->Record[SessionID],"'>Logout</a><br>\r\n";
      }
      else if (empty($Target))
        echo "          <a class='header-link' title='Log in to the site' href='",iPageLink('iMemberLogin.php'),"&session=",$Session->ST->Record[SessionID],"'>Login</a><br>\r\n";
      else
        echo "          <a class='header-link' title='Log in to the site' href='",iPageLink('iMemberLogin.php'),"&target=",$Target,"&session=",$Session->ST->Record[SessionID],"'>Login</a><br>\r\n";
      if ($Session->SCT->CFGOption(SiteCFGSiteMap) && empty($Session->PT->PageOption(PageOptionNoSiteMap)))
      { echo "          <a class='header-link' title='A Link to the Site Map' href='",iPageLink('iSiteMap.php'),"'>Site Map</a><br>\r\n";
      }
    }

    if (!empty($FAQ))      echo "          <a class='header-link' title='A Link to frequently asked questions' href='",iPageLink($FAQ),"&public=true'>FAQs</a><br>\r\n";
    if (!empty($Donate))   echo "          <a class='header-link' title='A Link to Donate to Charged Motion' href='",iPageLink($Donate),"&public=true'>Donatate</a><br>\r\n";
    if (!empty($Comment))  echo "          <a class='header-link' title='A Link to hear what others are saying' href='",iPageLink($Comment),"&public=true'>Comments</a><br>\r\n";
    if (!empty($Contact))  echo "          <a class='header-link' title='A Link to Contact Us' href='",iPageLink($Contact),"&public=true'>Contact Us</a><br>\r\n";
    else if (empty($Session->PT->PageOption(PageOptionNoContact)) && (!defined($NoContact) || empty($NoContact)))
        echo "          <a class='header-link' title='A Link to Contact Us' href='",iPageLink('iContactUs.php'),"&public=true'>Contact Us</a>\r\n";
?>

        </div>
<!--End Header Link Box-->

<!--Header Menu Bar-->

<?php

    if (!empty($MenuFile) && empty($Session->PT->PageOption(PageOptionNoMenuBar)))
    { echo "  <div id='MenuBar' class='MenuBar' style='width:100%; border:solid 1px Black; font-size:100%; position:relative; top:0px; left:0px; z-index:100; margin:0px; padding:0px;'></div>\r\n";
      if (strpos($MenuFile,'/') == false)
        include_once    SiteIncludeFile($MenuFile);
      else
        include_once    $MenuFile;
    }
?>
<!--End Header Menu Bar-->

<!--Header Sep-->
        <hr class='header_no_menu'>
<!--End Header Sep-->


<!--Header Debug Bar-->

<?php

    if ($Session->Admin && !empty($Debugger))
    { echo "  <div id='DebugBar' class='MenuBar' style='width:100%; border:solid 1px Black; font-size:100%; position:relative; top:0px; left:0px; z-index:95; margin:0px; padding:0px;'></div>\r\n";
      include_once $SRoot."Admin/Include/iAdminDebugMenu.inc";
      echo "  <hr class='header_no_menu'>\r\n";
    }
?>
<!--End Header Debug Bar-->

<?php

    if (!empty($Session->PT->Record[PageTitle]) || !empty($Prev) || !empty($PrevSection) || !empty($NextSection) || !empty($Next))
    { echo "      <div class='header_sub_title style='margin-bottom:0px; padding-bottom:0px; display:inline-block;'>\r\n";
      echo "<!--Header Nav-->\r\n";
      echo "        <div class='header_sub_title_left_links' style='width:15%; margin-bottom:0px; padding-bottom:0px; display:inline-block;'>\r\n";
      if (empty($Session->PT->PageOption(PageOptionNoPublicHdr)))
      { echo "          <a id='PrevSection' title='The webpages on this website can be accessed sequentially by section. Click on this link to go to the previous sequential section&apos;s webpage.' href='#' style='font-size:100%;' onclick='location.assign(PrevSection);'>Prev Sect</a>\r\n";
        echo "          <a id='Prev' title='The webpages on this website can be accessed sequentially. Click on this link to go to the previous sequential webpage.' href='#' style='font-size:100%;' onclick='location.assign(Prev);'>Prev</a>\r\n";
      }
      echo "        </div>\r\n";
      echo "<!--End Header Nav-->\r\n";
      echo "<!--Header Subtitle-->\r\n";
      echo "        <div id='header_subtitle' class='header_sub_title_title_box' style='white-space:nowrap; display:inline-block;'>\r\n";
      if (!empty($Session->PT->Record[PageTitle]))
      { if (!empty($Session->PT->Record[PageLink]))
        { if (strpos($Session->PT->Record[PageLink],"http://") === FALSE)
          { echo "          <a title='Click on the page Title for more information.' href=\"",iPageLink($Link),"\">\r\n";
            echo "            $Title\r\n";
            echo "          </a>\r\n";
          }
          else  OffSite($Session->PT->Record[iPageLink],$Title);
        }
        else  echo          $Title,"\r\n";
      }
      else  echo "          &nbsp;\r\n";
      echo "        </div>\r\n";
      echo "<!--End Header Subtitle-->\r\n";

      echo "<!--Header Nav-->\r\n";
      echo "        <div class='header_sub_title_right_links' style='width:15%; margin-bottom:0px; padding-bottom:0px; display:inline-block; text-align: right; vertical-align: middle; font-size:100%;'>\r\n";
      if (empty($Session->PT->PageOption(PageOptionNoPublicHdr)))
      { echo "          <a  id='Next' title='The webpages on this website can be accessed sequentially. Click on this link to go to the next sequential webpage.' href='#' onclick='location.assign(Next)'>Next</a>\r\n";
        echo "          <a  id='NextSection' title='The webpages on this website can be accessed by sections sequentially. Click on this link to go to the next sequential section&apos;s first webpage.' href='#' onclick='location.assign(NextSection);'>Next Sect</a>\r\n";
      }
      echo "        </div>\r\n";
      echo "<!--End Header Nav-->\r\n";
      echo "      </div>\r\n";
    }
    echo "<!--Header Quote-->\r\n";
    if (!empty($Quote) && empty($Session->PT->PageOption(PageOptionNoQuote)))
    { echo "      <div class='header_quote' style='vertical-align: top;'>\r\n";
      echo "        <hr class='header_quote_sep1'>\r\n";
      if (is_array($Quote))
      { if (!empty($Quote[1]))
          echo "        <div class='header_quote_text' title='",$Quote[1],"' style='vertical-align: top; background-color: rgb(240, 240, 240); font-size:1.25vw; text-align: center; border-style:outset; border-width:2px;'>\r\n";
        else
          echo "        <div class='header_quote_text' title='",$Quote[1],"' style='vertical-align: top; background-color: rgb(240, 240, 240); font-size:1.25vw; text-align: center; border-style:outset; border-width:2px;'>\r\n";
        echo "          ", $Quote[0], "\r\n";
      }
      else
      { echo "        <div class='header_quote_text' style='vertical-align: top; background-color: rgb(240, 240, 240); font-size:1.25vw; text-align: center; border-style:outset; border-width:2px;'>\r\n";
        echo "          ", $Quote, "\r\n";
      }
      echo "  	    </div>\r\n";
      echo "      </div>\r\n";
    }
    echo "<!--End Header Quote-->\r\n";
    echo "      </div>\r\n";
    echo "  <hr>\r\n";
    if (!empty($LetterHead))
    { echo "<!--Letterhead-->\r\n";
      echo "      <div style='text-align:left;'>\r\n";
      if (!empty($LetterHead['Topic']))
      { echo "      <div class='letterhead_topic'>\r\n";
        echo "        ",$LetterHead['Topic'],"\r\n";
        echo "      </div>\r\n";
      }
      if (!empty($LetterHead['From']))
      { echo "      <div class='letterhead_from'>\r\n";
        echo "        From:&nbsp;&nbsp;",$LetterHead['From'],"\r\n";
        echo "      </div>\r\n";
      }
      if (!empty($LetterHead['Date']))
      { echo "      <div class='letterhead_date'>\r\n";
        echo "        ",$LetterHead['Date'],"\r\n";
        echo "      </div>\r\n";
      }
      if (!empty($LetterHead['To']))
      { echo "      <div class='letterhead_to'>\r\n";
        echo "        To:&nbsp;&nbsp;",$LetterHead['To'],"\r\n";
        echo "      </div>\r\n";
      }
      echo "      </div>\r\n";
    }
    echo "<!--End Letterhead-->\r\n";
    echo "<!--Timeout Bar-->\r\n";
    if (empty($Session->PT->PageOption(PageOptionNoTimerBar)))
    { echo "    <div id='TimeOutBar' class='TimeOutBar'>\r\n";
      echo "      <div id='TimeOutText' class='TimeOutText'>\r\n";
      echo "      </div>\r\n";
      echo "      <div id='TimeOutMarker' title='Click on the I-Jet to Reset the Timeout' class='TimeOutMarker' onclick='ResetTimeoutTimer()'><img class='TimeOutMarker' alt='' src='",$URL,"Images/Timer.gif'>\r\n";
      echo "      </div>\r\n";
      echo "    </div>\r\n";
    }
    echo "    </div>\r\n";
    echo "<!--End Timeout Bar-->\r\n";

    echo "<!--Nav Vars-->\r\n";
    echo "  <script>\r\n";
    echo "    if (document.getElementById('PrevSection')) document.getElementById('PrevSection').style.display  = (PrevSection)?'':'none';\r\n";
    echo "    if (document.getElementById('Prev'))        document.getElementById('Prev').style.display         = (Prev)?'':'none';\r\n";
    echo "    if (document.getElementById('Next'))        document.getElementById('Next').style.display         = (Next)?'':'none';\r\n";
    echo "    if (document.getElementById('NextSection')) document.getElementById('NextSection').style.display  = (NextSection)?'':'none';\r\n";
    echo "  </script>\r\n";
    echo "<!--End Nav Vars-->\r\n";
    echo "<!--End Header-->\r\n";
  }
?>

