var active;// class "active" indicates the page you are currently on
var imageID;
var sectionName;
var index;
var menuID;
var imagesContainerName = "menuHolder";// the id of DIV containing menu images
var imageSourceBaseName = "images/menu"; // the first part of the image source :: images/nav_company_on.gif
var imageBaseName = "menu"; // the main part of the menu images ID :: topMenuImg_0[1,2,3,..]
var menuBaseName_top = "dropDownMenu"; // the main part of the menu ID :: dropDownMenu_0[1,2,3,..]
//var imageName = ["home", "learn", "message", "about", "media", "partners", "spanish"]; //names of images that have rollovers
var imageName = ["learn", "message", "about"]; //names of images that have rollovers

function rollovers(){
				var elemA, i, elemImg;
				elemA = document.getElementById(imagesContainerName).childNodes;
				for (i = 0; i < elemA.length; i++){
					if(elemA.item(i).nodeType == 1){
						if(elemA.item(i).tagName == "A"){
							elemImg = elemA.item(i).childNodes[0];
							elemImg.onmouseover = swapImage;		
							elemImg.onfocus = swapImage;		
							elemImg.onmouseout = swapImage;
							elemImg.onblur = swapImage;
						}
					}
					
				}
				
			}
function swapImage(evt){
				var active;// class "active" indicates the page you are currently on
				evt = (evt) ? evt : ((window.event) ? event : null);
				if(evt) {
					var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
					if(elem) {
						imageID = elem.id;
						sectionName = imageID.substring(parseInt(imageID.indexOf("_") + 1));
						
						var elemA = elem.parentNode;
						
						if(elemA.className == "active") {
							active = true;
						}else{
							active = false;
						}
					}
				}
				
				index = getIndex(sectionName);
				if(index != 100){//the function that displays menu will be called only if there is a menu for this section
					swap(evt);
				}else{// there is NO drop-down menu for the image
					
				var img = document.getElementById(imageID);
					if(img){
						var strDir;
						switch (evt.type){
							case "mouseover":
								strDir = "_on";
								break;
							case "focus":
								strDir = "_on";
								break;
							case "mouseout":
								
								if(active){
									strDir = "";
								}else{
									strDir = "_off";
								}
								
								break;
							case "blur":
								
								if(active){
									strDir = "";
								}else{
									strDir = "_off";
								}
								
								break;
						}
						
						img.src = imageSourceBaseName + "_" + sectionName + strDir +".jpg";
						
						window.status = "";
					}
				
				}
				return true;
				
			}	
			
function getIndex (strName) {
			var i, result = 100;// 100 is just a big number. It will be returned if there is NO matching menu for the topNav image
			for (i = 0; i < imageName.length; i++){
				if(imageName[i] == strName) {
					result = i;
					break;
				}
			}
			return result;
		}
function menus() {
				var i;
				for (i = 0; i < imageName.length; i++){
					//var menuId = menuBaseName + "_" + i; 
					var menuId = menuBaseName_top + "_" + i; 
					var menu = document.getElementById(menuId);
					if(menu){
						menu.onmouseover = keepMenu;
						menu.onmouseout = requestHide;
						menu.onfocus= keepMenu;
						menu.onblur = requestHide;
					}
				}
				
			}