// Left Navigation Script for NYC.gov Agency Templates

// Returns path with folder and file, else -1.
// ex. /folder/file.html
function getPath(thePath) {
	if (thePath == null) { return -1; }
	
	var startSlash = thePath.lastIndexOf("/");
	startSlash = thePath.lastIndexOf("/",startSlash -1);
	
	if (startSlash == -1) {
		return -1;
	} else {
		return thePath.substr(startSlash, thePath.length - startSlash);
	}
}

// Returns folder, else -1.
// ex. /folder/
function getFolder(thePath) {
	if (thePath == null) { return -1; }
	var startSlash = thePath.lastIndexOf("/");
	startSlash2 = thePath.lastIndexOf("/",startSlash -1);

	if(startSlash == startSlash2) { return -1; }
	if (startSlash == -1 || startSlash2 == -1) {
		return -1;
	} else {
		return thePath.substr(startSlash2, startSlash - startSlash2 + 1);
	}
}

function getFilename(thePath){		
	if (thePath == null) { return -1; }
	var slash = thePath.lastIndexOf("/");
	if (slash == -1) {
		return -1;
	} else {
		var fileName=thePath.substr(0,thePath.length-6);				
		return fileName.substr(slash+1);
	}	
}

var currentURL = getPath(location.href);
var tmpImgName="";

document.write("<tr><td><img src='images/spacer.gif' width='197' height='7'></td></tr>");
for(x=0;x<TOP_RIGHT_NAV_NODES.length;x++) {
	if (TOP_RIGHT_NAV_NODES[x] == null) break;

	if (currentURL.indexOf(TOP_RIGHT_NAV_NODES[x][1]) != -1) {		
		tmpImgName=TOP_RIGHT_NAV_NODES[x][2];					
		document.write("<tr><Td><a href='"+TOP_RIGHT_NAV_NODES[x][1]+"'><img src='images/"+tmpImgName+"_2.gif' alt='"+TOP_RIGHT_NAV_NODES[x][0]+"' border='0' name='"+tmpImgName+"' widht='197'></a></Td></tr>"); 
	}else {		
		tmpImgName=TOP_RIGHT_NAV_NODES[x][2];				
		document.write("<tr><Td><a href='"+TOP_RIGHT_NAV_NODES[x][1]+"' onMouseOver=\"MM_swapImage('"+tmpImgName+"','','images/"+tmpImgName+"_1.gif',1)\" onMouseOut=\"MM_swapImgRestore()\"><img src='images/"+tmpImgName+"_0.gif' alt='"+TOP_RIGHT_NAV_NODES[x][0]+"' border='0' name='"+tmpImgName+"' width='197'></a></Td></tr>"); 
	}
}
document.write("<tr><td><img src='images/spacer.gif' width='197' height='10'></td></tr>");