function SetCurrentTab(tabId, contentId, currentHiddenId, launchOnSelect)
   {
   var content = document.getElementById(contentId);
   var contents = content.parentNode.getElementsByTagName('div');
   
   for (i = 0; i < contents.length; i++)
      {
      var child = contents[i];
      if (child != content)
         {
         if (child.parentNode == content.parentNode)
            child.style.display = 'none';
         }
      }
   content.style.display = 'block';
   
   
                             //Patch for dynamic combo box.
   var dynamicComboBoxId = null;
   var subContents = content.getElementsByTagName('span');
   for (i = 0; i < subContents.length; i++)
      {
      var spanId = subContents[i].id;      
      var ctrlId = spanId.substr(spanId.length - 15);                         
      
      if (ctrlId == "DynamicComboBox")         
         {
         if (spanId.substr(0, tabId.length - 3) == tabId.substr(0, tabId.length - 3))
            dynamicComboBoxId = spanId;
         DynamicComboBoxLoad(spanId);                     
         }
      else
         {      
         ctrlId = spanId.substr(spanId.length - 8);
            
         if (ctrlId == "ComboBox")        
            ComboBoxLoad(spanId);   
         }         
      }
   
   var currentHidden = document.getElementById(currentHiddenId);
   currentHidden.value = tabId;
   
   var tab = document.getElementById(tabId);
   var tabs = tab.parentNode.getElementsByTagName('a');
   for (i = 0; i < tabs.length; i++)
      {
      var child = tabs[i];
      if (child != tab)
         child.className = '';
      else
         tab.className = 'current';
      }
      
   var textBoxId = null;
   if (dynamicComboBoxId == null)
      {
      var subContents = content.getElementsByTagName('input');
      for (i = 0; i < subContents.length; i++)
         {
         var inputId = subContents[i].id;
         if (inputId.substring(inputId.length - "TextBox".length) == "TextBox")
            textBoxId = inputId;
         }
      }
         
   if (!launchOnSelect || dynamicComboBoxId == null && textBoxId == null)
      return;
      
   var onSelectFunction = null;
   var value = null;
   var text = null;   
   if (dynamicComboBoxId != null)
      {
      onSelectFunction = dynamicComboBoxId + "_OnSelect";
      value = DynamicComboBoxGetValue(dynamicComboBoxId);
      text = DynamicComboBoxGetText(dynamicComboBoxId);
      if (value == text)
         return;      
      }
   else if (textBoxId != null)
      onSelectFunction = textBoxId + "_OnSelect";
      
   eval("if(" + onSelectFunction + " != null)" + onSelectFunction + "(value, text);");   
   }

function SelectLandmark(id, mun, typ,  lmk)
   {
   DynamicComboBoxClear(id + '_LandmarkMunicipalityDynamicComboBox');
   DynamicComboBoxSetReQueryText(id + '_LandmarkMunicipalityDynamicComboBox', mun, mun);
   
   DynamicComboBoxClear(id + '_LandmarkTypeDynamicComboBox');
   DynamicComboBoxSetReQueryText(id + '_LandmarkTypeDynamicComboBox', typ, typ);
   
   DynamicComboBoxSetReQueryText(id + '_LandmarkDynamicComboBox', lmk, lmk);
   
   DynamicComboBoxReQuery(id + '_LandmarkMunicipalityDynamicComboBox');
   if (mun == null || mun.length == 0)
      {
      DynamicComboBoxReQuery(id + '_LandmarkTypeDynamicComboBox');
      if (typ == null || typ.length == 0)
         DynamicComboBoxReQuery(id + '_LandmarkDynamicComboBox');
      }
   else if (typ == null || typ.length == 0)
      DynamicComboBoxReQuery(id + '_LandmarkDynamicComboBox');
   }

function SelectStopDescription(id, mun, stp)
   {
   DynamicComboBoxClear(id + '_StopMunicipalityDynamicComboBox');
   DynamicComboBoxSetReQueryText(id + '_StopMunicipalityDynamicComboBox', mun, mun);
   
   DynamicComboBoxSetReQueryText(id + '_StopDynamicComboBox', stp, stp);
   
   DynamicComboBoxReQuery(id + '_StopMunicipalityDynamicComboBox');
   if (mun == null || mun.length == 0)
      DynamicComboBoxReQuery(id + '_StopDynamicComboBox');
   }

function SelectStopPhoneNumber(id, pho)
   {
   document.getElementById(id + '_StopPhoneNumberTextBox').value = pho;
   }

function SelectStopIdentifier(id, ide)
   {
   document.getElementById(id + '_StopIdentifierTextBox').value = ide;
   }
   
function SelectIntersection(id, mun, street, streetRequeryText, inter, interRequeryText)
   {
   DynamicComboBoxClear(id + '_IntersectionMunicipalityDynamicComboBox');
   DynamicComboBoxSetReQueryText(id + '_IntersectionMunicipalityDynamicComboBox', mun, mun);
   
   DynamicComboBoxClear(id + '_IntersectionStreetDynamicComboBox');
   DynamicComboBoxSetReQueryText(id + '_IntersectionStreetDynamicComboBox', street, streetRequeryText);
   
   DynamicComboBoxSetReQueryText(id + '_IntersectionDynamicComboBox', inter, interRequeryText);
   
   DynamicComboBoxReQuery(id + '_IntersectionMunicipalityDynamicComboBox');
   if (mun == null || mun.length == 0)
      {
      DynamicComboBoxReQuery(id + '_IntersectionStreetDynamicComboBox');
      if (street == null || street.length == 0)
         DynamicComboBoxReQuery(id + '_IntersectionDynamicComboBox');
      }
   else if (street == null || street.length == 0)
      DynamicComboBoxReQuery(id + '_IntersectionDynamicComboBox');
   }
   
function SelectAddress(id, mun, civicNumber, street, streetRequeryText)
   {
   var civicNumberTextBox = document.getElementById(id + '_CivicNumberTextBox');
   civicNumberTextBox.value = civicNumber;
   
   DynamicComboBoxClear(id + '_AddressMunicipalityDynamicComboBox');
   DynamicComboBoxSetReQueryText(id + '_AddressMunicipalityDynamicComboBox', mun, mun);
   
   DynamicComboBoxSetReQueryText(id + '_AddressStreetDynamicComboBox', street, streetRequeryText);
   
   DynamicComboBoxReQuery(id + '_AddressMunicipalityDynamicComboBox');
   if (mun == null || mun.length == 0)
      DynamicComboBoxReQuery(id + '_AddressStreetDynamicComboBox');
   }
