matchHeight = function()
{
     var divs, contDivs, maxHeight, divHeight, d;

     // get all <div> elements in the document

     divs = document.getElementsByTagName('div');

     contDivs = [];

     // initialize maximum height value

     maxHeight = 0;

     // iterate over all <div> elements in the document

     for (var i = 0; i < divs.length; i++)
	 {
          // make collection with <div> elements with class attribute 'container'

          if (/\bcontainer\b/.test(divs[i].className))
		  {
                d = divs[i];

                contDivs[contDivs.length] = d;

                // determine height for <div> element

                if (d.offsetHeight)

                     divHeight = d.offsetHeight;

                else if (d.style.pixelHeight)

                     divHeight = d.style.pixelHeight;

                // calculate maximum height

                maxHeight = Math.max(maxHeight, divHeight);
          }
     }

     // assign maximum height value to all of container <div> elements
	 
	 if (document.getElementById('main').style.height < document.getElementById('left').style.height)
	 	document.getElementById('main').style.height = document.getElementById('left').style.height;

     for (var i = 0; i < contDivs.length; i++)
          contDivs[i].style.height = maxHeight + 'px';
}

// execute function when page loads

window.onload = function()
{
     if (document.getElementsByTagName)
	     matchHeight();
}

function ToggleSubMenu(catID)
{
	var divs, d, contDivs, leftHeight, contentHeight, rightHeight;
	
	divs = document.getElementsByTagName('div');
	contDivs = [];
	
	leftHeight = document.getElementById('left').style.height;
	leftHeight = parseInt(leftHeight.substr(0, leftHeight.length - 2));
	
	contentHeight = document.getElementById('content').style.height;
	contentHeight = parseInt(contentHeight.substr(0, contentHeight.length - 2));
	
	rightHeight = document.getElementById('right').style.height;
	rightHeight = parseInt(rightHeight.substr(0, rightHeight.length - 2));
	
    for (var i = 0; i < divs.length; i++)
	{
		// make collection with <div> elements with class attribute catID
		if (divs[i].className == catID)
		{
			d = divs[i];
		
			contDivs[contDivs.length] = d;
			
			if (d.style.visibility == 'visible')
			{
				// Make sub-category invisible and contract height
				d.style.visibility = 'hidden';
				d.style.display = 'none';
				d.style.height = '0px';
				
				// Set new div heights
				leftHeight = leftHeight - 17;
				
				document.getElementById('left').style.height = leftHeight.toString() + 'px';
				document.getElementById('content').style.height = leftHeight.toString() + 'px';
				document.getElementById('right').style.height = leftHeight.toString() + 'px';
			}
			else
			{
				// Make sub-category visible and expand height
				d.style.visibility = 'visible';
				d.style.display = 'block';
				d.style.height = '12px';
				
				// Set new div heights
				leftHeight = leftHeight + 17;
				
				document.getElementById('left').style.height = leftHeight.toString() + 'px';
				document.getElementById('content').style.height = leftHeight.toString() + 'px';
				document.getElementById('right').style.height = leftHeight.toString() + 'px';
			}
		}
	}
}

function ChangeImg(imgid, imgname, lrgimage)
{
	document.getElementById(imgid + 'img').src = imgname;
	document.getElementById(imgid + 'href').href = lrgimage;
}
