﻿function DivisionMaster_Init()
{
	SearchForm_Init();
	SuperiorProductLineSelectBox_Init();
	DivisionDropDownMenu_Init();
	
	var contentcontainer = document.getElementById("contentcontainer");
	var leftcontainer = document.getElementById("leftcontainer");

	// ensures that the content area is at least as long vertically as the left menu
	if(contentcontainer.clientHeight < leftcontainer.clientHeight)
	{
		contentcontainer.style.minHeight = leftcontainer.clientHeight + "px";
		contentcontainer.style.height = contentcontainer.style.minHeight;		// required for MSIE
	}
}

function SearchForm_Init()
{
	var modelnumber = document.getElementById("modelnumber");
	var defaultText = modelnumber.value;

	document.getElementById('searchbutton').disabled = true;

	modelnumber.onfocus = function()
	{
		if(this.value == defaultText)
		{
			document.getElementById('searchbutton').disabled = false;
			this.value = "";
			this.style.color = "black";
		}
	}
	
	modelnumber.onblur = function()
	{
		if(this.value == "")
		{
			document.getElementById('searchbutton').disabled = true;
			this.value = defaultText;
			this.style.color = "#999999";
		}
	}
}

function SuperiorProductLineSelectBox_Init()
{
	var selSuperiorProductLine = document.getElementById("leftcontainer").getElementsByTagName("select")[0];
	
	if(selSuperiorProductLine)
	    selSuperiorProductLine.onchange = function() { window.location.href = this.value; }
}

function DivisionDropDownMenu_Init()
{
	// mimics :hover CSS pseudo class for IE5 and above (reference:  www.alistapart.com/articles/dropdowns/)
	if(document.all && document.getElementById)
	{
		var divisiondropdownmenuParent = document.getElementById("divisiondropdownmenu").parentNode;
		divisiondropdownmenuParent.onmouseover = function() { this.className += " hover"; }		// The "hover" class is defined in Division.css.
		divisiondropdownmenuParent.onmouseout = function() { this.className = this.className.replace(" hover", ""); }
	}
}