<!--
//<![CDATA[
/*
 * Javascript for the HCMC Tapor page
 * 
 * October, 2005 by Mark van Hoek 
**/

//set up locations of the images for expanding/contracting the submenus
imgout=new Image(11,11); //the numbers here do not affect the displayed size of the image
imgin=new Image(11,11);
imgout.src="images/d.jpg";
imgin.src="images/u.jpg";

//set the image source for the image item
function filter(imagename,objectsrc){
	if (document.images && document.images[imagename]){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}

/* Find all elements of a certain style class
 * NN6 and IE4+
**/
function getElementsByStyleClass (className) {
  var all = document.all ? document.all : document.getElementsByTagName('*');
  var elements = new Array();
  for (var e = 0; e < all.length; e++)
    if (all[e].className == className)
      elements[elements.length] = all[e];
  return elements;
}

/* Hide all elements with the class name className
 * NN6 and IE4+
**/
function toggleByClass(className) {
	var elements = getElementsByStyleClass(className);
	//alert(elements.length);
	for (i = 0; i < elements.length; i++) {
		//alert(elements[i].id);
		toggleLayer(elements[i].id);
	}
	return;
}

//hide add elements UNDER the element with id=$id and class=$class
function toggleByID(id, className) {
	var elements = document.getElementById(id).childNodes;
	for (i = 0; i < elements.length; i++) {
		if (elements[i].className == className) {
			//alert("toggleByID: " + i + ' ' + elements[i].id  + ' ' + elements[i].className);
			toggleLayer(elements[i].id);
		}
	}
	return;
}

/* Make div's visible or hidden using display=none/block
 * 
 * id = id of the element to hide, e.g. <div id="unique">hide this</div>
 *
**/
function toggleLayer(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		//alert("toggleLayer: " + document.getElementById(id).id);
		if (document.getElementById(id).style.display == 'none'){
			document.getElementById(id).style.display = 'block';
			filter(('img_'+id),'imgin');
		} else {
			filter(('img_'+id),'imgout');
			document.getElementById(id).style.display = 'none';
		}
	} else {
		if (document.layers) {
			if (document.id.display == 'none'){
				document.id.display = 'block';
				filter(('img_'+id),'imgin');
			} else {
				filter(('img_'+id),'imgout');
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == 'none'){
				document.all.id.style.display = 'block';
			} else {
				filter(('img_'+id),'imgout');
				document.all.id.style.display = 'none';
			} //end if (document.all.id.style.visibility
		} //end if (document.layers)
	} //end if (document.getElementById)
} //end function toggleLayer


/* Add a function to the window onload event nicely - does not delete current onload events
 * 
 * strFunction - the function name & parameters enclosed in quotes, 
 * e.g. "myFunction(param1)"
**/
function addOnLoad(func) {
  /*var currentOnload = window.onload;
	if (!currentOnload) {
	  alert('a new onload: ' + strFunctionCall);
		window.onload = strFunctionCall;
	} else {
	  alert('adding to onload: ' + strFunctionCall);
		window.onload = function() { try{ currentOnload(); } finally { strFunctionCall(); }};
	}*/
   var oldonload = window.onload;
   if (typeof window.onload != 'function') {
      //window.onload = func;
	   alert('a new onload: ' + strFunctionCall);
   } else {
	   alert('adding to onload: ' + strFunctionCall);
      //window.onload = function() { try{ currentOnload(); } finally { strFunctionCall(); }};
  }
  alert('got here');
}

//]]>
-->

