 function showAll(visibility)
{
	func = visibility ? expand : collapse;
	target = "_content";
	
	nodes = document.getElementsByTagName('div');
	for (i = 0; i < nodes.length; i++) {
		node = nodes.item(i);
		
		id = node.getAttribute("id");
		if (id != null && id.indexOf(target) == (id.length - target.length) )
		{
			var targetID = id.substring(0, id.indexOf(target));
			func(targetID);
		}
		
	}
}

var imagePrefix = 'http://dumontierlab.com/images/';
var expandImage = imagePrefix + 'plus.jpg';
var collapseImage = imagePrefix + 'minus.jpg';

function getElement(id, component)
{
    return document.getElementById(id + '_' + component);
}

function Expanded(id)
{
    var content = getElement(id, 'content');
	return (content.style.display == 'none');
}

function doExpandCollapse(id)
{
    var content = getElement(id, 'content');
    if (content.style.display == 'none')
    {
        expand(id);
    }
    else
    {
        collapse(id);
    }
}

function expand(id)
{
    var content = getElement(id, 'content');
    var summary = getElement(id, 'summary');
    var expand = getElement(id, 'expand');

    content.style.display = 'block';
    expand.src = collapseImage;

    if (summary != null)
    {
        summary.style.display = 'none';
    }
}

function collapse(id)
{
    var content = getElement(id, 'content');
    var summary = getElement(id, 'summary');
    var expand = getElement(id, 'expand');

    content.style.display = 'none';
    expand.src = expandImage;

    if (summary != null)
    {
        summary.style.display = 'block';
    }
}


function doExpandCollapseHTML(id, imgCol, imgExp, title) {

    var content = getElement(id, 'content');
    if (content.style.display == 'none')
    {
        expandHTML(id, imgCol, title);
    }
    else
    {
        collapseHTML(id, imgExp, title);
    }
	
}

function expandHTML(id, img, title)
{
    var content = getElement(id, 'content');
    var summary = getElement(id, 'summary');
    var expand = getElement(id, 'expand');

    content.style.display = 'block';
    if(img!=null) {
    	expand.src = img;
    }
    else {
	    expand.src = collapseImage;
    }

    if(title!=null) {
    	expand.title = "Collapse " + title;
    	expand.alt = "Collapse " + title;
    }

    if (summary != null)
    {
        summary.style.display = 'none';
    }
}

function collapseHTML(id, img, title)
{
    var content = getElement(id, 'content');
    var summary = getElement(id, 'summary');
    var expand = getElement(id, 'expand');

    content.style.display = 'none';
    if(img!=null) {
    	expand.src = img;
    }
    else {
	    expand.src = expandImage;
    }

    if(title!=null) {
    	expand.title = "Expand " + title;
    	expand.alt = "Expand " + title;
    }

    if (summary != null)
    {
        summary.style.display = 'block';
    }
}
