var sPath = window.location.pathname; 
var sPage = sPath.substring(sPath.lastIndexOf("/") + 1);
sPage = sPage.split(".")[0].toLowerCase();

function writeheader(sHeader) {
    document.write("<img src=\"images/header.jpg\">");
    document.write("<div id=\"pagetitle\"><h1>" + sHeader + "</h1></div>");
}

function writefooter() {
	document.write("<div id=\"blockcenter\"><a href=\"mailto:michaeltroy@trespassmusic.org?subject=MAILING_LIST_SIGNUP\">Join our mailing list</a> <b>Mailing List Policy:</b> All emails go out as blind cc's. This means that everyone's email address remains private. In addition, our list will by no means be traded or sold to any other corporation or organization and no email will be sent to you that is unrelated to Michael Troy.</div><div id=\"blockleft\">Contact Information: <a href=\"mailto:tracey@trespassmusic.org?subject=BOOKINGS\">tracey@trespassmusic.org</a> for bookings</div><div id=\"blockright\">Michael Troy Copyright&copy; 2010 All Rights Reserved</div>");
}

function writehomefooter() {
	document.write("<div id=\"homecenter\">Michael Troy Copyright&copy; 2010 All Rights Reserved</div>");
}

function writeright(bQ,bWN,bCD,iQ) {
	if(bQ) {
		document.write("<div id=\"block1\"><p class=\"type3\">" + writequote(iQ) + "</p><p class=\"type\">-Michael Troy</p></div>");
	}	
	if(bWN) {
		document.write("<div id=\"block2\"><div id=\"header\">What's New</div><div id=\"contents\"><p class=\"typeright\">Michael is a WINNER at the <br>2010 Kerrville Folk Festival!</p><hr><p class=\"type3\">Click <a class=\"nyroModal\" href=\"http://www.folkmichaeltroy.com/nicewords.htm#nicewords\">here</a> to read some very nice words from a fan!</p><hr><p class=\"typeright\">Sound clips are now available for all of Michael's songs. Visit the <a href=\"cdpage0.htm\">\"CD & Lyrics\" </a>page and click on<br>\"more info...\".</p></div></div>");
	}	
	if(bCD) {
		document.write("<div id=\"block3\"><div id=\"header\">Michael's CDs</div><div id=\"contents\"><p class=\"typeright\">Michael's CDs have been very well received.<br>Check out</p><img src=\"images/cd1.jpg\"><p class=\"typeright\">\"<a href=\"cdpage1.htm\">Whispers in the Wind</a>\"</p><img src=\"images/cd2.jpg\"><p class=\"typeright\">\"<a href=\"cdpage2.htm\">Romancing the Moon</a>\"</p><img src=\"images/cd3.jpg\"><p class=\"typeright\">\"<a href=\"cdpage3.htm\">Mill Town Boy</a>\"</p></div></div>");
	}
}

function writequote(i) {
	var sQuote;
	var aQuotes = new Array (
		"Ghetto child is a lonesome child, he's just tumbling here and there. No prospects,<br>fate unknown.<br>Doesn't anybody care.",
		"And me, I look in wonder,<br>At the parting of the sky,<br>And the wind whistles,<br>Here am I, Here I am.",
		"Free from the rod<br>at his back,<br>He's Free from the call<br>of the clock,<br>Free from the yoke<br>at his neck,<br>A highway right of way.",
		"You'll never live your dreams if you don't take a chance, and let the chips fall where they may.",
		"Nothing so tender as<br>the love of a father<br>As sure and steady<br>as hourglass sand.<br>The fatherless boy,<br>the husbandless mother<br>The poet, the prophet,<br>the savior of man.",
		"And the sun breaks through the thunder,<br>And rays of beaming gold,<br>Are like God's own hands, collecting souls.",
		"Young and eager, wet and green, a lean mean laboring machine, consumed with American dreams.",
		"<br>All I want to do is play.<br>",
		"<br>Butterfly's a beautiful thing, just a whisper in the wind...",
		"Someday you'll grow into a beauty. Someday I'll grow to be old and gray.",
		"Conclusions are illusions,<br>It's just the horizon,<br>It's just the end,<br>Where you start again.",
		"Life happens, like rivers flow,<br>Dam  it all or let it go.",
		"I'm Fall River born and raised, between southern Mass. and the Ocean State, reared on the shoals of the Mount Hope Bay.",
		"When I die I'll shed this skin, spread my wings and<br>ride the wind.");
	if(typeof(i) == "undefined" || isNaN(i) || i < 0 || i > (aQuotes.length-1))
		i = Math.round(Math.random()*(aQuotes.length-1));
	sQuote = aQuotes[i];
	return sQuote;
}	

function writemenu(iCurrentPage) {
	var i, c;
	var menulinks = new Object();
		menulinks['0'] = "index.htm";
		menulinks['1'] = "bio.htm";
		menulinks['2'] = "awards.htm";
		menulinks['3'] = "press.htm";
		menulinks['4'] = "reviews.htm";
		menulinks['5'] = "cdpage0.htm";
		menulinks['6'] = "articles.htm";
		menulinks['8'] = "schedule.htm";
		menulinks['9'] = "gallery.htm";
		menulinks['10'] = "links.htm";
		menulinks['11'] = "contact.htm";
	
	var menutext = new Object();
		menutext['0'] = "Home";
		menutext['1'] = "Biography";
		menutext['2'] = "Awards";
		menutext['3'] = "Press Kit";
		menutext['4'] = "Reviews";
		menutext['5'] = "CDs & Lyrics";
		menutext['6'] = "Articles";
		menutext['8'] = "Schedule";
		menutext['9'] = "Gallery";
		menutext['10'] = "Links";
		menutext['11'] = "Contact";
	
	c = iCurrentPage.toString();
	// alert(c);
	for(i in menulinks) {
		// alert(i);
		if(i==c)
			document.write("<a href=\"" + menulinks[i] + "\" id=\"mcurrent\">" + menutext[i] + "</a>");
		else
			document.write("<a href=\"" + menulinks[i] + "\" id=\"mlink\">" + menutext[i] + "</a>");
	}
	
	delete menulinks;
	delete menutext;

}

function setheight() {
	var l = document.getElementById("pageleft");
	var c = document.getElementById("pagecontent");
	var r = document.getElementById("pageright");
 	var heights = new Array(
 		l.offsetHeight,
 		c.offsetHeight);
 	heights.sort(compare);
 	var h = heights[0];
 	
 	// need to compensate for the the footer image on the right (89)
 	var rh = r.offsetHeight+296;
 	if(rh>h)
 		h=rh;

	l.style.height = h+"px";
 	c.style.height = h+"px";
 	r.style.height = h+"px";
 	
 	// position the bottom image now that the heights are correct
 	setrightbottomimage(h);
}

function compare(a, b) {
	return b - a;
}

function setrightbottomimage(h) {
	var i = document.getElementById("rightbottomimg");
	// change the top of the image to the absolute position
	// h = height of longest column
	// absolute references page, so add in 289 for header
	// subtract 296 (89) for height of image
	i.style.top = (h-7)+"px";
}
