// Create a cookie with the specified name and value.
// The cookie expires at the end of the 20th century.
function SetCookie(sName, sValue, bAppend)
{
  if (bAppend) {
	var sC = GetCookie(sName)
	//sC=(sC!=null)?sC+',':' ';
	if (sC!=null) {
		var aExp = sC.split(",")
		for (var i=0; i<aExp.length; i++)
			//if the token is already there
			if (aExp[i] == sValue) {
				return;
			}
		sC = sC + ',' 
	} else
		sC=''
  } else
	sC = ''
//  document.cookie = sName + "=" + sC + escape(sValue) + " ; path=/"; 
//DBR--modified 9/25/2003 to properly set expiriation
  document.cookie = sName + "=" + sC + escape(sValue) + " ; path=/" + ";expires=Thu, 01-Jan-70 00:00:01 GMT; path=/";
}

// Retrieve the value of the cookie with the specified name.
function GetCookie(sCName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split(";");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sCName == trim(aCrumb[0])) {
	  if (aCrumb[1]+ '' != 'undefined')
		return unescape(aCrumb[1]);
    }
  }

  // a cookie with the requested name does not exist
  return null;
}
function removeToken(sName, sValue)
{
  var sC = GetCookie(sName)
  sC=(sC!=null)?sC:'';
  sC = sC.replace(','+sValue, ''); sC = sC.replace(sValue+',', ''); sC = sC.replace(sValue, '');

  if (sC.length==0) {
	document.cookie = sName + "=" + ";expires=Thu, 01-Jan-70 00:00:01 GMT; path=/"
  }
  else
	document.cookie = sName + "=" + sC + " ; path=/";
}

// Retrieve the value of the cookie with the specified name.
function GetCookie2(sKey, sCookie)
{
	var sPattern = ';*' + sKey + '=[^;]*;*'
	var re = new RegExp(sPattern,'ig');
	var str = document.cookie
	var aSearch = re.exec(str)
	if (aSearch != null && aSearch.length == 1)
	{
		var aCookie = (aSearch[0].replace(';', '')).split('&')
		for (var i=0; i < aCookie.length; i++)
		{
			// a name/value pair (a crumb) is separated by an equal sign
			var aCrumb = aCookie[i].split("=");
			if (sCookie.toLowerCase() == aCrumb[0].toLowerCase()) {
				return unescape(aCrumb[1]);
			}
		}
	}
	return null;
}

function AppendCookie (name, value) {
        var argv = AppendCookie.arguments;
        var argc = AppendCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires)) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}


var arAccounts = new Array();
var arRecordNos = new Array();

function setLeftNavHeight() {
  var leftNavHeight;
  leftNavHeight=top.document.body.clientHeight-headerHeight-25;
  if (leftNavHeight < 50){
     leftNavHeight=50}; 
  document.all['leftNavCol'].height=leftNavHeight;
}  
function defOnOpen(s) {
  setLeftNavHeight();
}


// Validate form for required fields

function CheckRequiredFields() {
var errormessage = new String();

// Check fields
if(WithoutContent(document.form1.accountNo.value))
	{ errormessage += "\n\nPlease enter your account number."; }
if(WithoutContent(document.form1.origPassword.value))
	{ errormessage += "\n\nPlease enter the initial password you were given."; }
if(WithoutContent(document.form1.UserName.value))
	{ errormessage += "\n\nPlease enter the username you wish to use."; }
if(WithoutContent(document.form1.EMail.value))
	{ errormessage += "\n\nPlease enter your E-Mail address. If you do not have an E-Mail address, enter the word 'none'. However, you will be unable to use the password retrieval system with no valid address."; }
if(WithoutContent(document.form1.FirstName.value))
	{ errormessage += "\n\nPlease enter your First Name."; }
if(WithoutContent(document.form1.LastName.value))
	{ errormessage += "\n\nPlease enter your Last Name."; }
if(WithoutContent(document.form1.NewPassword.value))
	{ errormessage += "\n\nPlease enter the password you wish to use."; }
if(WithoutContent(document.form1.NewPasswordConfirm.value))
	{ errormessage += "\n\nPlease confirm the password you wish to use."; }


if(errormessage.length > 2) {
	alert('Missing Required Information:' + errormessage);
	return false;
	}
return true;
} // end of function CheckRequiredFields()


function WithoutContent(ss) {
if(ss.length > 0) { return false; }
return true;
}

