public static String generateMenuItem1(
      DropDownMenu menuItem,
      String id,
      int selection,
      String selectionName,
      String anchorPrefix,
      String paramName) {
    String code = "";
    DropDownMenu menuList[] = menuItem.getMenuItems();

    String formType = "";
    if (selection == SELECTION_SINGLE) {
      formType = "radio";
    } else {
      formType = "checkbox";
    }

    code += "<ul id=\"" + id + "\">\n";
    if (menuList.length > 0) {
      for (int i = 0; i < menuList.length; i++) {
        code += "<li>";
        code += "<div>";
        if (selection != SELECTION_NONE) {
          code +=
              "<input type=\""
                  + formType
                  + "\" name=\""
                  + selectionName
                  + "\" value=\""
                  + menuItem.getMenuKey()
                  + "\" unchecked>";
        }
        if (anchorPrefix == null) {
          code += menuList[i].getMenuName() + "\n";
        } else {
          String href = anchorPrefix;
          if (anchorPrefix.indexOf("?") > 0) {
            href += "&" + paramName + "=" + menuList[i].getMenuKey();
          } else {
            href += "?" + paramName + "=" + menuList[i].getMenuKey();
          }
          code += "<a href='" + href + "'>" + menuList[i].getMenuName() + "</a>\n";
        }
        code += "</div>";
        if (menuList[i].getMenuItems().length > 0) {
          code +=
              generateMenuItem1(menuList[i], id, selection, selectionName, anchorPrefix, paramName);
        }
        code += "</li>";
      }
    }
    return code;
  }
  public static String generate1(
      DropDownMenu ddm,
      String selections[],
      String id,
      int selection,
      String selectionName,
      String anchorPrefix,
      String paramName) {
    String formType = "";
    if (selection == SELECTION_SINGLE) {
      formType = "radio";
    } else {
      formType = "checkbox";
    }

    String code = "";
    code += "<ul style=\"display:none\" id=\"" + id + "\">\n";
    DropDownMenu menuList[] = ddm.getMenuItems();
    for (int i = 0; i < menuList.length; i++) {
      DropDownMenu menuItem = menuList[i];

      code += "<li>";
      code += "<div>";
      if (selection != SELECTION_NONE) {
        String check = "";
        if (selections != null) {
          for (int j = 0; j < selections.length; j++) {
            if (menuItem.getMenuKey().equals(selections[j])) {
              check = "checked=\"checked\"";
              break;
            }
          }
        }
        code +=
            "<input type=\""
                + formType
                + "\" name=\""
                + selectionName
                + "\" value=\""
                + menuItem.getMenuKey()
                + "\" "
                + check
                + ">";
      }
      if (anchorPrefix == null) {
        code += menuList[i].getMenuName() + "\n";
      } else {
        String href = anchorPrefix;
        if (anchorPrefix.indexOf("?") > 0) {
          href += "&" + paramName + "=" + menuList[i].getMenuKey();
        } else {
          href += "?" + paramName + "=" + menuList[i].getMenuKey();
        }
        code +=
            "<a href='"
                + href
                + "'>"
                + menuList[i].getMenuName()
                + "<div style='display:none'>"
                + menuList[i].getMenuKey()
                + "</div></a>\n";
      }
      code += "</div>";
      if (menuList[i].getMenuItems().length > 0) {
        code +=
            generate1(
                menuList[i], selections, id, selection, selectionName, anchorPrefix, paramName);
      }
      code += "</li>";
    }

    code += "</ul>\n";
    return code;
  }
  public static String generateMenuItem(
      DropDownMenu menuItem,
      String id,
      int level,
      int selection,
      String selectionName,
      String anchorPrefix,
      String paramName) {
    String code = "";
    DropDownMenu menuList[] = menuItem.getMenuItems();

    String formType = "";
    if (selection == SELECTION_SINGLE) {
      formType = "radio";
    } else {
      formType = "checkbox";
    }

    String indent = "  ";
    for (int i = 0; i < level - 1; i++) {
      indent += "    ";
    }

    code += indent + "<li class=\"sm_DDM_item\">\n";
    for (int i = 0; i < level - 1; i++) {
      code += "<img src=\"" + imagePrefix + "btnBlank.gif\" border=\"0\">";
    }
    if (menuList.length > 0) {
      code +=
          indent
              + "  <a href=\"\" onclick=\"javascript:sm_DDM_toggle('"
              + id
              + "'); return false;\"><img src=\""
              + imagePrefix
              + "btnExpand.gif\" border=\"0\"></a>";
      if (selection != SELECTION_NONE) {
        code +=
            "<input type=\""
                + formType
                + "\" name=\""
                + selectionName
                + "\" value=\""
                + menuItem.getMenuKey()
                + "\" unchecked>";
      }
      //			code += menuItem.getMenuName() + "\n";
    } else {
      code += "<img src=\"" + imagePrefix + "btnBlank.gif\" border=\"0\">";
      if (selection != SELECTION_NONE) {
        code +=
            "<input type=\""
                + formType
                + "\" name=\""
                + selectionName
                + "\" value=\""
                + menuItem.getMenuKey()
                + "\" unchecked>";
      }
      //			code += menuItem.getMenuName() + "\n";
    }
    if (anchorPrefix == null) {
      code += menuItem.getMenuName() + "\n";
    } else {
      String href = anchorPrefix;
      if (anchorPrefix.indexOf("?") > 0) {
        href += "&" + paramName + "=" + menuItem.getMenuKey();
      } else {
        href += "?" + paramName + "=" + menuItem.getMenuKey();
      }
      code += "<a href='" + href + "'>" + menuItem.getMenuName() + "</a>\n";
    }
    code += indent + "</li>\n";
    if (menuList.length > 0) {
      code += indent + "<li id=\"" + id + "\" class=\"sm_DDM_hide\">\n";
      code += indent + "  <ul class=\"sm_DDM_container\">\n";
      for (int i = 0; i < menuList.length; i++) {
        id += "-" + String.valueOf(i);
        code +=
            generateMenuItem(
                menuList[i], id, level + 1, selection, selectionName, anchorPrefix, paramName);
      }
      code += indent + "  </ul>\n";
      code += indent + "</li>\n";
    }
    return code;
  }