/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Ultimater, Mr J :: http://www.webdeveloper.com/forum/showthread.php?t=77389 */

var expand_all = false;

function toggleMe(a)
{
	var e = document.getElementById(a);
	
	if (!e)
		return true;
	
	if (e.style.display == "block")
	{
		e.style.display = "none"
	}
	else
	{
		e.style.display = "block"
	}
	
	return true;
}


/*
 * used on earmarks bills
 */

function expandById(id)
{
  toggleMe(id); 
  var link = document.getElementById(id + '_all');
   
  if (expand_all == false) {
     link.innerHTML = 'Collapse all bill subsections';   
     expand_all = true;     
  }
  else
  {
     link.innerHTML = 'View all bill subsections'; 
     expand_all = false;
  }


}
function expandAll()
{

  var uls = document.getElementsByTagName('ul');
  var link = document.getElementById('expand_all');

  for(var i=0; i <  uls.length; i++)
  {
    if(uls[i].className  == 'expand-all')
    {
      if (expand_all == true) {

        if (uls[i].style.display == 'block') {
          uls[i].style.display = 'none';
          
        }


      }
      else {
        if (uls[i].style.display == 'none') {
          uls[i].style.display = 'block';
          
        }


      }
      
    }
    
  }
  
  var links = document.getElementsByTagName('a');
  
  for(var i=0; i < links.length; i++)
  {
    if (expand_all == false) {
      if (links[i].className == 'earmarks_plus') {
        links[i].className = 'earmarks_minus';
      }
    }else{
      if (links[i].className == 'earmarks_minus') {
        links[i].className = 'earmarks_plus';
      }      
    }
    
    
  }
  
  if (expand_all == false) {
   expand_all = true;
   link.innerHTML = 'Collapse all';   
  }
  else {
    expand_all = false;
    link.innerHTML = 'Show all bill sections and subsections';    
  }
  
}

function expandThis(id, a_id, s)
{
	var doc = document.getElementById(a_id);

  if(doc.className == 'earmarks_plus')
  {
    doc.className = 'earmarks_minus';
    if (s != '') {
      doc.title = 'Collapse all subsections of this bill';
    }else
    {
      doc.title = 'Collapse all sections of this bill';      
    }
  }
  else
  {
    doc.className = 'earmarks_plus'; 
    if (s != '') {
      doc.title = 'Show all subsections of this bill';
    }else
    {
      doc.title = 'Show all sections of this bill';      
    }    

  }
  
  toggleMe(id);
  
}
