/*******************
Fxns.js
********************/

/*******************
Data Members
*******************/
//Constants
var WIDTH = 600;
var MARGIN = 10;

//Page Properties
var pageType;

var bgCol;
var textCol;
var linkCol;
var vlinkCol;
var alinkCol;
var backImg;
var border;
//End Page Properties

//Button Stuff
var imgoff = new Array(new Image(),new Image(),new Image(),new Image(),new Image(), new Image(), new Image(), new Image());
var imgon  = new Array(new Image(),new Image(),new Image(),new Image(),new Image(), new Image(), new Image(), new Image());

imgoff[0].src = "images/home.gif";
imgon[0].src  = "images/homey.gif";
imgoff[1].src = "images/me.gif";
imgon[1].src  = "images/mey.gif";
imgoff[2].src = "images/images.gif";
imgon[2].src  = "images/imagesy.gif";
imgoff[3].src = "images/humor.gif";
imgon[3].src  = "images/humory.gif";
imgoff[4].src = "images/thought.gif";
imgon[4].src  =  "images/thoughty.gif";
imgoff[5].src = "images/shrines.gif";
imgon[5].src  = "images/shrinesy.gif";
imgoff[6].src = "images/computers.gif";
imgon[6].src = "images/computersy.gif";
imgoff[7].src = "images/links.gif";
imgon[7].src  = "images/linksy.gif";
//End Button Stuff


/*******************
Functions
*******************/
function setPage(setup){

	pageType = setup

	bgCol="#fffffff";
	textCol="#0000000";
	linkCol="#0066ff";
	vlinkCol="#ff66ff";
	alinkCol="#ff0000";
	backImg="images/yellroc.jpg";
	border = 0;
}
function on(i) {
	document[getcmdName(i)].src = imgon[i].src;
}

function off(i) {
	document[getcmdName(i)].src = imgoff[i].src;
}
function getcmdName(i){
	switch(i){
		case 0:
			return 'cmdHome';
		case 1:
			return 'cmdMe';
		case 2:
			return 'cmdImg';
		case 3:
			return 'cmdHumor';
		case 4:
			return 'cmdThought';
		case 5:
			return 'cmdShrines';
		case 6:
			return 'cmdComp';
		case 7:
			return 'cmdLinks';		
	}
}
function makeButtonBar() {
	var tr = "";
	var td = "";

	if (pageType == 1)
	{
		var tr = "<tr> <td width=10>";
		var td = "<td width=128> <center>";
	}

	document.write(tr);

	document.write(td);
	document.write('<a href=index.html onmouseover=on(0); onmouseout=off(0)>');
	document.write('<img src=images/home.gif width=100 height=40 border=0 name=cmdHome></a> <br>');

	document.write(td);
	document.write('<a href=me.html onmouseover=on(1); onmouseout=off(1)>');
	document.write('<img src=images/me.gif width=100 height=40 border=0 name=cmdMe></a> <br>');
	
	document.write(td);
	document.write('<a href=images.html onmouseover=on(2); onmouseout=off(2)>');
  	document.write('<img src=images/images.gif width=100 height=40 border=0 name=cmdImg></a> <br>');

	document.write(td);
	document.write('<a href=humor.html onmouseover=on(3); onmouseout=off(3)>');
  	document.write('<img src=images/humor.gif width=100 height=40 border=0 name=cmdHumor></a> <br>');

	document.write(tr);

	document.write(td);
	document.write('<a href=philosophy.html onmouseover=on(4); onmouseout=off(4)>');
  	document.write('<img src=images/thought.gif width=100 height=40 border=0 name=cmdThought></a> <br>');

	document.write(td);
	document.write('<a href=shrines.html onmouseover=on(5); onmouseout=off(5)>');
  	document.write('<img src=images/shrines.gif width=100 height=40 border=0 name=cmdShrines></a> <br>');

	document.write(td);
	document.write('<a href=computers.html onmouseover=on(6); onmouseout=off(6)>');
  	document.write('<img src=images/computers.gif width=100 height=40 border=0 name=cmdComp></a> <br>');

	document.write(td);		
	document.write('<a href=links.html onmouseover=on(7); onmouseout=off(7)>');
  	document.write('<img src=images/links.gif width=100 height=40 border=0 name=cmdLinks></a><br>');

	if (pageType == 1){
		document.write('</td></tr></table>');	
	
		document.write('<hr align=left width=' + WIDTH + '>');
		document.write('<table border=1 cellPadding=0 cellSpacing=0>');
		document.write('<tr>');
		document.write('<td width = ' + MARGIN + '>');
		document.write('<td width = ' + WIDTH + '>');
	}

}

function makeHeaderStruct(title, image, section){
	document.write('<body bgcolor=' + bgCol + ' text=' + textCol + ' link=' + linkCol + ' vlink=' + vlinkCol + ' alink=' + alinkCol + ' background=' + backImg +'>');

	document.write('<table border=' + border + ' cellPadding=0 cellSpacing=0>');
	document.write('<tbody>');
	document.write('<tr>');
	document.write('<td height=85 width =' + MARGIN + '>');
	document.write('<td valign=top width = 515>');
	document.write('<a name="Top">');
	document.write('<center><h1>');

	document.write(title);

	document.write('</center></h1>');
	document.write('</a>');
	document.write('<td valign=top width = 75>');
	document.write('<center>');

	if (section == ''){
		document.write('<img src=' + image + '></img>');
	}
	else{
		document.write('<a href=' + section + '><img src=' + image + ' border=0 alt=' + section + ' height=60 width=60></img></a>');
	}

	document.write('</center>');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
}

function makeBodyStruct(){

	document.write('<table border=' + border + ' cellPadding=0 cellSpacing=0>');
	document.write('<tbody>');
	document.write('<tr>');		
	document.write('<td width=' + MARGIN + '>');
	
	if (pageType == 0)
		document.write('<td valign=top width=104>'); //Button bar cell

	makeButtonBar();
	
	if (pageType == 0) {
		document.write('<td width=' + MARGIN + '>');
		document.write('<td valign=top width=476>'); //Body cell
	}
}

function closeBodyStruct(){
	document.write('</center>');
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');
}

function makeFootStruct(section, next, previous) {

	document.write('<hr align=left 	width=' + WIDTH + '>');
	document.write('<table border=' + border + ' cellPadding=0 cellSpacing=0>');
	document.write('<tr>');
	document.write('<td width=' + MARGIN + '>');
	document.write('<td width=171>');
	document.write('<center>');
	document.write('<a href=#Top>Back to Top</a><br>');
	document.write('</center>');
	document.write('<td width = 172>');
	document.write('<center>');

	if (section == '') {
		document.write('Section Index');
	}
	else {
		document.write('<a href=' + section +'>Back to Section Index</a>');
	}

	document.write('<center>');		
	document.write('<td width = ' + (WIDTH - MARGIN)/3 + '>');
	document.write('<center>');
	document.write('<a href=index.html>Back to Main Index</a>');
	document.write('</center>');
	document.write('<tr>');
	document.write('<td width=' + MARGIN + '>');
	document.write('<td width=' + (WIDTH - MARGIN)/3 + '>');
	document.write('<center>');

	if (next == ''){
		document.write('Last Page');
	}
	else {
		document.write('<a href=' + next + '>Next Page</a>');
	}

	document.write('<td width=' + (WIDTH - MARGIN)/3 + '>');
	document.write('<center>');

	if (previous == ''){
		document.write('First Page');
	}
	else {
		document.write('<a href=' + previous + '>Previous Page</a>');
	}
	
	document.write('<td width=171>');
	document.write('<center>');
	
	if (section == ''){
		document.write('<a href=\"mailto:ole_is@angelfire.com?subject=Ole\'s Kingdom\">E-mail Ole!</a>');
	}
	else {
		document.write('<a href=\"mailto:ole_is@angelfire.com?subject=Ole\'s Kingdom:  ' + section + ' \">E-mail Ole!</a>');
	}
	document.write('</td>');
	document.write('</tr>');
	document.write('</table>');

}


