//  JavaScript Functions used in frames implementation
function loadFrame(sourceFile)  {
//    Loads both the new content requested and the footer frame so that the
//    modification date will be updated for that page
//     Parameter:  relative Linux file name of the new content file
//			e.g.  "../directory/file.htm"
  
      window.top.Content.document.location = sourceFile;
//	  window.top.frames(1).name="Content";
      window.top.Footer.document.location = "../footer/footer-frames.html";
//	  window.top.frames(3).name="Footer";
//alert('loading file:  ' + sourceFile);
}

function goIfFrames()  {
//    Loads the content file associated with the SSI file (.shtml) that called this
//    function when in frames implementation.  This function is required when 
//    a link to another page from our site is called from our site.  It allows all
//    links on a page to another page to allways be specified to a server based 
//    SSI file, e.g.  "../sermons/sermons.shtml".
//    Also updates other franes on the page.      

   if (parent.frames.length != 0) {
      //  currently in frames implementation  
      var ext = ".htm";
	  var urlBase = document.location.pathname.substring(0, document.location.pathname.lastIndexOf("."));
      var urlArray = urlBase.split("\\");
      if (urlArray.length < 2){  // Running frames on server
         urlArray = urlBase.split("/");
      }
      var urlFile = urlArray[urlArray.length - 1];
      if (urlFile == "home") { ext = ".html"; }
	  var urlDir = urlArray[urlArray.length - 2];
	  
      window.top.Content.document.location = "../" + urlDir + "/" + urlFile + ext;
//	  window.top.frames(1).name="Content";
      window.top.Nav.document.location = "../nav/nav-frames.html";
//	  window.top.frames(2).name="Nav";
      window.top.Footer.document.location = "../footer/footer-frames.html";
//	  window.top.frames(3).name="Footer";
    return true;
   }
else {
    return false;
}
}

