
// Definition de la classe 'Tabs'
// NB: L'ordre des methodes est important
function Tabs(id)
{
	// Proprietes publiques et événements
	this.Id = id;
	this.HtmlObject = $("#" + id);
		
	// Champs et methodes privees
	var _this = this;
	var _alertBox = new AlertBox(id + "_alertBox");
	var _saveUrl = '';
	var _ribbon = null;
	var _loading = null;
	
	var SetAlerts = function()
	{	
		_alertBox.OnLoad();
		_alertBox.Click.push(function(sender, args)
		{
			if (args.ButtonId == "ok")
			{
				_loading.Show();
				var target = args.Target.attr("target");
				var href = args.Target.attr("href");
				if (Tools_IsNullOrEmpty(target))
					window.location = href;
				else
					window.open(href, target);
			}
			else if (args.ButtonId == "save" && Tools_IsNullOrEmpty(_saveUrl) == false)
			{
				_loading.Show();
				window.location = _saveUrl;
			}
			_alertBox.Hide();
			_ribbon.SetShadow(false);
		});
		_this.HtmlObject.find("td[class^=TabDeselected] a").click(function(event)
		{
			event.preventDefault(); 
			_ribbon.SetShadow(true);
			_alertBox.Show($(this));
			return false;
		});
	}
	
	this.OnLoad = function(ribbon, loading)
	{
		_ribbon = ribbon;
		_loading = loading;
		
		// Essaie de récuperer l'URL de la page Sauvegarde
		try { _saveUrl = eval("saveUrl"); }
		catch (ex) { _saveUrl = ''; }

		SetAlerts();
	}
}

