function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function insertAfter(newElement,targetElement) {
  var parent = targetElement.parentNode;
  if (parent.lastChild == targetElement) {
    parent.appendChild(newElement);
  } else {
    parent.insertBefore(newElement,targetElement.nextSibling);
  }
}

function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= " ";
    newClassName+= value;
    element.className = newClassName;
  }
}
function explodeArray(item,delimiter) { // this function to explode any path
 tempArray=new Array(1);
 var Count=0;
 var tempString=new String(item);
 while (tempString.indexOf(delimiter)>0) {
  tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
  tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
  Count=Count+1
 }
 tempArray[Count]=tempString;
 return tempArray;
}

	
function highlightPage() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("navigation_subsections")) return false;
  var nav = document.getElementById("navigation_subsections");
  var links = nav.getElementsByTagName("a");
		current_path = explodeArray(document.location,"cn"); // second parameter needs to be set to the point if explosion
		exploded_path = explodeArray(current_path[1],'/'); // second paramter defines charcter in string to explode
		var current_path = exploded_path[exploded_path.length-1]; // returns last index of array, i.e. index.php
  for (var i=0; i<links.length; i++) {
		var linkurl = links[i].getAttribute("href");
		this_path = explodeArray(linkurl,"cn"); // second parameter needs to be set to the point if explosion
		this_exploded_path = explodeArray(this_path[1],'/'); // second paramter defines charcter in string to explode
		var this_current_path = this_exploded_path[this_exploded_path.length-1]; // returns last index of array, i.e. index.php
if (current_path.indexOf(this_current_path) != -1) {
      links[i].className = "here";
      var linktext = links[i].lastChild.nodeValue.toLowerCase();
	}
  }
}
addLoadEvent(highlightPage);

// Alpha tint on all images contained within a DIV named image_tint
var FIsOn = 0;
function onMouseOverFuncion(aObjectID){
	FIsOn = 1;
	var pImagesDiv = document.getElementById('image_tint');
	var pAllImages = pImagesDiv.getElementsByTagName('img');
	
	for(var i=0; i < pAllImages.length; i++ ) {		
			pAllImages[i].className = 'tint';		
	}	
	for (var i=0; i < pAllImages.length; i++ ) {
		if (pAllImages[i].className == 'tint' && pAllImages[i].id != aObjectID) {
			pAllImages[i].className = 'tint_off';
		}
	}

}

function onMouseOutFuncion(aObjectID){
	FIsOn = 0;
	setTimeout('checkIsOn()', 500);
}

function checkIsOn(){
	if(FIsOn == 0){
		var pImagesDiv = document.getElementById('image_tint');
		var pAllImages = pImagesDiv.getElementsByTagName('img');
	
		for(var i=0; i < pAllImages.length; i++ ) {		
				pAllImages[i].className = 'tint';		
		}
	}
}



function showSection() {
		if (!document.getElementById) return false;
		if (!document.getElementById("close")) return false;
		var div = document.getElementById("close");
		div.setAttribute("id", "open");	
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function add_load_event(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
		if (oldonload) {
			oldonload();
		}
		func();
		}
	}
}
