<!--
// lib.js

// browser types
gIEBrowser = false;
gNBrowser = false;
gAOLBrowser = false;
gBrowserMajorVersion = 0;
gButtonCount = 0;
gWindowStatus = "";
			
gButtonNameArray= new Array();
gButtonOutArray = new Array();
gButtonOverArray = new Array();
gButtonDownArray = new Array();
gButtonIsDownArray = new Array();
gButtonOverTextArray = new Array();

LibGetBrowserInfo();

// --- functions ---
	
function LibGetBrowserInfo() {
	
	gIEBrowser = navigator.appName.indexOf("Microsoft") != -1;
	gNBrowser = navigator.appName.indexOf("Netscape") != -1;
	gAOLBrowser = navigator.appVersion.indexOf("AOL") != -1;		// aol is ie

	gBrowserMajorVersion = parseInt(navigator.appVersion.substring(0, navigator.appVersion.indexOf(".")));
}

function NewImage(inImageName) {

	if (document.images) {
			theImage = new Image();
			theImage.src = inImageName;
			return theImage;
		}
}

function UseButtons() {
	
	if (gIEBrowser && gBrowserMajorVersion >= 4)
		return true;
		
	if (gAOLBrowser && gBrowserMajorVersion >= 4)
		return true;

	if (gNBrowser && gBrowserMajorVersion >= 3)
		return true;
			
	return false;
}
			
function InitButtons(inPath, inType, inDefault, inButtonList) {
	
	if (UseButtons()) {
		buttonCount = InitButtons.arguments.length - 3;							// skip inPath and inType and inDefault
			
		for (counter = 0; counter < buttonCount; counter++) {
			if (counter == inDefault)
				AddButton(true, inPath, InitButtons.arguments[counter + 3], inType, "");
			else
				AddButton(false, inPath, InitButtons.arguments[counter + 3], inType, "");
		}
	}
}

function AddButton(inDefault, inPath, inButtonName, inType, inOverText) {
	
	if (UseButtons()) {
		gButtonNameArray[gButtonCount] = inButtonName;
		gButtonOutArray[gButtonCount] = NewImage(inPath + inButtonName + "." + inType);
		gButtonOverArray[gButtonCount] = NewImage(inPath + inButtonName + "-over." + inType);
		gButtonDownArray[gButtonCount] = NewImage(inPath + inButtonName + "-down." + inType);
		gButtonIsDownArray[gButtonCount] = false;
		gButtonOverTextArray[gButtonCount] = inOverText;
		
		if (!gNBrowser) {
			gButtonIsDownArray[gButtonCount] = inDefault;
			if (inDefault)
				document[gButtonCount].src = gButtonDownArray[gButtonCount].src;
		}
		
		gButtonCount = gButtonCount + 1;
	}
}

function SetOutState(inButton) {
	
	if (UseButtons() && document.images)
		for (counter = 0; counter < gButtonCount; counter++) {
			if (gButtonNameArray[counter] == inButton) {
				if (gButtonIsDownArray[counter])
					document[inButton].src = gButtonDownArray[counter].src;
				else
					document[inButton].src = gButtonOutArray[counter].src;
				window.status = gWindowStatus;				
				break;			
			}
		}
}

function SetOverState(inButton) {
		
	if (UseButtons() && document.images)
		for (counter = 0; counter < gButtonCount; counter++) {
			if (gButtonNameArray[counter] == inButton) {
				if (gButtonIsDownArray[counter])
					document[inButton].src = gButtonDownArray[counter].src;
				else
					document[inButton].src = gButtonOverArray[counter].src;
				window.status = gButtonOverTextArray[counter];				
				break;
			}
		}
}

function SetDownState(inButton) {
		
	if (UseButtons() && document.images)
		for (counter = 0; counter < gButtonCount; counter++) {
			if (gButtonNameArray[counter] == inButton) {
			
				for (j = 0; j < gButtonCount; j++) {
					gButtonIsDownArray[j] = false;
					if (counter != j)
						document[j].src = gButtonOutArray[j].src;
				}

				document[inButton].src = gButtonDownArray[counter].src;
				gButtonIsDownArray[counter] = true;
				window.status = gButtonOverTextArray[counter];				
				break;
			}
		}
}

// -->
