{     
 
 var errorMsg = new Array();
 var blank = "";
	 
	 
 // -- Localization
	// ------------------------------------------------------------
 var cky1 = "This web site requires the use of cookies.\n",
     cky2 = "Certain features may not work properly and in some\n",
     cky3 = "cases you will not be allowed to continue.\n\n",
	 cky4 = "Please make sure that the use of cookies has been\n",
	 cky5 = "enabled through your browser\'s settings.";
}












// -----------------------------------------------------------------------------
// This function
function executeMe()
{
 for(var x=0;x<onExecute.length;x++)
 {
  eval(onExecute[x]);
 } 
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function tracks the list of errors that occur
// during validation
function addError(which)
{
 errorMsg[errorMsg.length] = which; 
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function replaces the function statusMe(...) which has been depricated
// because it seems to be causing javascript errors in Netscape 7.x.
function marquee(what)
{
 this.window.status = (typeof(what)== "undefined")?"" : what;
 // Returning true displays text in the status bar.
 // Returning false prevents text from being displayed.
 if (typeof(displayMarquee) != "undefined")
  return displayMarquee;
  
 else
  return false;
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function displays the list of errors that occur
// during validation
function displayErrors()
{
 // Do the grammar thing
 if(errorMsg.length == 1)
 { 
  var pError = "error has",
      pNeed  = "needs";
 }
  
 else
 { 
  var pError = "errors have",
      pNeed  = "need";
 }
 
 
 if(errorMsg.length >400)
 {
  var msg1 = "Some of the required fields are either missing or are incorrect.\n",
      msg2 = "Please review the form and make the proper corrections.";
      
  alert(msg1+msg2)
 }
 
 else
 {
  var msg1 = "The following "+pError+" occurred and "+pNeed+"\n",
      msg2 = "to be corrected before continuing:\n\n",
	  msg3 = blank;
	  
  for(var i=0; i<errorMsg.length; i++)
  {
   msg3 += '  - '+errorMsg[i];
  }
  
  alert(msg1+msg2+msg3);
 }
 
 errorMsg.length = 0;
 errorMsg = new Array();
}
// -----------------------------------------------------------------------------




// -----------------------------------------------------------------------------
// This function validates text fields to see that they
// are not blank, or contain numeric values
function validateText(that,allowBlank)
{
 var blankAllowed = (typeof(allowBlank) == "undefined")?false :allowBlank;



 if(stripWS(that.value) == blank && !blankAllowed)
  return false;
 
 else
  return true;
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function validates zipcodes to verify that they
// are sized correctly and are valid numbers
function validateZipCode(zipcode)
{
 var thisZipCode = stripWS(zipcode.value);
 
 return (thisZipCode.length == 5 && !isNaN(thisZipCode,10));
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function checks to see that the length of a password
// is at least six characters if not blank
function validatePassword(password,minlength)
{
 var thisLength = (typeof(minlength)!="undefined")?minlength :6;
 var thisValue  = stripWS(password.value);
 
 return (password.value != blank && password.value.length < thisLength)
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function checks phone numbers by verifying that the argument passed
// is a number and that the length of the number is the digits.
function validatePhone(number)
{
 var thisNumber = stripWS(number);

 return (!isNaN(thisNumber,10) && thisNumber.length == 10);
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function checks phone numbers by verifying that the
// argument passed is a number and that the length of the
// number is the digits.
function validateEmail(address)
{
 return (stripWS(address) != blank)
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function validates that the argument passed is not
// blank and is a number.
function validateNumber(number,allowBlank,minNumber,maxNumber)
{ 
 if(typeof(number) != "undefined")
 {
  // First, check to see that the number is not blank
  if(number.length > 0)
  {
   // Check to see if the value is a valid number
   if(isNaN(number))
    return "isNaN";
  
   else if (typeof(minNumber) != "undefined" && number < minNumber)
    return "less than";
  
   else if (typeof(maxNumber) != "undefined" && number > maxNumber)
    return "greater than";
    
   else
    return "ok";
  }
 
  else if(typeof(allowBlank) != "undefined" && !allowBlank)
    return "blank";
  
  else
    return "ok";
 }
 
 else
 {
  var msg1 = "runtime error ~fUtility.mgr:validateNumber(...)\n\n";
      
  alert(msg1);
 }
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function pads numbers to the hundredth decimal place
function DollarFormat(number)
{
 var myNumber = number;
 
 // Isolate the decimal value
 tArg1 = myNumber;
 tArg2 = parseInt(myNumber);
 tArg3 = tArg1 - tArg2;

 if(tArg3 == 0)
 { myNumber += ".00"; }
	
 else
 {
  tArg1 = (Math.round(tArg3 * 10)*100)/100;
  tArg2 = parseInt(tArg1);
  tArg3 = tArg1 - tArg2;
  
  if(tArg3 == 0)
  { myNumber += "0"; }
 }
 
 // return myNumber;
 return Math.round(number*100)/100;
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function is used to resolve case sensitivity conflicts when ColdFusion
// dynamically writes field names. (They are written in uppercase).
function setField(thatForm,fieldName,fieldValue)
{
 with(thatForm)
 {
  for(var x=0;x<elements.length;x++)
  {
   if(elements[x].name.toLowerCase() == fieldName.toLowerCase())
   {
    elements[x].value = fieldValue;
    break;
   }
  }
 }
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function is used to resolve case sensitivity conflicts when ColdFusion
// dynamically writes field names. (They are written in uppercase).
function getField(thatForm,fieldName)
{
 var myValue = "undefined";
 
 with(thatForm)
 {
  for(var x=0;x<elements.length;x++)
  {
   if(elements[x].name.toLowerCase() == fieldName.toLowerCase())
   {
    myValue = elements[x].value;
    break;
   }
  }
 }
 
 return myValue;
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function is used for debugging and alerts the
// current value of a specified field.
function alertField(thatForm,fieldName)
{
 var myValue = "undefined";

 with(thatForm)
 { 
  for(var x=0;x<elements.length;x++)
  {
   if(elements[x].name.toLowerCase() == fieldName.toLowerCase())
   {
    myValue = elements[x].value;
    break;
   }
  }
 }
 
 alert(myValue);
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function removes all white space from a given string
function stripWS(thatString)
{
 return thatString.replace(/ /g,'');
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function
function setForm()
{
 if(window != top)
 {
  if(typeof(parent.content.document.cForm) != "undefined")
   return parent.content.document.cForm;
  
  else
   return "undefined";
 }
 
 else
 {
  return this.document.cForm;
 }
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function
function checkCookies()
{
 // Look for the preferences cookie first
 myCookie = document.cookie.toLowerCase();

 if(myCookie.indexOf("preferences") > -1)
 { return true; }
 
 
 
 else
 // The cookie did not exist so try to write
 // a default cookie.
 {
  var pTheme = "theme=default,",
      pLanguage = "locale=en_US";
	  
  document.cookie = "PREFERENCES="+escape(pTheme+pLanguage);
  
  if(myCookie.indexOf("PREFERENCES") > -1)
  { return true; }
 
  else
  {
   alert(cky1+cky2+cky3+cky4+cky5)
   
   return false;
  }
 }
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function fixes the month/day fieldsin the registration page.
function fixMonth()
{
 var months = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
 
 with(this.document.cForm)
 {
  var ddIndex = tDay.selectedIndex,
      yyIndex = tYear.selectedIndex,
	  mmIndex = tMonth.selectedIndex;
 
  // Check for february leapyear
  if(mmIndex == 2 && yyIndex >0)
   months[1] = (isLeapYear(tYear.options[yyIndex].text))?29 :28;

 
  tDay.length = months[mmIndex-1] +1;
  tDay.options[0].text = "--";
  
  for(i=1; i<tDay.length; i++)
  {
   tDay.options[i].value = i;
   tDay.options[i].text = i;
  }
  
  tDay.selectedIndex = (ddIndex > tDay.length) ?tDay.length-1 : ddIndex;
 }
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function
function isLeapYear(whichYear)
{
 var benchMark = 1884;
 
 var myDate = new Date();
     myYear = myDate.getFullYear();
	 
 var isLeapYear = false;
 
 for(var i=benchMark;i<=myYear;i+=4)
 {
  if(whichYear == i)
  {
   isLeapYear = true;
   break;
  }
 }

 return isLeapYear;
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function switches the form action form http to https
function secureForm(thatForm,secureForm)
{
 
 var ok2secure = (typeof(secureForm) == "undefined") ?true : secureForm;
 
 var thisFormAction  = thatForm.action; 
 var alreadySecure   = thisFormAction.indexOf("https://");
 
 if(alreadySecure >= 0 && !ok2secure)
 {
  // unsecure the form
  thisFormAction = thisFormAction.replace(/https/,"http");
 }
 
 else if(alreadySecure < 0 && ok2secure)
 {
  // secure the form
  // thisFormAction = thisFormAction.replace(/http/,"https");
  thisFormAction = thisFormAction.replace(/http/,"http");
 }
 
 thatForm.action = thisFormAction;
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function
function isSecured(thatForm)
{
 var myAction = thatForm.action;
 
 var securedIndex = myAction.indexOf("https");
 
 if(securedIndex >= 0)
  return true;
  
 else
  return false;
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function
function rememberMe(thatForm,how)
{
 var thisMethod = (typeof(how) != "undefined")? how: "string";
 var thisValue;
 
 if(thisMethod == "string")
  var memoryString = "";
 else
  var memoryString = new Array();
 
 
 
 with(thatForm)
 {
  for(var i=0;i<elements.length;i++)
  {
   if(elements[i].type == "select-one")
    thisValue = elements[i].selectedIndex;
   	
   else if(elements[i].type == "text"     ||
           elements[i].type == "textarea" ||
		   elements[i].type == "file"     ||
		   elements[i].type == "password" ||
          (elements[i].type == "checkbox" && elements[i].checked) ||
          (elements[i].type == "radio" && elements[i].checked))
    thisValue = elements[i].value
	
   else thisValue = "hidden";
	
	
   if(thisMethod == "string")
	memoryString += thisValue
	
   else if(thisMethod == "structure")
	memoryString[elements[i].name] = thisValue;
	
   else 
	memoryString[memoryString.length] = thisValue;   
  } // end for(i)
 } // end with(form)
 

  return memoryString;
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function
function hasChanged(array1,array2)
{
 var hasChanged = false;
 
 for(var x=0;x<array2.length;x++)
 {
  if(array1[x] != array2[x])
  {
   hasChanged = true;
   break;
  }
 }

 return hasChanged;
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function
function compareObjects(obj1,obj2)
{
 var tempArray = new Array();
 
 for(var x=0;x<obj1.length;x++)
 {
  if(obj1[x].type == "select-one")
   thisValue = obj1[x].selectedIndex;
	  
  else if(obj1[x].type == "text"     ||
          obj1[x].type == "textarea" ||
		  obj1[x].type == "password" ||
         (obj1[x].type == "checkbox" && obj1[x].checked) ||
         (obj1[x].type == "radio"    && obj1[x].checked))
   thisValue = obj1[x].value;
	  
  else thisValue = "hidden";
	 
  
  
  if(thisValue != "hidden" && thisValue != obj2[x])
   tempArray[tempArray.length] = obj1[x].name;
 } // end for(x)
 
 return tempArray;
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function was found at http://www.webreference.com/js/tips/990928.html
function isEmail(str)
{
 // are regular expressions supported?
 var supported = 0;

 if (window.RegExp) 
 {
   var tempStr = "a";
   var tempReg = new RegExp(tempStr);
  
   if (tempReg.test(tempStr))
    supported = 1;
 }
 
 if (!supported) 
  return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
 var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
 var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}
// -----------------------------------------------------------------------------



// -----------------------------------------------------------------------------
// This function
function signUp(domain)
{
 var sURL = domain;
 
 if(navigator.appName == "Netscape")
 {
  var jHt = 410,
      jWd = 600;
	  
  var jTop  = ",screenx=100",
      jLeft = ",screeny=100";
 }
 
 if(navigator.appName == "Microsoft Internet Explorer")
 {
  var jHt = 430,
      jWd = 580;
	  
  var jTop  = ",top=100",
      jLeft = ",left=100";
 }
	
 sWin = window.open(sURL,
	                'SignUp',
					'height='+jHt+',width='+jWd	+',menubar,scrollbars,resizable,status' +jTop +jLeft);
}
// -----------------------------------------------------------------------------






function changeTask(thatTask,thatForm)
{
 with(thatForm)
 {
  taskrequest.value = thatTask;
  submit(); 
 }
}

function manageObject(thatForm,thatObj,thatValue,thatTask)
{
 ok2continue = true;
 
 var msg1 = '',
     msg2 = 'Are you sure you want to ' +thatTask.toLowerCase()+ ' this record?';

 if(thatTask.toLowerCase() == 'purge')
  msg1 = 'A purged record cannot be recovered from the database!\n';
 
 if(thatTask.toLowerCase() == 'delete' 
 || thatTask.toLowerCase() == 'purge')
 {
  ok2continue = confirm(msg1 +msg2);
 }
 
 if(ok2continue)
 {
  thatForm[thatObj].value = thatValue;
  changeTask(thatTask,thatForm);
 }
}

function changeDepartment(thatDepartment,thatForm)
{
 with(thatForm)
 {
  taskrequest.value = '';
  manager.value     = thatDepartment;
  submit()
 }
}

function changeManager(thatManager,thatForm)
{
 with(thatForm)
 {
  taskrequest.value = '';
  assistantManager.value = thatManager;
  submit();
 }
}

function checkboxToRadio(that)
{
 with(this.document.eForm)
 {
  for(i=0;i<elements.length;i++)
  {
   if(that.checked 
   && elements[i].name == that.name 
   && elements[i].value != that.value 
   && that.type == elements[i].type)
   {
    elements[i].checked = false;
   }   
  }
 }
}

function base64encode(input) {
	// alan fullmer
	var output = "";
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;
	var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

	do {
		chr1 = input.charCodeAt(i++);
		chr2 = input.charCodeAt(i++);
		chr3 = input.charCodeAt(i++);

		enc1 = chr1 >> 2;
		enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
		enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
		enc4 = chr3 & 63;

		if (isNaN(chr2)) {
			enc3 = enc4 = 64;
		} else if (isNaN(chr3)) {
			enc4 = 64;
		}

		output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2)
				+ keyStr.charAt(enc3) + keyStr.charAt(enc4);
	} while (i < input.length);

	return output;
}

function base64decode(input) {
	// alan fullmer
	var output = "";
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;
	var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

	// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
	input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	do {
		enc1 = keyStr.indexOf(input.charAt(i++));
		enc2 = keyStr.indexOf(input.charAt(i++));
		enc3 = keyStr.indexOf(input.charAt(i++));
		enc4 = keyStr.indexOf(input.charAt(i++));

		chr1 = (enc1 << 2) | (enc2 >> 4);
		chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
		chr3 = ((enc3 & 3) << 6) | enc4;

		output = output + String.fromCharCode(chr1);

		if (enc3 != 64) {
			output = output + String.fromCharCode(chr2);
		}
		if (enc4 != 64) {
			output = output + String.fromCharCode(chr3);
		}
	} while (i < input.length);

	return output;
}

  

