/*
 * General functions.
 */
String.prototype.trim = function() 
{
	a = this.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
};

/*
 * Primary menu functions.
 */
function PrimaryMenuDisplay(id, action)
{
	if (document.getElementById(id) != null)
	{
		// Check if the menu item is selected. If so, do not change the display.
		if (document.getElementById(id).className == "selected") {
			return;
		}
		// Change the menu state according to the action specified.
		if (action == "hover") {
			document.getElementById(id).src = "images/primary_menu_" + id + "_hover.png";
		} else {
			document.getElementById(id).src = "images/primary_menu_" + id + ".png";
		}
	}
}

/*
 * Content functions.
 */
function ChangeButtonImage(imgObj, action)
{
	if (imgObj != null)
	{
		var fileExt = imgObj.src.substring(imgObj.src.length - 3);
		// Change the menu state according to the action specified.
		if (action == "hover") {
			imgObj.src = "images/" + imgObj.id + "_hover." + fileExt;
		} else {
			imgObj.src = "images/" + imgObj.id + "." + fileExt;
		}
	}
}

function EmailPage()
{
	// Get the page title and URL. These will be passed as querystring params to email_page.jsp
	var pageTitle = "";
	var pageUrl = window.location.href;
	
	if(document.all) {
		pageTitle = document.getElementsByTagName("h1")[0].innerText;
	} else {
		pageTitle = document.getElementsByTagName("h1")[0].textContent;
	}
	pageTitle = pageTitle.replace(/\u2019/g, "'");

	var newwindow = window.open("email_page.jsp?title=" + escape(pageTitle) + "&url=" + escape(pageUrl),'Email_this_page_to_a_friend','height=300,width=650');
 	if (window.focus) {
 		newwindow.focus();
 	}
}