$(function() {

	$('#page a').each(function(){
		rel = $(this).attr('rel');
		if (rel!=''){
			tmp = rel.split(/\|/);
			if (tmp.length>1){
				tmp = tmp[1];	
				tmp = tmp.replace(/^\s*([a-z]{4})|([a-z]{4})\s*$/gi, '');
				tmp = tmp.replace(/[a-z]{2}\@[a-z]{2}/gi, '@');
				//tmp = tmp.replace(/[a-z]{2}\.[a-z]{2}/gi, '.');
				tmp = tmp.replace(/[a-z]{2}\.(?!.*\..*)[a-z]{2}/gi, '.');
			
			
				$(this).attr('href', '' + tmp);	//mailto: weggehaald
				$(this).attr('rel', '');
			}
		}
		
	
	});

});

function showhidemodal (href) {
	$.get("data/modal.php", function(data){
				// create a modal dialog with the data
				$(data).modal({
					closeHTML: "<a href='#' title='Sluiten' class='modalCloseX simplemodal-close'>x</a>",
					position: ["15%",],
					overlayId: 'contact-overlay',
					containerId: 'contact-container',
					onOpen: form.open,
					onClose: form.close
				});
	});
}

var form = {
	message: null,
	open: function (dialog) {
		// add padding to the buttons in firefox/mozilla
		if ($.browser.mozilla) {
			$('#contact-container .contact-button').css({
				'padding-bottom': '2px'
			});
		}
		// input field font size
		if ($.browser.safari) {
			$('#contact-container .contact-input').css({
				'font-size': '.9em'
			});
		}

		// dynamically determine height
		var h = 380;
		if (formItem.length) {
			h += formItem.length/25;
		}

		var title = $('#contact-container .contact-title').html();
		$('#modaltargetid').html('<p>hi there</p>');
		dialog.overlay.fadeIn(100, function () {
			dialog.container.fadeIn(100, function () {
				dialog.data.fadeIn(100, function () {
					$('#contact-container .contact-content').animate({
						height: h
					}, function () {
						$('#contact-container .contact-title').html(title);
					});
				});
			});
		});
	},
	close: function (dialog) {
		$('#contact-container .contact-message').fadeOut();
		$('#contact-container .contact-title').html('Tot ziens...');
		$('#contact-container form').fadeOut(100);
		$('#contact-container .contact-content').animate({
			height: 40
		}, function () {
			dialog.data.fadeOut(100, function () {
				dialog.container.fadeOut(100, function () {
					dialog.overlay.fadeOut(100, function () {
						$.modal.close();
					});
				});
			});
		});
	}
};

