// ############################################################################
// ##
// ##  CUSTOM WEBSITE FUNCTIONS
// ##  (i.e. not standard white site functions)
// ##
// ############################################################################

// Put custom functions for your website here.

// ############################################################################
// ##
// ##  STANDARD WHITE SITE FUNCTIONS
// ##
// ############################################################################

// ####################################
// Navigation
// ####################################

// ====================
// Function:    NavPullDown
//
// Purpose:     Go to a URL that is selected from a form a pull-down form field
//
// Input:       strFormName - The ID of the form being used to select naviation
//              strFieldName - The ID of the field with URL select options
//
// Output:      Navigates to selected URL.
//
// Assumptions: -
//
// History:     DDSN created back in the Distant Past
// ====================
function NavFormSelect(strFormName,strFieldName) {
	intSelected = document[strFormName].elements[strFieldName].options.selectedIndex;
	strURL = document[strFormName].elements[strFieldName].options[intSelected].value;
	document[strFormName].elements[strFieldName].options.selectedIndex = 0;
	if (strURL != "") {
		location.href = strURL;
	}
}

// ####################################
// Windows & Alerts
// ####################################

// ====================
// Function:    Popup
//
// Purpose:     Open a popup window with a series of option settings.
//
// Input:       strPage - The URL of the page to open in the popup window.
//              intWidth - The window width in pixels 
//              intHeight - The window height in pixels
//              strID - The ID of the popup window. (This is important if the
//                window may be called on by other functions or if there are
//                multiple popup windows in a site.)
//              strScrollbars - Switch visible scrollbars on/off ("yes"/"no")
//              strLocation - Switch visible location bar on/off ("yes"/"no")
//              strToolbar - Switch visible toolbar on/off ("yes"/"no")
//              strStatus - Switch visible status bar on/off ("yes"/"no")
//              strResizable - Window is resizable or not ("yes"/"no")
//
// Output:      Window opens containing the specified URL.
//
// Assumptions: -
//
// History:     DDSN created back in the Distant Past
// ====================
function Popup(strPage,intWidth,intHeight,strID,strScrollbars,strLocation,strToolbar,strStatus,strResizable) {
	if (!strPage) {
		strPage = "/";
	}
	if (!intWidth) {
		intWidth = 500;
	}
	if (!intHeight) {
		intHeight = 320;
	}
	if (!strID) {
		strID = "PopupWindow";
	}
	if (!strScrollbars) {
		strScrollbars = "yes";
	}
	if (!strLocation) {
		strLocation = "no";
	}
	if (!strToolbar) {
		strToolbar = "no";
	}
	if (!strStatus) {
		strStatus = "no";
	}
	if (!strResizable) {
		strResizable = "yes";
	}
	//if (isLoaded == 0)
	//{
	//	location.reload();
	//}
	idPopup = window.open(strPage,strID,"width="+intWidth+",height="+intHeight+",scrollbars="+strScrollbars+",location="+strLocation+",toolbar="+strToolbar+",status="+strStatus+",resizable="+strResizable);
	if (window.focus) {
		idPopup.focus();
	}
	return false;
}

// ====================
// Function:    PopdownLink
//
// Purpose:     Open a link in a popup window in a specified main window and
//              close the popup window. If the specified link window does not
//              exist it is created. If no window is specified the link is
//              targeted to the original opener of the popup window.
//
// Input:       strURL - The URL of the page to open
//              strWindowID - The ID of the window in which to open the link
//
// Output:      Navigates to selected URL in selected window and closes current
//              window.
//
// Assumptions: -
//
// History:     DDSN created back in the Distant Past
//              2004 Multiple window targets added. (Previously could only
//                   target the opener.)
// ====================
function PopdownLink(strURL,strWindowID) {
	if (!strWindowID) {
		top.opener.location.href = strURL;
	}
	else {
		if (strWindowID.location) {
			strWindowID.location.href = strURL;
		}
		else {
			window.open(strURL,strWindowID);
		}
	}
	top.close();
}

// ====================
// Function:    CS
//
// Purpose:     Display a "coming soon" message for sections of a website that
//              have not been created yet. This function is sometimes used in
//              development to make links active before a site is finished.
//
//              Note: This is an evil funciton, it should not be used! It
//              encourages bad development habits.
//
// Input:       -
//
// Output:      Show a "coming soon" message.
//
// Assumptions: -
//
// History:     DDSN created back in the Distant Past
// ====================
function CS() {
	alert("That function is coming soon.");
}

// ####################################
// Image Manipulation
// ####################################

// ====================
// Function:    ImageSwap
//
// Purpose:     Swap any image to another.
//
// Input:       strImageID - ID of the image being swapped
//              strNewImageSrc - Source of the new image being loaded
//
// Output:      Swaps images.
//
// Assumptions: Images with all specified IDs exist and are pre-loaded.
//
// History:     DDSN created back in the Distant Past
// ====================
function ImageSwap(strImageID,strNewImageSrc) {
	if (document.images) {
		document.images[strImageID].src = eval(strNewImageSrc+".src");
	}
}

// ====================
// Function:    ImageSwapFX
//
// Purpose:     Swap any image to another using an optional fade effect. Can
//              also be called with the transition effect disabled, i.e. just
//              swap the images.
//
// Input:       strImageID - ID of the image being swapped
//              strNewImageSrc - Source of the new image being loaded
//              blnDisableTrans - Switch the transition off or on (1/0)
//
// Output:      Swaps images with optional fade effect.
//
// Assumptions: - Images with all specified IDs exist and are pre-loaded.
//              - Requires fading transition style to be set first on image tag
//              - Only works for IE5.5+ but falls back nicely
//              - Javascript Globals: blnToggleTrans
//
// History:     2003 DDSN Created
//              2004 Updated with more standard naming structures
// ====================
function ImageSwapFX(strImageID,strNewImageSrc,blnDisableTrans) {
	if (blnDisableTrans || !document.images[strImageID].filters || blnIE50) {
		if (document.images) {
			document.images[strImageID].src = eval(strNewImageSrc+".src");
		}
	}
	else {
		// After setting Apply, changes to the object are not displayed
		// until Play is called.
		document.images[strImageID].filters[0].Apply();

		if (blnToggleTrans) {
			blnToggleTrans = 0;
			document.images[strImageID].src = eval(strNewImageSrc+".src");
		}
		else {
			blnToggleTrans = 1;
			document.images[strImageID].src = eval(strNewImageSrc+".src");
		}
		document.images[strImageID].filters[0].Play();
	}
}

// ====================
// Function:    LoadGallery
//
// Purpose:     Loads the lightbox image gallery. Sets up a link for every
//              anchor tag in the page with a class of "galleryLink".
//
// Input:       strGalleryContainerElement - The HTML element in which to look
//                for gallery images.
//
// Output:      Adds popup gallery links to particular anchor tags.
//
// Assumptions: - The gallery Javascript is loaded (slide.js)
//
// History:     2010 RW Created
// ====================
function LoadGallery(strGalleryContainerElement) {
    var arrContentAnchors = document.getElementById(strGalleryContainerElement).getElementsByTagName("A");
    var j = 0;
    for (i = 0; i < arrContentAnchors.length; i++) {
        if (arrContentAnchors[i].className == "galleryLink") {
            viewer.add(arrContentAnchors[i].href);
            arrContentAnchors[i].href = "javascript:void(viewer.show(" + j + "));";
            j++;
        }
    }
}

// ####################################
// DOM Manipulation
// ####################################

// ====================
// Function:    GetObjectWidth
//
// Purpose:     Returns the width of any passed in block level object
//
// Input:       ID of item
//
// Output:      Returns the width of any passed in block level object
//
// Assumptions: -
//
// History:     SC 2006-05-15
// ====================
function GetObjectWidth(objectRef) {
	var intWidth = -1;

	if (document.getElementById) {
		if (document.getElementById(objectRef)) {
			intWidth = eval(document.getElementById(objectRef).offsetWidth);
		}
	}
	else if (document.all) {
		if (document.all[objectRef]) {
			intWidth = document.all[objectRef].scrollWidth;
		}
	}
	else if (document.layers) {
		if (document[objectRef]) {
			intWidth = document[objectRef].clip.bottom;
		}
	}

	return intWidth;
}

// ====================
// Function:    GetObjectHeight
//
// Purpose:     Returns the height of any passed in block level object
//
// Input:       ID of item
//
// Output:      Returns the height of any passed in block level object
//
// Assumptions: -
//
// History:     SC 2006-05-15
// ====================
function GetObjectHeight(objectRef) {
	var intHeight = -1;

	if (document.getElementById) {
		if (document.getElementById(objectRef)) {
			intHeight = eval(document.getElementById(objectRef).offsetHeight);
		}
	}
	else if (document.all) {
		if (document.all[objectRef]) {
			intHeight = document.all[objectRef].scrollHeight;
		}
	}
	else if (document.layers) {
		if (document[objectRef]) {
			intHeight = document[objectRef].clip.bottom;
		}
	}

	return intHeight;
}

// ====================
// Function:    SetUniformHeight
//
// Purpose:     Sets a number of page objects to a uniform height, being the
//              maximum height of any of the given objects.
//
// Input:       strPageObjects - Comma separated list of object IDs that should
//              be set to a uniform height.
//
// Output:      Updates the height of the given objects.
//
// Assumptions: GetObjectHeight()
//
// History:     20060823 RW Created
// ====================
function SetUniformHeight(strPageObjects) {
	intMaxHeight = 0;

	if (strPageObjects) {
		arrPageObjects = strPageObjects.split(",");
	}

	if (arrPageObjects) {
		// Find the height of the tallest object.
		for (i = 0; i < arrPageObjects.length; i++) {
			intThisHeight = GetObjectHeight(arrPageObjects[i]);
			if (intThisHeight > intMaxHeight) {
				intMaxHeight = intThisHeight;
			}
		}

		// Set all the objects to the same (maximum) height if a height larger
		// than 0 was found.
		if (intMaxHeight > 0 ) {
			for (i = 0; i < arrPageObjects.length; i++) {
				if (blnIE)  {
					strMaxHeight = intMaxHeight;
				}
				else {
					strMaxHeight = intMaxHeight + 'px';
				}
				if(document.getElementById(arrPageObjects[i])) {
					document.getElementById(arrPageObjects[i]).style.height = strMaxHeight;
				}
			}
		}
	}

}

/**********************************************************
Function:
getElementsByClassName

Purpose:
Provides compatibility for getElementsByClassName (a native function in
many browsers) for browsers that don't support it (IE).

Input:
className -  Mandatory. One or several class names, separated by space. 
Multiple class names demands that each match have all of the classes 
specified.
tag - Optional. Specifies the tag name of the elements to match.
elm - Optional. Reference to a DOM element to look amongst its children for
matches. Recommended for better performance in larger documents. 
            
Output:
An array of elements

Assumptions:
-

Examples:
To get all elements in the document with a “info-links” class.
getElementsByClassName("info-links");
    
To get all div elements within the element named “container”, with a “col” class.
getElementsByClassName("col", "div", document.getElementById("container")); 
    
To get all elements within in the document with a “click-me” and a “sure-thang” class.
getElementsByClassName("click-me sure-thang"); 

History:
20091022 RW Included from http://www.robertnyman.com

Notes:
Developed by Robert Nyman, http://www.robertnyman.com
Code/licensing: http://code.google.com/p/getelementsbyclassname/
DDSN Note: MIT Licence
**********************************************************/
var getElementsByClassName = function(className, tag, elm) {
    if (document.getElementsByClassName) {
        getElementsByClassName = function(className, tag, elm) {
            elm = elm || document;
            var elements = elm.getElementsByClassName(className),
				nodeName = (tag) ? new RegExp("\\b" + tag + "\\b", "i") : null,
				returnElements = [],
				current;
            for (var i = 0, il = elements.length; i < il; i += 1) {
                current = elements[i];
                if (!nodeName || nodeName.test(current.nodeName)) {
                    returnElements.push(current);
                }
            }
            return returnElements;
        };
    }
    else if (document.evaluate) {
        getElementsByClassName = function(className, tag, elm) {
            tag = tag || "*";
            elm = elm || document;
            var classes = className.split(" "),
				classesToCheck = "",
				xhtmlNamespace = "http://www.w3.org/1999/xhtml",
				namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace) ? xhtmlNamespace : null,
				returnElements = [],
				elements,
				node;
            for (var j = 0, jl = classes.length; j < jl; j += 1) {
                classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
            }
            try {
                elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
            }
            catch (e) {
                elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
            }
            while ((node = elements.iterateNext())) {
                returnElements.push(node);
            }
            return returnElements;
        };
    }
    else {
        getElementsByClassName = function(className, tag, elm) {
            tag = tag || "*";
            elm = elm || document;
            var classes = className.split(" "),
				classesToCheck = [],
				elements = (tag === "*" && elm.all) ? elm.all : elm.getElementsByTagName(tag),
				current,
				returnElements = [],
				match;
            for (var k = 0, kl = classes.length; k < kl; k += 1) {
                classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
            }
            for (var l = 0, ll = elements.length; l < ll; l += 1) {
                current = elements[l];
                match = false;
                for (var m = 0, ml = classesToCheck.length; m < ml; m += 1) {
                    match = classesToCheck[m].test(current.className);
                    if (!match) {
                        break;
                    }
                }
                if (match) {
                    returnElements.push(current);
                }
            }
            return returnElements;
        };
    }
    return getElementsByClassName(className, tag, elm);
};

// ####################################
// Printing
// ####################################

// ====================
// Function:    LoadVBPrinter
//
// Purpose:     Load Visual Basic printing commands for VB enabled browsers.
//
// Input:       -
//
// Output:      Loads (writes out) visual basic printing functions.
//
// Assumptions: Javascript Globals: blnIE, blnCanPrint, blnMac
//
// History:     DDSN created back in the Distant Past
// ====================
//function LoadVBPrinter()
//{
	if (blnIE && !blnCanPrint && !blnMac) with (document) {
		writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
		writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
		writeln('Sub window_onunload');
		writeln('    On Error Resume Next');
		writeln('    Set WB = nothing');
		writeln('End Sub');
		writeln('Sub vbPrintPage');
		writeln('    OLECMDID_PRINT = 6');
		writeln('    OLECMDEXECOPT_DONTPROMPTUSER = 2');
		writeln('    OLECMDEXECOPT_PROMPTUSER = 1');
		writeln('    On Error Resume Next');
		writeln('    WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
		writeln('End Sub');
		writeln('<' + '/SCRIPT>');
	}
//}

// ====================
// Function:    PrintPage
//
// Purpose:     Opens the print dialog window or shows a fallback message for
//              unsupported browsers
//
// Input:       -
//
// Output:      Opens the print dialog window or shows a fallback message for
//              unsupported browsers.
//
// Assumptions: Javascript Globals: blnCanPrint, blnIE, blnMac
//
// History:     DDSN created back in the Distant Past
// ====================
function PrintPage() {
	if (blnCanPrint) {
		window.print();
	}
	else if (blnIE && !blnMac) {
		vbPrintPage();
	}
	else {
		alert("Your web browser does not appear to support the automatic\nPrint function. To print this page, please select the \"Print\"\noption from the \"File\" menu of your web browser.");
	}
}


// Load Visual Basic printing commands for VB enabled browsers
//LoadVBPrinter()

// ####################################
// Custom scroller
// ####################################

//We wrap all the code in an object so that it doesn't interfere with any other code
var scroller = {
  init:   function() {
    if (document.getElementById("pagebody") && document.getElementById("pagebody-inner") && document.getElementById("scrollArea")) {

    //collect the variables
    scroller.docH = document.getElementById("pagebody-inner").offsetHeight;
    scroller.contH = document.getElementById("pagebody").offsetHeight;
    scroller.scrollAreaH = document.getElementById("scrollArea").offsetHeight;

    //calculate height of scroller and resize the scroller div
    //(however, we make sure that it isn't to small for long pages)
    scroller.scrollH = (scroller.contH * scroller.scrollAreaH) / scroller.docH;
    
    // Remember the scroller height...
    scroller.checkHeight = scroller.scrollH;
    
    //Set a minimum or fixed height for the scroller
    //if(scroller.scrollH < 57) scroller.scrollH = 57; // Minimum height
    scroller.scrollH = 57; // Fixed height
    document.getElementById("scroller").style.height = Math.round(scroller.scrollH) + "px";
	
    //what is the effective scroll distance once the scoller's height has been taken into account
    scroller.scrollDist = Math.round(scroller.scrollAreaH-scroller.scrollH);

    if (scroller.scrollAreaH < scroller.checkHeight) {
        //make the scrollbar invisible if the page is longer than the scroller
        document.getElementById("scrollArea").style.display = 'none';
    } else {
	
        //make the scroller div draggable
        Drag.init(document.getElementById("scroller"),null,0,0,-1,scroller.scrollDist);
        //add ondrag function
        document.getElementById("scroller").onDrag = function (x,y) {
          var scrollY = parseInt(document.getElementById("scroller").style.top);
          var docY = 0 - (scrollY * (scroller.docH - scroller.contH) / scroller.scrollDist);
          document.getElementById("pagebody-inner").style.top = docY + "px";

        }
    }
    
    }
  }
}

onload = scroller.init;

// ####################################
// Useful Functions
// ####################################

// ====================
// Function:    addEvent
//
// Purpose:     Attach an event dynamically to any object.
//
// Input:       obj - the object to attach event to
//              evType - name of the event - DONT ADD "on", pass only "mouseover", etc
//              fn - function to call
//              E.g. addEvent(window, "load", "WindowOnload")
//
// Output:      true | false
//
// Assumptions: -
//
// History:     20090113 RW Included from Seth Banks http://www.subimage.com/dhtml/
// ====================
function addEvent(obj, evType, fn) {
    //alert("addEvent here");
    if (obj.addEventListener) {
        obj.addEventListener(evType, fn, false);
        return true;
    } else if (obj.attachEvent) {
        var r = obj.attachEvent("on" + evType, fn);
        return r;
    } else {
        return false;
    }
}

// ====================
// Function:    removeEvent
//
// Purpose:     Remove an event dynamically from any object.
//
// Input:       obj - the object to attach event to
//              evType - name of the event - DONT ADD "on", pass only "mouseover", etc
//              fn - function to call
//              useCapture - ?
//
// Output:      true | false/error alert
//
// Assumptions: -
//
// History:     20090113 RW Included from Seth Banks http://www.subimage.com/dhtml/
// ====================
function removeEvent(obj, evType, fn, useCapture) {
    if (obj.removeEventListener) {
        obj.removeEventListener(evType, fn, useCapture);
        return true;
    } else if (obj.detachEvent) {
        var r = obj.detachEvent("on" + evType, fn);
        return r;
    } else {
        alert("Handler could not be removed");
    }
}

// ####################################
// Form Handling & Data Validation
// ####################################

// ====================
// Function:    RequireKeywords
//
// Purpose:     Checks any search form to make sure keywords are entered before
//              the form can be submitted. 
//
// Input:       strFormName - The ID of the form with the keywords field in it
//              strFieldName - The ID of the keywords field within the form 
//
// Output:      Give an error if no keywords are presented.
//
// Assumptions: -
//
// History:     20040109 RW Created to replace local code in site templates.
// ====================
function RequireKeywords(strFormID, strFieldName) {
    if (document.forms[strFormID].elements[strFieldName].value.length <= 3) {
        alert("Please alter your requested keyword(s) in the search form.\nThe search phrase must be 3 characters or more in length.")
        return false;
    }
}

// ====================
// Function:    SubmitAcuityForm
//
// Purpose:     Validate an Acuity CMS form submission.
//
// Input:       oForm -
//
// Output:      true or false
//
// Assumptions: -
//
// History:     20100426 RW Created 
// ====================
function SubmitAcuityForm(oForm) {
    strErrors = "";
    arrInputTags = oForm.getElementsByTagName("INPUT");
    arrTextareaTags = oForm.getElementsByTagName("TEXTAREA");
    arrSelectTags = oForm.getElementsByTagName("SELECT");
    
    for (i = 0; i < arrInputTags.length; i++) {
        if (arrInputTags[i].type == "text") {
            strFieldName = arrInputTags[i].name;
            if (strFieldName == "x_Email") {
                if (!CheckEmail(arrInputTags[i].value)) {
                    strErrors += "* " + strFieldName.replace("x_", "").replace("_r", "").replace(/_/gi, " ") + " must contain a valid email address.\n";
                    if (arrInputTags[i].className != "") {
                        arrInputTags[i].className = arrInputTags[i].className + " validationFailed";
                    } else {
                        arrInputTags[i].className = "validationFailed";
                    }
                } else {
                    if (arrInputTags[i].className.indexOf("validationFailed") > -1) {
                        arrInputTags[i].className = arrInputTags[i].className.replace(/validationFailed/gi, "");
                    }
                }
            } else if (IsAcuityRequiredField(strFieldName)) {
                // Required fields
                if (arrInputTags[i].value == "") {
                    strErrors += "* " + strFieldName.replace("x_", "").replace("_r", "").replace(/_/gi, " ") + " is a required field.\n";
                    if (arrInputTags[i].className != "") {
                        arrInputTags[i].className = arrInputTags[i].className + " validationFailed";
                    } else {
                        arrInputTags[i].className = "validationFailed";
                    }
                } else {
                    if (arrInputTags[i].className.indexOf("validationFailed") > -1) {
                        arrInputTags[i].className = arrInputTags[i].className.replace(/validationFailed/gi, "");
                    }
                }
            } 
        }
    }

    for (i = 0; i < arrTextareaTags.length; i++) {
        strFieldName = arrTextareaTags[i].name;
        if (IsAcuityRequiredField(strFieldName)) {
            // Required fields
            if (arrTextareaTags[i].value == "") {
                strErrors += "* " + strFieldName.replace("x_", "").replace("_r", "").replace(/_/gi, " ") + " is a required field.\n";
                if (arrTextareaTags[i].className != "") {
                    arrTextareaTags[i].className = arrTextareaTags[i].className + " validationFailed";
                } else {
                    arrTextareaTags[i].className = "validationFailed";
                }
            } else {
                if (arrTextareaTags[i].className.indexOf("validationFailed") > -1) {
                    arrTextareaTags[i].className = arrTextareaTags[i].className.replace(/validationFailed/gi, "");
                }
            }
        }
    }

    for (i = 0; i < arrSelectTags.length; i++) {
        strFieldName = arrSelectTags[i].name;
        if (IsAcuityRequiredField(strFieldName)) {
            // Required fields
            selectedIndex = arrSelectTags[i].selectedIndex;
            if (arrSelectTags[i][selectedIndex].value == "" || arrSelectTags[i][selectedIndex].value.substring(0, 13).toLowerCase() == "please select") {
                strErrors += "* " + strFieldName.replace("x_", "").replace("_r", "").replace(/_/gi, " ") + " is a required field.\n";
                if (arrSelectTags[i].className != "") {
                    arrSelectTags[i].className = arrSelectTags[i].className + " validationFailed";
                } else {
                    arrSelectTags[i].className = "validationFailed";
                }
            } else {
                if (arrSelectTags[i].className.indexOf("validationFailed") > -1) {
                    arrSelectTags[i].className = arrSelectTags[i].className.replace(/validationFailed/gi, "");
                }
            }
        }
    }

    if (strErrors.length > 0) {
        strErrors = "There were some problems with the form submission. Please check the following issues, adjust your form input, and try again.\n\n" + strErrors;
        alert(strErrors);
        return false;
    } else {
        return true;
    }
}

function CheckEmail(strEmail) {
    var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(strEmail)) {
        return true;
    } else {
        return false;
    }
}

function IsAcuityRequiredField(strFieldName) {
    if (strFieldName == "x_Name" || strFieldName == "x_Email" || strFieldName == "x_Message" || strFieldName.substring(strFieldName.length - 2, strFieldName.length) == "_r") {
        return true;
    } else {
        return false;
    }
}

// ====================
// Function:    LoadAcuityForms
//
// Purpose:     Configure forms that belong to Acuity CMS, e.g. add a validation
//              function on submit, and more if needed. Expects to run on page 
//              load.
//
// Input:       -
//
// Output:      Adds various events to any form that submits to /forms/submit.asp
//
// Assumptions: -
//
// History:     20100426 RW Created 
// ====================
function LoadAcuityForms() {
    var arrForms = document.forms;
    var strErros = "";

    if (arrForms.length > 0) {
        for (i = 0; i < arrForms.length; i++) {
            if (arrForms[i].action.indexOf("/forms/submit.asp") > 0) {
                // This must be an Acuity CMS form
                arrInputTags = arrForms[i].getElementsByTagName("INPUT");
                arrTextareaTags = arrForms[i].getElementsByTagName("TEXTAREA");
                arrSelectTags = arrForms[i].getElementsByTagName("SELECT");

                // Code here to add events to fields, and so on

                oForm = arrForms[i];
                oForm.onsubmit = function() {
                    return SubmitAcuityForm(oForm);
                }
            }
        }
    }
}

// ####################################
// Fun Stuff / Easter Eggs
// ####################################

// No easter eggs currently present. :-)

