var isNav, isIE;

if (parseInt(navigator.appVersion) >= 4) {
  if (navigator.appName == "Netscape") {
     isNav = true;
     isIE = false;}
  else {
     isIE = true;
     isNav = false;}
}

function ReadCookie(name){
//	alert("Read cookie Starts");
	var allCookie, CookieVal, length, start, end;
	cookieVal="";
	name=name+"=";
	allCookie=document.cookie;
//	alert("ReadCookie is: " + allCookie);
	length=allCookie.length;
	if (length>0) {
		start=allCookie.indexOf(name,0)
		if (start!=-1) {
			start+=name.length;
			end=allCookie.indexOf(";",start);
			if (end==-1) {end=length;}
			cookieVal=unescape(allCookie.substring(start, end));
		}
	}
	  	return (cookieVal);
}
function WriteCookie(name, value, expires, domain, path, secure){
//	alert("Write cookie Starts");
	var CookieVal, CookError;
	var temp;
	CookieVal=CookError="";
	if (name) {
		CookieVal=CookieVal+escape(name)+"=";
		if (value) {
			CookieVal=CookieVal+escape(value);
			if (expires)CookieVal=CookieVal+"; expires="+expires.toGMTString();
			if (domain)	CookieVal=CookieVal+"; domain="+domain;
			if (path) CookieVal=CookieVal+"; path="+path;
			if (secure) CookieVal=CookieVal+"; secure";
		} else {CookError=CookError+"Value failure";}
	} else {CookError=CookError+"Name failure";}
	if (!CookError){
		document.cookie=CookieVal;
		temp=ReadCookie(name);
		if (value!=temp) CookError="<p>Please make sure your browser can accept cookies.";
	
	}
        //The following line was added by David F. on 020320
        CookieVal=unescape(CookieVal);
	return (CookError);
	}
			
function NextTopic()
{
//   if (NextTopicVal == "")
//   {
//       alert("Next Topic button is only active\nwithin a lesson.");
//       return;
//   }
   
//   if (answeredquestion == 0)
//   {  alert("Please try the question before moving\nto the next topic.");
//      return;
//  }

//   if (timedelay == 1)
//   {
//      alert("Please listen to the audio before moving \n to the next topic.");
//      return;
//   }

   NextTopicVal=NextTopicVal.toUpperCase();
   if (NextTopicVal.substring(0, 4) == "/CGI")
   {
      self.document.gotopic.action = NextTopicVal;
      self.document.gotopic.submit();
   }
   else
   {
      top.location = NextTopicVal;
   }
}

function PreviousTopic()
{
//   if (PreviousTopicVal == "")
//   {
//      alert("Previous Topic button is only active\nwithin a lesson.");
//      return;
//   }
//   if (PreviousTopicVal == "none")
//   {
//      alert("There is no previous topic.");
//      return;
//   }   
   PreviousTopicVal = PreviousTopicVal.toUpperCase();
   if (PreviousTopicVal.substring(0, 4) == "/CGI")
   {
      self.document.gotopic.action = PreviousTopicVal;
      self.document.gotopic.submit();
   }
   else
   {
      top.location = PreviousTopicVal;
   }
}

function TopicMenu()
{

   TopicMenuVal=TopicMenuVal.toUpperCase();
   if (TopicMenuVal.substring(0, 4) == "/CGI")
   {
      self.document.gotopic.action = TopicMenuVal;
      self.document.gotopic.submit();
   }
   else
   {
      top.location = TopicMenuVal;
   }
}

