// JavaScript Document
var root;
var currentsq = 0;
if(location.protocol == "file:") {
	root = "file:///webpages/kaufman";
}
else {
	root = "http://" + location.hostname;
}

if(document.images) {
	abouton = new Image;
	aboutoff = new Image;
	poetryon = new Image;
	poetryoff = new Image;
	donateon = new Image;
	donateoff = new Image;
	downloadon = new Image;
	downloadoff = new Image;
	sq1on = new Image;
	sq1off = new Image;
	sq2on = new Image;
	sq2off = new Image;
	sq3on = new Image;
	sq3off = new Image;
	sq4on = new Image;
	sq4off = new Image;
	sq5on = new Image;
	sq5off = new Image;
	sq6on = new Image;
	sq6off = new Image;
	sq7on = new Image;
	sq7off = new Image;
	sq8on = new Image;
	sq8off = new Image;
	sq9on = new Image;
	sq9off = new Image;
	sq10on = new Image;
	sq10off = new Image;
	sq11on = new Image;
	sq11off = new Image;
	sq12on = new Image;
	sq12off = new Image;
	sq13on = new Image;
	sq13off = new Image;
	sq14on = new Image;
	sq14off = new Image;
	sq15on = new Image;
	sq15off = new Image;
	
	abouton.src = root + "/images/buttons/abouton.gif";
	aboutoff.src = root + "/images/buttons/aboutoff.gif";
	poetryon.src =root + "/images/buttons/poetryon.gif";
	poetryoff.src = root + "/images/buttons/poetryoff.gif";
	donateon.src = root + "/images/buttons/donateon.gif";
	donateoff.src = root + "/images/buttons/donateoff.gif";
	downloadon.src = root + "/images/buttons/downloadon.gif";
	downloadoff.src = root + "/images/buttons/downloadoff.gif";
	sq1on.src = root + "/images/buttons/sq1on.jpg";
	sq1off.src = root + "/images/buttons/sq1off.jpg";
	sq2on.src = root + "/images/buttons/sq2on.jpg";
	sq2off.src = root + "/images/buttons/sq2off.jpg";
	sq3on.src = root + "/images/buttons/sq3on.jpg";
	sq3off.src = root + "/images/buttons/sq3off.jpg";
	sq4on.src = root + "/images/buttons/sq4on.jpg";
	sq4off.src = root + "/images/buttons/sq4off.jpg";
	sq5on.src = root + "/images/buttons/sq5on.jpg";
	sq5off.src = root + "/images/buttons/sq5off.jpg";
	sq6on.src = root + "/images/buttons/sq6on.jpg";
	sq6off.src = root + "/images/buttons/sq6off.jpg";
	sq7on.src = root + "/images/buttons/sq7on.jpg";
	sq7off.src = root + "/images/buttons/sq7off.jpg";
	sq8on.src = root + "/images/buttons/sq8on.jpg";
	sq8off.src = root + "/images/buttons/sq8off.jpg";
	sq9on.src = root + "/images/buttons/sq9on.jpg";
	sq9off.src = root + "/images/buttons/sq9off.jpg";
	sq10on.src = root + "/images/buttons/sq10on.jpg";
	sq10off.src = root + "/images/buttons/sq10off.jpg";
	sq11on.src = root + "/images/buttons/sq11on.jpg";
	sq11off.src = root + "/images/buttons/sq11off.jpg";
	sq12on.src = root + "/images/buttons/sq12on.jpg";
	sq12off.src = root + "/images/buttons/sq12off.jpg";
	sq13on.src = root + "/images/buttons/sq13on.jpg";
	sq13off.src = root + "/images/buttons/sq13off.jpg";
	sq14on.src = root + "/images/buttons/sq14on.jpg";
	sq14off.src = root + "/images/buttons/sq14off.jpg";
	sq15on.src = root + "/images/buttons/sq15on.jpg";
	sq15off.src = root + "/images/buttons/sq15off.jpg";
}

function swapOn(imgLocation) {
  if(document.images && currentsq != imgLocation) {
    document.images[imgLocation].src = eval(imgLocation + "on.src");
	window.status=document.images[imgLocation].src;
  }
}

function swapOff(imgLocation) {
  if(document.images && currentsq != imgLocation) {
    document.images[imgLocation].src = eval(imgLocation + "off.src");
  }
}

function pickquote() {
	var page = "quotes/quote";
	var t = Math.round(Math.random() * 1) + 1;
	page = page + t + ".html";
	setiframe(page);
	currentsq = 0;
}
	
function pickpoem() {
	var page = "poem";
	var t;
	if(location.search.charAt(0) == '?') {
		t = location.search.substr(1);
	}
	else {
		do {
			var temp = Math.round(Math.random() * 14) + 1;
		} while(currentsq == "sq" + temp);
		t = temp;
	}
	page = page + t + ".html";
	var imgid = "sq" + t;
	setiframe(page);
	document.getElementById(imgid).src = root + "/images/buttons/" + imgid + "on.jpg";//turns the poem button on
	currentsq = imgid;
}

function setiframe(page) {
	document.getElementById("iframebody").src = page;
}
	