// JavaScript Document

function init() {
	var next = document.getElementById('nextlink').style;
	var prev = document.getElementById('prevlink').style;
	var bio = document.getElementById('bioDiv').style;
	next.display = 'inline';
	prev.display = 'none';
	bio.display = 'none';
	document.forms.data.showing.value = '1';
	document.getElementById('of').firstChild.data = document.forms.data.maximages.value;
	document.getElementById('num').firstChild.data = '1';
}

function showbio() {
	
	var bioDiv = document.getElementById('bioDiv').style;
	var at = parseInt(document.forms.data.showing.value);
	var imageDiv = document.getElementById('imageDiv'+at).style;
	
	if (bioDiv.display == 'none') {
		bioDiv.display = 'block';
		imageDiv.display = 'none';
	}
	else {
		bioDiv.display = 'none';
		imageDiv.display = 'block';
	}
}

function adjust(n) {


var imageChangeDiv = 'imageDiv'+n;
var captionChangeDiv = 'captionDiv'+n;

var d = document;
var imgwidth = document.images[n-1].width;
var titleDiv = d.getElementById('headerDiv').style;
var imageDiv = d.getElementById(imageChangeDiv).style;
var captionDiv = d.getElementById(captionChangeDiv).style;	
var creditDiv = d.getElementById('creditDiv').style;	
var footerDiv = d.getElementById('footerDiv').style;	


	if (imgwidth > 480) {
		titleDiv.width = imgwidth+'px';
		imageDiv.width = imgwidth+'px';
		captionDiv.width = imgwidth+'px';
		creditDiv.width = imgwidth+'px';
		footerDiv.width = imgwidth+'px';
	}
	else {
		titleDiv.width = '480px';
		imageDiv.width = '480px';
		captionDiv.width = '480px';
		creditDiv.width = '480px';
		footerDiv.width = '480px';	
	}
	

}

function next() {

var d = document;
var at = parseInt(d.forms.data.showing.value);
var maxval = parseInt(d.forms.data.maximages.value);
var to = at + 1;
var next = d.getElementById('nextlink').style;
var prev = d.getElementById('prevlink').style;

if (to == maxval) { next.display = 'none'; }

if (prev.display == 'none') { prev.display = 'inline'; }

if (to <= maxval) {
	
	var nowshowing = 'imageDiv' + at;
	var willshow = 'imageDiv' + (to);
	
	var nowcaption = 'captionDiv' + at;
	var willcaption = 'captionDiv' + (to);

	//alert (nowshowing+" ... "+willshow);
	
	var hidestyle = d.getElementById(nowshowing).style;
	var showstyle = d.getElementById(willshow).style;
	
	var bioDiv = document.getElementById('bioDiv').style;
	
	if (bioDiv.display == 'block') {
		bioDiv.display = 'none';
	}		
	
	hidestyle.display = 'none';
	showstyle.display = 'block';
		
	var hidestyle = d.getElementById(nowcaption).style;
	var showstyle = d.getElementById(willcaption).style;
	
	hidestyle.display = 'none';
	showstyle.display = 'block';
	
	d.forms.data.showing.value = to;
	
	document.getElementById('num').firstChild.data = to;
	
	adjust(to);

}

}

function prev() {

var d = document;
var at = parseInt(d.forms.data.showing.value);
var to = at - 1;

var next = d.getElementById('nextlink').style;
var prev = d.getElementById('prevlink').style;

if (to == 1) { prev.display = 'none'; }

if (next.display == 'none') { next.display = 'inline'; }

if (to > 0) {
	
	var nowshowing = 'imageDiv' + at;
	var willshow = 'imageDiv' + (to);
	var nowcaption = 'captionDiv' + at;
	var willcaption = 'captionDiv' + (to);
	
	//alert (nowshowing+" ... "+willshow);
	
	var hidestyle = d.getElementById(nowshowing).style;
	var showstyle = d.getElementById(willshow).style;
	
	var bioDiv = document.getElementById('bioDiv').style;
	
	if (bioDiv.display == 'block') {
		bioDiv.display = 'none';
	}	
	
	hidestyle.display = 'none';
	showstyle.display = 'block';
	
	var hidestyle = d.getElementById(nowcaption).style;
	var showstyle = d.getElementById(willcaption).style;
	
	hidestyle.display = 'none';
	showstyle.display = 'block';
	
	d.forms.data.showing.value = to;
	
	document.getElementById('num').firstChild.data = to;
	
	adjust(to);
	
	}

}
function boundarystates() {

var d = document;
var nowshowing = d.forms.data.showing.value;
var maxshowing = d.forms.data.showing.value;

}
