// no auto-init < 1.2
 

// SECTIONS
var numFeatures = 9;
var numEssays = 4;


// Menu IDs for feature stories
var kDummy = 0;
var kGecko = 1;
var kGravity = 2;
var kInventor = 3;
var kMethane = 4;
var kOak = 5;
var kRevenge = 6;
var kSound = 7;
var kSurgery = 8;


function Dummy() { return kDummy; }
function Gecko() { return kGecko; }
function Gravity() { return kGravity;}
function Inventor() { return kInventor; }
function Methane() { return kMethane; }
function Oak() { return kOak;}
function Revenge() { return kRevenge; }
function Sound() { return kSound; }
function Surgery() { return kSurgery; }


// Menu IDs for bookkeeping links
var kContents = 0;
var kAboutSciCom = 1;

function Contents() { return kContents; }
function AboutSciCom() { return kAboutSciCom; }



var kStop = -1;
function Stop() { return kStop; }

function MenuItem(name, author, illustrator, destination, authoranchor, illustratoranchor) {
     this.name = name;
     this.author = author;
     this.illustrator = illustrator;
     this.destination = destination;
     this.authoranchor = authoranchor;
     this.illustratoranchor = illustratoranchor;
}

var featureMenu = new Array();

// Initialize Feature menu
featureMenu[kDummy] = new MenuItem('The Dummies&#0146; Guide to Emergency Medicine', 'Regina Nuzzo', 'Tommy Moorman', 'dummy/index.html', 'Nuzzo', 'Moorman');
featureMenu[kGecko] = new MenuItem('Amazing Feet of Engineering', 'Anna Gosline', 'Tim Gunther', 'gecko/index.html', 'Gosline', 'Gunther');
featureMenu[kGravity] = new MenuItem('Catching the Cosmic Waves', 'Davide Castelvecchi', 'Amadeo Bachar', 'gravity/index.html', 'Castelvecchi', 'Bachar');
featureMenu[kInventor] = new MenuItem('The Man Who Found an Easier Way into Your Heart', 'Esther Landhuis', 'Diana Marques', 'inventor/index.html', 'Landhuis', 'Marques');
featureMenu[kMethane] = new MenuItem('Energy Saviour? Or Impending Disaster?', 'Quinn Eastman', 'Juna Kurihara', 'methane/index.html', 'Eastman', 'Kurihara');
featureMenu[kOak] = new MenuItem('Buy a Plant, Kill a Forest?', 'Megan Mansell Williams', 'Ali Kendall', 'oak/index.html', 'Williams', 'Kendall');
featureMenu[kRevenge] = new MenuItem('Civilized Outrage', 'Mason Inman', 'Eliza Jewett', 'revenge/index.html', 'Inman', 'Jewett');
featureMenu[kSound] = new MenuItem('The Information Orchestra', 'Czerne Reid', 'Dov Bock', 'sound/index.html', 'Reid', 'Bock');
featureMenu[kSurgery] = new MenuItem('Getting a Feel for Surgery', 'Shawne Neeper', 'Alan Chou', 'surgery/index.html', 'Neeper', 'Chou');

// Menu IDs for essays
var kHostel = 0;
var kJail = 1;
var kMice = 2;
var kWriting = 3;

function Hostel() { return kHostel + featureMenu.length; }
function Jail() { return kJail + featureMenu.length; }
function Mice() { return kMice + featureMenu.length; }
function Writing() { return kWriting + featureMenu.length; }


var essayMenu = new Array();

// Initialize Essay menu
essayMenu[kHostel] = new MenuItem('A Night at the Hostel', 'Anna Gosline', 'Stacey Vigallon', 'hostel/index.html', 'Gosline', 'Vigallon');
essayMenu[kJail] = new MenuItem('Past Imperfect', 'Czerne Reid', ' ', 'salinas/index.html', 'Reid', ' ');
essayMenu[kMice] = new MenuItem('Of Mice and Medicine', 'Quinn Eastman', ' ', 'mice/index.html', 'Eastman', ' ');
essayMenu[kWriting] = new MenuItem('A Different Breed of Science Writing', 'Regina Nuzzo', ' ', 'writing/index.html', 'Nuzzo', ' ');


var directoryPrefix = new Array();
directoryPrefix[0] = ''
directoryPrefix[1] = '../'
directoryPrefix[2] = '../../'
directoryPrefix[3] = '../../../'

function DisplayTitle(article) {
    document.write(featureMenu[article].name)
}

function DisplayHeadline(article, directoryDepth) {
    if (article < featureMenu.length) {

	document.write('<BR><IMG SRC="' + directoryPrefix[directoryDepth] +'images/spacer.gif" width="400" height="7"><BR>')
	document.write('<span class="headline">')
	document.write(featureMenu[article].name)
	document.write('</span>')
	document.write('<BR><IMG SRC="' + directoryPrefix[directoryDepth] +'images/spacer.gif" width="400" height="7"><BR>')
	document.write('<span class="byline">by ')
	
	// to change to links, change NAME to HREF 
	document.write('<A CLASS="byline" HREF="../writers.html#' + featureMenu[article].authoranchor + '">' + featureMenu[article].author + '</A>') 
	document.write('<BR>Illustration by ') 
	document.write('<A CLASS="byline" HREF="../illustrators.html#' + featureMenu[article].illustratoranchor + '">' + featureMenu[article].illustrator + '</A>')
	document.write('<br><BR></span>')
    
    } else {
	article = article - featureMenu.length
	document.write('<BR><IMG SRC="' + directoryPrefix[directoryDepth] +'images/spacer.gif" width="400" height="7"><BR>')
	document.write('<span class="headline">')
	document.write(essayMenu[article].name)
	document.write('</span>')
	document.write('<BR><IMG SRC="' + directoryPrefix[directoryDepth] +'images/spacer.gif" width="400" height="7"><BR>')
	document.write('<span class="byline">by ')

	// to change to links, change NAME to HREF
	document.write('<A CLASS="byline" HREF="../writers.html#' + essayMenu[article].authoranchor + '">' + essayMenu[article].author + '</A>')
	if (essayMenu[article].illustrator != ' ') {
	    document.write('<BR>Illustration by ')	    
	    document.write('<A CLASS="byline" HREF="../illustrators.html#' + featureMenu[article].illustratoranchor + '">' + essayMenu[article].illustrator + '</A>')
	}
	
	document.write('<br><BR></span>')
    }
    	
}

function DisplayNav(article, directoryDepth) {
    var navString = ''
    var dividerString = ''
    if (article == -1) {
        dividerString = ' / illustration by '
    }
    else {
        dividerString = '<BR>art:&nbsp;'
    }
//    navString += '<FONT FACE="verdana, geneva, helvetica" SIZE="1" COLOR="#990000">'
    
    document.write('<FONT COLOR="#777777" FACE="verdana,geneva,arial,helvetica" SIZE="1"><BR> <FONT COLOR="666699"><B>IN THIS ISSUE</B></FONT><P>')
    for (var i=0; i<featureMenu.length; i++) {
	navString += '<A HREF="' + directoryPrefix[directoryDepth] + featureMenu[i].destination + '" CLASS="navbar">'
	if (i == article) {
	    navString += '<IMG SRC="' + directoryPrefix[directoryDepth] +'images/redRightArrow.gif" WIDTH="8" HEIGHT="8" BORDER="0" ALT=""> <B><u>' + featureMenu[i].name + '</B></U><BR>by ' + featureMenu[i].author + dividerString + featureMenu[i].illustrator + '</A><P>' // highlight article name
	}
	else navString += '<B><u>' + featureMenu[i].name + '</B></U><BR>by ' + featureMenu[i].author + dividerString + featureMenu[i].illustrator + '</A><P>'
    }
    
    navString += '<BR><B>essays</B><P>'
    for (i=0; i<essayMenu.length; i++) {
	navString += '<A HREF="' + directoryPrefix[directoryDepth] + essayMenu[i].destination + '" CLASS="navbar">'
	if (i == article - featureMenu.length) {
	    navString += '<IMG SRC="' + directoryPrefix[directoryDepth] +'images/redRightArrow.gif" WIDTH="8" HEIGHT="8" BORDER="0" ALT=""> <B><u>' + essayMenu[i].name + '</B></U><BR>by ' + essayMenu[i].author // highlight article name
	    if (essayMenu[i].illustrator != ' ') {
	       navString += dividerString + essayMenu[i].illustrator
	    }
	    navString += '</A><P>' 
	}
	else {
	    navString += '<B><u>' + essayMenu[i].name + '</B></U><BR>by ' + essayMenu[i].author
	    if (essayMenu[i].illustrator != ' ') {
	       navString += dividerString + essayMenu[i].illustrator
	    }
	    navString += '</A><P>' 
	}
    }

 

//    if (article != -1) {
//	navString += '<BR><A HREF="' + directoryPrefix[directoryDepth] + 'index.html" CLASS="navbar">table of contents</A><P>'
//    }
    if (article != -1) {
         navString += '<BR><A HREF="http://scicom.ucsc.edu/" CLASS="navbar">about the UCSC Science Communication Program</A><BR><BR><BR></FONT>'
    }
    document.write(navString)
}