function AttachOnload(MyFunction) {
	if (window.attachEvent) { window.attachEvent("onload",MyFunction); }
	else if (window.addEventListener) { window.addEventListener("load",MyFunction,false); }
}

// attach functions to run on an object's (OBJ) event (EVT)
function AttachEvent(obj, evt, MyFunction) 
{
	if (typeof(obj) == "string") obj = document.getElementById(obj); 

	evt = evt.replace(/^on/i,"");

	if (obj.attachEvent)
		obj.attachEvent("on" + evt, MyFunction);
	else if (obj.addEventListener)
		obj.addEventListener(evt, MyFunction, false);
}

function DoListExpands() 
{
	var anchors = document.getElementsByTagName("a");
	var list = new Array();
	var k = 0;

	for (var i = 0; i < anchors.length; i++)
	{
		var anchor = anchors[i];
		var rel = anchor.getAttribute("rel") || anchor.rel;

		if (rel.match(/^list_expand/i))
		{
			anchor.onclick = function (e) 
			{
				e = e || window.event;

				// get the anchor we clicked on
					var src = e.target || e.srcElement;

				// get rel of this anchor
					var rel = src.getAttribute("rel") || src.rel;

				// get related id (same as rel)
					var obj = document.getElementById(rel);

				if (obj)
				{
					// is it currently expanded or hidden
						var list_expanded = String(src.className).match(/list_expanded/i) ? 1 : 0;

					// remove list_expanded from className
						src.className = String(src.className).replace(/[ ]*list_expanded[ ]*/i,"");	

					if (list_expanded) // turn off
					{
						// hide content
							obj.style.display = "none";
					}
					else // turn off
					{
						// show content
							obj.style.display = "";

						// add list_expanded to class
							src.className+= " list_expanded";
					}

					if (this.hasChildNodes)
					{
						var i = 0;
						var span = this.childNodes[i];
						
						while (!String(span.tagName).match(/span/i) && i < this.childNodes.length) span = this.childNodes[++i];

						if (span) span.innerHTML = list_expanded ? "(Click to show products)" : "(Click to hide products)";
					}
				}

				return false;
			}

			// hide current element
				var obj = document.getElementById(rel);

				if (obj) obj.style.display = "none";

			// modify anchor text
				anchor.innerHTML+= ' <span class="toggle">(Click to show products)</span>';

		}
	}
}


/* FUNCTIONS THAT USED TO BE IN THE HEADER */


	function displayToggle(id)
	{
		if(document.getElementById(id).style.display != 'none')
			document.getElementById(id).style.display = 'none';
		else
			document.getElementById(id).style.display = 'block';
	}

	function topMenu(name,mode,state) {

		var curr_left_img = document.getElementById('top_'+name+'_l');
		var curr_right_img = document.getElementById('top_'+name+'_r');
		var curr_arrow_img = document.getElementById('top_'+name+'_a');
		var curr_link = document.getElementById('top_'+name);

		if(state == 'on')
		{
			curr_left_img.src = left_img.src;
			curr_right_img.src = right_img.src;
			curr_arrow_img.src = arrow_img[1].src;
		}
		else
		{
			if(mode == 'over')
			{
				curr_left_img.src = left_img.src;
				curr_right_img.src = right_img.src;
				curr_arrow_img.src = arrow_img[1].src;
			}
			else if(mode== 'out')
			{
				curr_left_img.src = b_img.src;
				curr_right_img.src = b_img.src;
				curr_arrow_img.src = arrow_img[0].src;
			}
		}
	}

// makes the menu list IE compatible
function sfHover()
{
	var nav = document.getElementById("menu_list_red");
	if (!nav) return;
	
	var li = nav.getElementsByTagName("LI");

	for (var i = 0; i < li.length; i++)
	{
		li[i].onmouseover = function()	{ this.className+= " sfhover"; }
		li[i].onmouseout = function()	{ this.className = this.className.replace(new RegExp(" sfhover\\b"), ""); }
	}
}

// Firefox only likes next line an NOT AttachOnload(sfHover) (makes sub menus stick)
//if (0 /*@cc_on || (window.attachEvent && (@_jscript_version >= 5.7)) @*/) window.attachEvent("onload", sfHover);
//if (0 /*@cc_on || (window.attachEvent && (@_jscript_version < 5.7)) @*/) window.attachEvent("onload", sfHover);
if (window.attachEvent) window.attachEvent("onload", sfHover);