// The function to sniff out a browser that can do image-swaps
function getAppVersion(){
	appname= navigator.appName;
	var appversion = navigator.appVersion;
	majorver = appversion.substring(0, 1);
	if ( (appname == "Netscape") && ( majorver >= 3 ) ) return 0;
	if ( (appname == "Microsoft Internet Explorer") && (majorver >= 4) ) return 1;
	return -1;
} // end function getAppVersion



function getformSizes(element){
	appname= navigator.appName;
	var appversion = navigator.appVersion;
	if (getAppVersion() == 0) { //Netscape
		// format returned = "5.0(Windows; en-US)"
		pos = appversion.substring(5, 6);
		
	} else { // IE or other
		// format returned = "4.0(compatible; MSIE 6.0; Windows NT 5.1; Q312461)"
		majorver = appversion.substring(0, 1);
		var arAppVersion = appversion.split(";");
		var OS = arAppVersion[2];
		var pos = OS.substring(1,2);
	}
	if (pos == "W") { // Windows
		if (element == "textFull") {
			return 65;
		} else if (element == "textHalf") {
			return 30;
		} else if (element == "textQuarter") {
			return 9;
		} else if (element == "textThird") {
			return 18;
		} else if (element == "selectState") {
			return 120;
		} else if (element == "textareaRows") {
			return 5;
		} else if (element == "textareaCols") {
			return 49;
		} else if (element == "selectTitle") {
			return 163;
		} else if (element == "selectSize") {
			return 53;
		} else if (element == "selectColor") {
			return 100;
		}
	} else { // Macintosh or Unknown
		if (element == "textFull") {
			return 35;
		} else if (element == "textHalf") {
			return 16;
		} else if (element == "textQuarter") {
			return 5;
		} else if (element == "textThird") {
			return 9;
		} else if (element == "selectState") {
			return 115;
		} else if (element == "textareaRows") {
			return 5;
		} else if (element == "textareaCols") {
			return 34;
		} else if (element == "selectTitle") {
			return 140;
		} else if (element == "selectSize") {
			return 43;
		} else if (element == "selectColor") {
			return 100;
		}
	} 
} // end function getformSizes


// The function that does the image-swap
function chgImg(path,section,state) {
	if (getAppVersion()) {
		document[section].src = path + section + "_" + state + ".gif"; 
	}
} // end function chgImg

getAppVersion();

function launchWindow(url) {
	window.open(url, "_blank", "height=480,width=480,left=80,top=80,resizable=1,toolbar=1,scrollbars=yes");
}

function loadPrintIcon(href) {

	arPrint = new Array();
	arPrint[0] = new Image();
	arPrint[0].src = "images/icons/printIcon_off.gif";
	arPrint[1] = new Image();
	arPrint[1].src = "images/icons/printIcon_over.gif";
	
	output = "<br><br><div class='copyright'><a href='#' onClick='launchWindow(\"" + href + "\")' onmouseover=\"chgImg('images/icons/', 'printIcon','over');window.status='print this page';return true\" onmouseout=\"chgImg('images/icons/', 'printIcon','off');window.status=' ';return true\"><img src='images/icons/printIcon_off.gif' name='printIcon' border='0' alt='print this page'></a> print this page<br></div>";
	document.write(output);
}

function loadNav(section) {

	//preloadSubNav(section);
	
	arNav = new Array;
	arNav[0] = new Array("aboutUs");
	arNav[1] = new Array("boards");
	arNav[2] = new Array("employment");
	arNav[3] = new Array("events");
	arNav[4] = new Array("volunteers");
	

	expandSection = -1;
	output = "<td width='128' valign='top' HEIGHT='34' ><img src='images/header_bottomLeft.gif' width='128' height='34' border='0' alt='images'></td>";

	for (i=0; i < arNav.length; i++) {
		for(j=0; j < arNav[i].length; j++) {
			if (section == arNav[i][j]) {
				expandSection = i;
			}
		}
	} j=0; i=0;
	
	for (i=0; i < arNav.length; i++) {
		for(j=0; j < arNav[i].length; j++) {
			if (j == 0) { // main nav item
				path = "images/nav_";
				isMainNav = true;
			} else { // sub nav item
				path = "images/subNav_";
				isMainNav = false;
			}
			
			arImg = new Array();
			arImg[0] = new Image();
			arImg[0].src = path + arNav[i][j] + "_off.gif";
			arImg[1] = new Image();
			arImg[1].src = path + arNav[i][j] + "_on.gif";
			arImg[2] = new Image();
			arImg[2].src = path + arNav[i][j] + "_off.gif";
			onLoadState = new Image();
			if (section == arNav[i][j] || (expandSection == i && isMainNav == true)) {
				onLoadState.src = arImg[1].src; // on-state
				offState = "on";
				overState = "on";
			} else {
				onLoadState.src = arImg[0].src; // off-state
				offState = "off";
				overState = "on";
			}
			if (section == arNav[i][0] || isMainNav == true || expandSection == i) {
			
				output = output + "<td valign='top'><a href='" + arNav[i][j] + ".html' onmouseover=\"chgImg('" + path + "','" + arNav[i][j] + "','" + overState + "');window.status='" + arNav[i][j] + "';return true\" onmouseout=\"chgImg('" + path + "','" + arNav[i][j] + "','" + offState + "');window.status=' ';return true\"><img src='" + onLoadState.src + "' name='" + arNav[i][j] + "' border='0' alt='" + arNav[i][j] + "'></a></td>";
				
			}
		} // end for
	} // end for
	document.write(output);	


} // end function loadNav
