/*
    File name: gwdjavascript.js
    Author: Sharon L. Carroll-Tidman for Grafton Water District
    Creation Date: 8/2/10
    Purpose: This javascript file contains the basic functions required to support the GWD web-site 

    Modification History:
       Date     Initials	Summary of Changes Made
    ----------- --------------- ----------------------------------------------------------------------------------------------------
     8/2/10      slc             Creation
    ================================================================================================================================
    Function List:
        addEvent (object, evName, fnName, cap) -- function to associate a function with an object's event.
        add contactFormActionSetup (formid)  -- used add the e-mail action to the contact form.  receives the form's id. (not used)
        linktomailto(linkItemId) -- function to set up a e-mail link for the contact forms. (not used)
        gwdcheckformodifications(filename) -- used to determine if html needs to be modified.
*/

var sections = new Array ("h1","h2","h3","h4","h5","h6");
var alphabetHeaderLevelIndex = 1;  // identifies which header in the file indicates an alphabet heading.

function addEvent(object, evName, fnName, cap) {
   if (object.attachEvent)
       object.attachEvent("on" + evName, fnName);
   else if (object.addEventListener)
       object.addEventListener(evName, fnName, cap);
}

function contactFormActionSetup (formid) {
   var contactEmailAddress = "sales@greenlivinglandscapers.com";
   var contactForm = document.getElementById(formid);
   contactForm.action = "mailto:" + contactEmailAddress;
}


function linktoMailto(linkItemId) {  // may have to be modified -- slc
   var emailAddress = "emailaddress@domain.com";

   var linkItemObject = document.getElementById(linkItemId); 
   var linkItemUObject = linkItemObject.firstChild; //should be the <u> item
   var linkItemBObject = linkItemUObject.nextSibling;  //should be the <b> item
   var emailLinkto = "<a href='mailto:" + emailAddress + "'>"  //reconstruct using <a> element
   var newHTML = emailLinkto + "e-mail</a> <b>" + linkItemBObject.innerHTML + "</b></br>";
   linkItemObject.innerHTML = newHTML;  
}

