﻿function pageLoad()
{   randomTestamonial();
    // setCurrent(); not currentl used since all pages have headings and some do not appear in menu
}

// Creates random testamonial
function randomTestamonial()
{
    obj = new Array(3);

    obj[0] = "&quot;I can&#39;t believe that only two sessions here was so much more help than the five or six I had elsewhere.&quot;";
    obj[1] = "&quot;I don&#39;t know what kind of magic you performed on me, but the spell you cast appears to have done the trick!&quot;";
    obj[2] = "&quot;Thank you for sorting me out ... again!<br />My shoulder has been much improved over the last few days.&quot;";

    index = Math.floor(Math.random() * obj.length);
    document.write(obj[index]);
}

// Sets current links with the class 'current' so it is highlighted in the menu
function setCurrent()
{
    var hrefString = document.location.href ? document.location.href : document.location;
    var crtPage= extractPageName(hrefString);
    if (crtPage.length<1)
    {   crtPage="index.html";
    }
    if (document.getElementById("mainmenu")!=null)
    {   var links=document.getElementById("mainmenu").getElementsByTagName("a");
        for(var i=0; i < links.length; i++)
        if (extractPageName(links[i].href) == crtPage)
        {   links[i].className = "current";
            links[i].parentNode.className = "current";
            return;
        }
    }
}

// Extracts the page name from the hrefString
function extractPageName(hrefString)
{
    var arr = hrefString.split('/');
    return  (arr.length<2) ? hrefString : arr[arr.length-1].toLowerCase();               
}
