function activeLink (link_id, submenu_id) {
	setActiveLink (link_id);		// Remove the "class='active'" from other links, and make this one active
	showLayer (submenu_id);			// Hide submenus, and show the new active one
}

function setActiveLink (link_id) {
	// Make all menus inactive
	var i = 1;
	for (i = 1; i <= 5; i++) {
		link_full_id = 'topmenu_link_'+ i;
		topmenu_link = document.getElementById(link_full_id);

		if (link_full_id == link_id) {
			topmenu_link.className = 'active';
		} else {
			topmenu_link.className = '';
		}
	}
}

function showLayer (whichlayer)
{
	var elem, vis
	if (document.getElementById)
		elem = document.getElementById( whichlayer );
	else if (document.all)
		elem = document.all[whichlayer];
	else if (document.layers)
		elem = document.layers[whichlayer];
	vis = elem.style;

	vis.display = 'block'; 		// Layer tonen
	if (whichlayer != 'home_sub_menu_1')
		hideLayer('home_sub_menu_1');
	if (whichlayer != 'home_sub_menu_2')
		hideLayer('home_sub_menu_2');
	if (whichlayer != 'home_sub_menu_3')
		hideLayer('home_sub_menu_3');
	if (whichlayer != 'home_sub_menu_4')
		hideLayer('home_sub_menu_4');
	if (whichlayer != 'home_sub_menu_5')
		hideLayer('home_sub_menu_5');
}

function hideLayer (whichlayer)
{
	var elem, vis
	if (document.getElementById)
		elem = document.getElementById( whichlayer );
	else if (document.all)
		elem = document.all[whichlayer];
	else if (document.layers)
		elem = document.layers[whichlayer];
	vis = elem.style;

	vis.display = 'none';
}

function toggleLayer (whichlayer)
{
	var elem, vis
	if (document.getElementById)
		elem = document.getElementById( whichlayer );
	else if (document.all)
		elem = document.all[whichlayer];
	else if (document.layers)
		elem = document.layers[whichlayer];
	vis = elem.style;

	if (vis.display == 'block')
		vis.display = 'none'; 		// Layer verstoppen
	else
		vis.display = 'block';

}

var currentBalloon = null;

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

function findPosX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft;
            obj = obj.offsetParent;
        }
        if ( obj != null )
            curleft += obj.offsetLeft;
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop;
            obj = obj.offsetParent;
        }
        if ( obj != null )
            curtop += obj.offsetTop;
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

function hideBalloon()
{
  if ( !document.getElementById ) return;
  var balloon = document.getElementById("balloon");
  if ( balloon )
  {
    balloon.style.display = 'none';
    currentBalloon = null;
  }
  return false;
}

function displayBalloon(anImg)
{
	if ( !document.getElementById ) return;

	var imgID = anImg.getAttribute('id');
	if ( imgID == currentBalloon ) return false;

	currentBalloon = imgID;
	var objX = findPosX(anImg);
	var objY = findPosY(anImg);

	var balloon = document.getElementById("balloon");
	if ( balloon )
	{
	if ( balloon.childNodes )
	{
	  while ( balloon.childNodes.length > 0 )
	  {
	    balloon.removeChild(balloon.childNodes[0]);
	  }
	}
	var closeElt = document.createElement('img');
	closeElt.setAttribute("id","closebox");
	closeElt.setAttribute("src","http://localhost/includes/images/layout/closebox.png");
	closeElt.onclick = function(){ return hideBalloon(); }
	balloon.appendChild(closeElt);

	var newElt = document.createElement('div');
	newElt.setAttribute("id","balloon_contents");
	balloon.appendChild(newElt);

	var scriptElt = document.createElement('script');
	scriptElt.setAttribute("type","text/javascript");
	var scriptFile = new String("http://localhost/page_calendar_balloon.php?date=");
	scriptFile = scriptFile.concat(currentBalloon,"");
	scriptElt.setAttribute("src",scriptFile);
	balloon.appendChild(scriptElt);

	balloon.style.top = (objY-226) + 'px';
	balloon.style.left = (objX-300+45) + 'px';
	balloon.style.display = 'block';
	}
	return false;
}

function bodyLoad() {
	//showLayer('home_sub_menu_1');

}

function resizeAlbumFoto() {
	if (document.getElementById('fotoalbum_foto')) {
		foto = document.getElementById('fotoalbum_foto');

		if (foto.width > 500) {
			foto.width = 500;
		}
	}


}
