//nav.js adapted for buttons & Balls

// nav.js for the Beijing 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 the pages
arPages = new Array(
null,
"xian-01.html",	// 1
"xian-02.html",	// 2
"xian-03.html",	// 3
"xian-04.html",	// 4
"xian-05.html",	// 5
"xian-06.html",	// 6
"xian-07.html"	// 7
)	

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

// list the urls
arUrls = new Array(
null,
"../../index.html",	// 1
"../index.html",								// 2
"mailto:pat@tylersterritory.com",		// 3
"../resources/itinerary.html#guilin",		// 4
"../resources/weather.html",				// 5
"../resources/links.html",					// 6
"../resources/sitemap.html",				// 7
"dummy"										// 8
)			



// list the buttons
arButtons = new Array(
null,
"logo-tt", 			// 1
"menu",				// 2
"mail-tt",			// 3
"itinerary",		// 4
"weather",			// 5
"links",			// 6
"sitemap",			// 7
"dummy"				// 8
)		


// list the button text
arText = new Array(
null, 
"Tylers'<br>Travels",	// 1
"China<br>Home",		// 2
"E-Mail<br>Link",		// 3
"Tour<br>Itinerary",	// 4
"Weather<br>Page",		// 5
"China<br>Links",		// 6
"Site<br>Index",		// 7
"dummy"					// 8
)			

// 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("The Beijing Menu Page Navigator", 100, 3, txtColor, fface);
	//makeButs("ball", 1, 3, btnUp, btnOver, btnDown);
	drawBar(3, 125, 3);
}

// ********************************************* Page Navigator ****************


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 = "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'><b>" + txt + "</b> </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, 3, txtColor, fface);
loadButs(4, 7, txtColor, fface);
// loadButs(6, 13, txtColor, fface);
drawBar(3, 75, 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
		/*
		anchStr = "<a href='"+ arUrls[i] + "' ";
		if ( i <= 2 ) { anchStr = anchStr + "target='_top'";} 
		if ( i > 2 && i < 7 ) { anchStr = anchStr + "target='_blank'";} 
		anchStr = anchStr + ">";
		*/
		
		imStr = "<IMG SRC='"+ btnPre + arButtons[i] + "-off.gif'"
		imStr = imStr + "WIDTH=72 HEIGHT=96 BORDER=0></a><br>";
		txStr = "<font face=" + fface + " size='3' color=" + txtColor + "><b>" + arText[i] + "</b></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.gif";	// down
		tImg.overSrc = btnPre + arButtons[i] + "-ov.gif";	// over
		if ( i > 3 && i < 8 ) { tLink.target = "_blank";} 
		tLink.onmouseover = movr;
		tLink.onmouseout = tLink.onmouseup = mout;
		tLink.onmousedown = mdown;
		 // end added
		
	}}
	document.write("</tr></table>");
	document.write("</P>");
}

