// JavaScript Document

/* Simple Menu V1 */

var menuimg1=new Image();
var menuimg2=new Image();
var menuimg3=new Image();
var menuimg4=new Image();
var menuimg5=new Image();
var menuimg6=new Image();
var menuimg7=new Image();
var menuimg8=new Image();
var menuimg9=new Image();
var menuimg10=new Image();
menuimg1.src="images/structure/dsp_menu_left_end_hi.png";
menuimg2.src="images/structure/dsp_menu_left_hi.png";
menuimg3.src="images/structure/dsp_menu_middle_hi.png";
menuimg4.src="images/structure/dsp_menu_right_hi.png";
menuimg5.src="images/structure/dsp_menu_right_end_hi.png";
menuimg6.src="images/structure/dsp_menu_left_end_un.png";
menuimg7.src="images/structure/dsp_menu_right_end_un.png";
menuimg8.src="images/structure/dsp_menu_left_un.png";
menuimg9.src="images/structure/dsp_menu_middle_un.png";
menuimg10.src="images/structure/dsp_menu_right_un.png";

var menuID="dsp-menu";
var menuLeftEndBackgroundHi="url('images/structure/dsp_menu_left_end_hi.png') top center no-repeat";
var menuLeftEndBackgroundUn="url('images/structure/dsp_menu_left_end_un.png') top center no-repeat";
var menuLeftBackgroundHi="url('images/structure/dsp_menu_left_hi.png') top center no-repeat";
var menuLeftBackgroundUn="url('images/structure/dsp_menu_left_un.png') top center no-repeat";
var menuMiddleBackgroundHi="url('images/structure/dsp_menu_middle_hi.png') top center repeat-x";
var menuMiddleBackgroundUn="url('images/structure/dsp_menu_middle_un.png') top center repeat-x";
var menuRightBackgroundHi="url('images/structure/dsp_menu_right_hi.png') top center no-repeat";
var menuRightBackgroundUn="url('images/structure/dsp_menu_right_un.png') top center no-repeat";
var menuRightEndBackgroundHi="url('images/structure/dsp_menu_right_end_hi.png') top center no-repeat";
var menuRightEndBackgroundUn="url('images/structure/dsp_menu_right_end_un.png') top center no-repeat";
var menuLinkColourHi="#1ebcee";
var menuLinkColourUn="#ffffff";
var menuLeftEnd="dsp-menu-left-end";
var menuLeft="dsp-menu-left";
var menuRight="dsp-menu-right";
var menuRightEnd="dsp-menu-right-end";
var menuSub="dsp-menu-sub";

var menuTimer;
var menuHideTimeout=200;

function hideAllSubMenus(){
	var menuDivRefs=document.getElementById(menuID).getElementsByTagName("DIV");
	var i=0;
	while(menuDivRefs.length>i){
		if(menuDivRefs[i].className==menuSub){
			menuDivRefs[i].style.display="none";
		}
		i++;
	}
}

function menuTimeout(){
	hideAllSubMenus();
}

function menuTimerStop(){
	clearTimeout(menuTimer);
}

function showSubMenu(ref){
	ref.style.display="block";
}

function setMenuTimeout(){
	menuTimer=setTimeout("menuTimeout()",menuHideTimeout);
}

function initMenu(){
	var menuRef=document.getElementById(menuID);
	var linkRefs=menuRef.getElementsByTagName("A");
	var menuItemRefs=menuRef.childNodes;
	var i=0;
	while(linkRefs.length>i){
		linkRefs[i].onmouseover=onMouseOverLink;
		linkRefs[i].onmouseout=onMouseOutLink;
		i++;
	}
	i=0;
	while(menuItemRefs.length>i){
		menuItemRefs[i].onmouseover=onMouseOverEvt;
		menuItemRefs[i].onmouseout=onMouseOutEvt;
		i++;
	}
}

function onMouseOverEvt(){
	var divs=this.childNodes;
	var i=0;
	menuTimerStop();
	hideAllSubMenus();
	while(divs.length>i){
		if(divs[i].tagName=="DIV"){
			if(divs[i].className==menuLeftEnd){
				divs[i].style.background=menuLeftEndBackgroundHi;
			}
			else{
				if(divs[i].className==menuLeft){
					divs[i].style.background=menuLeftBackgroundHi;
				}
				else{
					if(divs[i].className==menuRight){
						divs[i].style.background=menuRightBackgroundHi;
					}
					else{
						if(divs[i].className==menuRightEnd){
							divs[i].style.background=menuRightEndBackgroundHi;
						}
						else{
							if(divs[i].className!=menuSub){
								divs[i].style.background=menuMiddleBackgroundHi;
							}
							else{
								showSubMenu(divs[i]);
							}
						}
					}
				}
			}
		}
		i++;
	}
}

function onMouseOutEvt(){
	var divs=this.childNodes;
	var i=0;
	while(divs.length>i){
		if(divs[i].tagName=="DIV"){
			if(divs[i].className==menuLeftEnd){
				divs[i].style.background=menuLeftEndBackgroundUn;
			}
			else{
				if(divs[i].className==menuLeft){
					divs[i].style.background=menuLeftBackgroundUn;
				}
				else{
					if(divs[i].className==menuRight){
						divs[i].style.background=menuRightBackgroundUn;
					}
					else{
						if(divs[i].className==menuRightEnd){
							divs[i].style.background=menuRightEndBackgroundUn;
						}
						else{
							if(divs[i].className!=menuSub){
								divs[i].style.background=menuMiddleBackgroundUn;
							}
							else{
								setMenuTimeout();
							}
						}
					}
				}
			}
		}
		i++;
	}
}

function onMouseOverLink(){
	this.style.color=menuLinkColourHi;
}

function onMouseOutLink(){
	this.style.color=menuLinkColourUn;
}
