/* ============================================================================
 * Companyname: cvcity.nl
 * Description: Common JavaScript
 * Designed by: 
 * Designed on: 06-06-2006
 * ============================================================================
 * History:
 * 
 * Version   Date        Comment                                     Initials
 * --------  ----------  ------------------------------------------  ----------
 * 1.00.000  06-06-2006  Design                                      DaGo
 * ============================================================================ */

window.onload = function()
{
	initMenu("topmenu");
	correctBackgroundPNG();
}

/* ==================================================================
 * Section Menu.
 * ================================================================== */

var currentMenu;
var hideMenuTimer;

function initMenu(menuID)
{
	if (document.getElementById(menuID))
	{
		// Get all the list items within the menu
		var menuRoot = document.getElementById(menuID);

		// currentStyle restricts IE only
		if (document.all && menuRoot.currentStyle)
		{
			var menuList = menuRoot.getElementsByTagName("LI");

			for (i = 0; i < menuList.length; i++)
			{
				// If the LI has another menu level
				if (menuList[i].lastChild.tagName == "UL")
				{
					// Assign the onmouseover event
					menuList[i].onmouseover = function()
					{
						hideMenu();
						this.lastChild.style.display = "block";
						currentMenu = this.lastChild;
					}

					// Assign the onmouseout event
					menuList[i].onmouseout = function()
					{
						hideMenuTimer = setTimeout("hideMenu()", 300);
					}
				}
			}
		}
	}
}

function hideMenu()
{
	clearTimeout(hideMenuTimer);

	if (currentMenu)
	{
		currentMenu.style.display = "none";
		currentMenu = null;
	}
}

/* ==================================================================
 * Correct background PNG transparency.
 * ================================================================== */

function correctBackgroundPNG()
{
	var divRoot = document.getElementById("container");

	if (document.all && divRoot.currentStyle)
	{
		var divList = divRoot.getElementsByTagName("div");

		for (i = 0; i < divList.length ; i++ )
		{
			var blnFilter = false;
			var divFilter = "progid:DXImageTransform.Microsoft.AlphaImageLoader";
			var divFilterProperties = "";

			// Split class names
			var className = divList[i].className;
			var classNameArray = className.split(" ");

			for (c = 0; c < classNameArray.length; c++)
			{
				// Get filter properties
				switch (classNameArray[c])
				{
					case "content_top":
						divFilterProperties += "src=\'images/layout/001/background_content_top.png\', ";
						divFilterProperties += "sizingMethod=\'crop\'";
						blnFilter = true;
						break;
					case "content_body":
						divFilterProperties += "src=\'images/layout/001/background_content_body.png\', ";
						divFilterProperties += "sizingMethod=\'scale\'";
						blnFilter = true;
						break;
					case "content_bottom":
						divFilterProperties += "src=\'images/layout/001/background_content_bottom.png\', ";
						divFilterProperties += "sizingMethod=\'crop\'";
						blnFilter = true;
						break;
					case "border_content_top":
						divFilterProperties += "src=\'images/layout/001/background_border_content_top.png\', ";
						divFilterProperties += "sizingMethod=\'crop\'";
						blnFilter = true;
						break;
					case "border_content_body":
						divFilterProperties += "src=\'images/layout/001/background_border_content_body.png\', ";
						divFilterProperties += "sizingMethod=\'scale\'";
						blnFilter = true;
						break;
					case "border_content_bottom":
						divFilterProperties += "src=\'images/layout/001/background_border_content_bottom.png\', ";
						divFilterProperties += "sizingMethod=\'crop\'";
						blnFilter = true;
						break;
					default:
						break;
				}

				// Set filter
				if (blnFilter)
				{
					divList[i].style.filter = divFilter + "(" + divFilterProperties + ")";
					divList[i].style.backgroundImage = 'none';
				}
			}
		}
	}
}

