
function open_popup()
{
    var liens = document.getElementsByTagName('a');
    var reg=new RegExp("^(javascript|http://(www\.)?maisonsdesassociations.fr)", "i");
    
    for (var i = 0 ; i < liens.length ; ++i){

        // Popup email protection
        if (liens[i].href.indexOf('email/?key=') > -1){
            liens[i].onclick = function(){
                var width = 450;
                var height = 230;
                var top =(screen.height-height)/2;
                var left =(screen.width-width)/2;
                window.open(this.href, "email", "width=" + width + ",height=" + height +",top=" + top + ",left=" + left );
                return false;
            };
        
        // Liens pointant vers l'extérieur via une classe = à "ext"
        }else if (liens[i].className == 'ext'){
            liens[i].onclick = function(){
                window.open(this.href);
                return false;
            };
        
        // Autres liens pointant vers l'extérieur
        }else if (!reg.test(liens[i].href)){
            liens[i].onclick = function(){
                window.open(this.href);
                return false;
            };
        }
    }
}

if (window.addEventListener) {
    window.addEventListener('load', open_popup, false);
}else{
    window.attachEvent('onload', open_popup);
}

