addLoadEvent(iFrames)
addLoadEvent(clubCardHovers)

function clubCardHovers()
{
	if (!getElem("clubThumbs")) return false;
	var ulElem = getElem("clubThumbs");
	var arrImgs = ulElem.getElementsByTagName("img");
	var baseUrl = "gfx/clubcards_small/"
	
	for (i=0; i<arrImgs.length; i++)
	{
		var src = (arrImgs[i].src).split("/");
		var fileName = src[src.length-1];
		arrImgs[i].normalState = baseUrl+fileName
		arrImgs[i].hoverState = baseUrl+"_"+fileName;

		arrImgs[i].onmouseover = function()
		{
			this.src = this.hoverState;
		}

		arrImgs[i].onmouseout = function()
		{
			this.src = this.normalState;
		}
	}
}

function iFrames()
{
	var elmIframe = document.getElementsByTagName("iframe")[0];
	if(elmIframe == undefined) return false;

	var hoogteIframe;
	var veiligheidsMarge1 = 75;
	var veiligheidsMarge2 = 130;

	var elmContent = getElem("content");

	if (!elmContent)
	{
		veiligheidsMarge2 = 24;
		elmContent = getElem("contentBreed");
	}

	var contentHeight = getHeight(elmContent);
	
	var vpHeight = viewPortSize()[1];		// Viewport hoogte
	var iframeY = findPos(elmIframe)[1];
	
	if ((vpHeight - iframeY) - veiligheidsMarge2 < contentHeight)
	{
		hoogteIframe = contentHeight - veiligheidsMarge1;
	}
	else
	{
		hoogteIframe = (vpHeight - iframeY) - veiligheidsMarge2;
	}
	
	setHeight(elmIframe,hoogteIframe);
}

function iFrameScaler()
{
	// Schaalt iframe hoogte aan de hand van de inhoud daarvan.
	// Werkt niet cross domain!

	var iFrame = window.frames['iFrame'];
	var iFrameHoogte = iFrame.document.body.scrollHeight;
	document.getElementById("iFrame").style.height = iFrameHoogte+"px";
}

function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	} else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

function getElem(id)
{
	if (!document.getElementById(id)) return false;
	return document.getElementById(id);
}

function getHeight(elm)
{
	return elm.offsetHeight;
}

function getWidthBreedte(elm)
{
	return elm.offsetWidth;
}

function setHeight(elm,height)
{
	elm.style.height = height+"px";
}

function findPos(obj)
{
	// Vind de absolute positie van een object.
	// Returned array: 0 = x, 1 = y
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft, curtop];
}

function viewPortSize(dimension)
{
	// Meet afmetingen van de viewport.
	// Returned array: 0 = width, 1 = height
	var myWidth = 0, myHeight = 0;

	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return [myWidth,myHeight];
}