﻿/***toggle.js***/
//
/*function toggle toggles the class attribute of two elements between two values*/
/*return: nothing*/
/*parameters:
    buttonID (string, optional) the id value of the controlling element, default "toggleText"
    divID (string, optional) the id value of the affected element, default "displayText"
    buttonState1Class (string, optional) the initial class attribute value of the controlling element, default "show"
    buttonState2Class (string, optional) the second class attribute value of the controlling element, default "hide"
    divState1Class (string, optional) the initial class attribute value of the affected element, default "hiding"
    divState2Class (string, optional) the second class attribute value of the affected element, default "showing"
*/
function toggle(buttonID, divID, buttonState1Class, buttonState2Class, divState1Class, divState2Class) {
    //parameter defaults
    if (buttonID == undefined) { buttonID = "toggleText"; }
    if (divID == undefined) { divID = "displayText"; }
    if (buttonState1Class == undefined) { buttonState1Class = "show"; }
    if (buttonState2Class == undefined) { buttonState2Class = "hide"; }
    if (divState1Class == undefined) { divState1Class = "hiding"; }
    if (divState2Class == undefined) { divState2Class = "showing"; }
    //function
    var toggler = document.getElementById(buttonID);
    var toggleee = document.getElementById(divID);
    if (toggler.className == buttonState2Class) {
        toggler.setAttribute("class", buttonState1Class);
        toggler.setAttribute("className", buttonState1Class); //IE HACK
        toggleee.setAttribute("class", divState1Class);
        toggleee.setAttribute("className", divState1Class); //IE HACK
    }
    else {
        if (toggler.className == buttonState1Class) {
            toggler.setAttribute("class", buttonState2Class);
            toggler.setAttribute("className", buttonState2Class); //IE HACK
            toggleee.setAttribute("class", divState2Class);
            toggleee.setAttribute("className", divState2Class); //IE HACK
        }
    }
}
