// Menu Navigation Functions


//----Global Variables----//

//Current Page URL
var currentURL = String(document.location);

//Temporary fix for the Guides section
var customPage = "/Testing-Information/lab-test-directory.jsp";

//Array containing all nav links
var linkArray = new Array();
var linkItem = new Array();

//-------Functions--------//

//This function finds all links in the nav bar and inserts them into an array
function getLinks(){
//Nav Bar pointer
var mainNav = document.getElementById('Acc7b');

//Loop variables that pull all of the links
linkItem = mainNav.getElementsByTagName('a');
var hashFront, linkURL, folderName;

	for(i=0;i<linkItem.length;i++){
		linkURL = linkItem[i].href;
		hashFront = linkURL.indexOf(".com/")
		folderName = linkURL.substring(hashFront+4,linkURL.length);
		linkArray.push(folderName);
	}

	//This function takes the resulting array from getLinks() and finds the current page link to highlight
	findActiveLink();
}


function findActiveLink(){

//Variable that compares the current page URL with the list of links in the nav bar
var expCheck;

	for(i=0;i<linkArray.length;i++){
		if(currentURL.indexOf('/guides/') == -1){
			expCheck = currentURL.indexOf(linkArray[i]);	//If no match is found, expCheck will be set to -1
		} else {
			expCheck = customPage.indexOf(linkArray[i]);	
		}
		
		if(expCheck > -1 && linkArray[i].length > 1){		//'linkArray[i].length > 1' is to ignore /index.jsp
			
			if(linkItem[i].className == "ulDown"){
				linkItem[i].className += " currentPageDown";	
			} else {
				linkItem[i].className = "currentPage";
			}
			linkItem[i].style.color = "#fff";				//Active link's font color
			break;
		}		
	}

}


//This function randomizes the images displayed at the bottom of the navbar
function rndImage(){
var linkImages = [								//To add a new image put the image name in single quotes
				  'section_about1.jpg',			//followed by a comma at the end of the list
				  'section_about2.jpg',			//Example: 'new_image_name.jpg',
				  'section_education1.jpg',
				  'section_education2.jpg',
				  'section_research1.jpg',
				  'section_research2.jpg',
				  'section_services1.jpg',
				  'section_testdirectory1.jpg',
				  'section_testdirectory2.jpg'
				  ]

var rndNumber = (Math.random() * linkImages.length);
var roundedNum = Math.round(rndNumber);
if (roundedNum >= linkImages.length){roundedNum = linkImages.length - 1;}
document.write('<img src="/resources/images/global/' + linkImages[roundedNum] + '" width="169" height="229" />');
}


function rightMenu(){
			if(null == activeTab){var activeTab = -1;}			
			
}
