﻿// Javascript file
// first of all we declare three arrays.
// One array called "links" that are the names of the links.
// Another array "links_text" which consists of the text of the links (eg. Javascripts).
// The former one will be used for comparison.
// Name the various elements in the links array as the link files but without the extension
// (i.e if the first link takes you to index.htm name it index).
// The third array called "links_url" is the URL to which a link will take you. 

// Now, what we want is to compare each element in the array links to the current page's file name
// without the extension and accordingly assign it a style and whatever extra text or image you want to add to the link
// text if that particular link is the active page. 

// Let loc be the comparison string. 

// Thus if current page is http://www.rochford-acupuncture.co.uk/index.html then loc will be index.
// Now we compare this with each element in the array links.
// First element of this array and loc are equal thus we write this link in the following way. 



var links = new Array ("Home", "Bio", "Book", "Advice", "About", "History", "FAQ", "Infertility", "Baby", "Child", "Facial", "Links", "ContactUs", "Asthma", "Eczema", "GetPregnant", "Hayfever", "IBS", "Infertility", "PregnancyLabour");
var links_text = new Array ("Home", "About Jo Rochford", "Appointment", "Free Advice", "About Acupuncture", "History", "FAQ", "Infertility", "Baby Massage", "Children", "Facial Enhancement", "Links", "Contact Us", "Asthma", "Eczema", "Get Pregnant", "Hayfever", "IBS", "Infertility", "Pregnancy &amp; Labour");
var links_url = new Array ("Home.html", "Bio.html", "Book.html", "Advice.html", "About.html", "History.html", "FAQ.html", "Infertility.html", "Baby.html", "Child.html", "Facial.html", "Links.html", "ContactUs.html", "Asthma.html", "Eczema.html", "GetPregnant.html", "Hayfever.html", "IBS.html", "Infertility.html", "PregnancyLabour.html");

var loc=String(this.location);

loc=loc.split("/");
loc=loc[loc.length-1].split(".");
loc=loc[loc.length-2];

function menu_Active_Gen()
{
	for(var i=0; i<links.length; i++)
	{
		if(loc==links[i])
		{
			// now we do the swap - have to handle weak js assignments by setting up some temp vars
			
			var myLink = '<a href="' + links_url[i] + '" class="menuItemActive">' + links_text[i] + '</a>';
			
			var thislink = links[i];
			
			var d = document.getElementById(thislink);
			
			d.innerHTML = myLink;
		}
	
	}
}

menu_Active_Gen(); 
