rem: setTimeout( function(firstTextBox) { firstTextBox.focus(); }, 0, firstName ); 
add: setTimeout( function(firstTextBox) { firstTextBox.focus(); }, 0, focus ); 
context: function OnLoadNewCard(){  InitEditCard();  doSetOKCancel(NewCardOKButton, 0);  var cardproperty = Components.classes["@mozilla.org/addressbook/cardproperty;1"].createInstance(Components.interfaces.nsIAbCard);  editCard.card = cardproperty;  editCard.titleProperty = "newCardTitle";  editCard.selectedAB = "";  if ("arguments" in window && window.arguments[0])  {    if ("selectedAB" in window.arguments[0]) {      // check if selected ab is a mailing list      var abURI = window.arguments[0].selectedAB;            var directory = GetDirectoryFromURI(abURI);      if (directory.isMailList) {        var parentURI = GetParentDirectoryFromMailingListURI(abURI);        if (parentURI) {          editCard.selectedAB = parentURI;        }        else {          // it's a mailing list, but we failed to determine the parent directory          // use the personal addressbook          editCard.selectedAB = kPersonalAddressbookURI;        }      }      else if (!(directory.operations & directory.opWrite)) {        editCard.selectedAB = kPersonalAddressbookURI;      }      else {      editCard.selectedAB = window.arguments[0].selectedAB;      }    }    else {      editCard.selectedAB = kPersonalAddressbookURI;    }    // we may have been given properties to pre-initialize the window with....    // we'll fill these in here...    if ("primaryEmail" in window.arguments[0])      editCard.card.primaryEmail = window.arguments[0].primaryEmail;    if ("displayName" in window.arguments[0]) {      editCard.card.displayName = window.arguments[0].displayName;      // if we've got a display name, don't generate      // a display name (and stomp on the existing display name)      // when the user types a first or last name      if (editCard.card.displayName.length)        editCard.generateDisplayName = false;    }  }  // set popup with address book names  var abPopup = document.getElementById('abPopup');  if ( abPopup )  {    var menupopup = document.getElementById('abPopup-menupopup');    if ( editCard.selectedAB && menupopup && menupopup.childNodes )    {      for ( var index = menupopup.childNodes.length - 1; index >= 0; index-- )      {        if ( menupopup.childNodes[index].getAttribute('value') == editCard.selectedAB )        {          abPopup.label = menupopup.childNodes[index].getAttribute('label');          abPopup.value = menupopup.childNodes[index].getAttribute('value');          break;        }      }    }    else {      // Default to the first valid addressbook when none is      // selected. (the 0th is an empty/invalid entry)      abPopup.label = menupopup.childNodes[1].getAttribute('label');      abPopup.value = menupopup.childNodes[1].getAttribute('value');    }  }  GetCardValues(editCard.card, document);  // FIX ME - looks like we need to focus on both the text field and the tab widget  // probably need to do the same in the addressing widget  // focus on first name  var firstName = document.getElementById('FirstName');  if ( firstName ) {    // XXX Using the setTimeout hack until bug 103197 is fixed    setTimeout( function(firstTextBox) { firstTextBox.focus(); }, 0, firstName );  }  moveToAlertPosition();}
meta: 10234	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/10234/e2128da10208e8f86359627a36c9ca107889e410/abCardOverlay.js/clean/mailnews/addrbook/resources/content/abCardOverlay.js