// Topic Map Path Scripts


var mapPathNames = new Array("FULL_TOPIC_VIEW",
		     "KEY_IDEAS",
		     "ACTIVITIES",
		     "PERSONAL_INSIGHTS",
		     "FORMS_AND_WORKSHEETS");

var global_bkg_class = "first_run";

function swap_bkg_element(id, newclass) {
	document.getElementById(id).style.display = "none";
	document.getElementById(id).className = newclass;
	document.getElementById(id).style.display = "block";
	//alert(newclass);
}



function showPath(path) {
	for(var i = 0; i < mapPathNames.length; i++) {
		if(mapPathNames[i] == path) {
			document.getElementById(mapPathNames[i]).style.display = "block";
		} else {
		    if(document.getElementById(mapPathNames[i])){
    			document.getElementById(mapPathNames[i]).style.display = "none";
    		}
		}
	}
	if (path == "FULL_TOPIC_VIEW") {
		global_bkg_class = "first_run"; 								
	}
	if (path == "KEY_IDEAS") {
		global_bkg_class = "keyarrow_bkg";		
	}
	if (path == "ACTIVITIES") {
		global_bkg_class = "activityarrow_bkg";		
	}
	if (path == "PERSONAL_INSIGHTS") {
		global_bkg_class = "piarrow_bkg";	
	}
	if (path == "FORMS_AND_WORKSHEETS") {
	    if(document.getElementById("PERSONAL_INSIGHTS")){
    		global_bkg_class = "formarrow_bkg";
    	} else {
    	    global_bkg_class = "piarrow_bkg";
    	}
	}
	swap_bkg_element("LEFT_COLUMN", global_bkg_class);
}

function swap_bkg_element_return(id) {
	if (document.getElementById) {
	    document.getElementById(id).className = global_bkg_class;
	}
}

function highlightPathChooser(path) {
	var allPaths = document.getElementById('PATH_CHOOSERS').getElementsByTagName('a');
	for(var i = 0; i < allPaths.length; i++) {
		if(allPaths[i].id.indexOf('_'+path) != -1) {
			allPaths[i].className = 'path_chooser_highlight';
		} else {
			allPaths[i].className = 'path_chooser';
		}
	}
}


/*  THIS FUNCTION HAS BEEN DEPRECATED IN FAVOR OF THE SIMPLER DIV HIDING
    AND REVEALING METHOD ABOVE

// script to reveal a particular path in the topic map. Each map is identified 
// with a character (a,b,c...). If a link belongs to a map, that map's corresponding
// character will be appended to the end of the link's ID. When you click on a 
// map's description, all of the links that are associated with that map are
// shown, and those that are not are hidden


// recursive function that shows paths based upon the information provided in 
// the ids of links in the topic map. The reason this is written recursively is
// that you presumably want to preserve the context (menu heirarchy) of a 
// link when it is in a given path (ie. don't just show link x, show the menu
// layers above link x as well). However, it would be a pain to have to place all
// of those relationships into the ids of all the links. SO, we are taking 
// advantage of the recursive nature of the ul-li structure. If a li has a 
// ul that contains a link in the current path, we tell the li to display its
// corresponding link... We need to hide and display the LI because IE is dumb
// and will not collapse the li units if their inner <a> tags are set to
// display = 'none'
function showPath(topicMapUl, path) {
	
	highlightPathChooser(path);
	
	
	var children = topicMapUl.childNodes;
	for(var i = 0; i < children.length; i++) {
		if(children[i].tagName == 'li' || children[i].tagName == 'LI') {
			var childLi = children[i];
			var childLisAtag;
			var childLisULtag;
			var containsAPathLink = false;
			for(var j = 0; j < childLi.childNodes.length; j++) {
				if(childLi.childNodes[j].tagName == 'a' || childLi.childNodes[j].tagName == 'A') {
					childLisAtag = childLi.childNodes[j];
				}
				else if(childLi.childNodes[j].tagName == 'ul' || childLi.childNodes[j].tagName == 'UL') {
					childLisULtag = childLi.childNodes[j];
				}
			}
			var allLowerATags = childLi.getElementsByTagName('a');
			for(var k = 0; k < allLowerATags.length; k++) {
				if(allLowerATags[k].id.indexOf('_PATH'+path) != -1 || path == 'all') {
					childLi.style.display = 'block';
					allLowerATags[k].style.display = 'block';
					containsAPathLink = true;
				} else {
					allLowerATags[k].style.display = 'none';
				}
			}
			if(containsAPathLink) { 
				childLisAtag.style.display = 'block'; 
				if(childLisULtag != null) { showPath(childLisULtag,path); }
			} else {
				childLi.style.display = 'none';
			}
		}
	}
}

*/
