private static String ensureUniqueId(String id){
  Object exists=DOM.getElementById(id);
  int i=0;
  while (exists != null) {
    exists=DOM.getElementById(id + "_" + (++i));
  }
  if (i > 0) {
    id=id + "_" + i;
  }
  return id;
}

private static String ensureUniqueId ( String id ) { Object exists = DOM . getElementById ( id ) ; int i = 0 ; while ( exists != null ) { exists = DOM . getElementById ( id + "_" + ( ++ i ) ) ; } if ( i > 0 ) { id = id + "_" + i ; } return id ; }
ensures that the given id is not being used in the current document . if this is not the case , returns an unique id .
