// Ajax initialiseren
initAjax();

// Instellingen zetten
ajax.alertOnError = true;

function showInfoDiv() {
	div = document.getElementById("infodiv");
	
	topval = getWindowHeight() + getScrollY() - div.clientHeight - 15;
	
	div.style.top = topval + 'px';
	div.style.visibility = 'visible';
}

function hideInfoDiv() {
	div = document.getElementById("infodiv");
	div.style.visibility = 'hidden';
}

function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} 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;
		}
	} else if (obj.y){
		curtop += obj.y;
	}
	return curtop;
}

function getWindowHeight() {
	if (typeof( window.innerWidth ) == 'number') return window.innerHeight;	//Non-IE
	if (document.documentElement && document.documentElement.clientHeight) return document.documentElement.clientHeight;	//IE 6+ in 'standards compliant mode'
	if (document.body && document.body.clientHeight) return document.body.clientHeight;	//IE 4 compatible
	return 0;
}

function getWindowWidth() {
	if (typeof( window.innerWidth ) == 'number') return window.innerWidth;		//Non-IE
	if (document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;	//IE 6+ in 'standards compliant mode'
	if (document.body && document.body.clientWidth) return document.body.clientWidth; //IE 4 compatible
	return 0;
}

function getScrollY() {
	if (typeof(window.pageYOffset) == 'number') return window.pageYOffset; //Netscape compliant
	if (document.body && document.body.scrollTop) return document.body.scrollTop;	//DOM compliant
	if (document.documentElement && document.documentElement.scrollTop) return document.documentElement.scrollTop;	//IE6 standards compliant mode
	return 0;
}

function getScrollX() {
	if (typeof(window.pageXOffset) == 'number') return window.pageXOffset; //Netscape compliant
	if (document.body && document.body.scrollLeft) return document.body.scrollLeft;	//DOM compliant
	if (document.documentElement && document.documentElement.scrollLeft) return document.documentElement.scrollLeft;	//IE6 standards compliant mode
	return 0;
}

function externalLinks() { 
	anchors = $$('a[rel=external]');
	
	for (i=0;i<anchors.length;i++)
	{
		anchors[i].setAttribute('target', '_blank');
	}
	
	forms = $$('form.external');
	
	for (i=0;i<forms.length;i++)
	{
		forms[i].setAttribute('target', '_blank');
	}
} 
window.onload = externalLinks;
