
//ts-userguide.js
//Shared js file for all TestSmith User Guide pages
//Created:  02 June 2005
//Author:   Tobias Mayer
//-------------------------------------------------------------------------


var userguidedate = "TestSmith User Guide, 07 September 2005" ;

function redirect()
{
   var url = window.location.toString();
   if (url.substring(0, 11) == "http://www.")
   {
      window.location = url.replace("www.", "");
   }
}

function setTitle(cat) {
   if (cat == 2) {  //history page
      document.getElementById("TSDATE").innerHTML = "TestSmith History" ;
   }
   else {  //all other pages
      document.getElementById("TSDATE").innerHTML = userguidedate ;
   }
   document.getElementById("TSTITLE").innerHTML = document.title.substring(10) ;
}

function setHeaderTable() {
   var elem = document.getElementById("HEADERTABLE");
   if (elem === null)
   {
      alert("Error creating page header");
      return;
   }
   elem.innerHTML =
      '<TABLE class=tverdana width=100% border=0 align=center cellpadding=0 cellspacing=0>' +
      '<TR><TD style=background-color:white><DIV id=TSDATE style="font-size:7pt"></DIV>' +
      '</TABLE>' +
      '<TABLE class=tverdana width=100% border=0 align=center cellpadding=0 cellspacing=0>' +
      '<TR><TD style=background-color:white valign=center nowrap=1>' +
      '<DIV id=TSTITLE style="font-size:20pt; font-weight:bold">&nbsp;</DIV>' +
      '<TD style=background-color:white valign=bottom align=right width=100%>' +
      '<DIV id=TOPLINKS style=font-size:10pt></DIV>' +
      '<HR size=0 color=black width=98% align=right>' +
      '</TABLE>' ;
}

function setTopLinks(server, cat) {

   if (parent.location != window.location) {
      //page is inside a frame - show no links to other pages
      document.getElementById("TOPLINKS").innerHTML = "&nbsp;" ;
      return;
   }

   //else set up the links

   var links = "" ;
   if (cat ==1) {
      // the index page
      if (server) {
         links = '<a href=search.html>Search&nbsp;Site</a>' +
                 '&nbsp;|&nbsp<A href=../index.html>TestSmith&nbsp;Home</A>';
      }
      else {
         links = '<a target=ie_browser href=http://agilethinking.net/qualityforge/testsmith/userguide/helpindex.html>View&nbsp;Live&nbsp;Version</a>' ;
      }
   }
   else
   {
      if (server) {
         links = '<A href=../index.html>TestSmith&nbsp;Home</A>&nbsp;|&nbsp' ;
      }
      if (cat == 2) {
         // history pages
         links += '<A href=history.html>History</A>' ;
      }
      else
      if (cat == 3) {
         // tscapi page
         links += '<A href=tscapi.html>TSCAPI</A>' ;
      }
      else
      if (cat == 4) {
         // tsmfcapi page
         links += '<A href=tsmfcapi.html>TSMFCAPI</A>' ;
      }
      else {  // all other pages
         links += '<A href=helpindex.html>User&nbsp;Guide</A>' ;
      }
      // add TestSmith Home to server pages only
   }
   document.getElementById("TOPLINKS").innerHTML = links ;
}

function setFooter() {
   document.getElementById("FOOTER").innerHTML =
      '<tr><td>' +
      '<br><br><br><br><br><br><br><br><br>' +
      '<br><br><br><br><br><br><br><br><br>' +
      '</td></tr>' +
      '<table align=center border=0 width=100% style="font-family: verdana,tahoma,arial,helvetica,sans-serif;; font-size:8pt">' +
      '<tr><td style=background-color:white colspan=2>' +
      '<hr size=1 color=black>' +
      '</td></tr>' +
      '<tr>' +
      '<td style="background-color:white; vertical-align:bottom" width=1% ><IMG src=gifs/icon.gif></IMG>' +
      '<td style="background-color:white; vertical-align:bottom">' +
      'TestSmith © 2003-2005, Quality Forge<br>' +
      'contact: <a href=mailto:tgm@qualityforge.com>info@qualityforge</a><br>' +
      '</table>' ;
}


//called by all user guide pages
function createPage(cat) {
   redirect();
   setHeaderTable();
   setTitle(cat);
   //---------------------------------------------
   var url = window.location.toString();
   var isLive = url.substring(0, 7) == "http://";
   if (isLive) {
      setTopLinks(1, cat);   // server version
   }
   else {
      setTopLinks(0, cat);  // local version
   }
   //---------------------------------------------
   setFooter();
}

