function    MM_ComboBox_AddTo_InitList ()
{
   window.MM_ComboBox_InitList   =  window.MM_ComboBox_InitList  ?  ( window.MM_ComboBox_InitList + 1 )  :  1;
}

//------------------------------------------------------------------------------------------------------------------------------------------------------------------

function    MM_ComboBox_Initialize ()
{
   var   count    =  window.MM_ComboBox_InitList  ?  window.MM_ComboBox_InitList  :  0;

   for  (  var i = 0;  i < count;  ++ i  )
   {
      var   obj_div  =  document.getElementById  (  'MM_ComboBox_DivID'    + '__' + i  );
      var   o        =  document.getElementById  (  'MM_ComboBox_SelectID' + '__' + i  );
      var   x        =  o . offsetLeft  +  3;
      var   y        =  o . offsetTop   +  2;

      while  (  ( o = o.offsetParent )  !=  null  )
      {
         x  +=  o.offsetLeft;
         y  +=  o.offsetTop;
      }

      obj_div.style.left      =  x + 'px';
      obj_div.style.top       =  y + 'px';
      obj_div.style.display   =  'block';
   }
}

//------------------------------------------------------------------------------------------------------------------------------------------------------------------

function    MM_ComboBox_SetValue_Select ( obj_select, obj_edit )
{
   obj_edit.value =  obj_select.value;

   obj_edit.focus ();
}

//------------------------------------------------------------------------------------------------------------------------------------------------------------------

function    MM_ComboBox_KeyUp_Select ( obj_select, obj_edit, keyCode )
{
   obj_edit.value =  obj_select.value;
}

//------------------------------------------------------------------------------------------------------------------------------------------------------------------

function    MM_ComboBox_SetValue_Input ( obj_edit, obj_select )
{
   var   count =  obj_select.size  ?  obj_select.size  :  obj_select.length;

   for  (  var i = 0;  i < count - 1;  ++ i  )
   {
      if  (  obj_edit.value  ==  obj_select.options [ i ].value  )
         break;
   }

   obj_select.selectedIndex   =  i;
}

//------------------------------------------------------------------------------------------------------------------------------------------------------------------

function    MM_ComboBox_KeyUp_Input ( obj_edit, obj_select, keyCode )
{
   var   newIndex    =  obj_select.selectedIndex;
   var   count       =  obj_select.size  ?  obj_select.size  :  obj_select.length;

         if  (  ( keyCode == 38 )  &&  ( newIndex > 0         )  )         -- newIndex;
   else  if  (  ( keyCode == 40 )  &&  ( newIndex < count - 1 )  )         ++ newIndex;

   if  (  newIndex  !=  obj_select.selectedIndex  )
   {
      obj_select.selectedIndex   =  newIndex;
      obj_edit.value             =  obj_select.options [ newIndex ].value;
      obj_edit.select();
   }
}

//------------------------------------------------------------------------------------------------------------------------------------------------------------------
