// Class Tools
function Tools()
{
    this.instance = null;

    try
    {
		if (Tools.caller != Tools.getInstance)
		{
			throw "singletonError";
		}
    }
    catch (error)
    {
		if (error == "singletonError")
		{
			var newError = new Error("this object cannot be instanciated");
		}
    }
    
    if (typeof Tools.initialized == "undefined")
    {
		// Méthodes

		//
		// Bind
		//
		Tools.prototype.bind = function (scope, fn)
		{
			return function()
			{
				if (fn)
				{
					fn.apply(scope, arguments);
				}
				return false;
			};
		};

		//
		// INHERITANCE : copy prototype method
		//
		Tools.prototype.inherits = function(destination, source)
		{
			for (var element in source)
			{
				if (true) // REMOVE WARNING ABOUT PROTOTYPE
				{
					destination[element] = source[element];
				}
			}
		};

		//
		// Set a Hint on Input
		//
		Tools.prototype.setHint = function(inputID, hint)
		{
			var hint = hint;
			var input = $("#" + inputID);
			
			if (input.val() == '')
			{
				input.focus(function()
					{
						if ($(this).attr('typedValue') == '')
						{
							$(this).val('');
						}
					});
				
				input.blur(function()
					{
						$(this).attr('typedValue', $(this).val());
						if ($(this).val() == '')
						{
							$(this).val(hint);
						}
					});
				
				input.blur();
			}
		};

		Tools.initialized = true;
    }
}

// SINGLETON DESIGN PATTERN
Tools.getInstance = function() {

    if (this.instance == null)
    {
		this.instance = new Tools();
    }

    return this.instance;
};
