/*
	CTMMA, Common JavaScript Functions	
	
	Description:
		Contains various JavaScript functions for the site.
	
	Change Log:
		2007-01-10 Created this file.
		2008-01-29 Added function to print mailtos.
		2008-04-17 Added separate show/hide calls.
		2008-05-14 Added ability to import pictures.
*/

// Precondition: Takes in full and short names
// Postcondition: Prints the mailto link with hidden address
function printMail(link, email, domain) {
	document.write("<a href=mailto:" + email + "@" + domain + ">" + link + "<" + "/a>");
}

// Precondition: Takes in the ID of an input box
// Postcondition: Adds image HTML to the beginning of the input text
function addPhoto(name) {
	url = prompt("Enter the address of the picture you would like to add.", "http://");
	if (url != null) {
		alt = prompt("Enter a description (optional).");
		message = document.getElementById(name).value;
		document.getElementById(name).value = "<img src=\"" + url + "\" alt=\"" + alt + "\" />\n" + message;
	}
}

// Precondition: Takes in the ID of an input box
// Postcondition: Adds link HTML to the end of the input text
function addLink(name) {
	url = prompt("Enter the address of the website you wish to link.", "http://");
	if (url != null) {
		title = prompt("Enter a description (optional).");
		if ((title == null) || (title == undefined) || (title == "")) title = url;
		document.getElementById(name).value += "<a href=\"" + url + "\">" + title + "</a>";
	}
}