//////////////////////////////////////////////////////////////
// Common functions
// v1.00 (Budd Wright)
//
// Description:
//////////////////////////////////////////////////////////////
// Contains common page functions
//////////////////////////////////////////////////////////////
//
// Usage:
//////////////////////////////////////////////////////////////
// <script language="javascript" src="js/common.js"></script>
//////////////////////////////////////////////////////////////
//
// v1.00 Notes
// -----------
// Requires pageName variable to be set elsewhere
//
// Known Issues
// ------------
// 
//////////////////////////////////////////////////////////////

/* pageName variable */
var pageName = location.href.substring(0, location.href.lastIndexOf("/") + 1);
	pageName = location.href.substring(pageName.length, location.href.length + 1);
	pageName = pageName.substring(0, pageName.indexOf("?"));



/* Action function */
// Jumps to a specified action for a given user
function Action(userId, action)
{
	// Check for pageName variable
	if(pageName == null)
	{
		alert("The pageName variable must be set for this function to work.");
		return;
	}


	location.href = pageName + "?action=" + action + "&id=" + userId;
}


/* ConfirmDelete function */
// Forces a user to confirm a delete action
function ConfirmDelete(userId, action)
{
	// Confirm the delete
	if(confirm("Are you sure you want to delete this? This action cannot be reversed."))
	{
		Action(userId, action);
	}
}


/* Resize function */
// Resizes a subframe to fit its contents on load
function Resize(frameName)
{
	var frameReference = parent.document.getElementById(frameName);
	var frameHeight = document.body.scrollHeight;

	frameReference.style.height = frameHeight + "px";
}


/* GoToLink function */
// Jumps to a specified link url selected from a link list drop down box
function GoToLink(linkList)
{
	var url = linkList.options[linkList.selectedIndex].value;

	if(url != "")
		location.href = url;
}