window.onload = changeTitle;
/*
The changeTitle function will change the title attributes of 4 specific items in the main menu from the defalut values
provided by WP.  
*/

function changeTitle() {
	var mainMenuListItems = document.getElementById('nav').getElementsByTagName('li'); // alert(mainMenuListItems.length);
	//var count = 0; 
	var pattern1 = /page-item-415/; // Image Gallery
	var pattern2 = /page-item-277/; // EQ Scenarios
	var pattern3 = /page-item-275/; // Retrofit Map
	var pattern4 = /cat-item-16/;
	for(i in mainMenuListItems) { //REMEMBER, this is not equivalent to for each!
		var links = mainMenuListItems[i].getElementsByTagName('a');
		var firstLink = links[0]; //alert(firstLink); //ok
		//alert(mainMenuListItems[2].getAttribute("class").match(testPattern)); //ok
		if(mainMenuListItems[i].getAttribute("class") && mainMenuListItems[i].getAttribute("class").match(pattern1)) {
			firstLink.removeAttribute("title");
			firstLink.setAttribute("title", "Enter this part of our site for a searchable library of images from past earthquakes, as well as slideshows focused on mitigation activities. This site is constantly evolving, so check back frequently for new additions.");
		}
		else if(mainMenuListItems[i].getAttribute("class") && mainMenuListItems[i].getAttribute("class").match(pattern2)) {
			firstLink.removeAttribute("title");
			firstLink.setAttribute("title", "This website was created to help communities through the process of developing and using effective earthquake scenarios.  The site has tools and suggestions, and has users sharing their experiences.");
		}
		else if (mainMenuListItems[i].getAttribute("class") && mainMenuListItems[i].getAttribute("class").match(pattern3)) {
			firstLink.removeAttribute("title");
			firstLink.setAttribute("title", "This map is a community mapping project to show Bay Area seismic retrofit projects from the last 20 years. We are in the process of expanding the map to cover the entire U.S. We encourage anyone with a retrofit project to enter basic information and provide a photo.");
		}
		else if (mainMenuListItems[i].getAttribute("class") && mainMenuListItems[i].getAttribute("class").match(pattern4)) {
			firstLink.removeAttribute("title");
			firstLink.setAttribute("title", "Our Online Resource Library is a searchable database of downloadable files that can be used to promote and implement mitigation activities, ranging from material for homeowners, government officials and earthquake professionals.");
		}
		else {
			//do nothing
		}
		//count++; //alert(count); //count stops at 21, as it should, but ignores code after loop
	}
	//alert(count); // either ignored, or count stops at 24!
}

