/*
 JavaScript Code for the left hand navigation - 
 to set the div background color when user uses their keyboard to go through the menu items.
 
 Innovations, Capita Symonds
 May 2006
 
 Amended 9th Jan 2007
 Added in code so that onload the background of all menu items, that may have been highlighted is reset back to white
*/

function resetBackground()
{
	/*Need to go through each menu item in turn*/
	for(var count = 1; count <= 18; count++)
	{
		if(document.getElementById("Homebutton"+count))
		{
			var menu = document.getElementById("Homebutton"+count);
			var anchor = document.getElementById("anchorHomebutton"+count);
		
			/*Will now set the background to white for the found element*/
			anchor.style.backgroundColor = "#FFFFFF";
			anchor.style.color="#000000";
			menu.style.backgroundColor = "#FFFFFF";
		}
	}
}

function  handleEnter(obj, event)
{
    //do nothing, this is required by the ITK.
}

function showBackButton()
{
    var _hiddenButton = document.getElementById("prev");
    var _buttonBar = document.getElementById("buttonBar");
    if (_hiddenButton != null && _buttonBar != null)
    {
        var atts = "";
        if (navigator.appName.indexOf("Microsoft Internet Explorer") >= 0)
        {
            atts = 'style="margin-bottom:3px;"';
        }
        
        if (_hiddenButton.style.display == "none")
        {
            var imgSrc = _hiddenButton.src;
            var pageLocation = "fault_wizard_locate_method.php";
            var myHtml = '<a href="' + pageLocation + '"><img '+atts+' src="'+imgSrc+'" /></a>';
            _buttonBar.innerHTML = myHtml + _buttonBar.innerHTML;
        }    
    }
}




function backgroundColor(colour, id)
{
	var menu = document.getElementById(id);
	var anchor = document.getElementById("anchor"+id);
	
	if (colour == 'green')
	{
		anchor.style.backgroundColor = "#00957E";
		menu.style.backgroundColor = "#00957E";
		anchor.style.color = "#FFFFFF";
	}
	else if (colour == 'yellow')
	{
		anchor.style.backgroundColor = "#FF9900";
		menu.style.backgroundColor = "#FF9900";
		anchor.style.color = "#FFFFFF";
	}
	else if (colour == 'blue')
	{
		anchor.style.backgroundColor = "#006FAE";
		menu.style.backgroundColor = "#006FAE";
		anchor.style.color = "#FFFFFF";
	}
	else if (colour == 'orange')
	{	
		anchor.style.backgroundColor = "#FD6F31";
		menu.style.backgroundColor = "#FD6F31";
		anchor.style.color = "#FFFFFF";
	}
	else if (colour =='white')
	{
		anchor.style.backgroundColor = "#FFFFFF";
		anchor.style.color="#000000";
		menu.style.backgroundColor = "#FFFFFF";
	}
}


if (document.addEventListener)
{
    document.addEventListener("DOMContentLoaded", showBackButton, false);
}
else
{
    window.attachEvent("onload", showBackButton);
}