var UD = 'undefined';
var _objects = new Array();
var _pre_loading = new Image();
_pre_loading.src = "/img_vistacorporate/loading.gif";

function $(idname, force)
{
	if (force || typeof(_objects[idname]) == "undefined")
	{
		if (document.getElementById)
		{
			_objects[idname] = document.getElementById(idname);
		}
		else if (document.all)
		{
			_objects[idname] = document.all[idname];
		}
		else if (document.layers)
		{
			_objects[idname] = document.layers[idname];
		}
		else
		{
			_objects[idname] = null;
		}
	}
	return _objects[idname];
}

function get_content(ids, objid, cls)
{
	this._disp = $(objid);
	this._obj = new Array();
	this._active = typeof(cls) == 'string' ? cls : '';
	this._current = '';
	this.construct(ids);
}

get_content.prototype = {
	_old_cnt: null,
	
	
	construct: function(ids)
	{
		for (var i = 0; i < ids.length; i++)
		{
			this._obj[ids[i]] = $(ids[i]);
			
			var th = this;
			if (this._obj[ids[i]])
			{
				if (!this._current && this._active && this._obj[ids[i]].className == ids[i])
				{
					this._current = ids[i];
				}
				
				if (this._obj[ids[i]].className == this._active)
				{
					this._current = ids[i];
					this._del_onclick(this._obj[ids[i]]);
				}
				else
				{
					this._add_onclick(this._obj[ids[i]]);
				}
			}
		}
	},
	
	_add_onclick: function(obj)
	{
		var th = this
		obj.onclick = function() {th.get(this); this.blur(); return false;}; 
		obj.style.cursor = 'pointer';
	},
	
	_del_onclick: function(obj)
	{
		var th = this
		obj.onclick = function() {this.blur(); return false;}; 
		obj.style.cursor = 'text';
	},
	
	get: function(obj)
	{
		if (!this._disp) return;
		this._old_cnt = this._disp.innerHTML;
		this._disp.innerHTML = '<img src="' + _pre_loading.src + '" alt="" />' + ' ' + '';
		var req = new JsHttpRequest();
		var th = this;
		req.onreadystatechange = function()
		{
			if (req.readyState != 4)  return;
			
			if(typeof(req.responseJS._valid) == UD || !req.responseJS._valid) return;
			if (th._active)
			{
				if (th._current)
				{
					th._obj[th._current].className = '';
					th._add_onclick(th._obj[th._current]);
				}
				obj.className = th._active;
			}
			th._current = obj.id;
			if (th._current) th._add_onclick(th._obj[th._current]);
			th._del_onclick(obj);
			th._disp.innerHTML = req.responseText;
		}
		req.caching = true;
		req.open(null, obj.href, true);
		req.send( { 'xmlcheck': 8546 } );
	}
	
};