﻿// This script grabs the URL of a photo gallery or audio slideshow, and writes it to the page for the user to copy.
// Author: Patrick Beeson
// Last modified: 1/23/07

function displayUrl() {
	// Checking to make sure the browser can access the DOM
	if (!document.getElementById) return false;
	if (!document.createElement) return false;
	if (!document.createTextNode) return false;
	// Create the <p> and <a> elements, and the text node
	var featureurl = document.createElement("p");
	featureurl.setAttribute("id","geturl");
	var urltext = document.createTextNode("Get the URL for this feature");
	var urllink = document.createElement("a");
	urllink.setAttribute("href","#");
	urllink.setAttribute("title","URL for this feature");
	// Append the child nodes
	urllink.appendChild(urltext);
	featureurl.appendChild(urllink);
	// This checks to see whether its a photo gallery or audio slideshow and inserts the created elements
	var feature = document.getElementById("footer");
	if (document.getElementById("right")) {
		var copyright = document.getElementById("right");
	} else {
		var copyright = document.getElementById("copyright");
	}
	feature.insertBefore(featureurl,copyright)
	// Reveals the <div> with the URL when the link is clicked
	var showurl = document.getElementById("url");
	urllink.onclick = function() {
		showurl.style.display = "block";
	}
}

function getUrl() {
	// Checking to make sure the browser can access the DOM
	if (!document.getElementById) return false;
	if (!document.createElement) return false;
	// Create the <div> element and insert the window URL via the innerHTML (I couldn't get this to work using the W3C methods
	var urlpopup = document.createElement("div");
	urlpopup.setAttribute("id","url");
	urlpopup.innerHTML = "<code>" + location.href + "</code><img src=\"/images/icons/mini/action_stop.gif\" width=\"16\" height=\"16\" alt=\"\" id=\"close\" />";
	// This checks to see whether its a photo gallery or audio slideshow and inserts the created elements
	var feature = document.getElementById("footer");
	if (document.getElementById("right")) {
		var copyright = document.getElementById("right");
	} else {
		var copyright = document.getElementById("copyright");

	}
	feature.insertBefore(urlpopup,copyright);
	urlpopup.style.display = "none";
	// Hides the <div> with the URL when the icon image is clicked
	var closelink = document.getElementById("close");
	closelink.onclick = function() {
		urlpopup.style.display = "none";
	}
}