function isBlank( s)
{
	for ( var i=0; i < s.length; i++)
		{
		var c= s.charAt(i);
		if ((c!= ' ') && (c != '\n') && (c != '\t'))
			{
	 		return false;
			}
		}
	return true;
}

function verify(f)
{
   var msg;
	var empty_fields="";
	var errors="";
	var mailer;

	for ( var i=0; i < f.length; i++)
		{
		var e = f.elements[ i];
		if ((( e.type == "text") || ( e.type == "password") || ( e.type == "textarea")) && !e.optional)
			{
			if ( (e.value == null) || (e.value == "") || (isBlank( e.value)))
				{
            
				empty_fields +="\n    "+ e.name;
				continue;
				}
			if ( e.name == "email")
				{
				mailer = e.value;
				if (	mailer.length < 5 || mailer.indexOf('@') == -1 || mailer.indexOf(' ') != -1)
					{
					empty_fields ="\n    "+ e.name + " empty or contains invalid characters";
					continue;
					}
				}
			if ( e.numeric || (e.min != null) || ( e.max != null))
				{
				var v = parseFloat( e.value);
				if (  isNaN(v)
			     	|| ((e.min != null) && ( v < e.min))
				  	|| ((e.max != null) && ( v > e.max))
					)
					{
					errors += "- the field " + e.name + " must be a number";
					if ( e.min != null)
				   	errors += " that is greater than " + e.min;
					if ( e.max != null && e.min != null)
				   	errors += " and less than " + e.max;
					else if ( e.max != null)
				   	errors += " that less than " + e.max;
					}
				}
			}
		}
	if ( !empty_fields && !errors)
	   return true;
	msg  = "_____________________________________________________________\n";
	msg += "The form was not submitted because of the following error(s).\n";
	msg += "Please correct these error(s) and re-submit.\n";
	msg += "_____________________________________________________________\n";
	if ( empty_fields)
		{
		msg += " - The following required field(s) are empty:" + empty_fields + "\n";
		if ( errors)
		   msg += "\n";
		}
	msg += errors;
	alert ( msg);
	return false;
}

function Confirm(f)
{
	if ( verify(f))
   	{

		//msg="\nYou are about to Generate a passcode\n\n"+
      // "Continue?\n\n";
   	//return confirm(msg);
      return true;
      }
   else
      return false;
}

function makedeletelist(f,n)
{
  	var list;
   var first;
   var mytmp
   var mymsg;

   first = 1;

   mymsg = "";
   alert ("n="+ n);
   return 0;
  	for ( k=1; k <= n; k++)
		{
      v = eval ("document.form1.CB"+k+".checked");
      if ( v)
         {
         op = eval("document.form1.CB"+k+".value");
         if ( first)
            {
            list = op;
            mytmp  = op;
            first = 0;
            }
         else
         	{
         	list = list +"="+op;
            mytmp= mytmp+"="+op;
            }
         }
      }
	document.form1.userlist.value = list;
   if ( list.length)
   	{

      mymsg ="Are you sure you want to delete the user(s) below?:"+ mytmp;
      alert (mymsg);
      alert (mytmp);
      /*
      mymsg += "\n"+ tmp;
      mymsg += "\nClick Yes to complete deletion. or No to cancel\n";
      alert (mymsg);

      if ( confirm(mymsg)
      	return true;
      else
      */
         return false;
      }
     else
     	  return false;
}


function makeslectedlist(f,n,Msg)
{
  	var list;
   var first;
   var mytmp
   var mymsg;

   first = 1;
	gotsome=0;
   mymsg = "";
  
  	for ( k=0; k < n; k++)
		{
      v = eval ("document.form1.CB"+k+".checked");
      if ( v)
         {
			op = eval("document.form1.CB"+k+".value");
         if ( first)
            {
            list = op;
            mytmp  = op;
            first = 0;
            }
         else
         	{
         	list = list +","+op;
            mytmp= mytmp+"\n"+op;
            }
			gotsome = 1;
         }
      }
	document.form1.selectedlist.value = list;
   if ( /*list.length*/gotsome)
   	{
		form = eval("document.form1");
      mymsg ="Are you sure you want to "+Msg+" the list below?:"+ mytmp;
      
		if ( confirm(mymsg))
			form.submit();
			//return true;
      else
			return false;
      }
     else
     	  return false;
}

