// change images on a page without having to go to a new page.

var pictitle = new Array(20);
var caption = new Array(20);
var alt = new Array(20);
var author = new Array(20);
// Enter the total number of images for the page here.
// Make sure there are at least this many images and alt tags in the array.
var totalpics = 5;

// titles, captions, and alt text for each picture
pictitle[1]="2000+";
caption[1]="The good news, sir, is that Harris was able to sell off our losing stocks. The bad news is that Simpson here bought them from Harris.";
alt[1]="cartoon";
author[1]="Dave Carpenter"

pictitle[2]="2000+";
caption[2]="Hoskins, try saying 'profits are up' <u>without</u> the finger quotes, okay?";
alt[2]="cartoon";
author[2]="Mike Lynch"

pictitle[3]="2000+";
caption[3]="Everybody say I.P.O.";
alt[3]="cartoon";
author[3]="Mike Shapiro"

pictitle[4]="2000+";
caption[4]="You can't report him to the CEO. He is the CEO.";
alt[4]="cartoon";
author[4]="Thomas Runyan"

pictitle[5]="2000+";
caption[5]="Since they've sequenced DNA, I suppose they'll be looking for the CEO gene.";
alt[5]="cartoon";
author[5]="Thomas Runyan"

var pn = 1  // start at 1

function showNext(){
	pn = pn + 1;
	if (pn > totalpics) {pn = 1;}
// unhighlight all the numbers
for (var i = 1; i <= totalpics; i ++)
{
document.getElementById('a'+i).style.color = "#FF0000";
document.getElementById('a'+i).style.fontWeight = "normal";
}
//	var heading = document.getElementById("heading");
//	heading.innerHTML = pictitle[pn];
//	var artist = document.getElementById("artist");
//	artist.innerHTML = author[pn];
//	var currentnumber = document.getElementById("currentpic");
//	currentnumber.innerHTML = pn;
	var imagecaption = document.getElementById("imagecaption");
	imagecaption.innerHTML = caption[pn];
	img = document.getElementById('placeholder');
	img.src = 'cartoon00s/slide' + pn + '.jpg';
// highlight current number
document.getElementById('a'+pn).style.color = "#000000";
document.getElementById('a'+pn).style.fontWeight = "bold";
	return false;
}

function showPrev(){
	pn = pn - 1;
	if (pn < 1) {pn = totalpics;}
// unhighlight all the numbers
for (var i = 1; i <= totalpics; i ++)
{
document.getElementById('a'+i).style.color = "#FF0000";
document.getElementById('a'+i).style.fontWeight = "normal";
}
//	var heading = document.getElementById("heading");
//	heading.innerHTML = pictitle[pn];
//	var artist = document.getElementById("artist");
//	artist.innerHTML = author[pn];
//	var currentnumber = document.getElementById("currentpic");
//	currentnumber.innerHTML = pn;
	var imagecaption = document.getElementById("imagecaption");
	imagecaption.innerHTML = caption[pn];
	img = document.getElementById('placeholder');
	img.src = 'cartoon00s/slide' + pn + '.jpg';
// highlight current number
document.getElementById('a'+pn).style.color = "#000000";
document.getElementById('a'+pn).style.fontWeight = "bold";
	return false;
}

function showThis(whichone){
	pn = whichone;
// unhighlight all the numbers
for (var i = 1; i <= totalpics; i ++)
{
document.getElementById('a'+i).style.color = "#FF0000";
document.getElementById('a'+i).style.fontWeight = "normal";
}
//	var heading = document.getElementById("heading");
//	heading.innerHTML = pictitle[pn];
//	var artist = document.getElementById("artist");
//	artist.innerHTML = author[pn];
// 	var currentnumber = document.getElementById("currentpic"); currentnumber.innerHTML = pn;
	var imagecaption = document.getElementById("imagecaption");
	imagecaption.innerHTML = caption[pn];
	img = document.getElementById('placeholder');
	img.src = 'cartoon00s/slide' + pn + '.jpg';
// highlight current number
document.getElementById('a'+pn).style.color = "#000000";
document.getElementById('a'+pn).style.fontWeight = "bold";
	return false;
}

function writePicture() {
    // picture and alt tag
    document.write('<img id="placeholder" class="linedrawing" src="cartoon00s/slide' + pn + '.jpg" border="0" alt=\"' + alt[pn]+ '\" />');
    // imagecaption
    document.write('<p id="imagecaption">' + caption[pn] + '</p>');
    // controls
    document.write('<div id="imagegallery"><a href="#" onclick="return showPrev()" title="Previous" id="previous"><img src="images/arrowleft.gif" alt="Previous" border="0" /></a> <a id="a1" href="#" onclick="return showThis(1)">1</a> <a id="a2" href="#" onclick="return showThis(2)">2</a> <a id="a3" href="#" onclick="return showThis(3)">3</a> <a id="a4" href="#" onclick="return showThis(4)">4</a> <a id="a5" href="#" onclick="return showThis(5)">5</a> <a href="#" onclick="return showNext()" title="Next" id="next"><img src="images/arrowright.gif" alt="Next" border="0"/></a></div>');
    // title
    // document.write('<h3 id="heading">' + pictitle[pn] + '</h3>');
    // artist
    // document.write('<p id="artist">' + author[pn] + '</p>');

    // first time the page loads highlight first link
    document.getElementById("a1").style.color = "#000000";
    document.getElementById("a1").style.fontWeight = "bold";
	// clear out noscript tag after a second
    window.setTimeout(function() {
        n = document.getElementsByTagName('noscript');
        if (n[0]) {
           n[0].style.display='none';
        }
    },1000);
}
