
var common= {

	init : function (){
		common.makePopups();
	},
	addEventOLD: function (obj, evType, fn, useCapture) {
		// cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko
		// By Scott Andrew
  		if (obj.addEventListener) {
    		obj.addEventListener(evType, fn, useCapture);
   	 		return true;
  		} else if (obj.attachEvent) {
    		var r = obj.attachEvent('on' + evType, fn);
    		return r;
  		} else {
    		obj['on' + evType] = fn;
    		return true;
  		}
	},
	addEvent : function ( obj, type, fn )
    {
    // cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko
    // By Scott Andrew
    //Revisited by John Resig (winner of recod contest)
    //http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
    	if (obj.addEventListener){
    		obj.addEventListener( type, fn, false );
    	} else if (obj.attachEvent){
    		obj["e"+type+fn] = fn;
    		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
    		obj.attachEvent( "on"+type, obj[type+fn] );
    	}
    },

	removeEvent : function ( obj, type, fn )
	{
		if (obj.removeEventListener) {
			obj.removeEventListener( type, fn, false );
		} else if (obj.detachEvent){
			obj.detachEvent( "on"+type, obj[type+fn] );
			obj[type+fn] = null;
			obj["e"+type+fn] = null;
		}
	},
	/*
	Transforme tous les liens avec la classe popup en liens popup (les fait ouvrir dans une nouvelle fenetre.
	Plus besoin de l'attribut target (non xhtml 1.1) ni de onclick=window.open()
	*/
	makePopups : function(){
		if(!document.getElementsByTagName )return;
		var as=document.getElementsByTagName('A');
		for(var i=0;i<as.length;i++){
			if (as[i].className.indexOf('popup') != -1) {
				common.addEvent(as[i],'click',common.openWindow);
				common.addEvent(as[i],'click',common.cancelClick,false);
				as[i].onclick=common.cancelClickSafari;
			}
		}
	},
	openWindow:function(e){
		var t = window.event ? window.event.srcElement : e ? e.target : null;
		//common.addEvent(t,'click',common.cancelClick,false);
		//t.onclick=common.cancelClickSafari;
		window.open(t.href,'newWindow');
	},
	cancelClick:function(e){
		if(window.event && window.event.returnValue){
			window.event.returnValue=false;
		}
		if(e && e.preventDefault){
			e.preventDefault();
		}
	},
	cancelClickSafari:function(){
		return false;
	}
}
common.addEvent(window,'load',common.init);

