$(window).load(function(){
	
	setMenuHeight();
	
});

function setMenuHeight() {
	
	$('*[getHeightFrom]').each(function() {
		
		var originalHeight = $(this).children().last().offset().top + $(this).children().last().outerHeight() - $(this).offset().top;
		
		var otherElementText = $(this).attr('getHeightFrom');
		var otherElement = $( otherElementText );
		
		var otherElementHeight = otherElement.outerHeight();
		
		if (otherElementHeight > originalHeight) {
			$(this).css('height', otherElementHeight + 'px');
		} else {
			$(this).css('height', originalHeight + 'px');
		}
		
	});
	
}

$(window).resize(function(){
	setMenuHeight();
});

function insertEmail() {
	
	var s1 = 'b.dk';
	var s2 = '@';
	var s3 = 'clt';
	var s4 = 'me';
	
	var s5 = s4 + s2 + s3 + s1;
	
	var o1 = document.getElementById('emailaddress');
	var o2 = document.createElement('a');
	var o3 = document.createTextNode( s4+' ' );
	var o4 = document.createElement('img');
	o4.setAttribute('src', '/images/a.png');
	o4.setAttribute('alt', '[at]');
	o4.setAttribute('width', '13');
	o4.setAttribute('height', '13');
	var o5 = document.createTextNode( ' '+s3 + s1 );
	
	o1.appendChild( o2 );
	o2.appendChild( o3 );
	o2.appendChild( o4 );
	o2.appendChild( o5 );
	
	o2.setAttribute('href', 'm'+'ai'+'lt'+'o:'+s5);
	o2.setAttribute('title', 'Send mig en e-mail');
	
}

/* Make thumbnails show titles with black background on hover.  */
$(window).load(function() {
	
	$('[overlay]').each(function() {
		
		$(this).attr('title', '');
		
		var oOverlay = $('#' + $(this).attr('overlay') );
		
		$(this).hover(function() {
			oOverlay.css('display', 'block');
		}, function() {
			oOverlay.css('display', 'none');
		});
		
	});
	
});
