// This code is necessary for browsers that don't reflect the DOM constants
// (like IE).
// From the IDL Definition for a Node interface
if (!document.ELEMENT_NODE) {
  // NodeType
  document.ELEMENT_NODE                   = 1;
  document.ATTRIBUTE_NODE                 = 2;
  document.TEXT_NODE                      = 3;
  document.CDATA_SECTION_NODE             = 4;
  document.ENTITY_REFERENCE_NODE          = 5;
  document.ENTITY_NODE                    = 6;
  document.PROCESSING_INSTRUCTION_NODE    = 7;
  document.COMMENT_NODE                   = 8;
  document.DOCUMENT_NODE                  = 9;
  document.DOCUMENT_TYPE_NODE             = 10;
  document.DOCUMENT_FRAGMENT_NODE         = 11;
  document.NOTATION_NODE                  = 12;
}


/*
 * Function print the contents of the footer
 */
function printFooter() {
    document.write('Last modified ' + document.lastModified);
    document.write('<br />');
    document.write('Problems with this webpage? Contact the webmaster at <a id="webmaster" href="mailto:webmatser@cityofbathac.org">webmaster@cityofbathac.org</a>');
}

var highlighted = false;
function HighLightItem(pr_Element)
{
    if (highlighted) {
        pr_Element.className = "";
        highlighted = false;
    } else {
        pr_Element.className = "highlighted";
        highlighted = true;
    }
}

function activateTab(pr_Element) { 
    if (pr_Element != null) {
        pr_Element.className = "activeIndex";
    } else {
        pr_Element.className = "";
    }
} // End function activateTab()

function buttonLink (pr_Element, pr_Link) {
    location.href = pr_Link;
}

/*
 * Function to insure that the footer sits at the bottom of the page
 */
function setFooter() {
    // Get the heights of the existing elements
    contentHeight   = document.getElementById("content").offsetheight;
    headerHeight    = document.getElementById("header").offsetheight; 
    welcomeHeight   = document.getElementById("welcome").offsetheight; 
    footerHeight    = document.getElementById("footer").offsetheight; 

    // Set the height of the index element
    //document.getElementById("index").height = 10px;
}

var character = 0;
var display = "";
var tmp = ""
var cursor = "|\\|/-|";
var loopNumber = 0;
var timer;

function typeText(pr_Text) {
    if (loopNumber > 5) {
        window.clearTimeout(timer);
        document.getElementById("headlines").innerHTML = pr_Text;
        return;
    }
    if (character <= pr_Text.length - 1) {
        display += pr_Text.charAt(character);
        current = cursor.charAt(character % cursor.length);
        document.getElementById("headlines").innerHTML = display + current;
        character++;
    } else {
        character = 0;
        display = "";
        loopNumber++;
        }
    tmp = pr_Text;
    timer = window.setTimeout("typeText(tmp)", 100);
} // end typeText()';


// AJAX

// Hides a JavaScript DOM ELEMENT
function hide(elt)
{
    if (elt) elt.style.display = 'none';
}

// Determines whether a JavaScript DOM ELEMENT is hidden
function ishidden(elt)
{
    return elt.style.display == 'none';
}

// Displays a JavaScript DOM ELEMENT
function show(elt)
{
    if (elt) elt.style.display = 'block';
}

// Populates the given SELECT ELEMENT with the data
function populateSelect(elt, arr)
{
    elt.options.length = 0;
    elt.options[0] = new Option('', '');
    for (i = 0; i < arr.length; i++) {
        elt.options[i+1] = new Option(arr[i][0], arr[i][1]);
    }
    elt.selectedIndex = 0;
}

// Populates the given SELECT ELEMENT with the data
function populateSelectList(elt, arr)
{
    elt.options.length = 0;
    for (i = 0; i < arr.length; i++) {
        elt.options[i] = new Option(arr[i][0], arr[i][1]);
    }
    elt.selectedIndex = -1;
}

// Empties the contents of a SELECT ELEMENT
function clearSelect(elt)
{
    elt.options.length = 0;
    elt.selectedIndex = 0;
}

function DateWindow(p_URL) 
{
    var newWindow;
    var props = 'scrollBars=no,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=300,height=80';
    newWindow = window.open(p_URL, "Select_Date", props);
}

function ClubWindow(p_URL) 
{
    var newWindow;
    var props = 'scrollBars=no,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=300,height=270';
    newWindow = window.open(p_URL, "Select_Club", props);
}
