// JavaScript Document

function styleSecondaryNav(){	
	var theTable = document.getElementById('secondary_nav_links_table');
	var theCells = theTable.getElementsByTagName('td');
	var curr_link=0;
	var curr_cell=0;
	var match_found=false;
	
	for (curr_cell = 0; curr_cell < theCells.length; curr_cell++)
	{
		//alert(theLinks[curr_link].parentNode.parentNode.parentNode.className);
				currentpath=window.location.href;
				curr_array=currentpath.split("/");
				theLink=theCells[curr_cell].getElementsByTagName('a')[0];
				newpath=theLink.href;
				new_array=newpath.split("/");
				
				//FILTER UNWANTED ITEMS FROM PATHS
				if(curr_array[curr_array.length-1]=="" || curr_array[curr_array.length-1]=="#"){
						curr_array.pop();
				}
				if(new_array[new_array.length-1]==""){
						new_array.pop();
				}
				if(new_array[new_array.length-1]=="default.aspx"){
					new_array.pop();	
				}
				if(curr_array[curr_array.length-1]=="default.aspx"){
					curr_array.pop();	
				}
				//alert((new_array.length-curr_array.length));
				//alert(curr_array[new_array.length-1]+"  :  "+new_array[new_array.length-1]);
				
				//SET DEFAULT ROLLOVER/OUT STYLES
				
				
				
				theLink.onmouseover = function() {
					this.parentNode.className="mmhide_secondary_nav_over";	
				}
				theLink.onmouseout = function() {	
					this.parentNode.className="mmhide_secondary_nav_td";	
				}
					
				//SEE IF THE FOLDERS MATCH AND MAKE SURE IT IS NOT A # LINK
				var i=0;
				var dir_lvl=0;
				if(curr_array.length>4) dir_lvl=3;

				for(i=(curr_array.length-1);i>dir_lvl;i--){	
					
					if(curr_array[i]==new_array[new_array.length-1] && newpath.lastIndexOf('#')<0){
						
							theCells[curr_cell].className="mmhide_secondary_nav_select";
							match_found=true;
							highlight_cell=curr_cell;
							
						
					}
				}
					
	}
	//MAKE SURE THE ROLLOVER/OUT STATES ARE REMOVED FROM THE HIGHLIGHTED CELL
	if(match_found){
			theCells[highlight_cell].getElementsByTagName('a')[0].onmouseover = function() {};
			theCells[highlight_cell].getElementsByTagName('a')[0].onmouseout = function() {};
	}
}

