//draws navigation bar w/ hard links
function navBar() {
	var sections = new Array('about','art','moving_pictures','still_images','sounds','downloads');
	var leadIn = 'http://rhymeswithart.com/';
	
	var addr = location.href.toLowerCase();
	var pager = addr.split('rhymeswithart.com/')[1].split('/');  // an array of everything after rwa.com/, split at the slashes

	var block = '<img id="rwa" src="http://rhymeswithart.com/navi/title.png" />';
	if (pager[0] != 'index.html') {
		block = '<a href="http://rhymeswithart.com/">' + block + '</a>';
	}
	for (i=0;i<sections.length;i++) {
		var temp = '<img src="' + leadIn + 'navi/' + sections[i] + '.png" />';
		if (pager[0] == sections[i] && pager[1] == 'index.html') {
			block += temp;
			continue;
		}
		temp = '<a href="' + leadIn + sections[i] + '/">' + temp + '</a>';
		block += temp;
	}
	document.write('<div class="navigation">' + block + '</div>');
}

//image functions

//loads 3 thumbnails maximum
function thumbs(cat) {
	var tomcat = window[cat];
	for (j=0;j<3&&tomcat.length;j++) {
		var rand = Math.floor(Math.random()*tomcat.length);
		document.write('<img class="thumbs" src="' + cat + '/thumbs/' + tomcat[rand] + '" />');
		tomcat.splice(rand,1);
	}
}

//loads all thumbnails
function spread(cat) {
	for (j=0;j<window[cat].length;j++) {
		document.write('<a href="' + (j + 1) + '.html"><img class="spread" src="thumbs/' + window[cat][j] + '" /></a>');
	}
}

//creates full gallery page
function galleryPage(stuff) {
	var s = window[stuff];
	if (s.title) {
		var stitle = s.title;
	}
	else {
		var stitle = stuff;
	}
	document.write('<div class="entry" id="' + s + '"><div class="name">' + stitle + '</div>' + s.date + '<br />' + s.desc + '</div><br />');
	spread(stuff);
}

//inserts entry on top level pages
function mainPage(stuff, stills) {
	var s = window[stuff];
	if (s.title) {
		var stitle = s.title;
	}
	else {
		var stitle = stuff;
	}
	document.write('<div class="entry" id="' + stuff + '"><a href="' + stuff + '/">');
	thumbs(stuff);
	document.write('<div class="name">' + stitle + '</a></div>' + s.date + '<br />' + s.desc);
	if (s.fatness) {
		document.write('<br />' + s.fatness);
	}
	document.write('</div>');
}

var gall, which;

//creates presentation page
function single() {
	var galler = window[gall];
	var whicho = which - 1;
	var backo = whicho;
	if (!backo) {
		backo = galler.length;
	}
	var nexto = which + 1;
	if (nexto > galler.length) {
		nexto = 1;
	}
	if (galler.title) {
		gall = galler.title;
	}
	document.write('<div class="name">' + gall);
	if (galler.length > 1) {	//if more than one image
		document.write(' - ' + which + '/' + galler.length + '</div>');
		document.write('<a href="' + backo + '.html">back</a> | <a href="' + nexto + '.html">next</a><br />');
		document.write('<a href="./">gallery view</a>');
	}
	else {
		document.write('</div>');
	}
	document.write('</div><br /><img src="media/' + galler[whicho] + '"/ >');
}