/*
* BlockFolder function
* @author: Marco Hoeck <marco.hoeck@tvi-services.de>
* @copyright	TV Information Services 2007
* @since		20.09.2007 - 10:00:00
*/

/*
* BlockFolder
*/
function BlockFolder(nodes)
{
	this.nodes = nodes;

	/*
	* setState
	*/
	this.setState = function (state)
	{
		for(var i = 0; i < this.nodes.length; i++)
		{
			if(!this.nodes[i].blockFolderState)
				this.nodes[i].blockFolderState = state;

			if(this.nodes[i].blockFolderState == 1)
			{
				//this.nodes[i].style.display = 'block';
				this.nodes[i].className = classNameRemove(this.nodes[i].className, 'blockfolder-hidden');
				this.nodes[i].className = classNameAppend(this.nodes[i].className, 'blockfolder-visible');
			}
			else
			{
				//this.nodes[i].style.display = 'none';
				this.nodes[i].className = classNameRemove(this.nodes[i].className, 'blockfolder-visible');
				this.nodes[i].className = classNameAppend(this.nodes[i].className, 'blockfolder-hidden');
			}
		}
	}

	/*
	* flipState
	*/
	this.flipState = function (state)
	{
		for(var i = 0; i < this.nodes.length; i++)
		{
			if(!this.nodes[i].blockFolderState)
				this.nodes[i].blockFolderState = state;
			else
			{
				if(this.nodes[i].blockFolderState == 0)
					this.nodes[i].blockFolderState = 1;
				else
					this.nodes[i].blockFolderState = 0;
			}

			if(this.nodes[i].blockFolderState == 1)
			{
				//this.nodes[i].style.display = 'block';
				this.nodes[i].className = classNameRemove(this.nodes[i].className, 'blockfolder-hidden');
				this.nodes[i].className = classNameAppend(this.nodes[i].className, 'blockfolder-visible');
			}
			else
			{
				//this.nodes[i].style.display = 'none';
				this.nodes[i].className = classNameRemove(this.nodes[i].className, 'blockfolder-visible');
				this.nodes[i].className = classNameAppend(this.nodes[i].className, 'blockfolder-hidden');
			}
		}
	}
}