
// Definition de la classe 'AlertBox'
// NB: L'ordre des methodes est important
function AlertBox(id)
{
	// Proprietes publiques et événements
	this.Id = id;
	this.HtmlObject = $("#" + id);
	this.Click = new Array();
	
	// Champs et methodes privees
	var _this = this;
	var _disableFade;
	var _target = null;
	var _content = _this.HtmlObject.find(".AlertBoxContent");
	var _header = _this.HtmlObject.find(".AlertBoxHeader");

	this.Show = function(target)
	{
		_target = target;
	
		if (_disableFade)
			_this.HtmlObject.show();
		else
			_this.HtmlObject.fadeIn(200);
	}

	this.Hide = function()
	{
		if (_disableFade)
			_this.HtmlObject.hide();
		else
			_this.HtmlObject.fadeOut(200);
	}
	
	this.GetMessage = function()
	{
		return _content.html();
	}
	
	this.SetMessage = function(message)
	{
		_content.html(message);
	}
	
	this.SetTitle = function(title)
	{
		_header.html(title);
	}
	
	this.SetButtonText = function(buttonId, text)
	{
		_this.HtmlObject.find(".AlertBoxFooter #" + id
			+ "_" + buttonId + " .ButtonText").html(text);
	}
	
	this.SetCheckBoxText = function(checkBoxId, text)
	{
		_this.HtmlObject.find(".AlertBoxFooter #" + id
			+ "_" + checkBoxId + " .Content").html(text);
	}
	
	this.OnLoad = function()
	{
		var bodyClass = document.body.className;
		_disableFade = (bodyClass == "IE6" || bodyClass == "IE7" || bodyClass == "IE8");
	
		_this.HtmlObject.find(".CheckBox").each(function()
		{
			var checkBox = new CheckBox($(this).attr("id"));
			checkBox.OnLoad();
		});
	
		_this.HtmlObject.find(".Button").click(function()
		{
			var buttonId = $(this).attr("id");
			buttonId = buttonId.substring(buttonId.lastIndexOf('_') + 1);
			
			var checked = new Array();
			_this.HtmlObject.find(".Checked").each(function()
			{
				var checkBoxId = $(this).parents(".CheckBox:first").attr("id")
				checkBoxId = checkBoxId.substring(checkBoxId.lastIndexOf('_') + 1);
				checked.push(checkBoxId);
			});
			
			var args = { ButtonId: buttonId, Target: _target, Checked: checked };
			Tools_DispatchEvent(_this.Click, _this, args);
			return false;
		});
	}
}

