//
// Load an XML document asynchronously.
// 
// Parameters:
//   parseFunc - function used to parse the XML document once it's loaded.
//   url       - url from which to load the document.
//
function loadXML(parseFunc, url) {
	url += "?nocache=" + new Date().getTime();
	if(window.XMLHttpRequest) {
		xml = new XMLHttpRequest();
		xml.onreadystatechange = function() {
			if(xml.readyState == 4) {
				parseFunc(xml.responseXML);
			}
		}
		xml.open("GET", url, true);
		xml.send(null);
	} else if(window.ActiveXObject) {
		xml = new ActiveXObject("Microsoft.XMLDOM");
		xml.onreadystatechange = function() {
			if(xml.readyState == 4) {
				parseFunc(xml);
			}
		}
		xml.load(url);
	} else {
		alert("Sorry, your browser doesn't support the XMLHttpRequest object.");
	}
}

function addFooter(contentDiv, dateElement) {
	
    // Display the author signature
    var sigDiv = document.createElement("div");
    var sigImg = document.createElement("img");
    sigImg.setAttribute("src", "images/signature.gif");
    sigDiv.appendChild(sigImg);
    contentDiv.appendChild(sigDiv);
    
    // Get the release date
    var relYear = dateElement.getAttribute("year");
    var relMonth = dateElement.getAttribute("month");
    var relDay = dateElement.getAttribute("day");

    // Display the release date
    var dateDiv = document.createElement("p");
    dateDiv.className = "poemText";
    var dateText = document.createTextNode(
            relMonth + "." + relDay + "." + relYear);
    dateDiv.appendChild(dateText);
    contentDiv.appendChild(dateDiv);
    
    // Display the copyright
    var copyDiv = document.createElement("p");
    copyDiv.className = "copyText";
    var copyText = document.createTextNode(
    		"Copyright \u00a9 " + relYear + ".\u00a0\u00a0All Rights Reserved.");
    copyDiv.appendChild(copyText);
    contentDiv.appendChild(copyDiv);
}

function addFacebookShare(contentDiv, url) {
	
	var aElement = document.createElement("a");
	aElement.setAttribute("name", "fb_share");
	aElement.setAttribute("type", "button_count");
	aElement.setAttribute("share_url", url);
	aElement.setAttribute("href", "http://www.facebook.com/sharer.php");
	contentDiv.appendChild(aElement);
	
	var scriptElement = document.createElement("script");
	scriptElement.setAttribute("src", "http://static.ak.fbcdn.net/connect.php/js/FB.Share");
	scriptElement.setAttribute("type", "text/javascript");
	contentDiv.appendChild(scriptElement);
}

