function SBLoadValues(objBox, arrArray, intValueColumn, intNameColumn, strFirstOption, intSelectValue, strCondition, intSelectOffSet)
{
   var intIndex = -1

   if (intSelectValue == undefined) { intSelectValue = -1 }
   if (intSelectOffSet == undefined) { intSelectOffSet = 0 }
   if (strFirstOption !== undefined && strFirstOption.length !== 0) { SBAdd(objBox, strFirstOption, -1) }

   for (var i = 0; i < arrArray.length; i++)
   {
      var intValue = arrArray[i][intValueColumn]
      var strName = StringDecode(arrArray[i][intNameColumn])

      if (intValue == intSelectValue) { intIndex = i }

      if (strCondition !== undefined) 
      { 
         if (eval(strCondition)) { SBAdd(objBox, strName, intValue) }
      }
      else
      {
         SBAdd(objBox, strName, intValue)
      }
   }

   if (intIndex !== -1)
   {
      intIndex = (intIndex + intSelectOffSet)

      if (strFirstOption !== undefined)
      {
         objBox.selectedIndex = intIndex + 1
      }
      else
      {
         objBox.selectedIndex = intIndex
      }
   }
}

function SBReturnValueIndex(objBox, strValue)
{
   for (var i = 0; i < objBox.length; i++)
   {
      if (objBox.options[i].value == strValue) 
      { 
         return i 
      }
   }

   return -1
}

function SBToString(objBox, blnOnlySelected)
{
   var strResult = new String()

   for (var i = 0; i < objBox.length; i++)
   {
      if (((objBox.options[i].selected == true) && (blnOnlySelected == true)) || (blnOnlySelected == false))
      { 
         strResult += objBox.options[i].value + ", "
      }
   }

   if (strResult.length !== 0) 
   { 
      if (strResult.substring(strResult.length - 2, strResult.length) == ", ") { strResult = strResult.substring(0, strResult.length - 2) }  
   }

   return strResult
}

function CBToString(objBox, blnOnlySelected)
{
   strResult = new String()

   if (objBox.length == undefined) { return objBox.value } 

   for (var i = 0; i < objBox.length; i++)
   {
      if (((objBox[i].checked == true) && (blnOnlySelected == true)) || (blnOnlySelected == false))
      {
         if (i !== 0) { strResult += ', ' + objBox[i].value } else { strResult += objBox[i].value }
      }
   }

   return strResult
}

function CBReturnValueIndex(objBox, strValue)
{
   if (objBox.length == undefined) { return -1 }

   for (var i = 0; i < objBox.length; i++)
   {
      if (objBox[i].value == strValue) 
      { 
         return i 
      }
   }

   return -1
}

function CBReturnSelected(objBox)
{
   if (objBox.length == undefined) { return -1 }

   for (var i = 0; i < objBox.length; i++)
   {
      if (objBox[i].checked) 
      { 
         return objBox[i].value 
      }
   }

   return new String()
}


function CBColorRed(objBox)
{
   if (objBox.length == undefined) { return }

   for (var i = 0; i < objBox.length; i++)
   {
      objBox[i].style.backgroundColor = '#FFAF95'
   }

   return new String()
}

function SBReturnTextIndex(objBox, strText)
{

   for (var i = 0; i < objBox.length; i++)
   {
      if (objBox.options[i].text.toLowerCase() == strText.toLowerCase()) 
      { 
         return i 
      }
   }

   return -1
}

function SBRemoveItem(objBox, intIndex)
{
   if (intIndex > -1)
   {
      objBox.options[intIndex] = null
   }
}

function SBSelect(objBox, intIndex)
{
   if (intIndex < objBox.length)
   {
      objBox.selectedIndex = intIndex
   }
   else
   {
      objBox.selectedIndex = 0
   }
}

function SBClear(objBox)
{
   for (var i = objBox.length - 1; i >= 0; i--) 
   { 
      objBox.options[i] = null 
   }   
}

function SBAdd(objBox, strText, strValue)
{
   objBox.options[objBox.length] = new Option(strText, strValue)
}

function MAReturnValueIndex(arrArray, intColumn, strValue)
{
   for (var i = 0; i < arrArray.length; i++)
   {
      if (arrArray[i][intColumn] == strValue) { return i }
   }

   return -1
}

function SBLookUp(objBox, strValue, blnIgnoreZero, blnSnapOptional, strEvalOnFullSnap, intOnNoMatchItem, intHelperEmptyItem)
{
   var intItemCount = objBox.length
   var intOptionValue = new Number()
   var strOptionText = new String()
   var strOptionMatch = new String()
   var blnFound = false

   if (intOnNoMatchItem == "undefined") { intOnNoMatchItem = 0 } 
   if (intHelperEmptyItem == "undefined") { intHelperEmptyItem = 0 }

   if (strValue.length == 0) { objBox.selectedIndex = intHelperEmptyItem; return false }

   for (var i = 0; i < intItemCount; i++)
   {
      var intOptionValue = objBox.options[i].value
      var strOptionText = objBox.options[i].text

      strOptionMatch = strOptionText.substr(0, strValue.length)

      if (CompareString(strOptionMatch, strValue) && intOptionValue !== 0)
      {
         objBox.selectedIndex = i

         if (CompareString(strOptionText, strValue))  
         {
            eval(strEvalOnFullSnap)
         }

         return true 
      }
      else
      {
         if (blnSnapOptional == false) { objBox.selectedIndex = intOnNoMatchItem }
      }
   }
}

function SBTransfer(objSourceBox, objTargetBox, intIndex, blnRemoveFromSource, blnAllowDoubles, strPrefix, strPostfix)
{
   var intKey
   var blnCheck
   var strText

   if (strPrefix == undefined) { strPrefix = new String() } 
   if (strPostfix == undefined) { strPostfix = new String() }

   if (intIndex > -1)
   {
      intKey = objSourceBox.options[intIndex].value
      strText = strPrefix + objSourceBox.options[intIndex].text + strPostfix

      if ((blnAllowDoubles == false) && (SBItemExists(objTargetBox, intKey) == true)) 
      {  
      }
      else 
      { 
         objTargetBox.options[objTargetBox.options.length] = new Option(strText, intKey)
         if (blnRemoveFromSource == true) 
         { 
            objSourceBox.options[intIndex] = null 
         } 
      }
   }
}

function SBItemExists(objBox, intKey)
{
   for (var i = objBox.length - 1; i >= 0; i--)
   {   
      if (objBox.options[i].value == intKey) 
      {
         return true;
      }
   }
   return false;
}

function FFDisable(objField)
{
   objField.disabled = true
   objField.style.background = "CCCCCC"
}

function FFEnable(objField)
{
   objField.disabled = false
   objField.style.background = "FFFFFF"
}

function GetValidationRules(arrArray)
{
   var strResult = new String()

   for (var i = 0; i < arrArray.length; i++)
   {
      strName = StringDecode(arrArray[i][0])
      strValue = StringDecode(arrArray[i][1])

      if (strName !== 'siteID') { strName = '!' + strName }

      strResult += '<INPUT TYPE="hidden" NAME="' + strName + '" VALUE="' + strValue + '">'
   }

   return strResult
}
//-->