// File: funcs.js
// Paul Henderson, April, 2006
//
//********************************************************************************************************
//functions

function msgverify()	//confirms that required data fields are filled in prior to further processing
{
	
	if ( message() )
	 	return true;
	else
		return false;
}

function message()
{
	var str = document.comment.message.value;
	var strlen = str.length;
	if (strlen == 0) {alert("Your comments have not been entered."); return false;}
	if (blank_check(str, strlen) == false)
	{
		alert("Your comments have not been entered.");
		return false;
	}
	else
		return true;
}

function logonverify()	//confirms that required data fields are filled in prior to further processing
{
	
	if ( userid() && password() )
	 	return true;
	else
		return false;
}

function userid()
{
	var str = document.login.userid.value;
	var strlen = str.length;
	if (strlen == 0) {alert("A userid has not been entered."); return false;}
	if (blank_check(str, strlen) == false)
	{
		alert("A userid has not been entered.");
		return false;
	}
	else
		return true;
}

function password()
{
	var str = document.login.password.value;
	var strlen = str.length;
	if (strlen == 0) {alert("A password has not been entered."); return false;}
	if (blank_check(str, strlen) == false)
	{
		alert("A password has not been entered.");
		return false;
	}
	else
		return true;
}

//********************************************************************************************************
//functions for admin/login.asp form data fields verification

function verify()	//confirms that required data fields are filled in prior to further processing
{
	
	if ( tenant() && location() && activity() && description())
	 	return true;
	else
		return false;
}

function tenant()
{
	var str = document.fmticket.tenant.value;
	if (str == "#")
	{
		alert("A tenant has not been selected.");
		return false;
	}
	else
		return true;
}

function location()
{
	var str = document.fmticket.location.value;
	var strlen = str.length;
	if (strlen == 0) {alert("A location has not been entered."); return false;}
	if (blank_check(str, strlen) == false)
	{
		alert("A location has not been entered.");
		return false;
	}
	else
		return true;
}

function activity()
{
	var str = document.fmticket.activity.value;
	if (str == "#")
	{
		alert("An activity has not been selected.");
		return false;
	}
	else
		return true;
}

function description()
{
	var str = document.fmticket.description.value;
	var strlen = str.length;
	if (strlen == 0) {alert("A description of the work request has not been entered."); return false;}
	if (blank_check(str, strlen) == false)
	{
		alert("A description of the work request has not been entered.");
		return false;
	}
	else
		return true;
}

//********************************************************************************************************
//general processing functions used by many functions / pages within this application

function blank_check(str, strlen)
{  var i=0, flag=0;
   var str, strlen;
   var posvalue=" ";

   for (i=0; i<strlen; i++)
   {  posvalue = str.substr(i,1);
      if (posvalue != ' ') flag=1;
   }

   if (flag == 1)
      return true;
   else
      return false;
}