function AcheteurPromoteur() {
	this.Version = "1";

	this.instances = new Array();
	this.stickyClassesLookup = new Array();
	this.windowArgs = new Array();
	this.loadedFiles = new Array();
	this.configs = new Array();
	this.currentConfig = 0;
	this.eventHandlers = new Array();

	// Browser check
	/*var ua = navigator.userAgent;
	this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
	this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1);
	this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1);
	this.isGecko = ua.indexOf('Gecko') != -1;
	this.isSafari = ua.indexOf('Safari') != -1;
	this.isOpera = ua.indexOf('Opera') != -1;
	this.isMac = ua.indexOf('Mac') != -1;
	this.isNS7 = ua.indexOf('Netscape/7') != -1;
	this.isNS71 = ua.indexOf('Netscape/7.1') != -1;
	this.dialogCounter = 0;

	// Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those
	if (this.isOpera) {
		this.isMSIE = true;
		this.isGecko = false;
		this.isSafari =  false;
	}*/

	// TwinLions editor id instance counter
	this.idCounter = 0;
};

AcheteurPromoteur.prototype.regexpReplace = function (in_str, reg_exp, replace_str, opts) 
{
	if (in_str == null)
		return in_str;

	if (typeof(opts) == "undefined")
		opts = 'g';

	var re = new RegExp(reg_exp, opts);
	return in_str.replace(re, replace_str);
};

AcheteurPromoteur.prototype.getParam = function (name, default_value, strip_whitespace, split_chr) 
{
	var value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];

	// Fix bool values
	if (value == "true" || value == "false")
		return (value == "true");

	if (strip_whitespace)
		value = acheteurpromoteur.regexpReplace(value, "[ \t\r\n]", "");

	if (typeof(split_chr) != "undefined" && split_chr != null) {
		value = value.split(split_chr);
		var outArray = new Array();

		for (var i=0; i<value.length; i++) {
			if (value[i] && value[i] != "")
				outArray[outArray.length] = value[i];
		}

		value = outArray;
	}

	return value;
};


AcheteurPromoteur.prototype.defParam = function (key, def_val, t) {
	var v = acheteurpromoteur.getParam(key, def_val);

	v = t ? v.replace(/\s+/g,"") : v;

	this.settings[key] = v;
};

AcheteurPromoteur.prototype.loadScript = function (url) 
{
	for (var i=0; i<this.loadedFiles.length; i++) 
	{
		if (this.loadedFiles[i] == url)
			return;
	}

	document.write('<script language="javascript" type="text/javascript" src="' + url + '"></script>');

	this.loadedFiles[this.loadedFiles.length] = url;
};

AcheteurPromoteur.prototype.init = function (settings) 
{
	var theme;

	this.settings = settings;
	// Check if valid browser has execcommand support
	/*if (typeof(document.execCommand) == 'undefined')
		return;*/
		
	// Set default values on settings
	this.defParam("base_url", ".");
	this.defParam("plugins", "", true);

	// Browser check IE
	/*if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1)
		return;

	// Browser check Gecko
	if (this.isGecko && this.settings['browsers'].indexOf('gecko') == -1)
		return;

	// Browser check Safari
	if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1)
		return;

	// Browser check Opera
	if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1)
		return;*/

	// Add plugins
	var themePlugins = acheteurpromoteur.getParam('plugins', '', true, ',');
	if (this.settings['plugins'] != '') {
		for (var i=0; i<themePlugins.length; i++)
			this.loadScript(settings['base_url'] + '/Plugins/' + themePlugins[i] + '.js');
	}
};


// Global instances
var acheteurpromoteur = new AcheteurPromoteur();