// menuIT
function menuIT(tmode, orientation, salign, mtype, salign_vertical)
{
	var menu_array = new Array();
	
	var parent_menu_array = new Array();
	var sub_menu_array = new Array();
	var parent_menu_image_array = new Array();
	var sub_menu_image_array = new Array();
	
	var mouseout_preloader_image_array = new Array();

	
	var main_menu = null;
	var test_mode = tmode;
	var menu_orientation = orientation;


	var menu_main_type = mtype;


	var menu_width = 0;
	var menu_height = 0;
	var menu_x = 0;
	var menu_y = 0;
	
	var menu_name = "";
	var menu_iframe = null;
	
	var sub_alignment = salign;
	var sub_alignment_vertical = salign_vertical;
	var fix_png = false;


	// IE code IFRAME for IE 6 and older
	if (window.ActiveXObject)
	{
		if (navigator.userAgent.toUpperCase().search(/MSIE/) > -1)
		{
			var start = navigator.userAgent.toUpperCase().search(/MSIE/);
			var tmp_useragent = navigator.userAgent.toUpperCase().substr(start);
			
			start = tmp_useragent.search(/;/);
			tmp_useragent = tmp_useragent.substr(0, start);
			
			tmp_useragent = tmp_useragent.split(" ");
			
			var version = tmp_useragent[1];
			
			version = Number(version);
			
			if (version < 7)
			{
				menu_iframe = document.createElement("iframe");
				
				menu_iframe.style.display = "none";
				menu_iframe.style.position = "absolute";
				menu_iframe.id = "menuIT_iframe";
				menu_iframe.src = "javascript: false;";
				menu_iframe.style.zIndex = "9";
				
				// document.body.appendChild(menu_iframe);
			}
			
			if (5 <= version && version < 7 && navigator.platform.toLowerCase() == "win32")
			{
				fix_png = true;
			}
		}
		else
		{
			menu_iframe = document.createElement("iframe");
			
			menu_iframe.style.display = "none";
			menu_iframe.style.position = "absolute";
			menu_iframe.id = "menuIT_iframe";
			menu_iframe.src = "javascript: false;";
			menu_iframe.style.zIndex = "9";
			
			// document.body.appendChild(menu_iframe);
		}
	}

	
	menu_array[0] = parent_menu_array;
	menu_array[1] = sub_menu_array;
	
	
	this.LoadMenu = function(mname)
	{
		menu_name = mname;
		
		if (document.getElementById(mname + "_" + menu_orientation))
		{
			LoadMainMenu(mname, this);
		}
		else
		{
			if (test_mode)
			{
				alert("Unable to locate menu.");	
			}
		}
	};
	
	
	function LoadMainMenu(mname, menuIT)
	{
		if (menu_orientation == "horizontal" && document.getElementById(mname + "_horizontal_lvl_one_container"))
		{
			main_menu = document.getElementById(mname + "_horizontal_lvl_one_container");
			var row = 0;
			
			var mwidth = 0;
			var mheight = 0;
			var position = null;
			var preload_image = null;
			
			var mouseover = null;
			var start_position = null;
			var end_position = null;
			var image_row = 0;


			for (var i = 0; i < main_menu.childNodes.length; i++)
			{
				if (main_menu.childNodes[i].id.length > 0)
				{
					row = parent_menu_array.push(main_menu.childNodes[i]) - 1;
					parent_menu_array[row].childMenu = null;
					parent_menu_array[row].menuIT = menuIT;
					parent_menu_array[row].mouseIsOut = true;
					
					SetMainMenuProperties(parent_menu_array[row]);
					
					if (main_menu.childNodes[i].firstChild.firstChild.nodeName.toLowerCase() == "img")
					{
						main_menu.childNodes[i].firstChild.firstChild.menuIT = menuIT;
						main_menu.childNodes[i].firstChild.firstChild.parentMenu = main_menu.childNodes[i];
						
						parent_menu_image_array.push(main_menu.childNodes[i].firstChild.firstChild);
						
						
						// Get mouseover image
						mouseover = String(main_menu.childNodes[i].firstChild.firstChild.onmouseover);

						start_position = mouseover.indexOf("/");
						end_position = mouseover.indexOf(";");
					
						mouseover = mouseover.substring(start_position, end_position - 1);						
						
						image_row = mouseout_preloader_image_array.push(new Image()) - 1;
						
						mouseout_preloader_image_array[image_row].src = mouseover;
						
						
						
						if (parent_menu_image_array.length == 1)
						{
							setTimeout("IsImageLoaded('" + main_menu.childNodes[i].firstChild.firstChild.id + "')", 50);
						}
					}
				}


				if (main_menu.childNodes[i].nodeName.toLowerCase() == "div")
				{
					mwidth += main_menu.childNodes[i].offsetWidth;
					
					if (mheight == 0)
					{
						mheight = main_menu.childNodes[i].offsetHeight;
					}
					
					if (position == null)
					{
						position = GetObjectPosition(main_menu.childNodes[i]);
					}
				}
			}


			if (parent_menu_image_array.length == 0)
			{
				menuIT.SetContainerWidth();
			}
				

			menu_width = mwidth;
			menu_height = mheight;
			menu_x = position.x;
			menu_y = position.y;
			
			LoadSubMenu(mname, menuIT);
		}
		else if (menu_orientation == "vertical" && document.getElementById(mname + "_vertical_lvl_one_container"))
		{
			main_menu = document.getElementById(mname + "_vertical_lvl_one_container");
			var row = 0;
			
			var mwidth = 0;
			var mheight = 0;
			var position = null;


			var mouseover = null;
			var start_position = null;
			var end_position = null;
			var image_row = 0;


			for (var i = 0; i < main_menu.childNodes.length; i++)
			{
				if (main_menu.childNodes[i].id.length > 0)
				{
					row = parent_menu_array.push(main_menu.childNodes[i]) - 1;
					parent_menu_array[row].childMenu = null;
					parent_menu_array[row].menuIT = menuIT;
					parent_menu_array[row].mouseIsOut = true;
					
					SetMainMenuProperties(parent_menu_array[row]);
					
					if (main_menu.childNodes[i].firstChild.firstChild.nodeName.toLowerCase() == "img")
					{
						main_menu.childNodes[i].firstChild.firstChild.menuIT = menuIT;
						main_menu.childNodes[i].firstChild.firstChild.parentMenu = main_menu.childNodes[i];
						
						parent_menu_image_array.push(main_menu.childNodes[i].firstChild.firstChild);



						// Get mouseover image
						mouseover = String(main_menu.childNodes[i].firstChild.firstChild.onmouseover);

						start_position = mouseover.indexOf("/");
						end_position = mouseover.indexOf(";");
					
						mouseover = mouseover.substring(start_position, end_position - 1);						
						
						image_row = mouseout_preloader_image_array.push(new Image()) - 1;
						
						mouseout_preloader_image_array[image_row].src = mouseover;



						if (parent_menu_image_array.length == 1)
						{
							setTimeout("IsImageLoaded('" + main_menu.childNodes[i].firstChild.firstChild.id + "')", 50);
						}
					}
				}
			}


			if (parent_menu_image_array.length == 0)
			{
				menuIT.SetContainerWidth();
			}


			position = GetObjectPosition(main_menu);
			menu_x = position.x;
			menu_y = position.y;

			LoadSubMenu(mname, menuIT);
			
		}
		else
		{
			if (test_mode)
			{
				alert("Unable to locate menu.");	
			}	
		}


		if (main_menu.childNodes[0])
		{
			if (main_menu.childNodes[0].firstChild.firstChild.nodeName.toLowerCase() == "img")
			{
				setTimeout("IsMouseOverImageLoaded('" + main_menu.childNodes[0].firstChild.firstChild.id + "')", 100);
			}
		}

		
		if (main_menu != null && parent_menu_image_array.length > 0)
		{
			main_menu.style.visibility = "hidden";
		}
	}


	function LoadSubMenu(mname, menuIT)
	{
		var sub_menu = null;
		var increment = 0;
		var image_increment = 0;


		var mouseover = null;
		var start_position = null;
		var end_position = null;
		var image_row = 0;

		var mouseout = "";
		var mouseover = "";
		
		var start_position = 0;
		var end_position = 0;
		
		var sub_image = null;


		for (var i = 0; i < parent_menu_array.length; i++)
		{
			increment += 1;

			if (document.getElementById(mname + "_" + menu_orientation + "_lvl_two_" + increment))
			{
				sub_menu = document.getElementById(mname + "_" + menu_orientation + "_lvl_two_" + increment);
				
				sub_menu_array[i] = sub_menu;
				sub_menu_array[i].parentMenu = parent_menu_array[i];
				sub_menu_array[i].menuIT = menuIT;
				sub_menu_array[i].mouseIsOut = true;
				
				sub_menu_array[i].adjust_x = Number(sub_menu_array[i].style.left.replace(/px/, ""));
				sub_menu_array[i].adjust_y = Number(sub_menu_array[i].style.top.replace(/px/, ""));
				

				parent_menu_array[i].childMenu = sub_menu_array[i];


				SetSubMenuProperties(sub_menu_array[i]);


				for (var j = 0; j < sub_menu_array[i].childNodes.length; j++)
				{
					image_increment += 1;

					if (
						sub_menu_array[i].childNodes[j].firstChild.nodeName.toLowerCase() == "a" && 
						sub_menu_array[i].childNodes[j].firstChild.firstChild.nodeName.toLowerCase() == "img"
						)
					{
						sub_image = sub_menu_array[i].childNodes[j].firstChild.firstChild;
						
						sub_image.id = menu_name + "_" + menu_orientation + "_image_" + increment;
						sub_image.menuIT = menuIT;
						sub_menu_image_array.push(sub_image);
						

						// Get mouseover image
						mouseover = String(sub_image.onmouseover);
	
						start_position = mouseover.indexOf("/");
						end_position = mouseover.indexOf(";");
					
						mouseover = mouseover.substring(start_position, end_position - 1);						
						
						image_row = mouseout_preloader_image_array.push(new Image()) - 1;
						
						mouseout_preloader_image_array[image_row].src = mouseover;
						
						mouseout_preloader_image_array[image_row].parentImage = sub_image;
	


						if (sub_menu_array.length == 1)
						{
							setTimeout("IsSubImageLoaded('" + sub_image.id + "')", 50);
						}
						
						
						
						if (fix_png)
						{
							mouseout = String(sub_image.onmouseout);
							mouseover = String(sub_image.onmouseover);
							
							start_position = mouseout.indexOf("/");
							end_position = mouseout.indexOf(";");
							
							mouseout = mouseout.substring(start_position, end_position - 1);
							
							start_position = mouseover.indexOf("/");
							end_position = mouseover.indexOf(";");
							
							mouseover = mouseover.substring(start_position, end_position - 1);
							
							
							//setTimeout("SetImageDimensions('" + sub_image.id + "')", 40);
							
							
							/*
							var tmp_image = new Image();
							tmp_image.src = sub_image.src;
							
							sub_image.style.width = tmp_image.width + "px";
							sub_image.style.height = tmp_image.height + "px";	
							
							
							tmp_image = null;
							*/
							

							if (mouseout.substring(mouseout.length - 4).toLowerCase() == ".png")
							{
								sub_image.mouseout = mouseout;
								sub_image.onmouseout = function()
								{
									var tmp_path_array = this.mouseout.split("/");
									var tmp_path = "";
									
									for (var k = 1; k < tmp_path_array.length - 2; k++)
									{
										tmp_path += "/" + tmp_path_array[k];
									}
									
									tmp_path += "/spacer.gif";
									
									this.src = tmp_path;
									this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.mouseout + "',sizingMethod='scale')";
								};
							}
	
	
							if (mouseover.substring(mouseover.length - 4).toLowerCase() == ".png")
							{
								sub_image.mouseover = mouseover;
								sub_image.onmouseover = function()
								{
									var tmp_path_array = this.mouseover.split("/");
									var tmp_path = "";
									
									for (var k = 1; k < tmp_path_array.length - 2; k++)
									{
										tmp_path += "/" + tmp_path_array[k];
									}
									
									tmp_path += "/spacer.gif";
									
									this.src = tmp_path;
									this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.mouseover + "',sizingMethod='scale')";
								};
							}
	
	
							if (sub_image.mouseout)
							{
								var tmp_path_array = sub_image.mouseout.split("/");
								var tmp_path = "";
								
								for (var k = 1; k < tmp_path_array.length - 2; k++)
								{
									tmp_path += "/" + tmp_path_array[k];
								}
								
								tmp_path += "/spacer.gif";
									
		
								sub_image.src = tmp_path;
								sub_image.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + sub_image.mouseout + "',sizingMethod='scale')";
							}
						}
					}

				}
			}
			else
			{
				sub_menu_array[i] = null;
			}
			
		}
	}







	function SetMainMenuProperties(main_menu_item)
	{
		main_menu_item.onmouseover = function()
		{
			//var messages = document.getElementById("messages");
			//messages.innerHTML = this.className + "<br />" + messages.innerHTML;

			this.mouseIsOut = false;
			
			if (this.className == "in_off" || this.className == "in_on")
			{
				this.className = "in_on";
			}
			else
			{
				this.className = "on";
			}
			
			
			if (menu_main_type == "image")
			{
				this.firstChild.firstChild.onmouseover();
			}


			if (this.childMenu != null)
			{
				this.childMenu.style.display = "block";
				this.menuIT.SetSubMenuPosition(this.childMenu);
			}
		};
		
		main_menu_item.onmouseout = function()
		{
			this.mouseIsOut = true;
			this.menuIT.IsMouseOut(this);
		};
	}
	
	
	function SetSubMenuProperties(sub_menu_item)
	{
		sub_menu_item.onmouseover = function()
		{
			this.mouseIsOut = false;

			if (menu_main_type == "image")
			{
				this.parentMenu.firstChild.firstChild.onmouseover();
			}
		};
		
		sub_menu_item.onmouseout = function()
		{
			this.mouseIsOut = true;
			this.menuIT.IsMouseOut(this.parentMenu);
		};
	}
	
	
	this.SetSubMenuPosition = function(sub_menu_item)
	{
		var position = GetObjectPosition(sub_menu_item.parentMenu);
		var x = 0;
		var y = 0;

		menu_width = main_menu.offsetWidth;

		menu_x = GetObjectPosition(main_menu).x;
		
		if (menu_orientation == "horizontal")
		{
			if (sub_alignment == "default")
			{
				if (menu_width > sub_menu_item.offsetWidth)
				{
					//alert(menu_width + " " + menu_x + " " + position.x + " " + sub_menu_item.offsetWidth + " " + sub_menu_item.parentMenu.offsetWidth);
					
					if ((menu_width + menu_x) < (position.x + sub_menu_item.offsetWidth) && sub_menu_item.offsetWidth > sub_menu_item.parentMenu.offsetWidth)
					{
						x = position.x - (sub_menu_item.offsetWidth - sub_menu_item.parentMenu.offsetWidth) + sub_menu_item.adjust_x;
						y = position.y + sub_menu_item.parentMenu.offsetHeight + sub_menu_item.adjust_y;
						
						//alert(x + " " + menu_x + " " + position.x + " " + sub_menu_item.offsetWidth + " " + sub_menu_item.parentMenu.offsetWidth + " " + sub_menu_item.adjust_x);
						
						if (x < menu_x)
						{
							x = position.x + sub_menu_item.adjust_x;
							y = position.y + sub_menu_item.parentMenu.offsetHeight + sub_menu_item.adjust_y;	
						}
					}
					else
					{
						x = position.x + sub_menu_item.adjust_x;
						y = position.y + sub_menu_item.parentMenu.offsetHeight + sub_menu_item.adjust_y;	
					}
				}
				else
				{
					x = position.x + sub_menu_item.adjust_x;
					y = position.y + sub_menu_item.parentMenu.offsetHeight + sub_menu_item.adjust_y;	
				}
			}
			else if (sub_alignment == "left")
			{
				x = position.x + sub_menu_item.adjust_x;
				y = position.y + sub_menu_item.parentMenu.offsetHeight + sub_menu_item.adjust_y;	
			}
			else if (sub_alignment == "right")
			{
				x = position.x - (sub_menu_item.offsetWidth - sub_menu_item.parentMenu.offsetWidth) + sub_menu_item.adjust_x;
				y = position.y + sub_menu_item.parentMenu.offsetHeight + sub_menu_item.adjust_y;
			}

			
			if (menu_iframe != null && !document.getElementById(menu_iframe.id))
			{
				document.body.appendChild(menu_iframe);	
			}


			if (document.getElementById("menuIT_iframe"))
			{
				document.getElementById("menuIT_iframe").style.display = "block";
				document.getElementById("menuIT_iframe").style.left = String(x) + "px";
				document.getElementById("menuIT_iframe").style.top = String(y) + "px";
				document.getElementById("menuIT_iframe").style.width = sub_menu_item.offsetWidth;
				document.getElementById("menuIT_iframe").style.height = sub_menu_item.offsetHeight;
				document.getElementById("menuIT_iframe").main_menu_id = sub_menu_item.parentMenu.id;
			}

			sub_menu_item.style.zIndex = "10";
			sub_menu_item.style.left = String(x) + "px";
			sub_menu_item.style.top = String(y) + "px";
		}
		else
		{
			if (sub_alignment_vertical == "right")
			{
				x = position.x + sub_menu_item.parentMenu.offsetWidth;
				y = position.y;
				
				sub_menu_item.style.zIndex = "10";
				sub_menu_item.style.left = String(x) + "px";
				sub_menu_item.style.top = String(y) + "px";
			}
			else
			{
				x = position.x - sub_menu_item.offsetWidth;
				y = position.y;
				
				sub_menu_item.style.zIndex = "10";
				sub_menu_item.style.left = String(x) + "px";
				sub_menu_item.style.top = String(y) + "px";
			}
		}
	}
	
	
	function GetObjectPosition(obj)
	{
		var x = 0;
		var y = 0;
		var position = new Object();
		
		if (obj.offsetParent)
		{
			x = obj.offsetLeft;
			y = obj.offsetTop;
			
			while (obj = obj.offsetParent)
			{
				x += obj.offsetLeft;
				y += obj.offsetTop;
			}
		}
		
		position.x = x;
		position.y = y;
		
		return position;
	}
	

	this.IsMouseOut = function(main_menu_item)
	{
		setTimeout("menuIT_TestMouseOut('" + main_menu_item.id + "');", 20);
	}




	this.SetContainerWidth = function()
	{

		var mouseout;
		var mouseover;
		var start_position;
		var end_position;

		
		if (parent_menu_image_array.length > 0)
		{
			for (var i = 0; i < parent_menu_image_array.length; i++)
			{
				// FIX INCLUDED FOR SAFARI NOT RECOGNIZING img.complete CORRECTLY
				if (parent_menu_image_array[i].complete == false || (parent_menu_image_array[i].complete == "undefined" && parent_menu_image_array[i].width == 0))
				{
					setTimeout("IsImageLoaded('" + parent_menu_image_array[i].id + "')", 50);

					return;
				}
				

				
				if (fix_png)
				{
					mouseout = String(parent_menu_image_array[i].onmouseout);
					mouseover = String(parent_menu_image_array[i].onmouseover);
					
					start_position = mouseout.indexOf("/");
					end_position = mouseout.indexOf(";");
					
					mouseout = mouseout.substring(start_position, end_position - 1);
					
					start_position = mouseover.indexOf("/");
					end_position = mouseover.indexOf(";");
					
					mouseover = mouseover.substring(start_position, end_position - 1);


					parent_menu_image_array[i].style.width = parent_menu_image_array[i].offsetWidth + "px";
					parent_menu_image_array[i].style.height = parent_menu_image_array[i].offsetHeight + "px";

					if (mouseout.substring(mouseout.length - 4).toLowerCase() == ".png")
					{
						parent_menu_image_array[i].mouseout = mouseout;
						parent_menu_image_array[i].onmouseout = function()
						{
							var tmp_path_array = this.mouseout.split("/");
							var tmp_path = "";
							
							for (var j = 1; j < tmp_path_array.length - 2; j++)
							{
								tmp_path += "/" + tmp_path_array[j];
							}
							
							tmp_path += "/spacer.gif";
							
							this.src = tmp_path;
							this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.mouseout + "',sizingMethod='scale')";
						};
					}
					
					if (mouseover.substring(mouseover.length - 4).toLowerCase() == ".png")
					{
						parent_menu_image_array[i].mouseover = mouseover;
						parent_menu_image_array[i].onmouseover = function()
						{
							var tmp_path_array = this.mouseout.split("/");
							var tmp_path = "";
							
							for (var j = 1; j < tmp_path_array.length - 2; j++)
							{
								tmp_path += "/" + tmp_path_array[j];
							}
							
							tmp_path += "/spacer.gif";
							
							this.src = tmp_path;
							this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.mouseover + "',sizingMethod='scale')";
						};
					}
					
					
					

					if (parent_menu_image_array[i].mouseout)
					{
						var tmp_path_array = parent_menu_image_array[i].mouseout.split("/");
						var tmp_path = "";

						for (var j = 1; j < tmp_path_array.length - 2; j++)
						{
							tmp_path += "/" + tmp_path_array[j];
						}
						
						tmp_path += "/spacer.gif";

						
						parent_menu_image_array[i].src = tmp_path;
						parent_menu_image_array[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + parent_menu_image_array[i].mouseout + "',sizingMethod='scale')";
					}
				}
			}
		}


		

		if (menu_orientation == "horizontal")
		{
			var w = 0;

			for (var i = 0; i < main_menu.childNodes.length; i++)
			{
				if (main_menu.childNodes[i].nodeType == 1)
				{
					w += main_menu.childNodes[i].offsetWidth;
				}
			}

			main_menu.style.width = w + "px";
		}
		else
		{
			var w = 0;

			w = main_menu.offsetWidth;

			main_menu.style.width = w + "px";
		}
		
		menu_width = w;
		menu_height = main_menu.offsetHeight;


		if (mouseout_preloader_image_array.length == 0)
		{
			main_menu.style.visibility = "visible";
		}
	};
	
	

	
	
	this.IsMouseOverImagePreloader = function(img_id)
	{
		var tmp_image = null;
		
		if (mouseout_preloader_image_array.length > 0)
		{
			for (var i = 0; i < mouseout_preloader_image_array.length; i++)
			{
				// FIX INCLUDED FOR SAFARI NOT RECOGNIZING img.complete CORRECTLY
				if (mouseout_preloader_image_array[i].complete == false || (mouseout_preloader_image_array[i].complete == "undefined" && mouseout_preloader_image_array[i].width == 0))
				{
					setTimeout("IsMouseOverImageLoaded('" + img_id + "')", 50);

					return;
				}
			}
		}


		while (mouseout_preloader_image_array.length != 0)
		{
			tmp_image = mouseout_preloader_image_array.pop();
			
			if (tmp_image.parentImage)
			{
				tmp_image.parentImage.style.width = tmp_image.width + "px";
				tmp_image.parentImage.style.height = tmp_image.height + "px";
				
				tmp_image.parentImage = null;
			}
			
			tmp_image = null;
		}
		

		
		

		if (mouseout_preloader_image_array.length == 0 && main_menu.style.visibility == "hidden")
		{
			main_menu.style.visibility = "visible";
		}
	};
}






function menuIT_TestMouseOut(main_menu_item_id)
{
	var main_menu_item = document.getElementById(main_menu_item_id);
	

	if (main_menu_item.childMenu != null)
	{
		if (main_menu_item.mouseIsOut && main_menu_item.childMenu.mouseIsOut)
		{
			if (main_menu_item.className == "in_on" || main_menu_item.className == "in_off")
			{
				main_menu_item.className = "in_off";
			}
			else
			{
				main_menu_item.className = "off";
			}
			
			main_menu_item.childMenu.style.display = "none";

			if (document.getElementById("menuIT_iframe") && document.getElementById("menuIT_iframe").main_menu_id == main_menu_item_id)
			{
				document.getElementById("menuIT_iframe").style.display = "none";
			}
			
			if (main_menu_item.firstChild.nodeName.toLowerCase() == "a" && main_menu_item.firstChild.firstChild.nodeName.toLowerCase() == "img")
			{
				main_menu_item.firstChild.firstChild.onmouseout();
			}
		}
	}
	else if (main_menu_item.mouseIsOut)
	{
		if (main_menu_item.className == "in_on" || main_menu_item.className == "in_off")
		{
			main_menu_item.className = "in_off";
		}
		else
		{
			main_menu_item.className = "off";
		}
		
		if (main_menu_item.firstChild.nodeName.toLowerCase() == "a" && main_menu_item.firstChild.firstChild.nodeName.toLowerCase() == "img")
		{
			main_menu_item.firstChild.firstChild.onmouseout();
		}
	}
}







function IsImageLoaded(img_id)
{
	var image = document.getElementById(img_id);

	image.menuIT.SetContainerWidth();
}




function IsMouseOverImageLoaded(img_id)
{
	var image = document.getElementById(img_id);

	image.menuIT.IsMouseOverImagePreloader(img_id);
}





function IsSubImageLoaded(img_id)
{
	var image = document.getElementById(img_id);

	//image.menuIT.SetContainerWidth();
}



/*
function SetImageDimensions(img_id)
{
	if (document.getElementById(img_id))
	{
		var image = document.getElementById(img_id);
		
		alert(image.id);
		
		if (image.width == 0)
		{
			setTimeout("SetImageDimensions('" + img_id + "')", 40);
		}
		else
		{
			image.style.width = image.width + "px";
			image.style.height = image.height + "px";
		}
	}
	else
	{
		alert("not found " + img_id);
	}
}
*/







function menuITSettings()
{
	var aform = null;
	var uwidth_label = null;
	var align_label = null;
	var valign_label = null;



	this.ValidateSettingsForm = function()
	{
		if (aform.menu_name.value.search(/\W/) > -1 || aform.menu_name.value.length == 0)
		{
			alert("Please enter a menu name using only Letters, Numbers and Underscores.");
			return false;
		}

		if (aform.uniform[0].checked == false && aform.uniform[1].checked == false)
		{
			alert("Please select if you want to use uniform widths.");
			return false;
		}
		
		if (aform.main_type[0].checked == false && aform.main_type[1].checked == false)
		{
			alert("Please select if the main menu will use text or images.");
			return false;
		}

		if (aform.sub_dropdown[0].checked == false && aform.sub_dropdown[1].checked == false)
		{
			alert("Please select if you want a dropdown sub menu generated automatically.");
			return false;
		}

		if (aform.sub_dropdown[0].checked == true && aform.sub_type[0].checked == false && aform.sub_type[1].checked == false)
		{
			alert("Please select if the sub menu will use text or images.");
			return false;
		}



		
		if (aform.main_delimiter.value.length > 0 && aform.main_delimiter2.value.length > 0)
		{
			alert("Please set only 1 main menu delimiter.");
			return false;
		}

		if (aform.main_delimiter2.value.length > 0)
		{
			var delimiter = aform.main_delimiter2.value;
			
			delimiter = delimiter.substr(delimiter.lastIndexOf('.'), delimiter.length - delimiter.lastIndexOf('.')).toLowerCase();
			
			if (delimiter != ".jpg" && delimiter != ".png" && delimiter != ".gif")
			{
				alert("A delimiter image can only be a jpg, png or gif.");
				return false;
			}
		}



		if (aform.crumb_delimiter.value.length > 0 && aform.crumb_delimiter2.value.length > 0)
		{
			alert("Please set only 1 bread crumb delimiter.");
			return false;
		}

		if (aform.crumb_delimiter2.value.length > 0)
		{
			var delimiter = aform.crumb_delimiter2.value;
			
			delimiter = delimiter.substr(delimiter.lastIndexOf('.'), delimiter.length - delimiter.lastIndexOf('.')).toLowerCase();
			
			if (delimiter != ".jpg" && delimiter != ".png" && delimiter != ".gif")
			{
				alert("A delimiter image can only be a jpg, png or gif.");
				return false;
			}
		}
		
		
		if (aform.custom_css[0].checked == false && aform.custom_css[1].checked == false)
		{
			alert("Please select if you want to use custom css.");
			return false;
		}
	};



	this.SetSubMenu = function()
	{
		if (aform.sub_dropdown[0].checked)
		{
			aform.sub_alignment.className = "";

			aform.sub_type[0].disabled = false;
			aform.sub_type[1].disabled = false;
			aform.sub_alignment.disabled = false;
			aform.sub_bullet[0].disabled = false;
			aform.sub_bullet[1].disabled = false;
			
			if (aform.sub_bullet[0].checked)
			{
				aform.sub_bullet_image.disabled = false;
				aform.sub_bullet_image.className = "";
			}
			else
			{
				aform.sub_bullet_image.disabled = true;
				aform.sub_bullet_image.className = "disabled";
			}
		}
		else
		{
			aform.sub_type[1].checked = true;
			aform.sub_alignment[0].selected = true;
			aform.sub_bullet[1].checked = true;
			
			aform.sub_alignment.className = "disabled";
			aform.sub_bullet_image.className = "disabled";

			aform.sub_type[0].disabled = true;
			aform.sub_type[1].disabled = true;
			aform.sub_alignment.disabled = true;
			aform.sub_bullet[0].disabled = true;
			aform.sub_bullet[1].disabled = true;
			aform.sub_bullet_image.disabled = true;
		}
	}


	this.InitializeForm = function(formObj, uwidth, align, valign)
	{
		aform = formObj;
		uwidth_label = uwidth;
		align_label = align;
		valign_label = valign;

		this.SetSubMenu(aform);
	};
}





function menuITData()
{
	var aform = null;
	
	
	this.ValidateDataForm = function()
	{
		if (aform.name.value.length == 0)
		{
			alert("Please enter a name.");
			return false;
		}

		if (aform.url.value.length == 0)
		{
			alert("Please enter the URL.");
			return false;
		}

		if (aform.image_file_off)
		{
			if (aform.image_file_off.value.length == 0 && !aform.menu_id)
			{
				alert("Please enter the image file for onMouseOut to be used.");
				return false;
			}
		}

		if (aform.image_file_on)
		{
			if (aform.image_file_on.value.length == 0 && !aform.menu_id)
			{
				alert("Please enter the image file for onMouseOver to be used.");
				return false;
			}
		}
		
		if (aform.sub_x.value.length == 0)
		{
			alert("Please enter the X adjustment.");
			return false;
		}
	}


	this.SetWindowOptions = function(initialize)
	{
		if (aform.new_window[0].checked)
		{
			aform.width.disabled = false;
			aform.height.disabled = false;
			aform.top.disabled = false;
			aform.left.disabled = false;
			aform.location.disabled = false;
			aform.menubar.disabled = false;
			aform.titlebar.disabled = false;
			aform.toolbar.disabled = false;
			aform.status.disabled = false;
			aform.scrollbars.disabled = false;
			aform.resizable.disabled = false;
			aform.fullscreen.disabled = false;

			aform.width.className = "";
			aform.height.className = "";
			aform.top.className = "";
			aform.left.className = "";
			aform.location.className = "";
			aform.menubar.className = "";
			aform.titlebar.className = "";
			aform.toolbar.className = "";
			aform.status.className = "";
			aform.scrollbars.className = "";
			aform.resizable.className = "";
			aform.fullscreen.className = "";
			
			if (!initialize)
			{
				aform.width.value = "";
				aform.height.value = "";
				aform.top.value = "";
				aform.left.value = "";

				aform.location.checked = true;
				aform.menubar.checked = true;
				aform.titlebar.checked = true;
				aform.toolbar.checked = true;
				aform.status.checked = true;
				aform.scrollbars.checked = true;
				aform.resizable.checked = true;
				aform.fullscreen.checked = false;
			}
		}
		else
		{
			aform.width.disabled = true;
			aform.height.disabled = true;
			aform.top.disabled = true;
			aform.left.disabled = true;
			aform.location.disabled = true;
			aform.menubar.disabled = true;
			aform.titlebar.disabled = true;
			aform.toolbar.disabled = true;
			aform.status.disabled = true;
			aform.scrollbars.disabled = true;
			aform.resizable.disabled = true;
			aform.fullscreen.disabled = true;

			aform.width.value = "";
			aform.height.value = "";
			aform.top.value = "";
			aform.left.value = "";

			aform.location.checked = false;
			aform.menubar.checked = false;
			aform.titlebar.checked = false;
			aform.toolbar.checked = false;
			aform.status.checked = false;
			aform.scrollbars.checked = false;
			aform.resizable.checked = false;
			aform.fullscreen.checked = false;

			aform.width.className = "disabled";
			aform.height.className = "disabled";
			aform.top.className = "disabled";
			aform.left.className = "disabled";
			aform.location.className = "disabled";
			aform.menubar.className = "disabled";
			aform.titlebar.className = "disabled";
			aform.toolbar.className = "disabled";
			aform.status.className = "disabled";
			aform.scrollbars.className = "disabled";
			aform.resizable.className = "disabled";
			aform.fullscreen.className = "disabled";
		}
	}


	this.InitializeForm = function(formObj)
	{
		aform = formObj;
		
		this.SetWindowOptions(true);
	}
}