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';
   
   var comboBoxId = null;
   var subContents = content.getElementsByTagName('div');
   for (i = 0; i < subContents.length; i++)
      {
      var divId = subContents[i].id;      
      var ctrlId = divId.substr(divId.length - 8);                         
      
      if (ctrlId == "ComboBox")         
         {
         if (divId.substr(0, tabId.length - 3) == divId.substr(0, tabId.length - 3))
            comboBoxId = divId.substr(0, divId.length - 9); 
         }       
      }
   
   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 (comboBoxId == 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 || comboBoxId == null && textBoxId == null)
      return;
      
   var onSelectFunction = null;
   var value = "";
   var text = "";   
   if (comboBoxId != null)
      {
      onSelectFunction = comboBoxId + "_OnSelect";
      value = $find(comboBoxId).GetValue();
      text = $find(comboBoxId).GetText();  
      }
   else if (textBoxId != null)
      onSelectFunction = textBoxId + "_OnSelect";
      
   eval("if(" + onSelectFunction + " != null)" + onSelectFunction + "(value, text);");   
   }

function SelectLandmark(id, mun, typ,  lmk)
   {
   var landmarkMunicipalityComboBox = $find(id + "_LandmarkMunicipalityComboBox");
   if (landmarkMunicipalityComboBox != null)
      {
      landmarkMunicipalityComboBox.ClearAll();
      landmarkMunicipalityComboBox.SetReQueryText(mun, mun);
      landmarkMunicipalityComboBox.ReQuery();
      }
   
   var landmarkTypeComboBox = $find(id + "_LandmarkTypeComboBox");   
   landmarkTypeComboBox.ClearAll();
   landmarkTypeComboBox.SetReQueryText(typ, typ);
   landmarkTypeComboBox.ReQuery();
   
   var landmarkComboBox = $find(id + "_LandmarkComboBox");      
   landmarkComboBox.SetReQueryText(lmk, lmk);
   landmarkComboBox.ReQuery();   
   }

function SelectStopDescription(id, mun, stp)
   {
   var stopMunicipalityComboBox = $find(id + "_StopMunicipalityComboBox");   
   if (stopMunicipalityComboBox != null)
      {   
      stopMunicipalityComboBox.ClearAll();
      stopMunicipalityComboBox.SetReQueryText(mun, mun);   
      stopMunicipalityComboBox.ReQuery();   
      }
      
   var stopComboBox = $find(id + "_StopComboBox");      
   if (stopComboBox != null)
      {        
      stopComboBox.SetReQueryText(stp, stp);   
      stopComboBox.ReQuery();   
      }   
   }

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)
   {
   var intersectionMunicipalityComboBox = $find(id + "_IntersectionMunicipalityComboBox");    
   if (intersectionMunicipalityComboBox != null)
      {      
      intersectionMunicipalityComboBox.ClearAll();
      intersectionMunicipalityComboBox.SetReQueryText(mun, mun);
      intersectionMunicipalityComboBox.ReQuery();  
      }  
   
   var intersectionStreetComboBox = $find(id + "_IntersectionStreetComboBox");    
   intersectionStreetComboBox.ClearAll();
   intersectionStreetComboBox.SetReQueryText(street, streetRequeryText);         
   intersectionStreetComboBox.ReQuery();    
   
   var intersectionComboBox = $find(id + "_IntersectionComboBox");     
   intersectionComboBox.SetReQueryText(inter, interRequeryText);     
   intersectionComboBox.ReQuery();       
   }
   
function SelectAddress(id, mun, civicNumber, street, streetRequeryText)
   {
   var civicNumberTextBox = document.getElementById(id + '_CivicNumberTextBox');
   civicNumberTextBox.value = civicNumber;
   
   var addressMunicipalityComboBox = $find(id + "_AddressMunicipalityComboBox");     
   if (addressMunicipalityComboBox != null)
      {     
      addressMunicipalityComboBox.ClearAll();
      addressMunicipalityComboBox.SetReQueryText(mun, mun); 
      addressMunicipalityComboBox.ReQuery(); 
      }   
      
   var addressStreetComboBox = $find(id + "_AddressStreetComboBox");        
   addressStreetComboBox.SetReQueryText(street, streetRequeryText);       
   addressStreetComboBox.ReQuery();    
   }
