function Init()
{
	ResizeWindow(); // used for homework pages
}
function LaunchReference()
{
	window.open('reference_downloadsAndLinks.htm','support','directories=0,location=0,menubar=0,resizable=1,scrollbars=1,status=1,toolbar=0');
}
function LaunchSupport()
{
	window.open('support.htm','support','directories=0,location=0,menubar=0,resizable=1,scrollbars=1,status=1,toolbar=0,height=480,width=640');
}
function PostAction(strAction, strP1, strP2)
{
  if(strAction=="menu"){ 
    window.location.href="courseMenu.htm";
  }else if(strAction=="qresponse"){
    GradeQuestion(strP1,strP2);
  }else if(strAction=="previous"){
    PreviousClicked();
  }else if(strAction=="next"){
    NextClicked();
  }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function GradeQuestion(iNum,bCorrect){
  if(bCorrect==true){
    GotoCorrectResponse();
  }else{
    GotoIncorrectResponse();
  }
}

/*--------------------------------------------------------------------------------------------------------------------*/
function PreviousClicked(){
    if(GetPageNumber()>1){
      window.location.href=GetChapterAndLesson() + "P" + Format(GetPageNumber()-1) + ".htm";
    }else{
      GotoLessonMenu();
    }
}
function NextClicked(){
    if(GetLessonNumber()==1){
      if(GetPageNumber()<3){
        window.location.href=GetChapterAndLesson() + "P" + Format(GetPageNumber()+1) + ".htm";
      }else{
        GotoLessonMenu();
      }
    }else if(GetLessonNumber()==2){
      if(GetPageNumber()<20){
        GotoNextPage();
      }else{
        GotoLessonMenu();
      }
    }else if(GetLessonNumber()==4){
      if(GetPageNumber()<4){
        GotoNextPage();
      }else{
        GotoLessonMenu();
      }
    }
}
/*--------------------------------------------------------------------------------------------------------------------*/
function IsResponsePage(){
  var end = window.location.href.lastIndexOf(".htm");
  var cChar = window.location.href.charAt(end-4);
  if(cChar=="I" || cChar=="C") return true;
  else return false;
}
/*--------------------------------------------------------------------------------------------------------------------*/
function GotoNextPage(){
  window.location.href=GetChapterAndLesson() + "P" + Format(GetPageNumber()+1) + ".htm";
}
function GotoCorrectResponse(){
  window.location.href=GetChapterLessonPage() + "C001.htm";
}
function GotoIncorrectResponse(){
  window.location.href=GetChapterLessonPage() + "I001.htm";

}
function GotoLessonMenu(){
  window.location.href="lessonMenu.htm";
}
/*--------------------------------------------------------------------------------------------------------------------*/

function GetPageNumber(){
  var sPage = GetPage();
  return Math.round(sPage.substr(1));
}
function GetLessonNumber(){
  var sLess = GetLesson();
  return Math.round(sLess.substr(1));
}
function GetPage(){
  var begin = GetTrailingSlashIndex();
  return window.location.href.substr(begin+9,4);
}
function GetLesson(){
  var begin = GetTrailingSlashIndex();
  return window.location.href.substr(begin+5,4);
}
function GetChapter(){
  var begin = GetTrailingSlashIndex();
  return window.location.href.substr(begin+1,4);
}
function GetChapterAndLesson(){
  return GetChapter() + GetLesson();
}
function GetChapterLessonPage(){
  return GetChapter() + GetLesson() + GetPage();
}
/*--------------------------------------------------------------------------------------------------------------------*/
function GetTrailingSlashIndex(){
  var index = window.location.href.lastIndexOf("/");
  var end = index!=-1 ? index : window.location.href.lastIndexOf("\\");
  return end;
}
function Format(iNum){
  var out;
  if(iNum<10) out = "00" + iNum;
  else if(iNum<100) out = "0" + iNum;

  return out;
}
/*--------------------------------------------------------------------------------------------------------------------*/


