addEvent(window, 'load', infoBoxes_initialise, false);

var boxDataList = new Array();

// Class for boxData
function BoxData(fullContent, summaryContent, status){
	this.fullContent = fullContent;
	this.summaryContent = summaryContent;
	this.status = status;
}
// end class for BoxData

function infoBoxes_initialise(){

	// Go through all infoboxes and hide anything after the [|]
	var divs = document.getElementsByTagName('div');
	for(var d = 0; d < divs.length; d++){
		if(divs[d].className.search(/\bInfoBox\b/) == -1)
			continue;

		// Get the ID number of this box.
		var myIdNo = new String();
		myIdNo = divs[d].id;
		myIdNo = myIdNo.replace('InfoBox','');
		
		// Get the content
		if($('InfoBoxContent' + myIdNo)){
			var myContent = $('InfoBoxContent' + myIdNo).innerHTML;
			//alert(myContent);
			parts = myContent.split("<!-- End Summary -->");
			if(parts.length > 1){
				$('InfoBoxContent' + myIdNo).innerHTML = parts[0] + "...";

				// Add boxdata object to boxDataList
				boxDataList[myIdNo] = new BoxData(myContent, parts[0], 'closed');
				
				// Update link href
				$('InfoBoxReadMoreLink' + myIdNo).setAttribute('href','javascript:void(0);');
				
				// Do event handlers
				addEvent($('InfoBoxReadMoreLink' + myIdNo), 'click', infoBoxes_toggle, false);

			}
		}
		

		///addEvent(node, 'mouseover', getMoverFor(node), false);
		///addEvent(node, 'mouseout', getMoutFor(node), false);
	}
	
} // end infoBoxe_initialise

function infoBoxes_toggle(e){
if(!e) var e = window.event;
if(e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;

	var myIdNo = new String();
	myIdNo = targ.id;
	myIdNo = myIdNo.replace('InfoBoxReadMoreLink','');

	if(boxDataList[myIdNo].status == 'closed'){
		$('InfoBoxContent' + myIdNo).innerHTML = boxDataList[myIdNo].fullContent;
		boxDataList[myIdNo].status = 'open';
		addClass(targ, 'Active');
	}else{
		$('InfoBoxContent' + myIdNo).innerHTML = boxDataList[myIdNo].summaryContent + "...";
		boxDataList[myIdNo].status = 'closed';
		removeClass(targ, 'Active');
	}

} // end infoBoxes_toggle