/*****************************************************
*	Function validate()
*	This Function validates the login page form fields
*	Return:	Boolean True or False whether or not the form
*					is in a valid format
******************************************************/
function validate()
{
	var username = document.getElementById('UserName');
	var password = document.getElementById('AccountNum');
	var roomnum = document.getElementById('RoomNum');

	var isValid = true;

	enforceNumeric(roomnum);

	var usertext = document.getElementById('userReq');
	var passtext = document.getElementById('passReq');
	usertext.style.color = "black";
	passtext.style.color = "black";

	if (isEmpty(username))
	{
		isValid = false;
		usertext.style.color = "red";
	}
	
	if (isEmpty(password))
	{
		isValid = false;
		passtext.style.color = "red";
	}
	
	return isValid;
}

/*****************************************************
*	Function isEmpty()
*	This function checks to see if a form field is empty
*	Return:	Boolean True or False whether or not the form
*					field is empty
******************************************************/
function isEmpty(field)
{
	var isEmpty = field.value == "";
	
	return isEmpty;
}

/*****************************************************
*	Function enforceNumeric()
*	This function forces a field to only contain numbers
******************************************************/
function enforceNumeric(field)
{
	field.value = field.value.replace(/^0+|(\D)/gi,"");
}

function mask(d)
{
	if (document.LoginForm.MaskedPWD.checked == true)
	{
		window.location='loginprompt.cfm';
	}
	else
	{
		window.location='loginprompt.cfm?MaskedPWD=No';
	}
}

function breakFrame()
{
  if (top.location != document.location) 
  {
    top.location = document.location;
  }
}

function HideContent(d) 
{
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}

function ShowContent(d) 
{
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "block";
}

function ReverseContentDisplay(d) 
{
	if(d.length < 1) { return; }
	if(document.getElementById(d).style.display == "block") { document.getElementById(d).style.display = "none"; }
	else { document.getElementById(d).style.display = "block"; }
}

