<!--
//
/**
 * utilityScripts.js 19MAR2002 Version 1.0
 * K. Fortenberry, March 2002
 * Copyright (c) 2002 Kforce, Inc.
 * 
 * This JavaScript source file contains a collection
 * of general purpose utility scripts.
 */
 
// -----------------------------------------------------------------

/**
 * This function removes leading and trailing whitespace
 * characters from an argument string.
 *
 * param str - input string
 * returns the input string with all leading and trailing whitespace removed
 */
function trim(str) 
{
	str = this != window? this : str;
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

// -----------------------------------------------------------------

/**
 * $Author: AWalker$
 * $Date: JUL01-2002$
 *
 * This function will remove the ability for the user to submit a page 
 * more than one time.
 *
 * This function call should be placed in the setActions function in 
 * each page of WCM Automation and wherever applicable (onSubmit etc...)
 * in any other applications.
 * This function has been tested in IE 5.5 and IE 6.x browsers.
 *
 * $Modifications: $
 */
// var submitcount = 0;
 function trimSubmit()
 {
 	errmsg = "You have already submitted a request for that action.\n";
	errmsg += "Some actions can take longer than others, please be patient while the system performs the requested task.\n\n";
	errmsg += "\tThank You,\n";
	errmsg += "\tWeb Services Group";
 	if( ! (document.form1.submitcount.value == "0") )  { alert ( errmsg ); return false; }   
	else { document.form1.submitcount.value = "1"; return true; }
 } // end trimSubmit()


 function noDblClick()
 {
 	errmsg = "The 'double-click' has been disabled in this application to prevent duplicate submissions.\n";
	errmsg += "Please try your action again using a single-click.\n\n";
	errmsg += "\tThank You,\n";
	errmsg += "\tWeb Services Group";
	var submitCountFld = document.getElementById("submitCount");
	if (submitCountFld)
	{
		if ( submitCountFld.value == "0" ) 
		{ 
			alert ( errmsg ); 
			return false; 
		}
	}
	else
	{
		alert("ERROR: submitcount field not found");
	}
 }
 
 document.ondblclick = noDblClick;
 
// This function is used to hide/show a div. The application of this function can be seen in the applyOnlineForm.jsp page when the errorbean is drawn.
//Added August 22, 2005 amoore 
function toggleDivDisplay(obj)
{
	var el = document.getElementById(obj);
	if(el.style.display != "block")
	{
		el.style.display = "block";
	}
	else
	{
		el.style.display = "none";
	}
}

function setDisplayMode(elementID, displayMode)
{
	// get reference to display element
	var displayElement = document.getElementById(elementID);
	// set display mode
	displayElement.style.display = displayMode;
}

//This function is currently being used to automatically tab in a phone number fields (if seperated into 3 text boxes). You can see an example of this in the 
//applyOnlineForm.jsp
//Added August 22, 2005 amoore 
var phone_field_length=0;
function TabNext(obj,event,len,next_field)
{

	if (event == "down")
    {
        phone_field_length=obj.value.length;
	}
	else if (event == "up")
	{
		if (obj.value.length != phone_field_length)
		{
			phone_field_length=obj.value.length;
			if (phone_field_length == len)
			{
				next_field.focus();
			}
		}
	}
}
//
-->


