// JavaScript Document

	var buttonover = false;
	
	function ButtonMouseOver(btn)
	{
		PositionMenus();
				
		if (btn.id == "HomeButton")
		{
			btn.style.background = "url(images/menubuttons/homeover.gif)";
		}
		else if (btn.id == "ProductsButton")
		{
			btn.style.background = "url(images/menubuttons/productsover.gif)";
		}	
		else if (btn.id == "ServicesButton")
		{
			btn.style.background = "url(images/menubuttons/servicesover.gif)";
		}		
		else if (btn.id == "AboutButton")
		{
			btn.style.background = "url(images/menubuttons/aboutover.gif)";
		}					
		else if (btn.id == "ContactButton")
		{
			btn.style.background = "url(images/menubuttons/contactover.gif)";
		}
		
		buttonover = true;
	}
	
	function ButtonMouseOut(btn)
	{
		if (btn.id == "HomeButton")
		{
			btn.style.background = "url(images/menubuttons/home.gif)";
		}
		else if (btn.id == "ProductsButton")
		{
			btn.style.background = "url(images/menubuttons/products.gif)";
		}	
		else if (btn.id == "ServicesButton")
		{
			btn.style.background = "url(images/menubuttons/services.gif)";
		}		
		else if (btn.id == "AboutButton")
		{
			btn.style.background = "url(images/menubuttons/about.gif)";
		}					
		else if (btn.id == "ContactButton")
		{
			btn.style.background = "url(images/menubuttons/contact.gif)";
		}
		
		buttonover = false;
	}
	
	function ButtonMouseDown(btn)
	{
		if (btn.id == "HomeButton")
		{
			btn.style.background = "url(images/menubuttons/homedown.gif)";
		}
		else if (btn.id == "ProductsButton")
		{
			btn.style.background = "url(images/menubuttons/productsdown.gif)";
		}	
		else if (btn.id == "ServicesButton")
		{
			btn.style.background = "url(images/menubuttons/servicesdown.gif)";
		}		
		else if (btn.id == "AboutButton")
		{
			btn.style.background = "url(images/menubuttons/aboutdown.gif)";
		}					
		else if (btn.id == "ContactButton")
		{
			btn.style.background = "url(images/menubuttons/contactdown.gif)";
		}
	}			
	
	function ButtonMouseUp(btn)
	{
		if (buttonover)
		{
			ButtonMouseOver(btn);
			return;
		}
		
		if (btn.id == "HomeButton")
		{
			btn.style.background = "url(images/menubuttons/home.gif)";
		}
		else if (btn.id == "ProductsButton")
		{
			btn.style.background = "url(images/menubuttons/products.gif)";
		}	
		else if (btn.id == "ServicesButton")
		{
			btn.style.background = "url(images/menubuttons/services.gif)";
		}		
		else if (btn.id == "AboutButton")
		{
			btn.style.background = "url(images/menubuttons/about.gif)";
		}					
		else if (btn.id == "ContactButton")
		{
			btn.style.background = "url(images/menubuttons/contact.gif)";
		}
	}	
	
	function ShowMenu(menu)
	{	
		document.getElementById(menu).style.visibility = "visible"; 	
	}
	
	function HideMenu(menu)
	{
		document.getElementById(menu).style.visibility = "hidden"; 	
	}
				
	function Hilight(divel)
	{
		divel.style.filter = "alpha(opacity=100)";
		divel.style.MozOpacity = "1";
	}
	
	function Dim(divel)
	{
		divel.style.filter = "alpha(opacity=70)";
		divel.style.MozOpacity = "0.7";
	}

	var preloaded = new Array();
	
	function preload_images() 
	{
		for (var i = 0; i < arguments.length; i++)
		{
			preloaded[i] = document.createElement('img');
			preloaded[i].setAttribute('src',arguments[i]);
		}
	}
	
	preload_images(
		'images/menubuttons/homeover.gif',
		'images/menubuttons/homedown.gif',
		'images/menubuttons/productsover.gif',
		'images/menubuttons/productsdown.gif',				
		'images/menubuttons/servicesover.gif',
		'images/menubuttons/servicesdown.gif',
		'images/menubuttons/aboutover.gif',
		'images/menubuttons/aboutdown.gif',
		'images/menubuttons/contactover.gif',
		'images/menubuttons/contactdown.gif',
		'images/menubuttons/menudownback.gif',
		'images/menubuttons/menuselectedback.gif',
		'images/buttons/readmore_over.gif',
		'images/buttons/readmore_down.gif'
	);

	function PositionMenus()
	{
		PositionMenu("ProductsMenu", "ProductsButton");
		PositionMenu("ServicesMenu", "ServicesButton");
	}
	
	function PositionMenu(menu, button)
	{
		var smen = document.getElementById(menu);
		var sbut = document.getElementById(button);
		
		var pos = findPos(sbut);
		smen.style.top = pos[1]+"px";
		smen.style.left = pos[0]+"px";		
	}

	function findPos(obj)
	{
		var curleft = curtop = 0;
	
		if (obj.offsetParent) 
		{
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
	
			return [curleft,curtop];
		}
	}
	
	function MenuButtonMouseOver(btn)
	{
		btn.style.background = "url(images/menubuttons/menuselectedback.gif)";
		btn.style.color = "#FFFFFF";
	}	
	
	function MenuButtonMouseOut(btn)
	{
		btn.style.background = "url(images/menubuttons/menuback.gif)";
		btn.style.color = "#FFFFFF";
	}	
	
	function MenuButtonMouseDown(btn)
	{
		btn.style.background = "url(images/menubuttons/menudownback.gif)";
		btn.style.color = "#FFFFFF";
	}	
	
	function MenuButtonMouseUp(btn)
	{
		MenuButtonMouseOver(btn);
	}	
