var loc=parent.location.toString();

var currentPage;

if(loc.indexOf("index.php")>0)
   currentPage="home";
else if(loc.indexOf("about_us.php")>0)
   currentPage="about";
else if(loc.indexOf("our_story.php")>0)
   currentPage="about";
else if(loc.indexOf("missions.php")>0)
   currentPage="about";
else if(loc.indexOf("staff.php")>0)
   currentPage="about";
else if(loc.indexOf("privacy_policy.php")>0)
   currentPage="about";
else if(loc.indexOf("visit2.php")>0)
   currentPage="visit";
else if(loc.indexOf("our_facility.php")>0)
   currentPage="visit";
else if(loc.indexOf("visit.php")>0)
   currentPage="visit";
else if(loc.indexOf("church_life.php")>0)
   currentPage="church";
else if(loc.indexOf("praise_reports.php")>0)
   currentPage="church";
else if(loc.indexOf("news_archive.php")>0)
   currentPage="church";
else if(loc.indexOf("growth_classes.php")>0)
   currentPage="church";
else if(loc.indexOf("children_youth.php")>0)
   currentPage="church";
else if(loc.indexOf("volunteers.php")>0)
   currentPage="church";
else if(loc.indexOf("communion.php")>0)
   currentPage="church";
else if(loc.indexOf("media.php")>0)
   currentPage="media";
else if(loc.indexOf("newsletter_archive.php")>0)
   currentPage="media";
else if(loc.indexOf("articles.php")>0)
   currentPage="media";
else if(loc.indexOf("articles_info.php")>0)
   currentPage="media";
else if(loc.indexOf("store.php")>0)
   currentPage="store";
else if(loc.indexOf("product_listing.php")>0)
   currentPage="store";
else if(loc.indexOf("donations.php")>0)
   currentPage="mygwc";
else if(loc.indexOf("mygwc.php")>0)
   currentPage="mygwc";
else if(loc.indexOf("contact.php")>0)
   currentPage="contact";
else
   currentPage=null;
   

subNavArray={"home"  : [],
               "about" : [["Vision Statement", "about_us.php"],
                          ["We Believe", "about_us.php#we_believe"],
                          ["Our Story", "our_story.php"],
                          ["Foreign Missions", "missions.php"],
                          ["Pastoral Staff", "staff.php"],
                          ["Privacy Policy", "privacy_policy.php"]],

               "visit" : [["What to Expect", "visit.php"],
                          ["Map/Directions", "visit2.php#map"],
                          ["Our Facility", "our_facility.php"],
                          ["Message From Pastor Greiner", "visit2.php"]],
                        
               "church" :[["Schedule", "church_life.php"],
                          ["News", "news_archive.php"],
                          ["iTestify", "praise_reports.php"],
                          ["Nursery - Sr. High", "children_youth.php"],
                          ["Volunteer", "volunteers.php"],
                          ["Communion, Baptism & Baby Dedication", "communion.php"], 
                          ["Photo Galleries", "photo_galleries.php"]],
                        
               "media" : [["Podcasts and Audio Archives", "media.php#podcasts"],
                          ["Newsletter Archives", "newsletter_archive.php"],
                          ["Article Archives", "articles.php"]],
                        
               "store" : [["Audio", "product_listing.php?category_id=51"],
                          ["Video", "product_listing.php?category_id=50"],
                          ["Books", "product_listing.php?category_id=49"]],
                        
               "mygwc" : [["Login", "mygwc.php"],
                          ["What is MY GWC?", "mygwc.php#faq"],
                          ["Give Online", "donations.php"]],
                          
               "contact":[]};
                        

// Shows sub navigation when nav is clicked
function showSubNav(index)
{
   if(index!=null)
   {
		var subNavContainer=document.getElementById("subnavContainer");
   
	   // Remove all old items
	   while(subNavContainer.firstChild)
	      subNavContainer.removeChild(subNavContainer.firstChild);
   
	   if(subNavArray[index].length>0)
	   {
	      var strong=document.createElement("strong");
	      strong.appendChild(document.createTextNode("\u00A0\u00A0\u00A0"));
	      subNavContainer.appendChild(strong);
	   }
   
	   // Insert new items
	   for(var i=0; i<subNavArray[index].length; i++)
	   {
	      var subNavLink=document.createElement("a");
	      subNavLink.className="sub";
	      subNavLink.href=subNavArray[index][i][1];
	      subNavLink.appendChild(document.createTextNode(subNavArray[index][i][0]));
      
	      subNavContainer.appendChild(subNavLink);
      
	      if(i!=subNavArray[index].length-1)
	         subNavContainer.appendChild(document.createTextNode("\u00a0\u00a0|\u00a0\u00a0"));
	   }
	}
}

if(window.addEventListener)
   window.addEventListener("load", function(){ showSubNav(currentPage); }, false);
else if(window.attachEvent)
   window.attachEvent("onload", function(){ showSubNav(currentPage); });
