function init(){
  thisDir = location.href.split('/')[3];
  thisPage = location.href.split('/')[4];
}
init();

function roll(id, newSrc) {
    var theImage = findImage(document, id, 0);
    if (theImage) theImage.src = newSrc;
}

function findImage(doc, name, j) {
    var theImage = false;
    if (doc.images) theImage = doc.images[name];
    if (theImage) return theImage;
    if (doc.layers) {
        for (j = 0; j < doc.layers.length; j++) {
            theImage = findImage(doc.layers[j].document, name, 0);
            if (theImage) return (theImage);
        }
    }
    return (false);
}


function openPopup(newURL, width, height) {
if (document.all || document.layers) {
   w = screen.availWidth;
   h = screen.availHeight;
}
	var popW = width;
	var popH = height;
	var leftPos = (w-popW)/2;
	var topPos = (h-popH)/2;
	var remote = open(newURL,'newWin', 'height='+popH+',width='+popW+',left='+leftPos+',top='+topPos+',channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0');
	if (parseInt(navigator.appVersion) >= 4) { remote.window.focus();}
}

function doNav(imageName, imagePath){
  // call like: doNav('saving', '/bankingstuff/images/savingOut.gif');

  currImageName = thisPage.substring(0, thisPage.lastIndexOf("."));
  if(thisDir=="bankingstuff"){
	if(currImageName.indexOf("money")>-1){
		currImageName = "money";
	}else if(currImageName.indexOf("banks")>-1){
		currImageName = "banks";
	}else if(currImageName.indexOf("saving")>-1){
		currImageName = "saving";
	}else if(currImageName.indexOf("branches")>-1){
		currImageName = "branches";
	}
	}
	// imageName and imagePath are null then reset imageName so the first condition is met for next function
  if(imageName==null && imagePath==null){
  	imageName=currImageName;
  }
    //alert(currImageName)
  if(imageName==currImageName){
	roll(currImageName,'/' + thisDir + '/images/' + currImageName + 'On.gif');
  }else{
	roll(imageName, imagePath);
  }

}

function doTopNav(imageName, imagePath){
  // call like: doTopNav('moneygames', '/images/nav/moneygamesOut.gif');

  currImageName = thisDir;
  // imageName and imagePath are null then reset imageName so the first condition is met for next function
  if(imageName==null && imagePath==null){
  	imageName=currImageName;
  }
  if(imageName==currImageName){
	roll(currImageName,'/images/nav/' + currImageName + 'On.gif');
  }else{
	roll(imageName, imagePath);
  }
}
