//nav.js adapted for buttons & Balls

// nav.js for the Cape Horn site.
NS4 = (document.layers);
IE4 = (document.all);
ver4 = (NS4 || IE4);
browserOK = document.images;
isMac = (navigator.appVersion.indexOf("Mac") != -1);


// locate the image files
btnPre = "../../buttons/btn-";
pgbtnPre = "../../buttons/";
imBase = "../../images/"
imBar = "../../images/bar-";

btnUp = "sphere-heather";
btnOver = "sphere-bronze";
btnDown = "sphere-yel-pink";


// List Spheres
arSpheres = new Array(
null,
"sphere-dark-red",	//	1
"sphere-bronze",		//	2
"sphere-yel-pink"		// 3
)

// list the pages
arPages = new Array(
null,
"horn-01.html",	// 1
"horn-02.html",	// 2
"horn-03.html",	// 3
"horn-04.html",	// 4
"horn-05.html",	// 5
"horn-06.html",	// 6
"horn-07.html",	// 7
"horn-08.html",	// 8
"horn-09.html",	// 9
"horn-10.html"	// 10	
)	

// list the urls
arUrls = new Array(
null,
"http://www.tylerstravels.com", 			// 1
"../../index.html",							// 2
"../../maps/sa-switch.html",				// 3
"../../chile/chile-menu.html",				// 4
"../../argentina/map-tierra.html",			// 5
"../../drake/drake-menu.html",				// 6
"mailto:pat@tylersterritory.com",		// 7
"../../itinerary/itinerary.html#horn",		// 8
"../../itinerary/weather.html",				// 9
"../../resources/links.html",				// 10
"../../resources/sitemap.html",				// 11
"dummy"										// 12
)			



// list the buttons
arButtons = new Array(
null,
"logo-tt", 			// 1
"antarctica",		// 2
"sa-sw",			// 3
"map-chile",		// 4
"map-tierra",		// 5
"drake",			// 6
"mail-tt",			// 6
"itinerary",		// 7
"weather",			// 8
"links",			// 9
"sitemap",			// 10
"dummy"				// 11
)		


// list the button text
arText = new Array(
null, 
"Tylers'<br>Travels",	// 1
"Cruise<br>Home",		// 2
"South<br>America",		// 3
"Chile<br>Menu",		// 4
"Tierra<br>del Fuego",	// 5
"Drake<br>Passage",		// 6

"E-Mail<br>Link",		// 5
"Tour<br>Itinerary",	// 6
"Weather<br>Page",		// 7
"Related<br>Links",		// 8
"Site<br>Index",		// 9
"dummy"					// 10
)			

// controls function calls & data
function doNavBtns(txtColor, fface, btnOff, btnOv, btnDn, barColor){
	imBar = imBar + barColor;
	btnUp = "sphere-" + btnOff;
	btnOver = "sphere-" + btnOv;
	btnDown = "sphere-" + btnDn;
	//initBtns(btnOver, btnDown);
	makeTitle("Cape Horn Page Navigator", 100, 3, txtColor, fface);
	makeButs("ball", 1, 3, btnUp, btnOver, btnDown);  // start & end numbers here 
	drawBar(3, 125, 3);
}

// ********************************************* Page Navigator ****************
// call & send data for bottom bar
function bottom_bar(dummy){
	drawBar(3, 75, 3);
}


function movr(){this.img.src = this.img.overSrc}
function mout(){this.img.src = this.img.outSrc}
function mdown(){this.img.src = this.img.downSrc}

function makeButs(pos, start, end, btnUp, btnOver, btnDown){
	lr = btnUp;
	document.write("<P ALIGN=center>") // align the images 
	if (end<=arPages.length) {
	for (i=start; i<= end; i++){
		if (i==curPage) lr = "sphere-ani-globe";
		imstr = "<IMG SRC='"+ pgbtnPre + lr + ".gif' WIDTH=30 HEIGHT=30 BORDER=0>";
		if (i==curPage) {document.write(imstr); lr=btnUp; continue}
		document.write(imstr.link(arPages[i]));
		if(!browserOK) continue;
		tLink =	document.links[document.links.length-1];
		tImg = tLink.img = document.images[document.images.length-1];
		tImg.outSrc = tImg.src;
		tImg.downSrc = pgbtnPre + btnDown + ".gif";	// down
		tImg.overSrc = pgbtnPre + btnOver + ".gif";	// over
		tLink.onmouseover = movr;
		tLink.onmouseout = tLink.onmouseup = mout;
		tLink.onmousedown = mdown;
	}
	document.write("</P>");
}}



function makeTitle(txt, len, hi, txtColor, fface){
	document.write("<P ALIGN='center'>") // align the title line
	document.write("<img src='" + imBar + ".gif' width='" + len + "' height='" + hi + "' align='middle' border='0'>");
	document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
	 document.write("<font face=" + fface + " color=" + txtColor + " size='4'>" + txt + " </font>"); 
	document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
	document.write("<img src='" + imBar + ".gif' width='" + len + "' height='" + hi + "' align='middle' border='0'>");
	document.write("</P>");
	}
	
function drawBar(num, len, hi){
	document.write("<P ALIGN='center'>") // align the bar
	for (i=1;i<=num;i++){
		document.write("<img src='" + imBar + ".gif' width='" + len + "' height='" + hi + "' align='middle' border='0'>")
	}
	document.write("</P>");
	}
	
// *********************************************  Section  Buttons
function button_loader(txtColor, fface){
loadButs(1, 2, txtColor, fface);
loadButs(3, 6, txtColor, fface);
loadButs(7, 11, txtColor, fface);
// loadButs(6, 13, txtColor, fface);
drawBar(3, 150, 3);
}

function loadButs(start, end, txtColor, fface){
	
	document.write("<P ALIGN='center'>"); // align the images 
	document.write("<table><tr>"); // start the table 
	if (end<=arButtons.length) {
	for (i=start; i<=end;i++){
		document.write("<td align='center' valign='top'>"); // table data
		imStr = "<IMG SRC='"+ btnPre + arButtons[i] + "-off.jpg'"
		imStr = imStr + "WIDTH=72 HEIGHT=96 BORDER=0></a><br>";
		txStr = "<font face=" + fface + " size='3' color=" + txtColor + ">" + arText[i] + "</font></td>";
		//document.write(anchStr);
		document.write(imStr.link(arUrls[i]));
		document.write(txStr);
		//document.write(imStr.link(arUrls[i]));
		if(!browserOK) continue;
		// added 
	
		tLink =	document.links[document.links.length-1];
		tImg = tLink.img = document.images[document.images.length-1];
		tImg.outSrc = tImg.src;
		tImg.downSrc = btnPre + arButtons[i] + "-dn.jpg";	// down
		tImg.overSrc = btnPre + arButtons[i] + "-ov.jpg";	// over
		if ( i > 3 && i < 12 ) { tLink.target = "_blank";} 
		tLink.onmouseover = movr;
		tLink.onmouseout = tLink.onmouseup = mout;
		tLink.onmousedown = mdown;
		 // end added
		
	}}
	document.write("</tr></table>");
	document.write("</P>");
}

