jQuery.fn.defuscate = function( settings ) {
    settings = jQuery.extend({
        link: true,
        find: /\b([A-Z0-9._%-]+)\([^)]+\)((?:[A-Z0-9-]+\.)+[A-Z]{2,6})\b/gi,
        replace: '$1@$2'
    }, settings);
    return this.each(function() {
        if ( $(this).is('a[@href]') ) {
            $(this).attr('href', $(this).attr('href').replace(settings.find, settings.replace));
            var is_link = true;
        }
        $(this).html($(this).html().replace(settings.find, (settings.link && !is_link ? '<a href="mailto:' + settings.replace + '">' + settings.replace + '</a>' : settings.replace)));
    });
};

$(document).ready(function(){
	
	$(".adresse").defuscate();
	
	$('#subMenu ul:not(.visible)').hide();
	var menuOuvert;
	$('#subMenu>li>a').mouseover(function(){
		if (!$(this).find('ul.visible').length) {
			menuOuvert = $(this).parent();
			menuOuvert.css({'height':'110px'});
			$(this).parent().find('ul').slideDown('fast');
		}
	});
	$('#subMenu>li').mouseleave(function(){
		if (!$(this).find('ul.visible').length) {
			menuOuvert = $(this);
			menuOuvert.css({'height':'auto'});
			$(this).find('ul').slideUp('fast');
		};
	});
	
    // open pdfs and googlemaps in new window
    $("a[href$='.pdf'],a[href^='http://maps.google.be'],a[href^='http']").click(function(){
        window.open(this.href);
        return false;
    });
});
