
function currentNav() {
	strCurrPage = getCurrentPath();
	navdiv = document.getElementById("nav_sub")
	if (!navdiv){return false;}
	navli = $('#nav_sub li');
	
	if ((typeof(strCurrPage[0])=="undefined")||strCurrPage[0].length<2){
		currPage = new Array();
		currPage[0] = strCurrPage;
	}
	else
	{
	 	currPage = strCurrPage;	
	}

	for (var i = 0; i < currPage.length; i++) {
		for (var j = 0; j < navli.length; j++) {
			strTestPath = getPath(navli[j].firstChild.href);
			if ((typeof(strTestPath[0])=="undefined")||strTestPath[0].length<2){
				testPath = new Array();
				testPath[0] = strTestPath;
			}
			else
			{
				testPath = strTestPath;	
			}

			for (var k = 0; k < testPath.length; k++) {
				if (cleanLastSlash(currPage[i]) == cleanLastSlash(testPath[k])) {
					// alert(currPage[i] + ' == ' + testPath[k]);
					navli[j].className = 'nav-current';
					$('.nav-current').parents('li').addClass('nav-current');
				}
				else
				{
					// alert(currPage[i] + ' != ' + testPath[k]);
				}
			}
		}
	}
}


function getPath(someurl){
 d = document;
 csite = d.domain;
 sp = someurl.indexOf(csite) + csite.length;
 cpath = someurl.substring(sp);
 if (cpath.search(/index/)!=-1){
  re = "(.*?)\/index.shtml";
  myRe = new RegExp(re);
  cpath = cpath.match(myRe);
 }
return cpath;
}

function cleanLastSlash(someurl){
 lastchar = someurl.length-1;
  if (someurl!="") {
	if (someurl.charAt(lastchar)=="/"){someurl = someurl.substring(0,(someurl.length-1))}
  }
return someurl;

}

function getCurrentPath(){
 d = document;
 cpage = d.URL;
 csite = d.domain;
 sp = cpage.indexOf(csite) + csite.length;
 cpath = cpage.substring(sp);
 if (cpath.search(/index/)!=-1){
  re = "(.*?)\/index.shtml";
  myRe = new RegExp(re);
  cpath = cpath.match(myRe);
 }
return cpath;
}


function rotatePhoto() {
	var rand = Math.floor(Math.random()*10)+1
	if(document.getElementById('rotate')) document.getElementById('rotate').src = "images/American"+rand+".jpg";
}


window.onload = init;

function init(){
	currentNav();
	rotatePhoto();
}