var StartTime;

function startPageTimer()
{
  StartTime = new Date();
  setTimeout("stopPageTimer()", 1*60*1000); // 1 minutes
  // if Cookie exists then use that as StartTime
  //alert("Timer Started");
}

function stopPageTimer()
{
 if (StartTime)
  {
  var Now = new Date();
  PageTime = Math.round ((Now - StartTime) / 60000);

  var PageTimeCookie = "TIME_"+PageID+"="+PageTime;
  document.cookie=PageTimeCookie+"; PATH=/";
  StartTime = 0; // Don't count anymore time for this page until it is loaded again.

  //alert(PageTime);
 }
}

function logOut()
{
 // Collect all page times and load them in hidden forms variables
 // Prepare the student and instructor variables
 // Create the submit button.

}


var Class;

function dummy()
{
 document.write(' ');
}


function anchor(href)
{
 document.write('<A onClick="stopPageTimer();"  HREF="',href,location.search,'"');
}

function ClearVisitPath()
{
 VisitPathValue = 0;
 VisitPath = "WAVP="+VisitPathValue;
 document.cookie=VisitPath+"; PATH=/";
}

var check=document.location.href

 function SetVisitPath(SetValue)
  {
   var Cookies = document.cookie;
   var CookieArray = Cookies.split(";");
   var Name;
   var Value;
   var VisitPathValue = 0

   /* Find the WAVP
   -----------------*/

   for (i=0; i<CookieArray.length; i++)
    {
     Pair = CookieArray[i].split("=")
     Name = Pair[0]
     Value = Pair[1]
     if (Name.search("WAVP") != -1)
      {
       VisitPathValue = Value | SetValue;
      }
    }
   VisitPath = "WAVP="+VisitPathValue;
   document.cookie=VisitPath+"; PATH=/";
  }

 server=check.indexOf("seascripts")+1;





 function GetCookieValue(Cookie)
  {
   var Cookies = document.cookie;
   var CookieArray = Cookies.split(";");
   var Name;
   var Value;

   /* Find the Cookie
   -----------------*/
   //document.write("<BR>Cookie ="+Cookie+"=<BR>");
   //document.write("CookieArray.length ="+CookieArray.length+"<BR>");
   //document.write("Cookies = "+Cookies+"<BR>");

   for (i=0; i<CookieArray.length; i++)
    {
     Pair = CookieArray[i].split("=")
     Name = Pair[0];
     Value = Pair[1];
     //document.write("Name ="+Name+"=<BR>");
     if (Name.search(Cookie) != -1)
      {
       //document.write("Cookie("+Cookie+") = "+Value+"<BR>");
       return Value;
      }
    }
   return 99;
  }



 function ValidateTest()
  {
   return 0;
  }



 function Validate()
  {
   var Valid = 0;
   var CheckValid = 0;
   var Today = new Date();


   Wacv = GetCookieValue("WACV");
   Ema  = GetCookieValue("EMA");

   testRE = /!SeaScripts/
   if ( testRE.test(document.URL)) return;



   /* Calculate WACV
   -----------------*/
   CheckValid = Today.getDate()+Today.getDay()+Today.getFullYear();
   Max = Ema.length;
   for (i=0;i<Max;i++)
    {
     CheckValid = CheckValid+Ema.charCodeAt(i);
    }

   if (Wacv == CheckValid)
    {
     Valid = 1;
    }

   if (!Valid)
    {
     location.replace("http://www.seascripts.com/wa/invalid.html");
    }
  }




 function CourseName()
  {
   SearchPairs = location.search.substr(1).split("&");
   CourseName = "Open Water SCUBA"
   for (x=0; x<SearchPairs.length; x++)
    {
     Pair = SearchPairs[x].split("=")
     Name = Pair[0]
     Value = Pair[1]
     if (Name=="course")
      {
       if (Value=="OW") CourseName = "Open Water SCUBA"
       else if (Value=="AOW") CourseName = "Advanced Open Water"
       else if (Value=="ADV") CourseName = "Advanced Diver"
       else if (Value=="SAMPLE") CourseName = "Your course type here:<BR><FONT SIZE=small>Open Water,<BR> Advanced Open Water,<BR> Advanced Diver,<BR> etc."

      }
    }
   document.write(CourseName);
  }

 Briefcase=check.indexOf("Briefcases/Paul")+1;
 server=check.indexOf("seascripts.com")+check.indexOf("webcom.com")+1;
 Home = check.indexOf("Data/SeaScripts")+1;













 function linkto(Who, What)
  {
   Link = 0;
   ExternalLink = 0;

   SearchPairs = location.search.substr(1).split("&");
   ExternalLink = 0
   for (x=0; x<SearchPairs.length; x++)
    {
     Pair = SearchPairs[x].split("=")
     Name = Pair[0]
     Value = Pair[1]
     if (Name==Who) Link = Value
     if (Name=="xLink") ExternalLink = Value
    }
   if (Link == 0) /* Didn't find it in the URL, so check the cookies */
    {
     if ((Value = GetCookieValue(Who)) != 99) Link = Value;
    }
   /* if ExternalLink = 0 then, always include how to get back to Web Advisor root directory in the URL
      All dynamic links should then be specified from the root
      ------------------------------------------------------------------------*/
   if (Link != 0)
    {
     if (ExternalLink == 1) document.write('<a onClick="stopPageTimer();" href="',Link,location.search,'">',What,'</A>');
     else                   document.write('<a onClick="stopPageTimer();" href="../',Link,location.search,'">',What,'</A>');
    }
  }






 function quiz(PageID)
  {
   Link = 0;

   SearchPairs = location.search.substr(1).split("&");
   for (x=0; x<SearchPairs.length; x++)
    {
     Pair = SearchPairs[x].split("=")
     Name = Pair[0]
     Value = Pair[1]
     if (Name == "quiz") Link = Value
    }
   if (Link == 1)
    {
     document.write('<a onClick="stopPageTimer();" href="./',PageID,'-quiz.html">Take the quiz for this page.</A>');
    }
  }



  function header()
  {
   document.write('<CENTER>');
   if(server || Home || Briefcase)
    {
   document.write('<TABLE CLASS=canvas BORDER=0 CELLSPACING=0 CELLPADDING=2 WIDTH=700');
   document.write('<TR>');
   document.write('  <TD WIDTH=70><IMG src="../../gifs/spacer.gif" WIDTH=68 HEIGHT=1> </TD>');
   document.write('  <TD WIDTH=70><IMG src="../../gifs/spacer.gif" WIDTH=68 HEIGHT=1> </TD>');
   document.write('  <TD WIDTH=70><IMG src="../../gifs/spacer.gif" WIDTH=68 HEIGHT=1> </TD>');
   document.write('  <TD WIDTH=70><IMG src="../../gifs/spacer.gif" WIDTH=68 HEIGHT=1> </TD>');
   document.write('  <TD WIDTH=70><IMG src="../../gifs/spacer.gif" WIDTH=68 HEIGHT=1> </TD>');
   document.write('  <TD WIDTH=70><IMG src="../../gifs/spacer.gif" WIDTH=68 HEIGHT=1> </TD>');
   document.write('  <TD WIDTH=70><IMG src="../../gifs/spacer.gif" WIDTH=68 HEIGHT=1> </TD>');
   document.write('  <TD WIDTH=70><IMG src="../../gifs/spacer.gif" WIDTH=68 HEIGHT=1> </TD>');
   document.write('  <TD WIDTH=70><IMG src="../../gifs/spacer.gif" WIDTH=68 HEIGHT=1> </TD>');
   document.write('  <TD WIDTH=70><IMG src="../../gifs/spacer.gif" WIDTH=68 HEIGHT=1> </TD>');
   document.write('</TR>');
   document.write('<TR>')
   document.write('  <TD COLSPAN=2 ALIGN=center>')
   document.write('    <A HREF="../../index.html"> <IMG width=100 height=40 SRC="../../gifs/ss-100.gif" ALT="Sea Scripts Home" BORDER=0></A>')
   document.write('  </TD>')
   document.write('  <TD COLSPAN=4 ALIGN=left>')
   document.write('    <SPAN CLASS=wa>Web Advisor</SPAN>')
   document.write('  </TD>')
   document.write('  <TD COLSPAN=4 ALIGN=center>')
   document.write('    <SPAN CLASS=watext>Companion Web Site for your Open Water,<BR> Advanced or Specialty SCUBA Course</SPAN>');
   document.write('  </TD>');
   document.write('</TR>');
   document.write('<TR>');
   document.write('<TD COLSPAN=10><HR SIZE=4 COLOR=red>')
   document.write('</TR>');
   }
  else
   {
   document.write('<FONT SIZE=1000');
   }
  }

 function copyright(LastDate)
  {

   document.write('</TABLE>');
   document.write('<HR WIDTH=700 COLOR=red SIZE=4>');
   document.write('<TABLE CLASS=canvas border=0 CELLPADDING=5 WIDTH=700>');
   document.write('<TR>');
   document.write('<TD COLSPAN=2><A HREF="../../index.html"> <IMG width=100 height=40 SRC="../../gifs/ss-100.gif" ALT="Sea Scripts" BORDER=0></A></TD>');
   document.write('<TD COLSPAN=8>Copyright (c) 2000-2005, Sea Scripts <A HREF="../forms/contact.html"><I>Contact us</I></A>');
   document.write('<BR>Last revision: ');

   lastmod = document.lastModified     // get string of last modified date
   lastmoddate = Date.parse(lastmod)   // convert modified string to date
   if(lastmoddate == 0)
    {               // unknown date (or January 1, 1970 GMT)
     document.write(LastDate)
    }
     else
    {
     document.write(lastmod)
    }

   document.write('<BR>URL:<I>'+ window.location.hostname + window.location.pathname + ' </I>');
   document.write('</TD></TR>');
   document.write('</TABLE>');
   document.write('</CENTER>');
  }

 function InputCookies()
  {
   Nickname = GetCookieValue("NICK");
   Class    = GetCookieValue("class");
   Ema      = GetCookieValue("EMA");
   Notify   = GetCookieValue("NOTIFY");
   document.write('<INPUT TYPE=hidden NAME="Nickname"  VALUE="'+Nickname+'">');
   document.write('<INPUT TYPE=hidden NAME="Class"     VALUE="'+Class+'">');
   document.write('<INPUT TYPE=hidden NAME="Ema"       VALUE="'+Ema+'">');
   document.write('<INPUT TYPE=hidden NAME="Notify"    VALUE="'+Notify+'">');
  }


//-->
