function init() {

    if (document.getElementById){

// just fill some variables to access the parts of the page we need later
    
        node = document.getElementById("faqlist");
        dtitems = node.getElementsByTagName("dt");
        dditems = node.getElementsByTagName("dd");
        links = node.getElementsByTagName("a");
        
        // set the ids of the list items based on the href
        
        for (i = 0; i < dditems.length; i++) {
            
            
            
            if (dtitems[i].parentNode.parentNode.nodeName == "DIV") {
            
            dditems[i].className = "faq-off"; // this hides the answers automatically, so if the user doesn't have javascript, all the answers still show up.
            
            
            
            dtid = "#q" + i;
            ddid = "#q" + i + "a";
            dtitems[i].setAttribute('id',dtid) // sets the id of all the LIs
            dditems[i].setAttribute('id',ddid) // sets the id of all the LIs
            
            dtitems[i].firstChild.firstChild.href = ddid; // this just makes the cursor go to a hand in all browsers. no other reason
            dtitems[i].firstChild.firstChild.title = "Click to view/hide the answer.";
            
            dtitems[i].firstChild.firstChild.onclick = switchit;
               
               }
            
        
        } // for loop
    
    }

}



/* --------------------------------------------- */


function switchit(e) {

    var clicked;
    
    // the following 3 if statements deal with the differences in how browsers deal with having events assigned programmatically
    // and how to reference the target of what has been clicked 
    
    
    // IE doesn't know the "e" variable for the event, it uses window.event
    if (!e) var e = window.event; // this is for IE only
    
    if (e.target) {
        clicked = e.target;
    }
    else if (e.srcElement) {
        clicked = e.srcElement;
    }
    if (clicked.nodeType == 3) {// defeat Safari bug
        clicked = clicked.parentNode;
    }
    
    clickedid = clicked.parentNode.parentNode.getAttribute('id');
    
    divshow = clickedid + "a";
    
    classoff = clicked.parentNode; // capture this to turn it off next time arround
        
    if (document.getElementById(divshow)!=null) { // if div to show actually exists        
         
    
        dsstatus = document.getElementById(divshow).className;
        
        
        if (dsstatus == "faq-off") {
            document.getElementById(divshow).className = "faq-on";
        }
        
        if (dsstatus == "faq-on") {
            document.getElementById(divshow).className = "faq-off";
        }
  
    }
    
    return false;
}


function toggle(which){

if (which == "on" || which == "off") {
    
   for (i = 0; i < dditems.length; i++) {
            

        if (dtitems[i].parentNode.parentNode.nodeName == "DIV") {

               if (which == "off") {
                   dditems[i].className = "faq-off"; 
               }
               else {
                 dditems[i].className = "faq-on";
                     
               }
         }
           
           } // for loop
     } // main if
     
     else {           
            
                which.parentNode.parentNode.className = "faq-off";
            
           }
        
 return false;
 
}

window.onload=init;