<!--
//// IE hover and focus ******************************************************************************
function suckerfish(type, tag, parentId) {
	if (window.attachEvent) {
		window.attachEvent("onload", function() {
			var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag);
			type(sfEls);
		});
	}
}

ieHover = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" iehover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}

ieFocus = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" iefocus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" iefocus\\b"), "");
		}
	}
}

suckerfish(ieHover, "LI");
suckerfish(ieHover, "INPUT");
suckerfish(ieFocus, "INPUT");
suckerfish(ieFocus, "TEXTAREA");

//// Alternative for target="_blank" to validate the xhtml ******************************************************************************
function addEvent(obj, evType, fn) {
  if (obj.addEventListener) {
    obj.addEventListener(evType, fn, false)
  } else if (obj.attachEvent) {
    obj.attachEvent("on"+evType, fn)
  }
}
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var objects = document.getElementsByTagName("a");
 for (var i=0; i<objects.length; i++) {
   var object = objects[i];
   if (object.getAttribute("href") && object.getAttribute("rel") == "external") {
     object.target = "_blank";
   }
 }
 var objects = document.getElementsByTagName("form");
 for (var i=0; i<objects.length; i++) {
   var object = objects[i];
   if (object.getAttribute("rel") == "external") {
     object.target = "_blank";
   }
 }
}
addEvent(window, "load", externalLinks);

//// Stylesheet switcher ******************************************************************************
var prefsLoaded = false;
var currentFontSize = 12;
function defaultTxt(){
	currentFontSize = 12;
	changeTxt(0);
	}
function changeTxt(sizeDifference){
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference);
	if(currentFontSize > 14){
		currentFontSize = 14;
	}else if(currentFontSize < 11){
			currentFontSize = 11;
	}
	setFontSize(currentFontSize);
};
function setFontSize(fontSize){
	var stObj = (document.getElementById) ? document.getElementById('body') : document.all('Content');
	if (stObj)	stObj.style.fontSize = fontSize + 'px';
};

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = "dso" + name + "=" + value + expires + "; path=/";
};

function readCookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
};

window.onload = setUIOptions;

function setUIOptions(){
	if(!prefsLoaded){
		cookie = readCookie("fontSize");
		currentFontSize = cookie ? cookie : 12;
		setFontSize(currentFontSize);
		
		prefsLoaded = true;
	}
}

window.onunload = saveSettings;

function saveSettings()
{
  createCookie("fontSize", currentFontSize, 365);
}

//// Popup a window ******************************************************************************
function popup(theURL,winName,features) 
{
	var hWin = window.open(theURL,winName,features);
	if (hWin) hWin.focus();
}

//// Popup a window ******************************************************************************
function closepopup(theURL,winName,features) {
	popup(theURL,winName,features);
	window.close();
}

function GotoNavSearch() {

	if (document.navZoek.navTrefwoord.value != '')
		location.href = webRoot + "/Archief/Zoek/Index.aspx?trefwoord=" + encodeURI(document.navZoek.navTrefwoord.value); 	
	else
		alert('Trefwoord is niet gespecifieerd');
}

function validateIsNumeric(evt) {  
    var theEvent = evt || window.event;  
    var key = theEvent.keyCode || theEvent.which;  
    key = String.fromCharCode( key );  
    var regex = /[0-9]|\./;  
    if( !regex.test(key) ) 
    {    
        theEvent.returnValue = false;    
        theEvent.preventDefault();  
    }
}
    