/*
 * faq_accordion.js
 */

function toggle()
{
	// alert("Section State for layer " +  this.layer + " is now " + this.section_state);
	
	if (this.section_state == 0)
	    this.section_state = 1;
	else
	    this.section_state = 0;
	this.toggleArrow();
	this.toggleLayer();
	// alert("Section State for layer " +  this.layer + " is now " + this.section_state);
}

function collapse()
{
	this.section_state = 1;
	this.toggleLayer();
}

function expand()
{
	this.section_state = 0;
	this.toggleLayer();
}

function toggleArrow()
{
	// alert("Toggling arrow.  arrow image id = " + this.arrowImage);
    var elem, vis;
    elem = document.getElementById(this.arrowImage);

    // alert("section state = " + this.section_state);
    if (this.section_state == 1) {
        elem.src = '../images/pub_arrow1.gif';	
    } else {
        elem.src = '../images/pub_arrow2.gif';
    }
}

function toggleLayer()
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( this.layer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[this.layer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[this.layer];
  vis = elem.style;

  if (this.section_state == 1) {
  	   vis.display = 'none';
  } else {
       vis.display = 'block';	
  }
}

function collapseAll()
{	
    for (k=0; k<question_set1.length; k++) {
		question_set1[k].collapse();
	}
	
    for (k=0; k<question_set2.length; k++) {
		question_set2[k].collapse();
	}
	
    var elem, vis;
    if( document.getElementById ) // this is the way the standards work
        elem = document.getElementById( 'collapse_all' );
    else if( document.all ) // this is the way old msie versions work
        elem = document.all[this.layer];
    else if( document.layers ) // this is the way nn4 works
       elem = document.layers[this.layer];
    vis = elem.style;

    vis.display = 'none';

    var elem, vis;
    if( document.getElementById ) // this is the way the standards work
        elem = document.getElementById( 'expand_all' );
    else if( document.all ) // this is the way old msie versions work
        elem = document.all[this.layer];
    else if( document.layers ) // this is the way nn4 works
       elem = document.layers[this.layer];
    vis = elem.style;

    vis.display = 'block';

}

function expandAll()
{
    for (k=0; k<question_set1.length; k++) {
		question_set1[k].expand();
	}

    for (k=0; k<question_set2.length; k++) {
		question_set2[k].expand();
	}
	
    var elem, vis;
    if( document.getElementById ) // this is the way the standards work
        elem = document.getElementById( 'collapse_all' );
    else if( document.all ) // this is the way old msie versions work
        elem = document.all[this.layer];
    else if( document.layers ) // this is the way nn4 works
       elem = document.layers[this.layer];
    vis = elem.style;

    vis.display = 'block';

    var elem, vis;
    if( document.getElementById ) // this is the way the standards work
        elem = document.getElementById( 'expand_all' );
    else if( document.all ) // this is the way old msie versions work
        elem = document.all[this.layer];
    else if( document.layers ) // this is the way nn4 works
       elem = document.layers[this.layer];
    vis = elem.style;

    vis.display = 'none';

}

function FAQAccordion( section_prefix)
{
	//alert("Initializing " + section_prefix);
	this.section_prefix = section_prefix;
	this.section_state = 0;
	this.layer         = section_prefix + "_answr";
	this.arrowImage    = section_prefix + "_heading";
	
	/* Methods */
	this.toggle        = toggle;
	this.toggleArrow   = toggleArrow;
	this.toggleLayer   = toggleLayer;
	this.collapse      = collapse;
	this.expand        = expand;
}






