addLoadEvent(makeTrail);

function addLoadEvent(func)
{
var oldonload=window.onload;
if(typeof window.onload!='function'){
window.onload=func;}
else{
window.onload=function()
{
oldonload();func();
}
}
}

  var trailMenu = new Object(); //Titles to be shown in trail menu on each page
    trailMenu["WebData"] = "Entry";
    trailMenu["ChurchWeb"] = "Home";
    trailMenu["skylight"] = "Skylight";
    trailMenu["skylight2010"] = "Skylight Index";
    trailMenu["skylight2009"] = "Skylight Index";
    trailMenu["skylight2008"] = "Skylight Index";
    trailMenu["skylight2007"] = "Skylight Index";
    trailMenu["History"] = "History";
    trailMenu["Skylight"] = "Skylight Reading Room";
    trailMenu["Minutes"] = "Minutes Index";
    trailMenu["Members"] = "Members Index";
    trailMenu["pictureFiles"] = "Picture Index";
    trailMenu["youthPictures"] = "Youth Picture Index"; 
    trailMenu["Christmas"] = "Christmas";
    trailMenu["2004"] = "2004";
    trailMenu["Construction"] = "1998";
    trailMenu["Biogs"] = "Tribute";
    trailMenu["FOL"] = "Festival of Love Index";
    trailMenu["FOL2005"] = "Festival of Love 2005";
    trailMenu["FOL2006"] = "Festival of Love 2006"; 
    trailMenu["FOL2007"] = "Festival of Love 2007";
    trailMenu["FOL2008"] = "Festival of Love 2008"; 
    trailMenu["FOL2009"] = "Festival of Love 2009";
    trailMenu["lighthouse"] = "Lighthouse";
    trailMenu["TFT"] = "Intellection";
    trailMenu["ByLaw"] = "Constitution";
    trailMenu["BFM"] = "Beliefs";
    trailMenu["support"] = "Pastor Page";
    trailMenu["reflections"] = "Reflections";
    
  var webPage = new Object(); //Destination pages for each Title
    webPage["WebData"] = "index.html";
    webPage["ChurchWeb"] = "home.html";
		webPage["skylight"] = "skylight/wantGod1.html";
    webPage["skylight2010"] = "History/electronicNewsletters2010.html";
    webPage["skylight2009"] = "History/electronicNewsletters2009.html";
    webPage["skylight2008"] = "History/electronicNewsletters2008.html";
    webPage["skylight2007"] = "History/electronicNewsletters.html";
    webPage["History"] = "churchHistory.html";
    webPage["Skylight"] = "History/skylightRR.html";
    webPage["Minutes"] = "History/businessMeetings.html";
    webPage["Members"] = "History/churchMembers.html";
    webPage["pictureFiles"] = "historyPictures.html";
    webPage["youthPictures"] = "historyPictures.html#youthPictures";
    webPage["Christmas"] = "pictureFiles/pictures2005.html";
    webPage["2004"] = "pictureFiles/pictures2004.html";
    webPage["Construction"] = "pictureFiles/pictures1998.html";
    webPage["Biogs"] = "Tribute.html";
    webPage["FOL"] = "History/FOLindex.html";
    webPage["FOL2005"] = "History/FOL/FestivalOfLove2005.html";
    webPage["FOL2006"] = "History/FOL/FestivalOfLove2006.html";
    webPage["FOL2007"] = "History/FOL/FestivalOfLove2007.html";
    webPage["FOL2008"] = "History/FOL/FestivalOfLove2008.html";
    webPage["FOL2009"] = "History/FOL/FestivalOfLove2009.html";
    webPage["lighthouse"] = "Intellection.html";
    webPage["TFT"] = "Intellection.html";
    webPage["ByLaw"] = "constitution.html";
    webPage["BFM"] = "Beliefs.html";
    webPage["support"] = "pastorPage.html";
    webPage["reflections"] = "reflections.html";

function makeTrail()  
  { 
  if(!document.getElementsByTagName)return false;
  if(!document.getElementById)return false;
  if(!document.getElementById("trailer"))return false;

  var isIE = (navigator.appName == "Microsoft Internet Explorer"); //Detect IE Browser

  var trailDisplay=document.getElementById("trailer");
  var path = location.pathname;
  leaves = path.split("/"); //parse the path
    
  if (location.protocol.indexOf("file") != -1) {  	
    //reading html page from file
    siteLoc = "file";
    volDelim = "/";
    fileHostName = "file:///" + leaves[1] + volDelim + leaves[2] + volDelim + leaves[3] + volDelim;
    parseStart = 2;
    parseEnd = leaves.length-1;
    } //endof if(location.protocol.......
    
    else {
    	//reading html page from web site
    	siteLoc = "web";
    	volDelim = "/";
      fileHostName = "http://newsalembaptistchurch.us/";
    	parseStart = 1;
    	parseEnd = leaves.length-1;
    }

    //Create span
    var trailSpan = document.createElement("span");
    trailSpan.setAttribute("class","L5");
    
    if (isIE) trailSpan.style.fontSize="10px";
  
    var separator = " >> ";;
    var trailA;

    if (siteLoc == "web") { 
    	trailA = document.createElement("a");
    	pageID = document.createTextNode(trailMenu["WebData"] + separator);
    	trailA.setAttribute("href",fileHostName + webPage["WebData"]);
      trailA.appendChild(pageID);
 
      //trailA.appendChild(separatorNode);
      trailSpan.appendChild(trailA);
      //alert("trailA = " + trailA);
      
     	//insert Home into trailA
    	trailA = document.createElement("a");
    	pageID = document.createTextNode(trailMenu["ChurchWeb"] + separator);
    	trailA.setAttribute("href",fileHostName + webPage["ChurchWeb"]);
      trailA.appendChild(pageID);
      trailSpan.appendChild(trailA);
    } //endof for if ((siteLoc == "web") && (i == 1))

    for (var i = parseStart; i < parseEnd; i++) {
    trailA = document.createElement("a");
    pageID = document.createTextNode(trailMenu[leaves[i]] + separator);
    trailA.setAttribute("href",fileHostName + webPage[leaves[i]]);
    trailA.appendChild(pageID);
    trailSpan.appendChild(trailA);
    } //endof for (var i = parseStart; i < parseEnd; i++)

    if (i == parseEnd) {
    var idx = leaves[i];
    var b = idx.indexOf(".html");
    
    if (b > 0) idx = idx.substring(0,b);

    pageID = document.createTextNode(idx);

    trailSpan.appendChild(pageID);
    var refp = trailDisplay.firstChild;
    trailDisplay.insertBefore(trailSpan,refp);
    } //endof if (i == parseEnd)
  
}//endof makeTrail()

//Other Functions

//Opens a new window and inserts "newWindow" into it.
function newWindow(newWindow,windowname) 
  {
  pWindow = window.open(newWindow, windowname, "width=800,height=400,left=100,top=100,status=yes,resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes")
  pWindow.focus()
  }

