/******************************************************************************
 PURPOSE: Determines if the argument is an email address.
 RETURNS: True if the argument is an email address; false otherwise.
 AUTHOR:  John Berberich
 HISTORY:
 
 DATE        WHO  NOTES
 ----------  ---  ------------------------------------------------------------
 08/01/2006  JAB  Initial version
******************************************************************************/
function isEmailAddress(email)
{
  // Matches:    "e@ee.com", "eee@e-e.com", "eee@ee.eee.museum"
  // Nonmatches: ".@eee.com", "eee@e-.com", "eee@ee.eee.eeeeeeeeee"
  var reEmail = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
  return reEmail.test(email);
}  // isEmailAddress(email)


/******************************************************************************
 PURPOSE: Determines if the argument is a phone number.
 RETURNS: True if the argument is a phone number; false otherwise.
 AUTHOR:  John Berberich
 HISTORY:
 
 DATE        WHO  NOTES
 ----------  ---  ------------------------------------------------------------
 08/01/2006  JAB  Initial version
******************************************************************************/
function isPhoneNumber(phone)
{
  // Matches:    "5305551212", "(530) 555-1212", "530-555-1212"
  // Nonmatches: "0010011212", "1991991212", "123) not-good"
  var rePhoneNo = /^(?:\([2-9]\d{2}\)\ ?|[2-9]\d{2}(?:\-?|\ ?))[2-9]\d{2}[- ]?\d{4}$/;
  return rePhoneNo.test(phone);
}  // isPhoneNumber(phone)


/******************************************************************************
 PURPOSE: 
 RETURNS: 
 AUTHOR:  John Berberich
 HISTORY:
 
 DATE        WHO  NOTES
 ----------  ---  ------------------------------------------------------------
 10/24/2006  JAB  Initial version (adapted from vpdclient.vbs)
******************************************************************************/
function doSpanRotationAll()
{
	var groups;
	
	groups = document.getElementsByTagName("div");
	//groups = document.getElementsByName("span-rotate");
	if(groups != null)
	{
		var i;
		for(i = 0; i < groups.length; i++)
		{
			if(groups[i].name = "span-rotate")
			{
				doSpanRotation(groups[i]);
			}
		}
	}
}  // doSpanRotationAll()


/******************************************************************************
 PURPOSE: 
 RETURNS: 
 AUTHOR:  John Berberich
 HISTORY:
 
 DATE        WHO  NOTES
 ----------  ---  ------------------------------------------------------------
 10/24/2006  JAB  Initial version (adapted from vpdclient.vbs)
******************************************************************************/
function doSpanRotation(group)
{
	var iNextIndex = 0;
	var spans;
	var i;
	
	spans = group.getElementsByTagName("span");
	
	// This function is pointless if we don't have at least two elements
	//Since having only 1 causes reference issues, just bail out
	if(spans.length < 2) return;
	
	// Find the next index to display.
	for(i = 0; i < spans.length; i++)
	{
		if(spans[i].style.display == "")
		{
			if(i == spans.length - 1)
			{
				iNextIndex = 0;
			}
			else
			{
				iNextIndex = i + 1;
			}
			break;
		}
	}
	
	// Set the display property.
	for(i = 0; i < spans.length; i++)
	{
		if(i == iNextIndex)
		{
			spans[i].style.display="";
		}
		else
		{
			spans[i].style.display="none";
		}
	}
}