//This variables are to be set by Designer
var LMS = false;
var XHLPLMS = false;
var displayFullScreen = true;
var HSBC = false;
var candidate = false;
var lowbandwidth = false;
var showReport = false;
var showHTMLReport = false;
var showCourseButton = true;
var showIndexButton = true;
var showNextButton = true;
var showPrevButton = true;
var contentButtonUrl = "";
var indexButtonUrl = "";
var nextButtonUrl = "";
var prevButtonUrl = "";
var contentPrompt = "";
var indexPrompt = "";
var nextPrompt = "";
var prevPrompt = "";
var reportX = 0;
var reportY = 0;
var reportW = 400;
var reportH = 500;
var allowFloatingToolbar = true;
var showSoundBar = false;
var showPageNumbers = false;
var serverURL = "";
var Unicode = false;
var unicodeFont = "";
var allowCookies = false;
var showHandOutline = true;
var showHSBorder = false;
var HSBorderColor = "FF0000";
var HSBorderWidth = 2;
var contentDeterminedStatus = false;
var passScore = 0;
var showActionPanel = false;
var isWindowMovable=true;
var mailingServerURL = "";

//This variables are NOT to be set by Designer
var postString;
var soundWindow;

function checkEnvironment() {
  if (navigator.javaEnabled() != true) {
    warningContent =
      "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 3.2//EN'>" +
      "<html>" +
      "  <head>" +
      "    <meta http-equiv='Content-Type' content='text/html; charset=windows-1252'>" +
      "    <title>" +
      "      Unable to run: Java is either not enabled or not installed" +
      "    </title>" +
      "  </head>" +
      "  <body>" +
      "    <H2>" +
      "      Unable to run" +
      "    </H2>" +
      "    Java is either not installed, or not enabled in your web-browser." +
      "    <H2>" +
      "      Resolution" +
      "    </H2>" +
      "    <ol>" +
      "      <li>" +
      "        Enable Java or," +
      "      </li>" +
      "      <li>" +
      "        <a href='http://java.sun.com/webapps/getjava/BrowserRedirect?locale=en&host=www.java.com:80'>Install</a> the latest JVM from Sun Microsystems (java.sun.com)." +
      "      </li>" +
      "    </ol>" +
      "    In case of any questions please contact your local IT resource." +
      "  </body>" +
      "</html>"
    var warningWindow = window.open('../../Lessons/blank.html');
    if (warningWindow) { 
      warningWindow.moveTo(0, 0);
      warningWindow.focus();
    }
    warningWindow.document.open();
    warningWindow.document.write(warningContent);
    warningWindow.document.close();
    return false;
  }
  if (screen.width < 800) {
    alert("Please set your screen-resolution to at least 800x600.");
    return false;
  }
  if (parseInt(navigator.appVersion.charAt(0)) < 4) {
    alert("WebTutor can only run in browsers from version 4.0 and up.");
    return false;
  }
  return true;
}

function killPlayer() {

}

function setSoundStage() {   

}

function initPlayers() {

} 

function isIE() {
  return (navigator.appName == "Microsoft Internet Explorer");
}

function setDatango(ProjectURL) {
    var ParamString = '';
    if (parent.XHLPAPI != null) { ParamString = '\&logsid=' + parent.XHLPAPI.aiccsid;}
    var datangowin = window.open(ProjectURL + ParamString, '');
}

function setLesson(lesson, sound, tracking, autoRun) {  

  TEMP = document.applets[0];

  if (TEMP != null) {
    TEMP.stop();
  }

  if (checkEnvironment()) {

    var newWindow;
    var browserName = navigator.appName; 
    var browserVersion = navigator.appVersion;

    function getCookie(name) {
      if (allowCookies) {
        var dc = document.cookie;
        var prefix = name + '=';
        var begin = dc.indexOf('; ' + prefix);
        if (begin == -1) {
          begin = dc.indexOf(prefix);
          if (begin != 0) {
            return null;
          }
        }
        else {
          begin += 2;
        }  
        var end = document.cookie.indexOf(';', begin);
        if (end == -1) {
          end = dc.length;
        } 
        return unescape(dc.substring(begin + prefix.length, end));
      }
      else {
        return"";
      }
    }

    function enlight_popup(url,windowname,width,height,x,y) {
      width = (width)?width:screen.width/3;
      height = (height)?height:screen.height/3;
      if ((x == 0) && (y == 0)) {
        var screenX = (screen.width/2 - width/2);
        var screenY = (screen.height/2 - height/2);
      }
      else {
        var screenX = x;
        var screenY = y;
      }
      var features = "width=" + width + ",height=" + height;
      features += ",screenX=" + screenX + ",left=" + screenX;
      features += ",screenY=" + screenY  +",top=" + screenY;
      var mywin = window.open(url, windowname, features);
      if (mywin) { 
        mywin.moveTo(screenX, screenY);
        mywin.focus();
      }
      return mywin;
    }

    ArchiveFiles = " archive='AppletPlayer.jar, xhlp_jogg.jar, xhlp_jorbis.jar, xhlp_media.jar'";
    newContent = 
    " <body onFocus='window.blur();' onunload='appletDone();'>" +
    " <iframe name='dummy' style='DISPLAY: none' src='../../Lessons/blank.html'></iframe>" +
    " <form method='POST' name='SAPI' target='dummy' action='" + serverURL + "'>" +
    "   <input type='hidden' name='Status'>" +
    "   <input type='hidden' name='ID'>" +
    " </form>" +
    " <form method='POST' name='QUIZMAILER' target='dummy' action='" + mailingServerURL + "'>" +
    "   <input type='hidden' name='UserName'>" +
    "   <input type='hidden' name='Department'>" +
    "   <input type='hidden' name='Content'>" +
    " </form>" +
    " <p><b><FONT color='#22517D'>Loading, please wait...</FONT></b></p>" +
    " <p><img src='../../Lessons/Progress.gif' align='middle'></p>" +
    " <applet code='AppletPlayer'" + ArchiveFiles + "align='top' width='1' height='1' name='AppletPlayer' MAYSCRIPT codebase='../../Lessons/'>" +
    "   <param name='lessonjar' value='" + lesson + "/" + lesson + ".jar'>" + 
    "   <param name='tutorNo' value='" + lesson + "'>" +
    "   <param name='audio' value='" + sound + "'>" + 
    "   <param name='autoRun' value='" + autoRun + "'>" +
    "   <param name='XHLPLMS' value='" + XHLPLMS + "'>" +
    "   <param name='LMS' value='" + LMS + "'>" +
    "   <param name='showCourseButton' value='" + showCourseButton+ "'>" +
    "   <param name='showIndexButton' value='" + showIndexButton + "'>" +
    "   <param name='showNextButton' value='" + showNextButton + "'>" +
    "   <param name='showPrevButton' value='" + showPrevButton + "'>" +
    "   <param name='contentButtonUrl' value='" + contentButtonUrl + "'>" +
    "   <param name='indexButtonUrl' value='" + indexButtonUrl + "'>" +
    "   <param name='nextButtonUrl' value='" + nextButtonUrl + "'>" +
    "   <param name='prevButtonUrl' value='" + prevButtonUrl + "'>" +
    "   <param name='contentPrompt' value='" + contentPrompt + "'>" +
    "   <param name='indexPrompt' value='" + indexPrompt + "'>" +
    "   <param name='nextPrompt' value='" + nextPrompt + "'>" +
    "   <param name='prevPrompt' value='" + prevPrompt + "'>" +
    "   <param name='displayFullScreen' value='" + displayFullScreen + "'>" +
    "   <param name='reportX' value='" + reportX + "'>" +
    "   <param name='reportY' value='" + reportY + "'>" +
    "   <param name='reportW' value='" + reportW + "'>" +
    "   <param name='reportH' value='" + reportH + "'>" +
    "   <param name='showReport' value='" + showReport + "'>" +
    "   <param name='showHTMLReport' value='" + showHTMLReport + "'>" +
    "   <param name='showSoundBar' value='" + showSoundBar  + "'>" +
    "   <param name='showPageNumbers' value='" + showPageNumbers + "'>" +
    "   <param name='allowFloatingToolbar' value='" + allowFloatingToolbar + "'>" +
    "   <param name='serverURL' value='" + serverURL + "'>" +
    "   <param name='mailingServerURL' value='" + mailingServerURL + "'>" +
    "   <param name='Unicode' value='" + Unicode + "'>" +
    "   <param name='unicodeFont' value='" + unicodeFont + "'>" +
    "   <param name='allowCookies' value='" + allowCookies + "'>" +
    "   <param name='posx' value='" + getCookie('posx') + "'>" +
    "   <param name='posy' value='" + getCookie('posy') + "'>" +
    "   <param name='muted' value='" + getCookie('muted') + "'>" +
    "   <param name='toolBarX' value='" + getCookie('toolBarX') + "'>" +
    "   <param name='toolBarY' value='" + getCookie('toolBarY') + "'>" +
    "   <param name='soundBarX' value='" + getCookie('soundBarX') + "'>" +
    "   <param name='soundBarY' value='" + getCookie('soundBarY') + "'>" +
    "   <param name='showHandOutline' value='" + showHandOutline + "'>" +
    "   <param name='showActionPanel' value='" + showActionPanel + "'>" +
    "   <param name='showHSBorder' value='" + showHSBorder + "'>" +
    "   <param name='HSBorderColor' value='" + HSBorderColor + "'>" +
    "   <param name='HSBorderWidth' value='" + HSBorderWidth + "'>" +
    "   <param name='isWindowMovable' value='" + isWindowMovable + "'>" +
    "   <param name='MP3Enabled' value='false'>" +
    " </applet>" +
    " <script language=JavaScript>" +
    "   var LMS = " + LMS +";" +
    "   var XHLPLMS = " + XHLPLMS +";" +
    "   var URL = document.location;" +
    "   var serverURL = '" + serverURL + "';" +
    "   var allowCookies = '" + allowCookies + "';" +
    "   var tracking = '" + tracking + "';" +
    "   var myWind;" +
    "   var today = new Date();" +
    "   var expiry = new Date(today.getTime() + 1000 * 24 * 60 * 60 * 1000);" +
    "   var score_reported = false;" +
    "   var tempScore = 0;" +
    "   var passScore = 0;" +
    "   function toHex(str) {" +
    "       var r='';" +
    "       var e=str.length;" +
    "       var c=0;" +
    "       var h;" +
    "       while(c<e){" +
    "           h=str.charCodeAt(c++).toString(16);" +
    "           r+=h;" +
    "       }" +
    "    return r;" +
    "   }" +
    "   function showReport(txt) {" +
    "     txt = toHex(txt);" +    
    "       myWind = window.open('../../Lessons/reporthost.html','Report','toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, screenX=0, screenY=0, top=0, left=0, scrollbars=yes, Height=" + reportH + ",width=" + reportW + "');" +
    "       myWind.focus();" +
    "     while(myWind.document.getElementById('state').innerHTML != 'ready') {" +
    "     }" +
    "     myWind.document.getElementById('newsource').innerHTML = txt;" +
    "   }" +
    "   function closeLesson() {" +
    "     appletDone();" +
    "   }" +
    "   function showScreenResError() {" +
    "     appletDone();" +
    "     alert('Your resolution is lower than lesson images. Increase it to see the entire image.');" +
    "   }" +
    "   function showVersionError() {" +
    "     appletDone();" +
    "     alert('WebTutor requires at least version 1.1.4 of the Microsoft (R) VM for Java. Please upgrade the VM.');" +
    "   }" +
    "   function sendSurveyData() {" +
    "     document.SAPI.Status.value = document.AppletPlayer.getStatus();" +
    "     document.SAPI.ID.value = document.AppletPlayer.getID();" +
    "     document.SAPI.submit();" +
    "   }" + 
    "   function sendQuizData() {" +
    "     document.QUIZMAILER.Content.value = document.AppletPlayer.getMailContent();" +
    "     document.QUIZMAILER.UserName.value = prompt('Please Enter Your Name:', '');" +
    "     document.QUIZMAILER.Department.value = prompt('Please Enter Your Department:', '');" + 
    "     document.QUIZMAILER.submit();" +
    "   }";
    if (contentDeterminedStatus) {
      newContent = newContent +
      "   function sendScoreToLMS(ret) {" +
      "     if (tracking == 'true') { " +
      "       if (!score_reported) {" +
      "         score_reported = true;" +
      "         opener.parent.XHLPAPI.setCoreTime();" +
      "         var minScore = opener.parent.XHLPAPI.LMSGetValue('cmi.student_data.mastery_score');" +
      "         var tempScore = 0;" +
      "         if (ret.substring(0,1) == '%') {" +
      "           if (isIE()) {" +
      "             tempScore = ret.substring(1, ret.length);" +
      "           }" +
      "           else { " +
      "             tempScore = opener.parent.XHLPAPI.convString(ret);" +
      "           }" +
      "         }" +
      "         if (tempScore >= minScore) {" +
      "           opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'passed');" +
      "         }" +
      "         else {" +
      "           opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'failed');" +
      "         }" +
      "       }" +
      "       opener.parent.XHLPAPI.LMSSetValue('cmi.core.score.raw', ret);" +
      "       opener.parent.XHLPAPI.LMSCommit('');" +
      "     }" + 
      "   }" + 
      "   function LMSCloseUnfinishedLesson() {" +
      "     if (tracking == 'true') {" +
      "       opener.parent.XHLPAPI.setCoreTime();" +  
      "       opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'incomplete');" +
      "       opener.parent.XHLPAPI.LMSCommit('');" + 
      "     }" +  
      "     appletDone();" +
      "   }" +
      "   function LMSCloseLesson() {" +
      "     if (tracking == 'true') {" +
      "       opener.parent.XHLPAPI.setCoreTime();" +  
      "       opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'completed');" +
      "       opener.parent.XHLPAPI.LMSCommit('');" + 
      "     }" +  
      "     appletDone();" +
      "   }";
    }
    else {
      newContent = newContent +
      "   function sendScoreToLMS(ret) {" +
      "     if (tracking == 'true') { " +
      "       if (!score_reported) {" +
      "         score_reported = true;" +
      "         if (ret.substring(0,1) == '%') {" +
      "           if (isIE()) {" +
      "             tempScore = ret.substring(1, ret.length);" +
      "           }" +
      "           else { " +
      "             tempScore = opener.parent.XHLPAPI.convString(ret);" +
      "           }" +
      "           var tempScore1 = parseInt(tempScore);" +
      "         }" +
      "         if (tempScore1 >= passScore) {" +
      "           opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'completed');" +
      "         }" +
      "         else {" +
      "           opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'incomplete');" +
      "         }" +
      "       }" +
      "       opener.parent.XHLPAPI.LMSSetValue('cmi.core.score.raw', ret);" +
      "       opener.parent.XHLPAPI.LMSCommit('');" +
      "     }" + 
      "   }" + 
      "   function sendPassScoreToLMS(ret) {" +
      "     if (ret.substring(0,1) == '%') {" +
      "       if (isIE()) {" +
      "         tempScore = ret.substring(1, ret.length);" +
      "       }" +
      "       else { " +
      "         tempScore = opener.parent.XHLPAPI.convString(ret);" +
      "       }" +
      "     }" + 
      "     passScore = parseInt(tempScore);" +
      "   }" + 
      "   function LMSCloseUnfinishedLesson() {" +
      "     if (tracking == 'true') {" +
      "       opener.parent.XHLPAPI.setCoreTime();" +  
      "       opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'incomplete');" +
      "       opener.parent.XHLPAPI.LMSCommit('');" + 
      "     }" +  
      "     appletDone();" +
      "   }" +
      "   function LMSCloseLesson() {" +
      "     if (tracking == 'true') {" +
      "       opener.parent.XHLPAPI.setCoreTime();" +  
      "       opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'completed');" +
      "       opener.parent.XHLPAPI.LMSCommit('');" + 
      "     }" +  
      "     appletDone();" +
      "   }"
    }
    newContent = newContent +
    "   function setATValue(ret) {" +
    "     var result; "+
    "     result = opener.parent.XHLPAPI.LMSSetXHLPValue(ret);" +
    "     if (result != 'true') { " +
    "       opener.parent.XHLPAPI.relogin();" +
    "       appletDone();" +   
    "     }" + 
    "   }" +
    "   function setCookie(name, value, expires, path, domain, secure) {" +
    "     if (allowCookies) {" +
    "       var curCookie = name + '=' + escape(value) +" +
    "         ((expires) ? '; expires=' + expires.toGMTString() : '') +" +
    "         ((path) ? '; path=' + path : '') +" +
    "         ((domain) ? '; domain=' + domain : '') +" +
    "         ((secure) ? '; secure' : '');" +
    "       document.cookie = curCookie;" +
    "      }" +
    "   }" +
    "   function isIE() {" +
    "     return (navigator.appName == 'Microsoft Internet Explorer');" +
    "   }" +
    "   function setC(name, value) {" +
    "     setCookie(name, value, expiry, '/');" +
    "   }";
    if ((browserName == 'Netscape') && (browserVersion.substring(0,3) != '5.0')) {
      newContent = newContent +
      "   function appletDone() {" +
      "     setTimeout('document.location = URL',100);" +
      "   }";       
    }
    else {
      newContent = newContent +
      "   function appletDone() {" +
      "     close();" +
      "   }"; 
    }
    newContent = newContent +  
    " </script>" +
    " </body> "
    if ((browserName == 'Netscape') && (browserVersion.substring(0,3) != '5.0')) {
      document.write(newContent);
      document.close();
    }
    else {
      newWindow = enlight_popup('../../Lessons/blank.html',newWindow,200,200,0,0);
      newWindow.document.open();
      newWindow.document.write(newContent);
      newWindow.document.close();
      newWindow.blur();
    }
  }
}


function setQuiz(lesson, inWindow, tracking) {  

  TEMP = document.applets[0];

  if (TEMP != null) {
    TEMP.stop();
  }

  if (checkEnvironment()) {

    var newWindow;
    var browserName = navigator.appName; 
    var browserVersion = navigator.appVersion;

    function getCookie(name) {
      if (allowCookies) {
        var dc = document.cookie;
        var prefix = name + '=';
        var begin = dc.indexOf('; ' + prefix);
        if (begin == -1) {
          begin = dc.indexOf(prefix);
          if (begin != 0) {
            return null;
          }
        }
        else {
          begin += 2;
        }  
        var end = document.cookie.indexOf(';', begin);
        if (end == -1) {
          end = dc.length;
        } 
        return unescape(dc.substring(begin + prefix.length, end));
      }
      else {
        return"";
      }
    }

    function enlight_popup(url,windowname,width,height,x,y) {
      width = (width)?width:screen.width/3;
      height = (height)?height:screen.height/3;
      if ((x == 0) && (y == 0)) {
        var screenX = (screen.width/2 - width/2);
        var screenY = (screen.height/2 - height/2);
      }
      else {
        var screenX = x;
        var screenY = y;
      }
      var features = "width=" + width + ",height=" + height;
      features += ",screenX=" + screenX + ",left=" + screenX;
      features += ",screenY=" + screenY  +",top=" + screenY;
      var mywin = window.open(url, windowname, features);
      if (mywin) { 
        mywin.moveTo(screenX, screenY);
        mywin.focus();
      }
      return mywin;
    }

    ArchiveFiles = " archive='AppletPlayer.jar, xhlp_jogg.jar, xhlp_jorbis.jar, xhlp_media.jar'";
    newContent = 
    " <body onFocus='window.blur();' onunload='appletDone();'>" +
    " <iframe name='dummy' style='DISPLAY: none'></iframe>" +
    " <form method='POST' name='SAPI' target='dummy' action='" + serverURL + "'>" +
    "   <input type='hidden' name='Status'>" +
    "   <input type='hidden' name='ID'>" +
    " </form>" +
    " <form method='POST' name='QUIZMAILER' target='dummy' action='" + mailingServerURL + "'>" +
    "   <input type='hidden' name='UserName'>" +
    "   <input type='hidden' name='Department'>" +
    "   <input type='hidden' name='Content'>" +
    " </form>" +
    " <p><b><FONT color='#22517D'>Loading, please wait...</FONT></b></p>" +
    " <p><img src='../../Lessons/Progress.gif' align='middle'></p>" +
    " <applet code='QuizPlayer'" + ArchiveFiles + "align='top' width='1' height='1' name='QuizPlayer' MAYSCRIPT codebase='../../Lessons/'>" +
    "   <param name='lessonjar' value='" + lesson + "/" + lesson + ".jar'>" + 
    "   <param name='tutorNo' value='" + lesson + "'>" +
    "   <param name='XHLPLMS' value='" + XHLPLMS + "'>" +
    "   <param name='LMS' value='" + LMS + "'>" +
    "   <param name='displayFullScreen' value='" + inWindow+ "'>" +
    "   <param name='Unicode' value='" + Unicode + "'>" +
    "   <param name='unicodeFont' value='" + unicodeFont + "'>" +
    "   <param name='appletWidth' value='840'>" + 
    "   <param name='appletHeight' value='550'>" +
    "   <param name='serverURL' value='" + serverURL + "'>" +
    "   <param name='mailingServerURL' value='" + mailingServerURL + "'>" +
    "   <param name='allowCookies' value='" + allowCookies + "'>" +
    "   <param name='muted' value='" + getCookie('muted') + "'>" +
    "   <param name='posx' value='" + getCookie('posx') + "'>" +
    "   <param name='posy' value='" + getCookie('posy') + "'>" +
    " </applet>" +
    " <script language=JavaScript>" +
    "   var LMS = " + LMS +";" +
    "   var XHLPLMS = " + XHLPLMS +";" +
    "   var serverURL = '" + serverURL + "';" +
    "   var allowCookies = '" + allowCookies + "';" +
    "   var tracking = '" + tracking + "';" +
    "   var myWind;" +
    "   var today = new Date();" +
    "   var expiry = new Date(today.getTime() + 1000 * 24 * 60 * 60 * 1000);" +
    "   var score_reported = false;" +
    "   var tempScore = 0;" +
    "   var passScore = 0;" +
    "   var browserWindow;" +
    "   function closeLesson() {" +
    "     appletDone();" +
    "   }" +
    "   function showScreenResError() {" +
    "     appletDone();" +
    "     alert('Your resolution is lower than lesson images. Increase it to see the entire image.');" +
    "   }" +
    "   function showVersionError() {" +
    "     appletDone();" +
    "     alert('WebTutor requires at least version 1.1.4 of the Microsoft (R) VM for Java. Please upgrade the VM.');" +
    "   }" +
    "   function toHex(str) {" +
    "       var r='';" +
    "       var e=str.length;" +
    "       var c=0;" +
    "       var h;" +
    "       while(c<e){" +
    "           h=str.charCodeAt(c++).toString(16);" +
    "           r+=h;" +
    "       }" +
    "    return r;" +
    "   }" +
    "   function showReport(txt) {" +
    "     txt = toHex(txt);" +
    "     mylWind = window.open('../../Lessons/reporthost.html','Report','toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, screenX=0, screenY=0, top=0, left=0, scrollbars=yes, Height=" + reportH + ",width=" + reportW + "');" +
    "     mylWind.focus();" +
    "     while(mylWind.document.getElementById('state').innerHTML != 'ready') {" +
    "     }" +
    "     mylWind.document.getElementById('newsource').innerHTML = txt;" +
    "   }" +
    "   function sendSurveyData() {" +
    "     document.SAPI.Status.value = document.QuizPlayer.getStatus();" +
    "     document.SAPI.ID.value = document.QuizPlayer.getID();" +
    "     document.SAPI.submit();" +
    "   }" +
    "   function sendQuizData() {" +
    "     document.QUIZMAILER.Content.value = document.AppletPlayer.getMailContent();" +
    "     document.QUIZMAILER.UserName.value = prompt('Please Enter Your Name:', '');" +
    "     document.QUIZMAILER.Department.value = prompt('Please Enter Your Department:', '');" + 
    "     document.QUIZMAILER.submit();" +
    "   }";
    if (contentDeterminedStatus) {
      newContent = newContent +
      "   function sendScoreToLMS(ret) {" +
      "     if (tracking == 'true') { " +
      "       if (!score_reported) {" +
      "         score_reported = true;" +
      "         var tempScore = 0;" +        
      "         opener.parent.XHLPAPI.setCoreTime();" +
      "         var minScore = opener.parent.XHLPAPI.LMSGetValue('cmi.student_data.mastery_score');" +
      "         tempScore = ret.substring(0, ret.length);" +  
      "         var tempScore1 = parseInt(tempScore);" +      
      "         if (tempScore1 >= minScore) {" + 
      "           opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'passed');" +
      "         }" +
      "         else {" +
      "           opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'failed');" +
      "         }" +
      "       }" +
      "       opener.parent.XHLPAPI.LMSSetValue('cmi.core.score.raw', ret);" +
      "       opener.parent.XHLPAPI.LMSCommit('');" +
      "     }" + 
      "   }" + 
      "   function LMSCloseUnfinishedLesson() {" +
      "     if (tracking == 'true') {" +
      "       opener.parent.XHLPAPI.setCoreTime();" +  
      "       opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'incomplete');" +
      "       opener.parent.XHLPAPI.LMSCommit('');" + 
      "     }" +  
      "     appletDone();" +
      "   }" +
      "   function LMSCloseLesson() {" +
      "     if (tracking == 'true') {" +
      "       opener.parent.XHLPAPI.setCoreTime();" +  
      "       opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'completed');" +
      "       opener.parent.XHLPAPI.LMSCommit('');" + 
      "     }" +  
      "     appletDone();" +
      "   }";
    }
    else {
      newContent = newContent +
      "   function sendScoreToLMS(ret) {" +
      "     if (tracking == 'true') { " +
      "       if (!score_reported) {" +
      "         score_reported = true;" +
      "         if (ret.substring(0,1) == '%') {" +
      "           if (isIE()) {" +
      "             tempScore = ret.substring(1, ret.length);" +
      "           }" +
      "           else { " +
      "             tempScore = opener.parent.XHLPAPI.convString(ret);" +
      "           }" +
      "           var tempScore1 = parseInt(tempScore);" +
      "         }" +
      "         if (tempScore1 >= passScore) {" +
      "           opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'completed');" +
      "         }" +
      "         else {" +
      "           opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'incomplete');" +
      "         }" +
      "       }" +
      "       opener.parent.XHLPAPI.LMSSetValue('cmi.core.score.raw', ret);" +
      "       opener.parent.XHLPAPI.LMSCommit('');" +
      "     }" + 
      "   }" + 
      "   function sendPassScoreToLMS(ret) {" +
      "     if (ret.substring(0,1) == '%') {" +
      "       if (isIE()) {" +
      "         tempScore = ret.substring(1, ret.length);" +
      "       }" +
      "       else { " +
      "         tempScore = opener.parent.XHLPAPI.convString(ret);" +
      "       }" +
      "     }" + 
      "     passScore = parseInt(tempScore);" +
      "   }" + 
      "   function closeBrowser() {" +
      "     if (browserWindow != null) {" +
      "       browserWindow.close();" +
      "     }" +
      "   }" +
      "   function showBrowser(temp){" +
      "     var address=temp.substring(0,temp.indexOf(','));" +
      "     var features=temp.substring(temp.indexOf(','));" +
      "     browserWindow = window.open(address, '', features);" +
      "   }" +
      "   function LMSCloseUnfinishedLesson() {" +
      "     if (tracking == 'true') {" +
      "       opener.parent.XHLPAPI.setCoreTime();" +  
      "       opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'incomplete');" +
      "       opener.parent.XHLPAPI.LMSCommit('');" +       
      "     }" +  
      "     appletDone();" +
      "   }" +
      "   function LMSCloseLesson() {" +
      "     if (tracking == 'true') {" +
      "       opener.parent.XHLPAPI.setCoreTime();" +  
      "       opener.parent.XHLPAPI.LMSSetValue('cmi.core.lesson_status', 'completed');" +
      "       opener.parent.XHLPAPI.LMSCommit('');" +
      "     }" +  
      "     appletDone();" +
      "   }"
    }
    newContent = newContent +
    "   function setATValue(ret) {" +
    "     var result; "+
    "     result = opener.parent.XHLPAPI.LMSSetXHLPValue(ret);" +
    "     if (result != 'true') { " +
    "       opener.parent.XHLPAPI.relogin();" +
    "       appletDone();" +   
    "     }" + 
    "   }" +
    "   function setCookie(name, value, expires, path, domain, secure) {" +
    "     if (allowCookies) {" +
    "       var curCookie = name + '=' + escape(value) +" +
    "         ((expires) ? '; expires=' + expires.toGMTString() : '') +" +
    "         ((path) ? '; path=' + path : '') +" +
    "         ((domain) ? '; domain=' + domain : '') +" +
    "         ((secure) ? '; secure' : '');" +
    "       document.cookie = curCookie;" +
    "      }" +
    "   }" +
    "   function isIE() {" +
    "     return (navigator.appName == 'Microsoft Internet Explorer');" +
    "   }" +
    "   function setC(name, value) {" +
    "     setCookie(name, value, expiry, '/');" +
    "   }";
    if ((browserName == 'Netscape') && (browserVersion.substring(0,3) != '5.0')) {
      newContent = newContent +
      "   function appletDone() {" +
      "     setTimeout('document.location = URL',100);" +
      "   }";       
    }   
    else {
      newContent = newContent +
      "   function appletDone() {" +
      "     close();" +
      "   }"; 
    }
    newContent = newContent +  
    " </script>" +
    " </body> "
    if ((browserName == 'Netscape') && (browserVersion.substring(0,3) != '5.0')) {
      document.write(newContent);
      document.close();
    }
    else {
      newWindow = enlight_popup('../../Lessons/blank.html',newWindow,200,200,0,0);
      newWindow.document.open();
      newWindow.document.write(newContent);
      newWindow.document.close();
      newWindow.blur();     
    }
  }
}

//************************************************************************
//***                     LearningSpace Specific                       ***
//************************************************************************

function prevAU() {
  parent.XHLPAPI.prevAU();
}

function nextAU() {
  parent.XHLPAPI.nextAU();
}  



//************************************************************************
//***                        xhlpsrv Specific                          ***
//************************************************************************

function SetPage(action,comments,url) {
  var result;
  postString=
    "Series" + "LINEBRK" + document.forms[0].Series.value + "LINEBRK" + 
    "Course" + "LINEBRK" + document.forms[0].Course.value + "LINEBRK" +
    "Module" + "LINEBRK" + document.forms[0].Module.value + "LINEBRK" +
    "Lesson" + "LINEBRK" + document.forms[0].Lesson.value + "LINEBRK" +
    "Page" + "LINEBRK" + document.forms[0].Page.value + "LINEBRK" +
    "PageName" + "LINEBRK" + document.forms[0].PageName.value + "LINEBRK" +
    "Action" + "LINEBRK" + action + "LINEBRK" +
    "Comments" + "LINEBRK" + comments + "LINEBRK" +
    "MaxPage" + "LINEBRK" + document.forms[0].MaxPage.value + "LINEBRK" +
    "LessonType" + "LINEBRK" + document.forms[0].LessonType.value + "LINEBRK";
  result = parent.XHLPAPI.LMSSetXHLPValue(postString);
  if (result == "true") {
    if (url != 0) {
      document.location = url;
    }
  }
  else {
    parent.XHLPAPI.relogin();
  } 
}

function SetQuizPage(action,comments,url) {
  var result = false;
  result = QuizPlayer.okToProgress();
  if (result.toString() == "true") {
    SetPage(action,comments,url);
  }
}


function setTest(tid) {
  if (checkEnvironment()) {
    var newWindow;
    var browserName = navigator.appName;
    var browserVersion = navigator.appVersion;
    function enlight_popup(url,windowname,width,height,x,y) {
      width = (width)?width:screen.width/3;
      height = (height)?height:screen.height/3;
      if ((x == 0) && (y == 0)) {
        var screenX = (screen.width/2 - width/2);
        var screenY = (screen.height/2 - height/2);
      }
      else {
        var screenX = x;
        var screenY = y;
      }
      var features = "width=" + width + ",height=" + height;
      features += ",screenX=" + screenX + ",left=" + screenX;
      features += ",screenY=" + screenY  +",top=" + screenY;
      var mywin = window.open(url, windowname, features);
      if (mywin) {
         mywin.moveTo(screenX, screenY);
        mywin.focus();
      }
      return mywin;
    }
    newContent =
    "<html>" +
    "<meta HTTP-EQUIV='REFRESH' content='0; url=" + parent.XHLPAPI.aiccurl + "\?test_id=" + tid + "\&Session_id=" + parent.XHLPAPI.aiccsid + "\&Command=STARTTEST'>" +    
    " <p><b><FONT color='#22517D'>Loading, please wait...</FONT></b></p>" +
    " <p><img src='../../Lessons/Progress.gif' align='middle'></p>" +    
    " </body> " +
    "</html>" 
    if ((browserName == 'Netscape') && (browserVersion.substring(0,3) != '5.0')) {
      document.write(newContent);
      document.close();
    }
    else {
      newWindow = enlight_popup('../../Lessons/blank.html',newWindow,800,600,0,0);
      newWindow.document.open();
      newWindow.document.write(newContent);
      newWindow.document.close();
    }
  }
}

function showBookmarks() {
  if (checkEnvironment()) {
    var newWindow;
    var browserName = navigator.appName;
    var browserVersion = navigator.appVersion;
    function enlight_popup(url,windowname,width,height,x,y) {
      width = (width)?width:screen.width/3;
      height = (height)?height:screen.height/3;
      if ((x == 0) && (y == 0)) {
        var screenX = (screen.width/2 - width/2);
        var screenY = (screen.height/2 - height/2);
      }
      else {
        var screenX = x;
        var screenY = y;
      }
      var features = "width=" + width + ",height=" + height;
      features += ",screenX=" + screenX + ",left=" + screenX;
      features += ",screenY=" + screenY  +",top=" + screenY;
      features += ", scrollbars=yes";
      var mywin = window.open(url, windowname, features);
      if (mywin) {
        mywin.moveTo(screenX, screenY);
        mywin.focus();
      }
      return mywin;
    }
    newContent =
    "<html>" +
    "<meta HTTP-EQUIV='REFRESH' content='0; url=" + parent.XHLPAPI.aiccurl + 
    "\?Session_id=" + parent.XHLPAPI.aiccsid + "\&page=" + document.forms[0].Page.value + 
    "\&coursename=" + document.forms[0].Course.value + "\&pagename=" + document.forms[0].PageName.value + 
    "\&Command=SHOWBOOKMARKS'>" +       
    " <p><b><FONT color='#22517D'>Loading, please wait...</FONT></b></p>" +
    " <p><img src='../../Lessons/Progress.gif' align='middle'></p>" +    
    " </body> " +
    "</html>" 
    if ((browserName == 'Netscape') && (browserVersion.substring(0,3) != '5.0')) {
      document.write(newContent);
      document.close();
    }
    else {
      newWindow = enlight_popup('../../Lessons/blank.html',newWindow,500,600,0,0);
      newWindow.document.open();
      newWindow.document.write(newContent);
      newWindow.document.close();
    }
  }
}

