// the central repository of general functions called from all pages

// create a new image object for the preloader..
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

// set the highlight state of a given button..
function changeImage(theImg,state){
	if(preloadFlag){
		theImgObject = eval("document." + theImg);
		theImgReplacement = eval(theImg + "_" + state);
		theImgObject.src = theImgReplacement.src;
	}
}

// set the highlight state of a given nav button to select it and deselect its predecessor..
currentlySelectedBtn = "";
function setNavState(theImg,state){
	if(preloadFlag){
		// if first time into this function, highlight selected letter and set currentlySelectedBtn
		if(state == "down" && currentlySelectedBtn == ""){
			theImgObject = eval("document." + theImg);
			theImgReplacement = eval(theImg + "_" + state);
			theImgObject.src = theImgReplacement.src;
			currentlySelectedBtn = theImg;
		// a letter is already highlighted, un-highlight it..
		} else if(state == "down" && theImg != currentlySelectedBtn){
			theImgObject = eval("document." + currentlySelectedBtn);
			theImgReplacement = eval(currentlySelectedBtn + "_off");
			theImgObject.src = theImgReplacement.src;
			// then set currentlySelectedBtn..
			currentlySelectedBtn = theImg;
			// and finally highlight selected letter..
			theImgObject = eval("document." + theImg);
			theImgReplacement = eval(theImg + "_" + state);
			theImgObject.src = theImgReplacement.src;
		// otherwise do rollover (UNLESS this image is currently highlighted - then do nothing)..
		} else if(theImg != currentlySelectedBtn){
			theImgObject = eval("document." + theImg);
			theImgReplacement = eval(theImg + "_" + state);
			theImgObject.src = theImgReplacement.src;
		}
	}
}
