// ********************************
// Copyright © 2004 by Online-Learning.com, All Rights Reserved.
//
// All materials protected by copyright laws. Materials may not be reproduced,
// republished, distributed, or otherwise exploited in any manner without the
// express prior written permission of Online-Learning.com.
// ********************************
//
// Description: Defines the main layout of an OLL course.
// ********************************

var bannerFrameSize = "25";
var hideNarrator=true;

if ((navigator.appName == "Netscape" && parseInt (navigator.appVersion) == 4)){
   bannerFrameSize = "35"; //by testing we've determined this to be the optimal size for NS4
} 

if (self.name == 'menu') {
   // Sometimes, Netscape will try to load this index inside the menu frame.  I haven't
   // worked out why but this will detect that situation and reset the location property.
   self.location.href = "menu.html";
} else {
   // Fix for bug 339. Allow either the URL or the LMS to override the page and language
   var urlToParse = self.window.location.href;
   if (window.inSCORMMode) {
      // fix bug 770
      var lessonLocationDataElement = "cmi.location";
      if (isSCORM12()) lessonLocationDataElement = "cmi.core.lesson_location";
      var lastLocationInSCO = doGetValue(lessonLocationDataElement);
      if (lastLocationInSCO) {//has a value ?
         urlToParse = lastLocationInSCO;
      }
   }
   // last chance to flip the language - see what the URL says (ensureFraming, for example, could override)
   var languageSuffix = getParm (urlToParse, "lang", "&"); // give the URL a chance to say what language (ensureFraming)
   if (languageSuffix!="") {
      setCourseLanguage(languageSuffix);
   }

   var thePage = getParm (urlToParse, "page", "&");
   if (thePage=="") { // no page passed in, so use default
      // The first page name to load: course firstpage - is auto-gen'ed and in firstPage.js. Note that we load the correct one for the language.
      thePage = pageFromSearch(window.courseLanguages[window.courseLanguage].firstpage, theMenu, true);
   }

   // Now that the course language is defined, init Joust etc
   initialise();
   
   // target document is self
   var targetDocument = self.document;
   
   var hideOutliner = "true" == getParm (urlToParse, "hideOutliner", "&");
   
   //set the narration pane size (0 if it is being hidden)
   var narrationPaneSize = hideNarrator ? '0' : '65';
   
   // write top container of course
   targetDocument.writeln('<frameset id="rootFrameset" cols="100%" rows="35,*,' + narrationPaneSize + '" border="4" onResize="defaultResizeHandler();" onload="OLLloadPage();" onunload="OLLunloadPage();">');
   

   // course banner frame 
   targetDocument.writeln('<frame name="banner" src="' + bannerLocation() + '" scrolling="no" marginwidth="0" marginheight="0" APPLICATION="yes" noresize >');
   
   // determine if the outliner is visible or whether we are using IE
   var notHidingOutlinerOrBrowserCodeIsMSIE = !hideOutliner || parent.theBrowser.code == 'MSIE';
   
   // optional container for outliner and course page
   if (notHidingOutlinerOrBrowserCodeIsMSIE) {
      var outlinePaneSize = hideOutliner ? '0' : '200'; // when hidden the size is 0
      //For Bug Fix #142
      targetDocument.writeln('<frameset id="contentFrameset" name="contentFrameset" cols="' + outlinePaneSize + ',*" rows="100%" border="0">');
      targetDocument.writeln('<frame id="menu" name="menu" src="player_menu.html" border="0" scrolling="auto" marginwidth="1" marginheight="1" APPLICATION="yes">');
   }
   
   // course page
   targetDocument.writeln('<frame name="text" src="' + thePage + '" border="0" scroll="auto" APPLICATION="yes"/>');
   
   // close optional container, if opened
   if (notHidingOutlinerOrBrowserCodeIsMSIE) {
      targetDocument.writeln("</frameset>"); //contentFrameset
   }
   
   // narration pane
   //Fix for bug #796
   targetDocument.writeln('<frame name="narration" src="../player_html/blank.html" scroll="auto" marginwidth="0" marginheight="0" APPLICATION="yes" />');
   
   targetDocument.writeln("</frameset>"); //rootFrameset;
}

