﻿function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
function $getId(obj) {
	if (document.getElementById) {
		if (obj && document.getElementById(obj)) {
			var foundObj = document.getElementById(obj);
			if (foundObj) return foundObj;
		}
	}
}
addLoadEvent(init);

function init() {
	ShowOrHideEmptyHighlightsAndSpotlights();
	//ShowOrHideEmptyArea();
	hideBackArrowOnHomePages();
}
function ShowOrHideEmptyHighlightsAndSpotlights() {
	var objHighlightBox, objSpotlightBox;
	if ($getId("BlockHighlights")) objHighlightBox = $getId("BlockHighlights");
	if ($getId("BlockSpotlights")) objSpotlightBox = $getId("BlockSpotlights");
	if (objHighlightBox) doShowOrHideEmpty(objHighlightBox,"LI");
	if (objSpotlightBox) doShowOrHideEmpty(objSpotlightBox,"LI");
}
function doShowOrHideEmpty(obj,objChildren) {
	if (obj) {
		var children = obj.getElementsByTagName(objChildren);
		if (children.length < 1) {
			obj.style.display = "none";
		} else {
			obj.style.display = "block";	
		}
	}
}
function ShowOrHideEmptyArea() {
	var objArea;
	if ($get("SubContentPage")) objArea = $get("SubContentPage");
	if(objArea) {
		if (objArea.innerHTML.length < 20) {
			objArea.style.display = "none";
			if (objArea.parentNode.className == "text") objArea.parentNode.style.display = "none";
		}
	}
}
function game(){
    var windowbreedte=750;
    var windowhoogte=420;

    var posx=(screen.width-windowbreedte)/2;
    var posy=(screen.height-windowhoogte)/2;

    window.open("http://games.stibat.nl/games/battle.asp","_blank","scrollbars=no,resizable=no,status=no,menubar=no,left="+posx+",top="+posy+",width="+windowbreedte+",height="+windowhoogte);
}
function hideBackArrowOnHomePages() {
	if ($get("Visual")) {
		if ($get("back")) {
			$get("back").style.display = 'none';
			$get("back").parentNode.style.backgroundImage = 'none';
		}
	}
}