/* Tools */
(function(){
	var instance = null;
	function _Tools(){};
	
	_Tools.prototype = {
		/* Stop action/propagation d'un evenement */
		/* @argument - (Obj) evt : evenement */
		/* @return - (Obj) evt : evenement */
		stopEvent: function(evt){
			if(window.event){ //IE
				evt = window.event;
				evt.returnValue = false;
			}
			try {
				evt.cancelBubble = true;
				if(evt.preventDefault) evt.preventDefault();
				if(evt.stopPropagation) evt.stopPropagation();
				if(evt.stopped) evt.stopped = true;
			} catch(e) {
				/* console.log(e.message); */
			}		
			return evt;
		},
		
		/* Heritage Class */
		extendClass: function(childClass, parentClass){
			var F = function(){};
			F.prototype = parentClass.prototype;
			childClass.prototype = new F();
			childClass.prototype.constructor = parentClass;
			childClass.parentClass = parentClass.prototype;
			if(parentClass.prototype.constructor == Object.prototype.constructor){
				parentClass.prototype.constructor = parentClass;
			}
		},
		
		/* Recupere une reference URL background */
		getBckg: function(token){
			var static = '/static/swf/bckg';
			var bckgs = {
					index: 'bg_events.swf',
					optique: 'bg_fibre_optique.swf',
					impact: 'bg_impact.swf',
					network: 'bg_network.swf',
					newsroom: 'bg_newsroom.swf',
					project: 'bg_project.swf',
					events: 'bg_events.swf'
			};
			var value = false;
			var _default = bckgs['index'];
			for(var prop in bckgs){
				if(prop != token) continue;
				value = bckgs[prop];
				break;
			}	
			return (value)? static + '/' + value : static + '/' + _default;		
		}		
	};
	
	/* Singleton - getInstance */
	var getInstance = function(){
		instance = (!instance)? new _Tools() : instance;
		return instance;		
	};
	
	window.canarie = window.canarie || {};
	window.canarie.tools = window.canarie.tools || getInstance();		
})();