// no auto-init < 1.2
 

// SECTIONS
var numFeatures = 10;
var numEssays = 0;


// Menu IDs for feature stories
var kLevee = 0;
var kPrayer = 1;
var kCochlear = 2;
var kPesticide = 3;
var kAttention = 4;
var kDream = 5;
var kVideogame = 6;
var kInjury = 7;
var kSeti = 8;
var kRocks = 9;


function Attention() { return kAttention; }
function Pesticide() { return kPesticide; }
function Cochlear() { return kCochlear;}
function Dream() { return kDream; }
function Injury() { return kInjury; }
function Levee() { return kLevee;}
function Prayer() { return kPrayer; }
function Rocks() { return kRocks; }
function Seti() { return kSeti; }
function Videogame() {
    return kVideogame;
}


// 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, blurb, author, illustrator, destination, authoranchor, illustratoranchor) {
     this.name = name;
     this.blurb = blurb;
     this.author = author;
     this.illustrator = illustrator;
     this.destination = destination;
     this.authoranchor = authoranchor;
     this.illustratoranchor = illustratoranchor;
}

var featureMenu = new Array();
var essayMenu = new Array();

// Initialize Feature menu
featureMenu[kAttention] = new MenuItem('Pay Attention. Here\'s How Your Mind Does It.', 'Scientists struggling to understand how our brains pay attention are turning to an unexpected resource: barn owls.', 'Juhi Yajnik', 'Glenda Lee', 'attention/index.html', 'writer', 'artist');
featureMenu[kPesticide] = new MenuItem('Killing Bugs Organically', 'The biopesticide industry promises to fight crop pests without harming the environment.', 'Emily Saarman', 'Erin Hunter', 'pesticide/index.html', 'writer', 'artist');
featureMenu[kCochlear] = new MenuItem('Broken Silence', 'Tiny implants are allowing deaf people to hear for the first time. That\'s just the first change in their lives.','Aria Pearson', 'Stephen Nakazawa Hewitt &amp; Janet Chao', 'cochlear/index.html', 'writer', 'artist');
featureMenu[kDream] = new MenuItem('Conscious Dreams', 'Some people claim they are fully conscious while dreaming. Neuroscientists doubt this.', 'Chandra Shekhar', 'Daniela Naomi Molnar', 'dream/index.html', 'writer', 'artist');
featureMenu[kInjury] = new MenuItem('The Re-Built Athlete, Almost as Good as New', 'Cutting-edge surgical techniques allow injured athletes to compete again, but it\'s the post-op therapies that separate the amateurs from the pros.', 'Aditi Risbud', 'Christine Elder', 'injury/index.html', 'writer', 'artist');
featureMenu[kLevee] = new MenuItem('The Next New Orleans', 'Land is subsiding, and the aging levees are weakening. Sound familiar? But this time, it\'s California\'s economy that could wash away in a flood.', 'Julie Rehmeyer', 'Erika Beyer &amp; Karen Czuleger', 'levee/index.html', 'writer', 'artist');
featureMenu[kPrayer] = new MenuItem('The Power(lessness) of Prayer', 'Some researchers want to know whether prayer and good intentions have the power to heal. They\'re using taxpayer money to find out. Are they operating within the limits of science &#151; or trying to test the untestable?', 'Susanne McDowell', 'Anne Gutmann', 'prayer/index.html', 'writer', 'artist');
featureMenu[kRocks] = new MenuItem('Stealth Rocks', 'Boulders lumber across an ancient lakebed in Death Valley, leaving furrows that hint at their clandestine acts. Scientists have stalked these stones for decades, but will they ever catch the rocks a-rollin\' ?', 'Krista Zala', 'Angela Liounis &amp; Justin Hofman', 'rocks/index.html', 'writer', 'artist');
featureMenu[kSeti] = new MenuItem('Where Is Everybody?', 'Scientists searching for extraterrestrial life rely on a simple equation to answer profound questions about who we are. But no one has the numbers to plug into it.', 'Erik Vance', 'Katherine A. Smith &amp; Ian Harlow Williams', 'seti/index.html', 'writer', 'artist');
featureMenu[kVideogame] = new MenuItem('Designing a Smarter Enemy', 'In the competitive video game industry, successful game designers must offer savvy players ever more complexity.  Now, devilishly smart enemies are taking on a life all their own.','Anne Pinckard','Jennifer Marie Bolen', 'videogame/index.html','writer', 'artist');


// Menu IDs for essays

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>Illustrated 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>Illustrated by ')	    
	    document.write('<A CLASS="byline" HREF="../illustrators.html#' + featureMenu[article].illustratoranchor + '">' + essayMenu[article].illustrator + '</A>')
	}
	
	document.write('<br><BR></span>')
    }}

function DisplayAuthor(article) {
    document.write(featureMenu[article].author)
}

function DisplayIllustrator(article) {
    document.write(featureMenu[article].illustrator)
}

function DisplayBlurb(article) {
    document.write(featureMenu[article].blurb)
}

function DisplayHeader(article) {
    document.write('<H1>')
    document.write(featureMenu[article].name)
    document.write('</H1> ')
    document.write('<H3>by <A CLASS="author" HREF="#writer">')
    document.write(featureMenu[article].author)
    document.write('</A>')
    document.write('<SPAN CLASS="blurb"> / </SPAN>')
    document.write('<SPAN CLASS="illustrator">illustrated by <A CLASS="illustrator" HREF="#illustrator">')
    document.write(featureMenu[article].illustrator)
    document.write('</A></SPAN></H3>')
    document.write('<H4 CLASS="blurb">')
    document.write(featureMenu[article].blurb)
    document.write('</H4> ')
//    document.write('<BR><BR>')
    
}

function DisplayNav(article, directoryDepth) {
    var navString = ''
    var dividerString = ''
    if (article == -1) {
        dividerString = ' / illustrated 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 class="nav">')
    for (var i=0; i<featureMenu.length; i++) {
	navString += '<A HREF="' + directoryPrefix[directoryDepth] + featureMenu[i].destination + '" CLASS="navbar">'
	if (i == article) {
	    navString += '<B><u>' + featureMenu[i].name + '</B></U></A><BR>by ' + featureMenu[i].author + dividerString + featureMenu[i].illustrator + '</A><P class="nav">' // highlight article name
	}
	else navString += '<B><u>' + featureMenu[i].name + '</B></U></A><BR>by ' + featureMenu[i].author + dividerString + featureMenu[i].illustrator + '</A><P class="nav">'
	if (article == -1) {
	    navString += featureMenu[i].blurb + '<BR><BR>'
	}
	
    }
    
//    navString += '<BR><B>essays</B><P class="nav">'
    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 class="nav">' 
	}
	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 class="nav">' 
	}
    }

 

//    if (article != -1) {
//	navString += '<BR><A HREF="' + directoryPrefix[directoryDepth] + 'index.html" CLASS="navbar">table of contents</A><P class="nav">'
//    }
//    if (article != -1) {
         navString += '<BR><SPAN CLASS="navbar"><B>Editors</B><BR>Robert Irion, Jonathan Knight<BR><B>Web design</B><BR> Kenneth Chang<BR></SPAN><BR><BR><B><A HREF="http://scicom.ucsc.edu/SciWriting.html" CLASS="navbar"><U>about the UCSC Science Writing Program</U></A><BR><BR><A HREF="http://scicom.ucsc.edu/illus" CLASS="navbar"><U>about the UCSC Science Illustration Program</U></A></B><BR><BR><BR><A HREF="http://scicom.ucsc.edu/SciNotes/" CLASS="navbar"><B><U>other issues of <I>Science Notes</I></U></B></A><BR><BR><BR></FONT>'
//    }
    document.write(navString)
}

function DisplayLogo(directoryDepth) {
    document.write('<A HREF="../index.html" CLASS="nounderline"><B>Science Notes 2006</B></A>')
}
