extendClass = function(_self, base)
{
	var obj = new base();
	for (var k in obj) _self[k] = obj[k];
}

BaseJsControl = function()
{
	var _self = this;

	/*
	 * Client IDs
	 */

	_self.clientIds = {};
	_self.clientNames = {};

	_self.SetClientId = function(id, clientId)
	{
		_self.clientIds['i_' + id] = clientId;
	}

	_self.GetClientId = function(id)
	{
		if (typeof(_self.clientIds['i_' + id]) == 'undefined') throw 'Client id for control ' + id + ' not found';
		return _self.clientIds['i_' + id];
	}

	_self.SetUniqueName = function(id, uniqueName)
	{
		_self.clientNames['i_' + id] = uniqueName;
	}

	_self.GetUniqueName = function(id)
	{
		if (typeof(_self.clientNames['i_' + id]) == 'undefined') throw 'Unique name for control ' + id + ' not found';
		return _self.clientNames['i_' + id];
	}

	_self.SetIdAndName = function(id, clientId, uniqueName)
	{
		_self.SetClientId(id, clientId);
		_self.SetUniqueName(id, uniqueName);
	}

	/*
	 * Localization
	 */

	_self.localeStrings = {};

	_self.SetLocaleString = function(id, value)
	{
		_self.localeStrings['i_' + id] = value;
	}

	_self.GetLocaleString = function(id)
	{
		if (typeof(_self.localeStrings['i_' + id]) == 'undefined') return id;
		return _self.localeStrings['i_' + id];
	}

	/*
	 * Other
	 */

	_self.CreateDelegate = function(_func)
	{
		var func = _func;

		var args = [];
		for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);

		return function(_event) { if (typeof(event)=='undefined') event=_event; return func.apply(this, args); };
	}

	_self.GetElement = function(clientId)
	{
		return document.getElementById(_self.GetClientId(clientId));
	}

	_self.NewUID = function()
	{
		if (typeof(window['__global_guid_counter__']) == 'undefined') window['__global_guid_counter__'] = 0;
		window['__global_guid_counter__']++;
		return String(window['__global_guid_counter__']) + (new Date()).valueOf();
	}
}

if (typeof(Sys)!='undefined' && Sys.Application!=null && Sys.Application.notifyScriptLoaded!=null) Sys.Application.notifyScriptLoaded();
