
//
// form-related functions //
//

// isValidEmailAddress - returns true if valid email address //
function isValidEmailAddress(theEmailAddress) {
  var thePattern = /^\w+((-\w+)|(\.\w+)|(\'\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
  return thePattern.test(theEmailAddress);
  }

// isValidPassword - returns true if valid password //
function isValidPassword(thePassword) {
  var thePattern = /^[A-Za-z0-9]+$/;
  return (thePattern.test(thePassword) && (thePassword.length >= 4) && (thePassword.length <= 8));
  }
  
// doReadCookieValue - extracts cookie value for supplied name //
function doReadCookieValue(theCookieName) {
  if (document.cookie != null) {
    var theCookieString = document.cookie;
    var thePos = theCookieString.indexOf(theCookieName);
    if (thePos != -1) {
      var theStart = thePos + theCookieName.length + 1;
      var theEnd = theCookieString.indexOf(";",theStart);
      if (theEnd == -1) theEnd = theCookieString.length;
      var theValue = theCookieString.substring(theStart,theEnd);
      return unescape(theValue);
      }
    else {
      return "";
      }
    }
  else {
    return "";
    }
	}

// doWriteCookieValue - writes cookie for supplied name with supplied value //
function doWriteCookieValue(theCookieName,theCookieValue) {
  document.cookies = theCookieName + "=" + escape(theCookieValue);
	}
	
//
//
//
