
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// gebruikt bij het toevoegen van een album... maakt het tekstveld leeg indien een bestaand album geselecteerd wordt
function emptytxt() {
	var field = document.getElementById('album');
	field.value='';
}

// rand nummer (van 1 tot n) afgerond naar beneden
function rand (n) {
	return ( Math.floor ( Math.random ( ) * n + 1 ) );
}

// foto op de frontpage randomizen, via JS omdat dan ook in de cache-versie een willekeurige foto verschijnt
function frontimage () {
	myimg1 = document.getElementById('front1');
	myimg2 = document.getElementById('front2');
	if (myimg1) {
		pnum1 = rand(7);
		myimg1.src = "img/pic.small."+pnum1+".jpg";
	}
	if (myimg2) {
		pnum2 = rand(7);
		if (pnum2==pnum1) {
			pnum2 = rand(7);	
			if (pnum2==pnum1) {
				pnum2 = rand(7);	
			}
		}
		myimg2.src = "img/pic.small."+pnum2+".jpg";
	}
}

// (div) id's zichtbaar en/of onzichtbaar maken afhankelijk van hun huidige status
function showid (id) {
	myitem = document.getElementById(id);
	if (myitem.style.display == "none") {
		myitem.style.display = "block";
	}
	else {
		myitem.style.display = "none";
	}
}


// mygoto
function mygoto (id,url) {
	myitem = document.getElementById(id);
	myitem.src = url;
}

function ReloadPage(timeout) {
	setTimeout('location.reload();', timeout);	
}

function PortSize() {
	var viewHeight;
	if (typeof window.innerWidth != 'undefined') {
	  viewHeight = window.innerHeight
	} else if (typeof document.documentElement != 'undefined'
	 && typeof document.documentElement.clientWidth !=
	 'undefined' && document.documentElement.clientWidth != 0) {
	   viewHeight = document.documentElement.clientHeight
	} else {
	   viewHeight = document.getElementsByTagName('body')[0].clientHeight
	}
	var totalHeight = TotalSize();
	if (document.getElementById("Bottom")) {
		if (viewHeight < totalHeight) {
			document.getElementById("Bottom").style.top = totalHeight + "px";
		} else {
			document.getElementById("Bottom").style.top = viewHeight + "px";
		}
	document.getElementById("Bottom").style.display = 'block';
	}

}

function TotalSize() {
	var totalHeight;
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		totalHeight = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		totalHeight = document.body.scrollHeight;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		totalHeight = document.body.offsetHeight;
  	}
	return totalHeight;
}

function DisplayMonth(id) {
	// Getting Screeninformation
	var viewHeight = document.documentElement.clientHeight; // IE
	var topHeight = document.documentElement.scrollTop;
	var object = document.getElementById("display");
	displayHeight = ((viewHeight/2)-object.style.height);
	object.style.top = displayHeight+topHeight+"px";
	object.style.display = 'inline';
}

function Theme() {
	//alert(TotalSize());
}

// Check enter
function checkEnter(e) { //e is event object passed from function invocation
	var characterCode;
	if(e && e.which){
		e = e
		characterCode = e.which;
	}
	else{
		e = event
		characterCode = e.keyCode;
	}

	if(characterCode == 13){
		document.forms[0].submit();
		return false;
	}
	else{
		return true;
	}
}