/*********************************************************************
'***    Program: selectListItem( objList, strItemValue )
'***    Type: Function
'***
'***    Function: Selects item in a list box
'***
'***    Parameters: 
'***		objList - listbox (select) object
'***		strItemValue  - value to look for. the item with this value gets selected
'***
'***    Returns: Void
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 8/12/99
'*********************************************************************/
function selectListItem( objList, strItemValue ) {
	for (var i=0; i < objList.length; i++) {
		if (objList.options[i].value == strItemValue) {
			// this item needs to get selected
			objList.options[i].selected = true;
			break;
		}
	}
	return;
}


/*********************************************************************
'***    Program: isAlphaAndDigitString(strToCheck) 
'***    Type: Function
'***
'***    Function: Tests a string for presence of alpha and digit chars only
'***
'***    Parameters: 
'***		strToCheck - sting to check for validity
'***
'***    Returns: True/False
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 8/12/99
'*********************************************************************/
function isAlphaAndDigitString(strToCheck) {
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
  var checkStr = strToCheck;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++) {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) {
      allValid = false;
      break;
    }
  }
  return (allValid);
}

/*********************************************************************
'***    Program: isAlphaAndDigitEntry(objText) 
'***    Type: Function
'***
'***    Function: Checks a text box object's value for alpha and digit chars only
'***
'***    Parameters: 
'***		objText - object to check value in
'***
'***    Returns: True/False
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 8/12/99
'*********************************************************************/
function isAlphaAndDigitEntry(objText) {
  return (isAlphaAndDigitString(objText.value));
}

/*********************************************************************
'***    Program: isObjectOnForm(objForm, strObjName)
'***    Type: Function
'***
'***    Function: Checks whether an object exists on a given form 
'***
'***    Parameters: 
'***		objForm - form object to use when looking for an element
'***		strObjName - name of an object to look for. Case sensitive!
'***
'***    Returns: True/False
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 8/12/99
'*********************************************************************/
function isObjectOnForm(objForm, strObjName) {
	for (intFormIndex = 0; intFormIndex < objForm.elements.length; intFormIndex++) {
		if (objForm.elements[intFormIndex].name == strObjName) {
			return true;
		}
	}
	return false;
}

/*********************************************************************
'***    Program: getSelectedItems( lstWhereToLook )
'***    Type: Function
'***
'***    Function: Enumerates through a list box and returns a comma separated list of selected
'***		items
'***
'***    Parameters: 
'***		lstWhereToLook  - select object to look in
'***
'***    Returns: String
'***    Remarks: none
'***
'***    Created by: Dimab
'***    Changed by: Dimab
'***    Last change: 9/30/99
'*********************************************************************/
function getSelectedItems( lstWhereToLook ) {
	if (lstWhereToLook == null) {
		return "";
	}

	var strResult = "" ;
	for (intItemIndex = 0; intItemIndex < lstWhereToLook.length; intItemIndex++ ) {
		if (lstWhereToLook[intItemIndex].selected) {
			strResult += "," + lstWhereToLook[intItemIndex].value;
		}
	}
	if (strResult.length > 0) {
		return strResult.substring(1); // all but first comma
	}
	return strResult
}


