$(document).ready(function() {
//	if (location.href == 'http://mdz.jeroenvader.nl/onderzoek.php?id=71') {
		$('a').each(function() {
			if ($(this).attr('href').substr(0,7) == 'http://') {
				$(this).attr('target','_blank');
			}
			else if ($(this).attr('href').substr(0,8) == 'https://') {
				$(this).attr('target','_blank');
			}
		});
//	}
	$('a').each(function() {
		if ($(this).attr('href').substr($(this).attr('href').length-4,4).toLowerCase() == '.pdf') {
			$(this).attr('rel','external');
		}
		if ($(this).attr('href').substr($(this).attr('href').length-4,4).toLowerCase() == '.doc') {
			$(this).attr('rel','external');
		}
		if ($(this).attr('href').substr($(this).attr('href').length-5,5).toLowerCase() == '.docx') {
			$(this).attr('rel','external');
		}
	});
	$('a[rel="external"]').each(function() {
		$(this).attr('target','_blank');
	});
	try {
		var selectednav = $('#navmenu a.selectednav');
		var selectednavwidth = selectednav.width();
		var selectedx = selectednav.offset().left;
		var selectedy = selectednav.offset().top;
		var selectedmx = $('#navmenu').offset().left;
		var selectedmy = $('#navmenu').offset().top;
		$('#selectedcircle').css('position','absolute').css('left', selectedx-selectedmx+((selectednavwidth+11)/2)).css('top', selectedy-selectedmy+25).css('display','inline').css('z-index',1);
	} catch(e) {}
	$('ul.thumb img').live('mouseover', function() {
	//	$('#mainphoto').attr('src', $(this).attr('src').replace(/\/thumbs\//, '/300/'));
	});
	if ($.fn.thumbPopup) {
		if ($(window).width() > 800) {
			largeflag = "/600/";
		}
		else {
			largeflag = "/300/";
		}
		$("img[alt=''][src*='/images/hmlinks/thumbs/']").thumbPopup({
			imgSmallFlag: "/thumbs/",
			imgLargeFlag: largeflag
		});
		$("img[src*='/images/hmart/thumbs/']").thumbPopup({
			imgSmallFlag: "/thumbs/",
			imgLargeFlag: largeflag
		});
		$("img[src*='/images/hmcat/thumbs/']").thumbPopup({
			imgSmallFlag: "/thumbs/",
			imgLargeFlag: largeflag
		});
	}
/*
	if ($.fn.equalHeights) {
		$('#contentcontainer').equalHeights();
		$('#contenthome').equalHeights();
	}
	$('#footer').css('top',$('#contentleft')[0].scrollHeight-10);
*/
	// let's align the logo in the middle
	// how much space do the nav buttons take up?
	var totalbuttonwidths = 0;
	$('#navmenu a').each(function() {
		totalbuttonwidths += $(this).width();
		totalbuttonwidths += 22;	// padding!
		totalbuttonwidths += 1;	// space between buttons
	});
	$('#navmenu a').live({
		mouseenter:
		function() {
			$('#menuiteminfo').css('display','none');
			if (menuiteminfoarray[$(this).html()] && menuiteminfoarray[$(this).html()] != '') {
				$('#menuiteminfo').css('left',$(this).position().left + 10);
				$('#menuiteminfo').html(menuiteminfoarray[$(this).html()]);
				$('#menuiteminfo').css('display','block');
			}
		},
		mouseleave:
		function() {
			$('#menuiteminfo').css('display','none');
		}
	});
/*
	$('#navmenu a').live('mouseover', function() {
		alert('hier');
	});
*/
	// the margin for logo klein will then become (959-119(logowidth)-totalbuttonwidths)/2
	$('#logoklein').css('margin-left', ((959-119-totalbuttonwidths)/2));
});
window.onload = function() {
	dofooter();
}
function dofooter() {
	if ($.fn.equalHeights) {
		$('#contentcontainer').equalHeights();
		$('#contenthome').equalHeights();
	}
	// IE7
	$('#footer').css('position','absolute').css('top',$('#contentleft')[0].scrollHeight-30);
	if (navigator.userAgent.indexOf("MSIE 7.0") != -1) {
		$('#footer').css('position','absolute').css('top',$('#contentleft')[0].scrollHeight+10);
	}
}
function validateContactform(theform) {
	var msg = '';
	if (theform.elements['f[name]'].value == '') {
		msg += "U heeft uw naam nog niet ingevuld.\n";
	}
	if (theform.elements['f[phone]'].value == '') {
		msg += "U heeft uw telefoonnummer nog niet ingevuld.\n";
	}
	if (theform.elements['f[email]'].value == '') {
		msg += "U heeft uw e-mail-adres nog niet ingevuld.\n";
	}
	if (theform.elements['f[message]'].value == '') {
		msg += "U heeft nog geen bericht ingevuld.\n";
	}
	if (msg != '') {
		alert (msg);
		return false;
	}
	if (prompt('Ter bestrijding van spamberichten graag 1234 invullen:') != '1234') {
		return false;
	}
	alert("Dank voor uw bericht!");
	return true;
}
function show_props2(obj, obj_name) {
	var result = '';
	for (var i in obj) {
		if (i)
			result += obj_name + '.' + i + ' = ' + obj[i] + '<br />\n';
	}
	return result
}

