var oBlocking;

// Public Functions //

function Blocking(arr)
{
	this.isToggle = true;
	this.Blocks = new Array;

	for (i = 0; i < arr.length; i++) {
		this.Blocks[i] = new _getObj(arr[i]);
	}
	
	this.showBlock = _showBlock;
}

function initBlocking()
{
	arr = new Array;
	
	for(i = 0; i < arguments.length; i++) {
		arr[i] = arguments[i]; 
	}

	oBlocking = new Blocking(arr);
}

function showBlock(nr)
{
	oBlocking.showBlock(nr);
}

function containerStart(nr)
{
	document.write('<div id=' + nr + ' style="display: none;">');
}

function containerEnd()
{
	document.write('</div>');
}

function setStatus(txt)
{
	status = txt;
	// below is for browers that update status bar AFTER javascript load
	setTimeout('_timeOutStatus("' + txt + '")', 1);
	return true;
}

function noToggle()
{
	oBlocking.isToggle = false;
}


// Private Functions //

function _getObj(name)
{
	this.isLayers = false;

	if (document.getElementById)
	{
 		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
		this.style.display = 'none';
		this.style.position = 'relative';
	}
	else if (document.all)
	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
		this.style.display = 'none';
		this.style.position = 'relative';
	}
	else if (document.layers)
	{
 	  	this.obj = _getObjNN4(name);
		this.style = this.obj;
		this.style.visibility = 'hidden';
		
		this.isLayers = true;
	}
}

function _timeOutStatus(txt)
{
	status=txt;
}

function _showBlock(nr)
{
	for (i = 0; i < this.Blocks.length; i++) {
		if (this.Blocks[i].obj.id != nr) {
			_setVisFalse(this.Blocks[i]);
		}
		else if (this.isToggle) {
			_toggleVis(this.Blocks[i]);
		}
		else if (!this.isToggle) {
			_showVis(this.Blocks[i]);
		}
	}
}

function _toggleVis(objBlock)
{
	if (!objBlock.isLayers) {
		objBlock.style.display = (objBlock.style.display == 'none') ? 'block' : 'none';
	}
	else {
		objBlock.style.visibility = (objBlock.style.visibility == 'hide') ? 'visible' : 'hidden';
	}
}

function _showVis(objBlock)
{
	if (!objBlock.isLayers) {
		objBlock.style.display ='block';
	}
	else {
		objBlock.style.visibility = 'visible';
	}
}

function _setVisFalse(objBlock)
{
	if (!objBlock.isLayers) {
		objBlock.style.display = 'none';
	}
	else {
		objBlock.style.visibility = 'hidden';
	}
}

// searches the entire DOM 0 model for element
function _getObjNN4(name)
{
	var x = document.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}