/**
 *
 * 2008-04-15   Luke Quinnell, BoxUK  Created
 * 
 */

function showhide(id, container)
{
    var number_of_tabs = 6;
    var bro;
    
    if(container!=null && document.getElementById(container)) {
        bro = getNextSibling(document.getElementById(container));
        cleanWhitespace(bro);
    }
    
    for(var i=1; i <= number_of_tabs; i++)
    {
        if(container==null) {
            obj = document.getElementById('fragment-'+i);
            tab = document.getElementById('tab'+i);
        } else {
            obj = bro.childNodes[i-1];
            tab = document.getElementById(container).getElementsByTagName('li')[i-1];
        }
        
        if(i == id)
        {
            obj.style.display = "block";
            if(tab)
            {
                tab.className = "active";
            }
        }
        else
        {
            obj.style.display = "none";
            if(tab)
            {
                tab.className = "not_active";
            }
        }
    }
}

var notWhitespace = /\S/;
function cleanWhitespace(node) {
  for (var x = 0; x < node.childNodes.length; x++) {
    var childNode = node.childNodes[x]
    if ((childNode.nodeType == 3)&&(!notWhitespace.test(childNode.nodeValue))) {
// that is, if it's a whitespace text node
      node.removeChild(node.childNodes[x])
      x--
    }
    if (childNode.nodeType == 1) {
      cleanWhitespace(childNode)
    }
  }
}

function getNextSibling(startBrother){
    endBrother=startBrother.nextSibling;
    while(endBrother.nodeType!=1)
    {
        endBrother = endBrother.nextSibling;
    }
    return endBrother;
} 