// 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 loadNav(section) {

	//preloadSubNav(section);
	
	arNav = new Array;
	arNav[0] = new Array("whimze");
	arNav[1] = new Array("gallery");
	arNav[2] = new Array("sets", "girl", "rat", "boys", "manly", "breakfast", "cookin");
	arNav[3] = new Array("order");
	arNav[4] = new Array("frequentflyer");
	arNav[5] = new Array("appearances");
	arNav[6] = new Array("news");
	arNav[7] = new Array("guest");
	arNav[8] = new Array("gazette");
	

	expandSection = -1;
	
	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] + "_over.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 = "over";
			}
			if (section == arNav[i][0] || isMainNav == true || expandSection == i) {
			
			//<A HREF='whimze.html'><IMG SRC='../images/nav_whimze_off.gif' ALT='' WIDTH='157' HEIGHT='39' BORDER='0'></A><br><A HREF='gallery.html'><IMG SRC='../images/nav_gallery_off.gif' ALT='' WIDTH='157' HEIGHT='39' BORDER='0'></A><br><A HREF='sets.html'><IMG SRC='../images/nav_sets_off.gif' ALT='' WIDTH='157' HEIGHT='39' BORDER='0'></A><br><A HREF='order.html'><IMG SRC='../images/nav_order_off.gif' ALT='' WIDTH='157' HEIGHT='39' BORDER='0'></A><br><IMG SRC='../images/nav_appearances_off.gif' ALT='' WIDTH='157' HEIGHT='39' BORDER='0'>
			
			
				output = "<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><br>";
				document.write(output);
			}
		} // end for
	} // end for
		


} // end function loadNav

