﻿function addLoadEvent(func) { 
    var oldonload = window.onload; 
    if (typeof window.onload != 'function') { 
        window.onload = func; 
    } else { 
        window.onload = function() { 
            if (oldonload) { 
                oldonload(); 
            } 
        func(); 
        } 
    } 
}

var maxWidth = "320"
var maxHeight = "240";
function rollOverImage(id){
    var imgMain = document.getElementById(hoofdFotoID);
    imgMain.src = fotos[id];
    
    imgMain.src = fotos[id].file;

    var newWidth = fotos[id].width;
    var newHeight = fotos[id].height;
    
    if (newWidth < maxWidth){
        var diff =  maxWidth / newWidth;
        newWidth = newWidth * diff;
        newHeight = newHeight *  diff;
    }
    
    if (newHeight < maxHeight){
        var diff =  maxHeight / newHeight;
        newWidth = newWidth * diff;
        newHeight = newHeight *  diff;
    }

    if (newWidth >= maxWidth){
        var diff =  maxWidth / newWidth;
        newWidth = newWidth * diff;
        newHeight = newHeight *  diff;
    }

    if (newHeight >= maxHeight){
        var diff =  maxHeight / newHeight;
        newWidth = newWidth * diff;
        newHeight = newHeight *  diff;
    }          
    imgMain.style.width= newWidth + "px";
    imgMain.style.height= newHeight + "px";
}

function lightbox_show(url){
            //roep lightbox op
        var objLink = document.createElement('a');
	objLink.setAttribute('href',url);
	objLink.setAttribute('rel','lightbox');
	objLink.setAttribute('title','');
	Lightbox.prototype.start(objLink);
}

