String.prototype.capitalize = function(){ 
    return this.replace(/\w+/g, function(a){
        return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
    });
};


// Current Page Reference
// copyright Stephen Chapman, 1st Jan 2005
// you may copy this function but please keep the copyright notice with it
function getURL(uri) {
uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
uri.path = ''; var pos = uri.dom.indexOf('\/'); if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
pos = uri.page.indexOf('?');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
pos = uri.page.indexOf('#');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
uri.ext = ''; pos = uri.page.indexOf('.');if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
uri.file = uri.page;
if (uri.ext != '') uri.file += '.' + uri.ext;
if (uri.file == '') uri.page = 'index';
uri.args = location.search.substr(1).split("?");
return uri;
}

var uri = new Object();
getURL(uri);

var idname = 'nav' + uri.path.capitalize();

//if (uri.ext) {
//	idname = 'nav' + uri.path.capitalize();
//}

var currentUrlFromHome = '/' + uri.path + '/' + uri.file;

function navLoader() {	
	//alert(currentUrlFromHome);	
	whichElement = document.getElementById(idname);
	
	//whichElement.style.visibility = "visible";
	
	arraySublinks = document.getElementsByTagName('a');
	
	for (x=0;x<arraySublinks.length;x++) {
		//alert('arrayTag' + x + ':  ' + arraySublinks[x].href);
		if ((arraySublinks[x].href == location.href) || (arraySublinks[x].href == location.href+'index.asp'))
		{
			arraySublinks[x].style.color = "#ffffff";
			arraySublinks[x].style.fontWeight = "bold";
		}
	}

	if (whichElement) {
		whichElement.style.borderBottomWidth = "1px";
		whichElement.style.borderBottomStyle = "solid";
		whichElement.style.borderBottomColor = "#ffffff";
		whichElement.style.display = "block";
	}
	else {
		//alert('problem with whichElement: ' + whichElement);	
	}
	
	if (document.getElementById(idname + 'Img')) {
	
		imgHolderElement = document.getElementById(idname + 'Img');
		imgHolderElement.innerHTML = "<img src=\"/graphics/nav/" + uri.path + "-at.gif\" border=0 	style=\"display:block; float:left; padding:0px; margin:0px; \" /><div style=\"clear:both; height:0px;\"></div>";
	}
	
	subMenu = document.getElementById(idname + 'Submenu');	

	//alert(subMenu.childNodes.length);
	if (subMenu) {
		if (subMenu.childNodes.length > 0) {
			subMenu.style.display = "block";
			subMenu.style.paddingBottom = "7px";
		}
	}

}
	

