var loader = function(path, width, height, options) {
	// Les informations de l'élément Flash
	this.options = {
		classid: null,
		type: null,
		data: null,
		id: null,
		width: width,
		height: height,
		params: {
			movie: path,
			pluginurl: 'http://www.adobe.com/go/BPCKN',
			quality: 'best',
			wmode: 'transparent',
			bgcolor: 'transparent',
			menu: 'false',
			scale: 'exactfit',
			allowScriptAccess: 'sameDomain',
			flashVars: ''
		}
	};
	
	// Le code final sera stocké dans cette variable
	this.build = null;
	
	// Ajout de variables flash
	this.assign = function(a, b) {
		if (typeof a == 'string' && typeof b != 'undefined') {
			this.options.params.flashVars += (this.options.params.flashVars == '') ? a+'='+b : '&'+a+'='+b;
		}
		else if (typeof a == 'object') {
			for (var v in a) {
				this.options.params.flashVars += (this.options.params.flashVars == '') ? v+'='+a[v] : '&'+v+'='+a[v];
			}
		}
		else if (typeof a == 'string' && typeof b == 'undefined') {
			this.options.params.flashVars += (this.options.params.flashVars == '') ? a : '&'+a;
		}
	};
	
	// Assemblage de deux objets (Inspiré de Mootools)
	this.merge = function() {
		var ret = {};
		
		for (var i = 0; i < arguments.length; i++) {
			for (var property in arguments[i]) {
				var argP = arguments[i][property];
				var retP = ret[property];
				
				if (retP && typeof argP == 'object' && typeof retP == 'object') { // La propriété existe déjà
					ret[property] = this.merge(retP, argP);
				} else {
					ret[property] = argP;
				}
			}
		}
		
		return ret;
	};
	
	// Creation du code d'affichage du flash
	this.parse = function() {
		// Mise a jour des infos
		this.options = this.merge(this.options, options);
		
		// Ajout des variables flash
		if (typeof options == 'object' && typeof options.flashVars != 'undefined') {
			this.options.flashVars = null;
			this.assign(options.flashVars);
		}
		
		if (window.ActiveXObject) {
			this.options.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
		} else {
			this.options.type = 'application/x-shockwave-flash';
			this.options.data = path;
		}
		
		this.build = '<object';
		for (var attr in this.options) {
			if (this.options[attr] != null && typeof this.options[attr] != 'object') {
				this.build += ' '+attr+'="'+this.options[attr]+'"';
			}
		}
		this.build += '>\n';
		
		// Ecriture des balises <param>
		for (var name in this.options.params) {
			this.build += '\t<param name="'+name+'" value="'+this.options.params[name]+'" />\n';
		}
		
		// Ajout des variables et fin d'ecriture
		this.build += '</object>\n';
	};
	
	// Fonction d'écriture du code
	this.write = function(element) {
		this.parse();
		
		if (typeof element !== 'undefined') {
			try {
				if (typeof element == 'string') {
					document.getElementById(element).innerHTML += this.build;
				}
				else {
					element.innerHTML += this.build;
				}
			}
			catch(e) {};
		}
		else {
			document.write(this.build);
		}
	};
	
	// Fonction de retour d'une propriete
	this.get = function(v) {
		if (typeof this.options[v] != 'undefined') {
			return this.options[v];
		}
		else if (typeof this[v] != 'undefined') {
			if (v == 'build') this.parse();
			
			return this[v];
		}
	};
	
	return this;
};
