	var opera = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
	var mozilla = (navigator.userAgent.indexOf('Gecko') >= 0)? true : false;
	var ie = (document.all && !opera && !mozilla)? true : false;
	var dom = (document.getElementById)? true : false;

	//classes definitions
	if ( !Array.push )
	{
		Array.prototype.push = function( newElement )
		{
			this[ this.length ] = newElement;
		}
	}

	function ControledElement( elemID, isVisible )
	{
		this.ID = elemID;
		this.isVisible = isVisible;

		if ( arguments.length == 3 )
			this.controledImages = arguments[ 2 ];
	}

	ControledElement.prototype.ChangeVisibility = function()
	{
		if ( this.isVisible )
		{
			hideElem( this.ID );
		}
		else
			showElem( this.ID );

		this.isVisible = !this.isVisible;

		if ( this.controledImages )
		{
			for( i = 0; i < this.controledImages.length; i++ )
			{
				var controledImage = this.controledImages[ i ];

				controledImage.ChangeState( this.isVisible );
			}
		}
	}

	function ControledImage( imageID, collapsedImage, expandedImage )
	{
		this.ID = imageID;
		this.collapsedImage = collapsedImage;
		this.expandedImage = expandedImage;
	}

	ControledImage.prototype.ChangeState = function( state )
	{
		var image = document.getElementById( this.ID );

		if ( state )
		{
			image.src = this.expandedImage.src;
			image.alt = this.expandedImage.alt;
		}
		else
		{
			image.src = this.collapsedImage.src;
			image.alt = this.collapsedImage.alt;
		}
	}

	function VisibilityControler( controledElements )
	{
		this.controledElements = controledElements;
	}

	VisibilityControler.prototype.changeElementsVisibility = function()
	{
		if ( this.controledElements )
		{
			for( i = 0; i < this.controledElements.length; i++ )
			{
				var controledElement = this.controledElements[ i ];

				if ( arguments.length == 1 )
					controledElement.isVisible = !arguments[ 0 ];

				controledElement.ChangeVisibility();
			}
		}
	}

	VisibilityControler.prototype.initElements = function()
	{
		if ( this.controledElements )
		{
			for( i = 0; i < this.controledElements.length; i++ )
			{
				var c = this.controledElements[ i ];
				c.isVisible = !c.isVisible;
				c.ChangeVisibility();
			}
		}
	}

	//show-hide functions
	function showElem( elemId )
	{
		var el = document.getElementById( elemId );
		el.style.display = ( ie || el.nodeName != "TR" ) ? "block" : "table-row";
	}

	function hideElem( elemId )
	{
		document.getElementById(elemId).style.display = "none";
	}

	function changeControlerElementsVisibility( controlersCollection, controlerID )
	{
		if ( controlersCollection && controlersCollection[ controlerID ] )
			controlersCollection[ controlerID ].changeElementsVisibility();
	}

	function setControlersElementsVisibility( controlersCollection, visible )
	{
		if ( controlersCollection )
		{
			for( i in controlersCollection )
			{
				controlersCollection[ i ].changeElementsVisibility( visible );
			}
		}
	}

	function initControlersElements( controlersCollection )
	{
		if ( controlersCollection )
		{
			for( i in controlersCollection )
			{
				controlersCollection[ i ].initElements();
			}
		}
	}
