function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
		anchor.target = "_blank";
		anchor.className = "external";
		}
	}
}

function initDLHide()
{
 var DTs,i,tohide,tohideobj,isexpanded;
// grab all second level headlines and loop over them 
 DTs=document.getElementsByTagName('dt');
 for (i=0;i<DTs.length;i++)
 {
// get next sibling (the element to hide, check that it is an element
  tohide=DTs[i].nextSibling;
  while(tohide.nodeType!=1)
  {
   tohide=tohide.nextSibling;
  }
  DTs[i].tohideobj=tohide;
// add the hover function onmouseover and onmouseout 
  DTs[i].onmouseover=function(){hover(this,this.tohideobj,1);}
  DTs[i].onmouseout=function(){hover(this,this.tohideobj,0);}
// hide next element and add onclick event to the header to show and hide it
  juggleClass(tohide,'DThidden',1);
  juggleClass(DTs[i],'DTnormal',1);
  DTs[i].onclick=function(){collapse(this,this.tohideobj);return false}
 }
}
// hover function, adds the hover colour 
// unless the headline is an active trigger
function hover(o,ho,state)
{
 if(checkClass(ho,'DThidden'))
 {
  if(state==1)
  {
   juggleClass(o,'DTnormal',0);
   juggleClass(o,'DThover',1);
  } else {
   juggleClass(o,'DTnormal',1);
   juggleClass(o,'DThover',0);
  }
 }
}
// collapse function, shows and hides the element and sets the highlight 
// colour of the headline
function collapse(o,ho)
{
 if(checkClass(ho,'DThidden'))
 {
  juggleClass(ho,'DThidden',0);
  juggleClass(o,'DTnormal',0);
  juggleClass(o,'DThighlight',1);
 }else{
  juggleClass(ho,'DThidden',1);
  juggleClass(o,'DThighlight',0);
  juggleClass(o,'DTnormal',1);
 }
}
	function juggleClass(o,c,s)
	{
		if(s==0) 
		{
			o.className=o.className.replace(c,'');	
		}
		if (s==1 && !checkClass(o,c))
		{
			o.className+=' '+c
		}
	}

function checkClass(o,c)
{
	var re=new RegExp('\\b'+c+'\\b');
	return re.test(o.className);
}


function tableChange() {
	var rows = window.document.getElementsByTagName('tr');
	for(var i = 0; i < rows.length; i++) {
		(i%2==0)? rows.item(i).style.backgroundColor = "#ffffff" : rows.item(i).style.backgroundColor = "#f8f8f8"
	}
}

function init() {
	externalLinks();
	initDLHide();
	tableChange();	
}
window.onload=init;