// JavaScript Document
window.onerror = stopError
function stopError() {
	return true;
}

// We need the path bacause of the base-tag
var baseHref = "";
function getBase(){
     var baseTag = document.getElementsByTagName("base");
     for(var i = 0; i < baseTag.length; i++){
          baseId = baseTag[i].id;
          baseHref = baseTag[i].href;
     }
}
getBase();

// We need to modify the anchors bacause of the base-tag
function replaceAnchors(){
     var linkTags = document.getElementsByTagName("a");
     for(var i = 0; i < linkTags.length; i++){
          linkHref = linkTags[i].href;
		  anchorPos = linkHref.indexOf("#");
		  if(anchorPos!=-1){
			anchorName = linkHref.substr(anchorPos);
			linkTags[i].href = "javascript:void(document.location.hash='"+anchorName+"')";
		 }
     }
}
if(window.addEventListener) window.addEventListener('load', replaceAnchors, false);
else if (window.attachEvent) window.attachEvent("onload", replaceAnchors);

function doPrint(_base, _text, _logo, _adres) {
	if (document.getElementById(_text)) {
		tekst = document.getElementById(_text).innerHTML;
	}
	else {
		alert("Container niet gevonden");
	}
	tekst = "<html><head><title>Printvriendelijke versie</title><base href='"+_base+"'><link href='css/print.css' rel='stylesheet' /></head><body>"+_logo+"<br /><br />"+tekst+"<br /><br /><hr /> "+_adres+"<br /><br /><br /><br /><center><a href='javascript: window.print()'>Pagina printen</a> &nbsp;&nbsp; <a href='javascript: window.close()'>Venster sluiten</a></center></body></html>";
	printWin = window.open('','','width=700,height=600,scrollbars=yes,resizable=yes,titlebar=0');
	printWin.document.write(tekst);
	printWin.document.close();
	printWin.print();
}
