function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
		xScroll = document.documentElement.scrollWidth;
		yScroll = document.documentElement.scrollHeight;
	} else { // Explorer Mac...would also work in Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) { // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}	
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

/* Algemene functies */
function getNodeValue(obj,tag) { /* XML uitlezen */
    return obj.getElementsByTagName(tag)[0].firstChild.nodeValue;
}

function getSingleData(response,tag) { /* XML uitlezen */
	return response.getElementsByTagName(tag)[0].firstChild.data;
}

function setLoading(state) { /* Overlay laten zien of weghalen */
	if(state == 'inactive') {
		document.getElementById('overlay').style.display = 'none';
		document.getElementById('loading').style.display = 'none';
	} else {
		if(document.getElementById('overlay')) {
			document.getElementById('overlay').style.display = 'block';
		} else {
			var newdiv = document.createElement('div');
			newdiv.setAttribute('id', 'overlay');
			document.body.appendChild(newdiv);
		}
		document.getElementById('loading').style.display = 'block';
	}
}

/* Formulieren */
function activateField(id) { /* Veld/button actief maken */
	document.getElementById(id).disabled = false;
}

function focusField(id) { /* Zet cursor in veld */
	$(id).focus();
}

function submitForm(form) { /* Verzenden van een formulier */
	setLoading();
	form.submit();
}

/* Toetsaanslagen */
function checkKeyCode(evt) {
	var charCode = (evt.which) ? evt.which : event.keyCode;
	return charCode;
}

function checkCapsLock( e ) {
	var key, shift;
	
	var caps = document.getElementById('error');
	
	if (typeof e == 'undefined') {
		e = window.event;
		
		if (typeof e == 'undefined') {
			return;
		}
	}  
		
	if (e.which) { // netscape, firefox
		key = e.which;
	} else if (e.keyCode) { // IE
		key = e.keyCode;
	} else {
		return;
	}
		
	if (typeof e.shiftKey != 'undefined') { // IE, firefox
		shift = e.shiftKey;
	} else if (e.modifiers) { // netscape
		shift = (e.modifiers & 4); // 3e bit is shift
	} else {
		return;
	}
		
	if ((key > 64) && (key < 91)) {
		if (shift == false) {
			caps.innerHTML = 'Let op! Uw Caps Lock staat aan. E-mailadres en wachtwoord zijn hoofdletter gevoelig!';
		} else {
			caps.innerHTML = '';
		}
	} else if ((key > 96) && (key < 123)) {
		if (shift == true) {
			caps.innerHTML = 'Let op! Uw Caps Lock staat aan. E-mailadres en wachtwoord zijn hoofdletter gevoelig!';
		} else {
			caps.innerHTML = '';
		} 
	}
}


function filterInstructeur() {
	location.href = linkprefix + 'instructeurs/' + $('woonplaats').value + '/' + $('resultaten').value + '/';
}

function uitloggen() {
	setLoading();
	var antwoord = confirm('Weet je zeker dat je wilt uitloggen?');
	if(antwoord) {
		location.href = linkprefix + 'uitloggen/';
	}
	else {
		setLoading('inactive');
	}
}
