<!--
//Adds another method to javascript string object. 
//Method executes strim() function declared below.
String.prototype.trim = strim; 
/************************************************************************
*STRIM																	
*************************************************************************
*Description:															
*      Extends the string object adding String.trim.  String.trim		
*	   removes spaces from beginning and end of the string.	  Call		
*	   by coding string_variable.trim()									
*Arguments:																
*		string to trim													
*Returns:																
*       trimmed string													
*																		
*Created/Modified:														
* User Name		Date		Description									
* STJOBE		1999		Original Version							
* STJOBE		10/17/2000	Comments Added								
*************************************************************************/
function strim() { 
	var v, ileft, iright;
	
	v = this; 
	
	ileft = 0;
	iright = v.length - 1; 
	
	
	while (v.charAt(ileft) == ' ') ileft++; 
	
	while ((v.charAt(iright) == ' ') && (iright > ileft)) iright--; 
	
	return v.substring(ileft,iright+1); 
} 



/************************************************************************
*trim												
*************************************************************************
*Description:															
*       Returns a copy of a string without trailing or leading spaces.			
*Arguments:																
*	    strStringVal - the string to be trimmed								
*Returns:																
*       Returns an trimmed string 	
*Dependencies:
*       ltrim and rtrim																							
*Created/Modified:														
* User Name		Date		Description									
* BBROWER       6/1/2001	Original Version - Changed to Use DCC Standards					
*************************************************************************/
function trim(strStringVal)
{
        return rtrim(ltrim(strStringVal));
}

/************************************************************************
*ltrim												
*************************************************************************
*Description:															
*       Returns a copy of a string without leading spaces.				
*Arguments:																
*	    strStringVal - the string to be trimmed								
*Returns:																
*       Returns an string with no leading spaces																								
*Created/Modified:														
* User Name		Date		Description									
* BBROWER       6/1/2001	Original Version - Changed to Use DCC Standards					
*************************************************************************/
function ltrim(strStringVal)       
 {
	     var whitespace = new String(" \t\n\r");

         var strTempS = strStringVal;

         if (whitespace.indexOf(strTempS.charAt(0)) != -1) {
             // We have a string with leading blank(s)...

             var intGSFJ=0, intGSFI = strTempS.length;

             // Iterate from the far left of string until we don't have any more whitespace...
             while (intGSFJ < intGSFI && whitespace.indexOf(strTempS.charAt(intGSFJ)) != -1)
                 intGSFJ++;


             // Get the substring from the first non-whitespace
             // character to the end of the string...
             strTempS = strTempS.substring(intGSFJ, intGSFI);
         }

         return strTempS;
 }
 
/************************************************************************
*rtrim												
*************************************************************************
*Description:															
*       Returns a copy of a string without trailing spaces.			
*Arguments:																
*	    strStringVal - the string to be trimmed								
*Returns:																
*       Returns an string with no trailing spaces																								
*Created/Modified:														
* User Name		Date		Description									
* BBROWER       6/1/2001	Original Version - Changed to Use DCC Standards					
*************************************************************************/
function rtrim(strStringVal)
{
        // We don't want to trip JUST spaces, but also tabs,
        // line feeds, etc.  Add anything else you want to
        // "trim" here in Whitespace
        var whitespace = new String(" \t\n\r");

        var strTempS = strStringVal;

        if (whitespace.indexOf(strTempS.charAt(strTempS.length-1)) != -1) {
            // We have a string with trailing blank(s)...

            var intGSFI = strTempS.length - 1;       // Get length of string

            // Iterate from the far right of string until we
            // don't have any more whitespace...
            while (intGSFI >= 0 && whitespace.indexOf(strTempS.charAt(intGSFI)) != -1)
                intGSFI--;


            // Get the substring from the front of the string to
            // where the last non-whitespace character is...
            strTempS = strTempS.substring(0, intGSFI+1);
        }

        return strTempS;
}

/*****************************************************************************
Name:
    changeContent(ccElement,ccStrText) 
Description:
    Changes the content of a div or span for both IE and Netscape
    what - name of the span or div
    text - text that you want to use to replace the contents of the span/div
Create/Modify Information:
     Date        Developer      Description
     ----------  ----------     -----------
     2/5/2001    Brenda Brower  Original Version - Changed to Use DCC Standards    
     1/2/2002    Brenda Brower  Changed so that if it is not document.layers it defaults to using innerHTML.
***************************************************************************/
function changeContent(ccElement,ccStrText) 
{
	if (document.layers) 
    {
        ccElement.document.open();
        ccElement.document.write(ccStrText);
        ccElement.document.close();
    }
    else 
    {
		ccElement.innerHTML = ccStrText;
    }
}

/*****************************************************************************
Name:
    changeContent1(ccElement,ccStrText) 
Description:
    Changes the content of a div or span (works in IE and Mozilla)
    what - the div or span
				if (document.all) then pass document.all.DIVNAME
				if (document.layers) then pass document.layers.DIVNAME
				otherwise, pass document.getElementById('DIVNAME')
    text - text that you want to use to replace the contents of the span/div
Create/Modify Information:
     Date        Developer      Description
     ----------  ----------     -----------
     9/13/2005    Brenda Brower  Original Version - Changed to Use DCC Standards    
***************************************************************************/
function changeContent1(ccElement,ccStrText) 
{
	ccElement.innerHTML = ccStrText;    
}


/************************************************************************
*len												
*************************************************************************
*Description:															
*       Returns the number of characters in a string.			
*Arguments:																
*	    strStringVal - the string whose length we are interested in					
*Returns:																
*       Returns the length of the string																								
*Created/Modified:														
* User Name		Date		Description									
* BBROWER       6/1/2001	Original Version - Changed to Use DCC Standards					
*************************************************************************/
function len(strStringVal)
{  
	return String(strStringVal).length;  
}

/************************************************************************
*left												
*************************************************************************
*Description:															
*       Used to get a specified number of characters from the left side of a string	
*Arguments:																
*	    strStringVal - the string we are LEFTing
*       intGSFNum - the number of characters we want to return			
*Returns:																
*       Returns a specified number of characters from the left side of a string																								
*Created/Modified:														
* User Name		Date		Description									
* BBROWER       6/1/2001	Original Version - Changed to Use DCC Standards					
*************************************************************************/
function left(strStringVal, intGSFNum)
{
        if (intGSFNum <= 0)     // Invalid bound, return blank string
                return "";
        else if (intGSFNum > String(strStringVal).length)   // Invalid bound, return
                return strStringVal;                // entire string
        else // Valid bound, return appropriate substring
                return String(strStringVal).substring(0,intGSFNum);
}

/************************************************************************
*right												
*************************************************************************
*Description:															
*       Used to get a specified number of characters from the right side of a string	
*Arguments:																
*	    strStringVal - the string we are RIGHTing	
*       n - the number of characters we want to return			
*Returns:																
*       Returns a specified number of characters from the right side of a string																								
*Created/Modified:														
* User Name		Date		Description									
* BBROWER       6/1/2001	Original Version - Changed to Use DCC Standards					
*************************************************************************/
function right(strStringVal, intGSFNum)       
{
        if (intGSFNum <= 0)     // Invalid bound, return blank string
           return "";
        else if (intGSFNum > String(strStringVal).length)   // Invalid bound, return
           return strStringVal;                     // entire string
        else 
        { // Valid bound, return appropriate substring
           var iLen = String(strStringVal).length;
           return String(strStringVal).substring(iLen, iLen - intGSFNum);
        }
}

/************************************************************************
*mid												
*************************************************************************
*Description:															
*       Returns a specified number of characters from a string	
*Arguments:																
*	    strStringVal - the string we are MIDing	
*       start - our string's starting position (0 based!!)
*       len - how many characters from start we want to get		
*Returns:																
*       The substring from start to start+len																							
*Created/Modified:														
* User Name		Date		Description									
* BBROWER       6/1/2001	Original Version - Changed to Use DCC Standards					
*************************************************************************/
function mid(strStringVal, start, len)
{
        // Make sure start and len are within proper bounds
        if (start < 0 || len < 0) return "";

        var iEnd, iLen = String(strStringVal).length;
        if (start + len > iLen)
                iEnd = iLen;
        else
                iEnd = start + len;

        return String(strStringVal).substring(start,iEnd);
}

/************************************************************************
*instr												
*************************************************************************
*Description:															
*       Used to find if the specified string can be found within another string
*Arguments:																
*	    strSearch - the string we are searching	
*       strSearchFor - the string that you are searching for
*Returns:																
*       Returns the first location a substring (SearchForStr) was found in the string str.  
*       (If the character is not found, -1 is returned.)		
*Dependencies:
*       mid																				
*Created/Modified:														
* User Name		Date		Description									
* BBROWER       6/1/2001	Original Version - Changed to use DCC standards and allow searching
*                           a string rather than just one character.					
*************************************************************************/
function instr(strSearch, strSearchFor)
{
	var intGSFI;
	
	for (intGSFI=0; intGSFI < strSearch.length; intGSFI++)
	{
	    if (strSearchFor == mid(strSearch, intGSFI, strSearchFor.length))
	    {
			return intGSFI;
	    }
	}
	
	return -1;
}


/************************************************************************
*instr1												
*************************************************************************
*Description:															
*       Used to find if the specified string can be found within another string
*Arguments:																
*	    strSearch - the string we are searching	
*       strSearchFor - the string that you are searching for
*Returns:																
*       Returns the first location a substring (SearchForStr) was found in the string str.  
*       (If the character is not found, -1 is returned.)		
*Dependencies:
*       mid																				
*Created/Modified:														
* User Name		Date		Description									
* BBROWER       3/18/2003   Original Version					
*************************************************************************/
function instr1(start,strSearch, strSearchFor)
{
	var intGFSI;

	for (intGSFI=start; intGSFI < strSearch.length; intGSFI++)
	{
	    if (strSearchFor == mid(strSearch, intGSFI, strSearchFor.length))
	    {
			return intGSFI;
	    }
	}
	
	return -1;
}
/********************************************************************************
*replace												
*********************************************************************************
*Description:															
*       Used to replace part of a string with another string.  
*       ****This function is proprietary property of Dow Corning Corporation.****
*Arguments:																
*       strString - The string that is having characters replaced
*       strFind - The string to be replaced
*       strReplace - The string used to replace strParmFind 
*       blnCaseSensitive - if the search must be case sensitive, set this to true
*Returns:																
*       Returns the string with the replaced characters
*Dependencies:
*       none																			
*Created/Modified:														
* User Name	 Date		Description									
* BBROWER    11/26/2001       Original Version				
*********************************************************************************/
function replace(strString, strFind, strReplace, blnCaseSensitive)
{
	var blnfound = false;
	var textData = strString;
	var textLength = strString.length;
	var searchStr = ((strFind == "") ? null : strFind);
	var replaceStr = strReplace;
	var i;
  
	if(replaceStr == null)
	{
		replaceStr = "";
	}

	if(searchStr != null)
	{     
		searchLength = searchStr.length;
		replaceLength = replaceStr.length;
  
		//If the string being replaced is not a part of the replacement string (normal situation) 
		if(replaceStr.indexOf(searchStr) == -1)
		{
			for (i = 0; i <= (textLength - searchLength); i++)
			{
				//Call method to validate if it's a match based on case sensitivity          
				if(replaceMatch(blnCaseSensitive, textData.substring(i,i+searchLength), searchStr))
				{
					blnfound = true;
					textData = textData.substring(0,i) + replaceStr + textData.substring(i+searchLength,textLength);
					i -= searchLength + replaceLength;   	              
					textLength = textData.length;                                        
				}
			}
		}
		//If the string being replace is a part of the replacement string (i.e. "ALL" to "ALL OF YOU")
		else
		{
			//create an array of characters to be used as "inbetween"
			var midStrings = new Array("~", "`", "_", "^", "#");
			var midString = "";
			
			//Find a string that doesn't exist in the inputString to be used
			//as an "inbetween" string
			for (var i=0; i < midStrings.length; i++) 
			{
				if(midString == "")
				{
					var tempMidString = "";
				
					tempMidString = midStrings[i]; 
				
					if (replaceStr.indexOf(tempMidString) == -1) 
					{
						midString = tempMidString;
					}
				}
			}
			
			//Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
			while (textData.indexOf(searchStr) != -1) 
			{
				var toTheLeft = textData.substring(0, textData.indexOf(searchStr));
				var toTheRight = textData.substring(textData.indexOf(searchStr)+searchStr.length, textData.length);
				textData = toTheLeft + midString + toTheRight;
			}
			
			//Next, replace the "inbetween" string with the "toString"
			while (textData.indexOf(midString) != -1) 
			{
				blnfound = true;
				var toTheLeft = textData.substring(0, textData.indexOf(midString));
				var toTheRight = textData.substring(textData.indexOf(midString)+midString.length, textData.length);
				textData = toTheLeft + replaceStr + toTheRight;
			}
		}
	}
   
	if (!(blnfound))
	{ 
		return strString;
	}
	else
	{
		return textData; 
	}
}

function replaceMatch(blnCaseSensitive, compareData1, compareData2)
{
	if(blnCaseSensitive)
	{
		if (compareData1 == compareData2)
		{
			return true;
		}
	}
	else
	{
		if (compareData1.toLowerCase() == compareData2.toLowerCase())
		{
			return true;
		}
	}
	return false;
}

/************************************************************************
*FieldRequired												
*************************************************************************
*Description:															
*       
*Arguments:																
*	    strField
*       strString
*Returns:																
*       
*Dependencies:
*       																			
*Created/Modified:														
* User Name		Date		Description									
* JWGAUS2       12/1/2001	Original Version 		
*************************************************************************/

function FieldRequired(strField, strString)
{
	if ( len(strString) == 0)
	{
		return strField + " is required.";
	}
	else if ( instr(strString,"and") == -1)
	{
		return strField + " and " + left(strString,len(strString)-13) + " are required.";
	}
	else
	{
		return strField + ", " + strString;
	}	
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
  }  

// -->
