function GetBookmark (CourseCode) 
{
	var CookieVal; 
      var slashpos;    
	CookieVal=ReadCookie("BM"+CourseCode);     
	if (!CookieVal) {         
		ResultWin=window.open("", "Bookmark", "menubar=no,resizable=no,scrollbars=no,width=250,height=100");         
		ResultWin=ResultWin.document;         
		ResultWin.write ('<body bgcolor="white" onload="self.focus();">');         
		ResultWin.write ('<center><font face="arial"><b>');         
		ResultWin.write ("<br>Bookmark not found.</b></font></center>");         
		ResultWin.close();     
	} else {  
		slashpos = CookieVal.indexOf("/");
		// Note that the following correction is to remove the lesson folder name
		// which is stored as part of the cookie.  This isn't done at the course
 		// level.  Commented out 8/24/00
            //if (slashpos > -1){
			//CookieVal = CookieVal.substring(slashpos + 1);
		//}
		parent.course.location=CookieVal;
		parent.navigator.location=CookieVal.substring(0, CookieVal.indexOf("content"))+"nv.htm";     
	}    
}

function ReadCookie(name){
	var allCookie, CookieVal, length, start, end;
	cookieVal="";
	name=name+"=";
	allCookie=document.cookie;
	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){
	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.";
	
	}
	return (CookError);
}
			
function SetBookmark (URL, CourseCode) {
	var ErrorCode;	
	Expiration = new Date ()
	Expiration.setTime(Expiration.getTime()+ 19440000000);
	ErrorCode=WriteCookie ("BM"+CourseCode, URL, Expiration, "","/");
 	ResultWin=window.open("", "Bookmark", "menubar=no,resizable=no,scrollbars=no,width=250,height=100");
	ResultWin=ResultWin.document;
	ResultWin.write ('<body bgcolor="white" onload="self.focus();">');
	ResultWin.write ('<center><font face="arial"><b>');
	if (ErrorCode) {
		ResultWin.write ('Could not set bookmark.</b>'+ErrorCode+'');
	} else {
		ResultWin.write ('<br>Bookmark set.</b>');
	}		
	ResultWin.write ('</font></center>');
	ResultWin.close();
}		
function QuestionFeedback() {
  var WindowQuestion=window.open("../AnswerWait.htm", "Answer_Feedback", "resizable=yes,scrollbars=yes,width=400,height=350")
}
function Assessment() {
  var WindowAssessment=window.open("../AssessmentWait.htm", "AssessmentWindow", "menubar=yes,resizable=yes,scrollbars=yes,width=550,height=400")
}
function NamedDetailWindow(filename, w, h,name) {
  var WindowDetail=window.open(filename, name, "menubar=yes,resizable=yes,scrollbars=yes,width="+w+",height="+h)
}
function DetailWindow(filename, w, h) {
  var WindowDetail=window.open(filename, "DetailWindow", "menubar=yes,resizable=yes,scrollbars=yes,width="+w+",height="+h)
}
function DetailWindowWithMenu(filename, w, h) {
  var DetailWindowWithMenu=window.open(filename, "DetailWindowWithMenu", "menubar=yes,resizable=yes,scrollbars=yes,width="+w+",height="+h)
}
function AddSpaceInIEOnly()
{
   IElen = "Microsoft Internet Explorer".length;
   Applen = navigator.appName.length;
   if (IElen == Applen)
   {  document.write("<pre>  </pre>");      }
}
function WScreate(filename, w, h, QID){
   var WSwindow=window.open(filename, "WSwindow", "menubar=yes,resizable=yes,scrollbars=yes,width="+w+",height="+h);
}

// Variables and functions used by exhibit questions
var childflag = 0;
var questionid = "none";
var childwin = null;
var browser = "";

if (navigator.appName == "Netscape")
   {browser = "NN";} 
else 
   {browser = "IE";}

function setChildFlag(val){
   childflag = val;
}
function ExhibitWindow(qid, w, h) {
   if (childflag == 0){
      childwin=window.open("/cgi-win/auth/$exhibit.dll/" + qid, "ExhibitWindowName","menubar=yes,resizable=no,scrollbars=yes,width="+w+",height="+h);
      questionid = qid;
   }
   else {
      if (qid == questionid && browser=="NN") {
         childwin.closer.toTop();
      }
      else {
         childwin=window.open("/cgi-win/auth/$exhibit.dll/" + qid, "ExhibitWindowName","menubar=yes,resizable=no,scrollbars=yes,width="+w+",height="+h);
         questionid = qid;
      }
   }
}

function AnimationWindow(filename, w, h) {
  window.open(filename, "DetailWindow", "menubar=no,resizable=yes,scrollbars=yes,width="+w+",height="+h)
}

function PopUpWindow(filename, windowname, w, h) {
  window.open(filename, windowname, "menubar=no,resizable=yes,scrollbars=yes,width="+w+",height="+h)
}

function AudioPlay(clip){
  var i;
  var s1;
  var s2;
  i = clip.indexOf('.');
  s1 = clip.substring(0, i);
  s2 = s1 + ".HTM";
  parent.audio.location = s2;
}

function AudioInit(){
  with(parent.audio.document){
  write("<html>\n\r");
  write("<body>\n\r");
  write("</body>\n\r");
  write("</html>\n\r");
  close();
  }
}

function SelectResp(qid, choice, alt){
  QuestionFeedback();
  var obj;
  obj = eval("document." + qid + "form");
  obj.elements[0].value = choice;
  obj.elements[1].value = alt;
  obj.submit();
}
