$(document).ready(function() {
	initAankeilers();
	externalLinks();
	fillDatefields();
});



//====================== externe links in nieuw venster
function externalLinks() {
	var extLinks = $(".external");
	for (var i=0; i<extLinks.length; i++) {
		anchors = extLinks[i].getElementsByTagName('a');
		for (var j=0; j<anchors.length; j++) {
			anchors[j].onclick = function() {
				this.target = '_blank';
			}
		}
	}
}
//====================== 



//====================== externe links in nieuw venster
function fillDatefields() {
	var def = 'dd-mm-jjjj';
	var datefields = $(".ddmmjjjj");
	for (var i=0; i<datefields.length; i++) {
		datefields[i].value = def;
		datefields[i].onfocus = function() {
			if (this.value == def)
				this.value = '';
		}
		datefields[i].onblur = function() {
			if (this.value == '')
				this.value = def;
		}
	}
}
//====================== 



//====================== voegt rollover en click functie toe aan class="preview"
function initAankeilers() {
	var aankeilers = $(".preview");
	for (var i=0; i<aankeilers.length; i++) {
		var anchors = aankeilers[i].getElementsByTagName("a");
		if (anchors.length > 0) {
			if (typeof(document.documentElement.style.maxHeight)=='undefined' && aankeilers[i].className.indexOf('external') > -1) {
				aankeilers[i].style.backgroundImage = 'url("/img/blt-extern.gif")';
			}
			aankeilers[i].setAttribute("title",anchors[anchors.length-1].getAttribute("title"));
			aankeilers[i].ref = anchors[anchors.length-1].getAttribute("href");
			aankeilers[i].onclick = function() {
				if (this.className.indexOf('external') > -1)
					window.open(this.ref, 'popup');
				else
					document.location.href = this.ref;
			}
			aankeilers[i].onmouseover = function() {
				if (document.all)
					window.status = this.ref;
				else
					window.status = 'http://' + document.domain + this.ref;
				$(this).addClass("over");
				if (typeof(document.documentElement.style.maxHeight)=='undefined' && this.className.indexOf('external') > -1)
					this.style.backgroundImage = 'url("/img/blt_extern_o.gif")';
				else if (typeof(document.documentElement.style.maxHeight)=='undefined')
					this.style.backgroundImage = this.style.backgroundImage.replace('.gif','-o.gif');
			}
			aankeilers[i].onmouseout = function() {
				window.status = "";
				$(this).removeClass("over");
				if (typeof(document.documentElement.style.maxHeight)=='undefined' && this.className.indexOf('external') > -1)
					this.style.backgroundImage = 'url("/img/blt_extern.gif")';
				else if (typeof(document.documentElement.style.maxHeight)=='undefined')
					this.style.backgroundImage = this.style.backgroundImage.replace('-o.gif','.gif');
			}
		} else {
			aankeilers[i].style.backgroundImage = "none";
			aankeilers[i].style.cursor = "default";
		}
	}
}
//====================== 



