public void main(IWContext iwc) throws Exception {
    _editPermission = (iwc.hasEditPermission(this) || this.isOwnerOfProject(iwc));
    Text tBreak = (Text) Text.getBreak().clone();
    tBreak.setFontSize(Text.FONT_SIZE_7_HTML_1);
    this.addAtBeginning(tBreak);

    IWBundle iwb = this.getBundle(iwc);
    IWResourceBundle iwrb = iwb.getResourceBundle(iwc);

    // this.addAtBeginning(new Text(this.getGroupName(),true,false,true));
    super.main(iwc);
    if (_editPermission) {
      Table table = new Table(8, 1);
      table.setHorizontalAlignment("left");
      table.setCellpadding(0);
      table.setCellpadding(0);

      table.setWidth(1, "6");
      table.setWidth(3, "6");
      table.setWidth(5, "12");
      table.setWidth(7, "6");

      //      table.add(getAddAndRemoveGroupLinkIcon(iwc, iwb),2,1);
      //      table.add(getAddAndRemoveGroupLink(iwc, iwrb),4,1);
      //
      //      table.add(getAddAndRemoveUserLinkIcon(iwc, iwb),6,1);
      //      table.add(getAddAndRemoveUserLink(iwc, iwrb),8,1);

      table.add(getAddAndRemoveUserLinkIcon(iwc, iwb), 2, 1);
      table.add(getAddAndRemoveUserLink(iwc, iwrb), 4, 1);

      this.add(table);
    }
  }
  // private Layer getNavigationTree(IWContext iwc) {
  private Layer getNavigationTree() {
    Layer layersNav = new Layer(Layer.DIV);
    layersNav.setOverflow("scroll");
    layersNav.setPositionType("relative");
    layersNav.setWidth("320");
    layersNav.setHeight("400");

    layersNav.setStyleClass("ehealth_div_no_border");
    // layersNav.setMarkupAttribute("class", "ehealth_div");

    layersNav.setBackgroundImage(imageBgVertOut);

    Table table = new Table(3, 20);
    table.setNoWrap();
    table.setCellpadding(0);
    table.setCellspacing(0);
    table.setBorder(0);

    table.setWidth("280");
    table.setHeight("350");

    int row = 1;
    int i = 1;

    for (i = 1; i <= 4; i++) {
      table.mergeCells(2, row, 3, row);
      if (i <= 2) {
        table.add(getLayer1(i), 2, row);
        table.setHeight(1, row, "16");
        table.setHeight(2, row, "16");
        table.setWidth(1, row, "16");
        table.setWidth(2, row, "16");
        table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP);
        table.add(imageCircleD, 1, row++);
      }
      // table.setBackgroundImage(1, row, imageBgVert);
      table.setHeight(2, row, "16");
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP);
      table.add(getLayer2(i), 2, row++);
      table.setBackgroundImage(1, row, imageBgVert);
      table.setHeight(1, row, "20");
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP);
      table.add(getLayer3(i), 2, row++);
      table.setHeight(1, row, "10");
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP);
      table.setBackgroundImage(1, row++, imageBgVert);

      /*table.add(getLayer1(i), 2, row);
      table.add(getLayer2(i), 2, row);
      table.add(getLayer3(i), 2, row);
      */
    }
    table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_TOP);
    table.setHeight(1, row, "25");
    table.setBackgroundImage(1, row++, imageBgVert);

    layersNav.add(table);
    return layersNav;
  }
  public Table getNavigationTable(IWContext iwc) {

    int usersSize = 0;
    if (this.users != null) {
      usersSize = this.users.size();
    }

    int maxPage = (int) Math.ceil(usersSize / this.USERS_PER_PAGE);

    Table navigationTable = new Table(3, 1);
    navigationTable.setCellpadding(2);
    navigationTable.setCellspacing(0);
    navigationTable.setWidth(Table.HUNDRED_PERCENT);
    navigationTable.setBorder(0);
    navigationTable.setWidth(1, "33%");
    navigationTable.setWidth(2, "33%");
    navigationTable.setWidth(3, "33%");
    navigationTable.setAlignment(2, 1, Table.HORIZONTAL_ALIGN_CENTER);
    navigationTable.setAlignment(3, 1, Table.HORIZONTAL_ALIGN_RIGHT);

    Text prev = getSmallText(localize("previous", "Previous"));
    Text next = getSmallText(localize("next", "Next"));
    Text info =
        getSmallText(
            localize("page", "Page")
                + " "
                + (this.currentPage + 1)
                + " "
                + localize("of", "of")
                + " "
                + (maxPage + 1));
    if (this.currentPage > 0) {
      Link lPrev = getLink(getSmallText(localize("previous", "Previous")), iwc);
      lPrev.addParameter(this.PARAMETER_CURRENT_PAGE, Integer.toString(this.currentPage - 1));
      lPrev.addParameter(this.PARAMETER_SEARCH, iwc.getParameter(this.PARAMETER_SEARCH));
      if (this.showAll) {
        lPrev.addParameter(this.PARAMETER_VIEW_ALL, "true");
      }
      navigationTable.add(lPrev, 1, 1);
    } else {
      navigationTable.add(prev, 1, 1);
    }
    navigationTable.add(info, 2, 1);

    if (this.currentPage < maxPage) {
      Link lNext = getLink(getSmallText(localize("next", "Next")), iwc);
      lNext.addParameter(this.PARAMETER_CURRENT_PAGE, Integer.toString(this.currentPage + 1));
      lNext.addParameter(this.PARAMETER_SEARCH, iwc.getParameter(this.PARAMETER_SEARCH));
      if (this.showAll) {
        lNext.addParameter(this.PARAMETER_VIEW_ALL, "true");
      }
      navigationTable.add(lNext, 3, 1);
    } else {
      navigationTable.add(next, 3, 1);
    }
    return navigationTable;
  }
  private void addForm(IWContext iwc) {
    Form form = new Form();
    form.maintainParameter(PARAMETER_GROUP_ID);

    Table mainTable = new Table();
    mainTable.setWidth(660);
    mainTable.setHeight(200);
    mainTable.setCellpadding(0);
    mainTable.setCellspacing(0);
    form.add(mainTable);

    Table topTable = new Table(1, 1);
    topTable.setStyleClass(MAIN_STYLECLASS);
    topTable.setWidth(Table.HUNDRED_PERCENT);
    topTable.setHeight(160);

    topTable.add(
        this.iwrb.getLocalizedString(
            UPDATE_INFO, "Press Update to update all clubs linked to this league."),
        1,
        1);

    CloseButton close =
        new CloseButton(
            this.iwrb.getLocalizedImageButton("updateclubdivisiontemplate.close", "Close"));
    SubmitButton start =
        new SubmitButton(
            this.iwrb.getLocalizedImageButton("updateclubdivisiontemplate.update", "Update"),
            ACTION,
            ACTION_UPDATE);
    start.setSubmitConfirm(
        this.iwrb.getLocalizedString(
            "updateclubdivisiontemplate.confirm_message",
            "Are you sure you want to start the update process? The process will start in the background and once it is running you can not stop it nor start a new one."));
    Help help = getHelp(HELP_TEXT_KEY);

    Table bottomTable = new Table();
    bottomTable.setCellpadding(0);
    bottomTable.setCellspacing(5);
    bottomTable.setWidth(Table.HUNDRED_PERCENT);
    bottomTable.setHeight(39);
    bottomTable.setStyleClass(MAIN_STYLECLASS);
    bottomTable.add(help, 1, 1);
    bottomTable.setAlignment(2, 1, Table.HORIZONTAL_ALIGN_RIGHT);
    bottomTable.add(start, 2, 1);
    bottomTable.add(Text.getNonBrakingSpace(), 2, 1);
    bottomTable.add(close, 2, 1);

    mainTable.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_TOP);
    mainTable.setVerticalAlignment(1, 3, Table.VERTICAL_ALIGN_TOP);
    mainTable.add(topTable, 1, 1);
    mainTable.add(bottomTable, 1, 3);

    add(form, iwc);
  }
  private void addInfo(IWContext iwc) {
    Form form = new Form();
    form.maintainParameter(PARAMETER_GROUP_ID);

    Table mainTable = new Table();
    mainTable.setWidth(660);
    mainTable.setHeight(200);
    mainTable.setCellpadding(0);
    mainTable.setCellspacing(0);
    form.add(mainTable);

    Table topTable = new Table(1, 1);
    topTable.setStyleClass(MAIN_STYLECLASS);
    topTable.setWidth(Table.HUNDRED_PERCENT);
    topTable.setHeight(160);

    topTable.add(
        this.iwrb.getLocalizedString(
            UPDATE_RUNNING,
            "The update process is now running in the background. You cannot start another one while this one is running."),
        1,
        1);

    CloseButton close =
        new CloseButton(
            this.iwrb.getLocalizedImageButton("updateclubdivisiontemplate.close", "Close"));
    Help help = getHelp(HELP_TEXT_KEY);

    Table bottomTable = new Table();
    bottomTable.setCellpadding(0);
    bottomTable.setCellspacing(5);
    bottomTable.setWidth(Table.HUNDRED_PERCENT);
    bottomTable.setHeight(39);
    bottomTable.setStyleClass(MAIN_STYLECLASS);
    bottomTable.add(help, 1, 1);
    bottomTable.setAlignment(2, 1, Table.HORIZONTAL_ALIGN_RIGHT);
    bottomTable.add(close, 2, 1);

    mainTable.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_TOP);
    mainTable.setVerticalAlignment(1, 3, Table.VERTICAL_ALIGN_TOP);
    mainTable.add(topTable, 1, 1);
    mainTable.add(bottomTable, 1, 3);

    add(form, iwc);
  }
    private void LineUpElements(IWContext iwc) {

      Form form = new Form();

      Table frameTable = new Table(3, 3);
      frameTable.setWidth("100%");
      frameTable.setHeight("100%");
      // frameTable.setBorder(1);

      SelectionDoubleBox sdb =
          new SelectionDoubleBox(GroupGroupSetter.FIELDNAME_SELECTION_DOUBLE_BOX, "Not in", "In");

      SelectionBox left = sdb.getLeftBox();
      left.setHeight(8);
      left.selectAllOnSubmit();

      SelectionBox right = sdb.getRightBox();
      right.setHeight(8);
      right.selectAllOnSubmit();

      String stringGroupId = iwc.getParameter(GroupGroupSetter.PARAMETER_GROUP_ID);
      int groupId = Integer.parseInt(stringGroupId);
      form.addParameter(GroupGroupSetter.PARAMETER_GROUP_ID, stringGroupId);

      List directGroups = UserGroupBusiness.getGroupsContainingDirectlyRelated(groupId);

      Iterator iter = null;
      if (directGroups != null) {
        iter = directGroups.iterator();
        while (iter.hasNext()) {
          Object item = iter.next();
          right.addElement(
              Integer.toString(((GenericGroup) item).getID()), ((GenericGroup) item).getName());
        }
      }
      List notDirectGroups = UserGroupBusiness.getRegisteredGroupsNotDirectlyRelated(groupId, iwc);
      if (notDirectGroups != null) {
        iter = notDirectGroups.iterator();
        while (iter.hasNext()) {
          Object item = iter.next();
          left.addElement(
              Integer.toString(((GenericGroup) item).getID()), ((GenericGroup) item).getName());
        }
      }

      // left.addSeparator();
      // right.addSeparator();

      frameTable.setAlignment(2, 2, "center");
      frameTable.add("GroupId: " + groupId, 2, 1);
      frameTable.add(sdb, 2, 2);
      frameTable.add(new SubmitButton("  Save  ", "save", "true"), 2, 3);
      frameTable.add(new CloseButton("  Cancel  "), 2, 3);
      frameTable.setAlignment(2, 3, "right");
      form.add(frameTable);
      this.add(form);
    }
  public Table getListTable(IWContext iwc) throws RemoteException {
    Table table = new Table(2, this.USERS_PER_PAGE + 1);
    table.setCellspacing(0);
    table.setCellpadding(2);
    table.setWidth(Table.HUNDRED_PERCENT);
    table.setHorizontalZebraColored(
        IWConstants.DEFAULT_INTERFACE_COLOR, IWConstants.DEFAULT_LIGHT_INTERFACE_COLOR);
    int row = 1;
    int rowHeight = 12;
    table.setHeight(table.getRows() * rowHeight);

    table.add(getTitleText(localize("user", "User")), 1, row);
    table.add(getTitleText(localize("personal_id", "Personal ID")), 2, row);
    table.setRowColor(row, IWConstants.DEFAULT_DARK_INTERFACE_COLOR);
    table.setHeight(row, rowHeight);

    if (this.users != null) {
      /** Calculating page....starts */
      int start = this.currentPage * this.USERS_PER_PAGE;
      Iterator iter = this.users.iterator();
      for (int i = 0; i < start; i++) {
        if (iter.hasNext()) {
          iter.next();
        }
      }
      /** Calculating page....ends */
      int counter = 0;
      User user;
      Link link;
      String pId;
      while (iter.hasNext() && counter < this.USERS_PER_PAGE) {
        ++counter;
        ++row;
        table.setHeight(row, rowHeight);

        user = (User) iter.next();
        pId = user.getPersonalID();
        if (pId == null) {
          pId = "-";
        }
        link = getLink(getText(user.getName()), iwc);
        link.addParameter(this.PARAMETER_USER_ID, user.getPrimaryKey().toString());
        table.add(link, 1, row);
        table.add(getText(pId), 2, row);
      }
    }

    return table;
  }
  public Table getListTable(IWContext iwc) throws RemoteException {
    Table table = new Table(3, this.USERS_PER_PAGE + 1);
    table.setCellspacing(0);
    table.setCellpadding(2);
    table.setWidth("100%");
    table.setHorizontalZebraColored("#C1C3B4", "#FFFFFF");
    int row = 1;
    int rowHeight = 12;
    table.setHeight(table.getRows() * rowHeight);
    table.add(getTitleText(localize("user", "User")), 1, row);
    table.add(getTitleText(localize("school", "School")), 2, row);
    table.add(getTitleText(localize("personal_id", "Personal ID")), 3, row);
    table.setRowColor(row, "#74858D");
    table.setHeight(row, rowHeight);

    if (this.users != null) {
      int start = this.currentPage * this.USERS_PER_PAGE;
      Iterator iter = this.users.iterator();
      for (int i = 0; i < start; i++) {
        if (iter.hasNext()) {
          iter.next();
        }
      }

      String pId;
      for (int counter = 0;
          iter.hasNext() && counter < this.USERS_PER_PAGE;
          table.add(getText(pId), 3, row)) {
        counter++;
        row++;
        table.setHeight(row, rowHeight);
        User user = (User) iter.next();
        pId = user.getPersonalID();
        if (pId == null) {
          pId = "-";
        }
        Link link = getLink(getText(user.getName()), iwc);

        link.addParameter(this.PARAMETER_USER_ID, user.getPrimaryKey().toString());
        table.add(link, 1, row);

        table.add(getText(getSchoolName(user)), 2, row);
      }
    }
    return table;
  }
  /**
   * @see
   *     com.idega.presentation.ui.AbstractChooserWindow#displaySelection(com.idega.presentation.IWContext)
   */
  public void displaySelection(IWContext iwc) {
    String uId = iwc.getParameter(this.PARAMETER_USER_ID);
    if (uId != null) {
      try {
        User user = getUserHome().findByPrimaryKey(new Integer(uId));
        Page page = getParentPage();
        page.setOnLoad(SELECT_FUNCTION_NAME + "('" + user.getName() + "','" + uId + "')");
      } catch (RemoteException e) {
      } catch (FinderException e) {
      }
    } else {

      init(iwc);

      addTitle(this.iwrb.getLocalizedString("select_a_user", "Select a user"), TITLE_STYLECLASS);

      this.form.maintainParameter(SCRIPT_PREFIX_PARAMETER);
      this.form.maintainParameter(SCRIPT_SUFFIX_PARAMETER);
      this.form.maintainParameter(DISPLAYSTRING_PARAMETER_NAME);
      this.form.maintainParameter(VALUE_PARAMETER_NAME);

      Table mainTable = new Table(1, 4);
      mainTable.setStyleClass(this.mainTableStyle);
      mainTable.setWidth(Table.HUNDRED_PERCENT);
      mainTable.setBorder(0);

      mainTable.add(getHeaderTable(iwc), 1, 1);
      mainTable.add(getNavigationTable(iwc), 1, 3);
      try {
        mainTable.add(getListTable(iwc), 1, 4);
      } catch (RemoteException r) {
        throw new RuntimeException(r.getMessage());
      }
      this.form.add(mainTable);
      add(this.form, iwc);
    }
  }
  private void catalog(IWContext iwc) throws RemoteException, FinderException {
    try {
      Link createLink = ProductEditorWindow.getEditorLink(-1);
      createLink.setImage(this.iCreate);
      //			createLink.addParameter(ProductEditorWindow.PRODUCT_CATALOG_OBJECT_INSTANCE_ID,
      // getICObjectInstanceID());
      createLink.setToolTip(
          this.iwrb.getLocalizedString(
              "trade.product_catalog.create_new_product", "Create new product"));
      Link detachLink =
          getCategoryLink(
              com.idega.block.trade.stockroom.data.ProductCategoryBMPBean.CATEGORY_TYPE_PRODUCT);
      detachLink.addParameter(CategoryWindow.prmObjInstId, getICObjectInstanceID());
      detachLink.setImage(this.iDetach);
      detachLink.setToolTip(
          this.iwrb.getLocalizedString(
              "trade.product_catalog.select_categories", "Select categories"));
      if (hasEditPermission()) {
        add(createLink);
        if (!this._useParameterCategory) {
          add(detachLink);
        }
      }
      this.layout = (AbstractProductCatalogLayout) this._layoutClass.newInstance();
      this.productCategories = new Vector();
      if (iwc.isParameterSet(CATEGORY_ID)) {
        String[] categoryIDs = iwc.getParameterValues(CATEGORY_ID);
        for (int a = 0; a < categoryIDs.length; a++) {
          this.productCategories.add(
              CategoryFinder.getInstance().getCategory(Integer.parseInt(categoryIDs[a])));
        }
      }
      if (this.productCategories.size() == 0 || !this._useParameterCategory) {
        try {
          this.productCategories = (List) getCategories();
          if (this.productCategories == null) {
            this.productCategories = new Vector();
          }
          Collections.sort(this.productCategories, new CategoryComparator(this));
        } catch (Exception e) {
          e.printStackTrace(System.err);
        }
      }

      Iterator iter = this.productCategories.iterator();
      while (iter.hasNext()) {
        createLink.addParameter(
            ProductEditorWindow.PARAMETER_CATEGORY_ID,
            ((ICCategory) iter.next()).getPrimaryKey().toString());
      }
      Table table = new Table();
      table.setCellpadding(0);
      table.setCellspacing(0);
      if (this._width != null) {
        table.setWidth(this._width);
      } else {
        table.setWidth(Table.HUNDRED_PERCENT);
      }
      PresentationObject po = this.layout.getCatalog(this, iwc, this.productCategories);
      table.add(po);
      /*      if (hasEditPermission()) {
        Link clearCache = new Link(iwrb.getLocalizedImageButton("clear_cache","Clear cache"));
          clearCache.addParameter(prmClrCache, "true");
        table.add(clearCache, 1, 2);
      }*/
      add(table);
    } catch (IllegalAccessException iae) {
      iae.printStackTrace(System.err);
    } catch (InstantiationException ie) {
      ie.printStackTrace(System.err);
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see is.idega.idegaweb.member.presentation.UserEditor#presentateUserRelations(com.idega.presentation.IWContext)
   */
  protected void presentUserRelations(IWContext iwc) throws RemoteException {
    Table relationsTable = new Table();
    relationsTable.setCellspacing(4);
    relationsTable.setWidth(Table.HUNDRED_PERCENT);
    int row = 1;

    if (user != null) {
      addSeperator(iwrb.getLocalizedString("mbe.user_relations", "User relations"));
      CommuneFamilyService familyService = getFamilyService(iwc);

      // parent handling
      relationsTable.add(getHeader(iwrb.getLocalizedString("mbe.parents", "Parents")), 1, row++);
      Collection parents = null;
      try {
        parents = familyService.getParentsFor(user);
        if (parents != null && !parents.isEmpty()) {
          for (Iterator iter = parents.iterator(); iter.hasNext(); ) {
            User parent = (User) iter.next();
            relationsTable.add(getRelatedUserLink(parent), 1, row);
            relationsTable.add(
                PersonalIDFormatter.format(parent.getPersonalID(), iwc.getCurrentLocale()),
                2,
                row++);
          }
        }
      } catch (Exception e1) {
      }
      row++;

      // partner handling
      relationsTable.add(getHeader(iwrb.getLocalizedString("mbe.spouse", "Spouse")), 1, row++);
      User partner = null;
      try {
        partner = familyService.getSpouseFor(this.user);
      } catch (NoSpouseFound e) {
      } catch (Exception e) {
      }
      if (partner != null) {
        relationsTable.add(getRelatedUserLink(partner), 1, row);
        relationsTable.add(
            PersonalIDFormatter.format(partner.getPersonalID(), iwc.getCurrentLocale()), 2, row++);
      }
      row++;

      // cohabitant handling
      relationsTable.add(
          getHeader(iwrb.getLocalizedString("mbe.cohabitant", "Cohabitant")), 1, row++);
      User cohabitant = null;
      try {
        cohabitant = familyService.getCohabitantFor(this.user);
      } catch (NoCohabitantFound e) {
      }
      if (cohabitant != null) {
        relationsTable.add(getRelatedUserLink(cohabitant), 1, row);
        relationsTable.add(
            PersonalIDFormatter.format(cohabitant.getPersonalID(), iwc.getCurrentLocale()),
            2,
            row++);
      }
      row++;

      // biological children handling
      relationsTable.add(
          getHeader(iwrb.getLocalizedString("mbe.parential_children", "Parential children")),
          1,
          row++);
      Collection children = null;
      Collection custodianChildren = null;
      Text star = new Text(" *");
      star.setStyleClass(STYLENAME_HEADER);
      try {
        children = familyService.getChildrenFor(user);
        custodianChildren = familyService.getChildrenInCustodyOf(user);
        if (custodianChildren != null && !custodianChildren.isEmpty()) {
          for (Iterator iter = custodianChildren.iterator(); iter.hasNext(); ) {
            User child = (User) iter.next();
            relationsTable.add(getRelatedUserLink(child), 1, row);
            if (children != null && !children.contains(child)) {
              relationsTable.add(star, 1, row);
            }
            relationsTable.add(
                PersonalIDFormatter.format(child.getPersonalID(), iwc.getCurrentLocale()),
                2,
                row++);
            row++;
          }
        }
      } catch (Exception e2) {
      }
    }
    relationsTable.setWidth(1, "300");
    row++;

    Text infoText =
        new Text(
            iwrb.getLocalizedString(
                "person_is_only_custodian", "* Not child, person is only custodian"));
    infoText.setStyleClass(STYLENAME_TEXT);
    relationsTable.add(infoText, 1, row++);
    row++;

    relationsTable.setAlignment(2, row, Table.HORIZONTAL_ALIGN_RIGHT);
    relationsTable.add(getEditButton(iwc, ACTION_EDIT_RELATIONS), 2, row);

    addToMainPart(relationsTable);
  }
  private void drawForm(IWContext iwc) {
    Form form = new Form();
    Table T = new Table();
    T.setCellpadding(2);
    T.setCellspacing(2);
    T.setBorder(0);
    form.add(T);

    Table table = new Table();
    //		table.setWidth(getWidth());
    table.setCellpadding(2);
    table.setCellspacing(2);
    table.setBorder(0);
    T.add(table, 1, 1);
    T.setWidth(2, 1, "20");

    T.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_BOTTOM);
    T.setVerticalAlignment(3, 1, Table.VERTICAL_ALIGN_BOTTOM);

    int row = 1;

    String personalID =
        PersonalIDFormatter.format(
            user.getPersonalID(), iwc.getIWMainApplication().getSettings().getApplicationLocale());

    table.add(new Break(2), 1, row);
    table.add(getSmallHeader(localize(KEY_PID, DEFAULT_PID)), 1, row);

    if (user.getPersonalID() != null) {
      table.add(getSmallText(personalID), 2, row);
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_BOTTOM);
      table.setVerticalAlignment(2, row, Table.VERTICAL_ALIGN_BOTTOM);
    }
    row++;
    table.add(getSmallHeader(localize(KEY_LOGIN, DEFAULT_LOGIN)), 1, row);
    LoginTable loginTable =
        LoginDBHandler.getUserLogin(((Integer) user.getPrimaryKey()).intValue());
    if (loginTable != null) {
      table.add(new HiddenInput(PARAMETER_OLD_LOGIN, loginTable.getUserLogin()), 2, row);
      table.add(getSmallText(loginTable.getUserLogin()), 2, row);
      table.setVerticalAlignment(1, row, Table.VERTICAL_ALIGN_BOTTOM);
      table.setVerticalAlignment(2, row, Table.VERTICAL_ALIGN_BOTTOM);
    }

    String valueCurrentPassword =
        iwc.getParameter(PARAMETER_CURRENT_PASSWORD) != null
            ? iwc.getParameter(PARAMETER_CURRENT_PASSWORD)
            : "";
    String valueNewPassword =
        iwc.getParameter(PARAMETER_NEW_PASSWORD) != null
            ? iwc.getParameter(PARAMETER_NEW_PASSWORD)
            : "";
    String valueNewPasswordRepeated =
        iwc.getParameter(PARAMETER_NEW_PASSWORD_REPEATED) != null
            ? iwc.getParameter(PARAMETER_NEW_PASSWORD_REPEATED)
            : "";

    // Text tLogin = getSmallHeader(localize(KEY_LOGIN, DEFAULT_LOGIN));
    Text tCurrentPassword =
        getSmallHeader(localize(KEY_CURRENT_PASSWORD, DEFAULT_CURRENT_PASSWORD));
    Text tNewPassword = getSmallHeader(localize(KEY_NEW_PASSWORD, DEFAULT_NEW_PASSWORD));
    Text tNewPasswordRepeated =
        getSmallHeader(localize(KEY_NEW_PASSWORD_REPEATED, DEFAULT_NEW_PASSWORD_REPEATED));

    PasswordInput tiCurrentPassword =
        (PasswordInput) getStyledInterface(new PasswordInput(PARAMETER_CURRENT_PASSWORD));
    if (valueCurrentPassword != null) {
      tiCurrentPassword.setValue(valueCurrentPassword);
    }
    PasswordInput tiNewPassword =
        (PasswordInput) getStyledInterface(new PasswordInput(PARAMETER_NEW_PASSWORD));
    if (valueNewPassword != null) {
      tiNewPassword.setValue(valueNewPassword);
    }
    PasswordInput tiNewPasswordRepeated =
        (PasswordInput) getStyledInterface(new PasswordInput(PARAMETER_NEW_PASSWORD_REPEATED));
    if (valueNewPasswordRepeated != null) {
      tiNewPasswordRepeated.setValue(valueNewPasswordRepeated);
    }

    SubmitButton sbUpdate =
        (SubmitButton)
            getStyledInterface(
                new SubmitButton(
                    localize(KEY_UPDATE, DEFAULT_UPDATE), PARAMETER_FORM_SUBMIT, "true"));

    row++;
    table.setHeight(row, 12);

    if (requirePasswordVerification) {
      row++;
      table.add(tCurrentPassword, 1, row);
      table.add(tiCurrentPassword, 2, row);
    }

    row++;
    table.add(tNewPassword, 1, row);
    table.add(tiNewPassword, 2, row);

    row++;
    table.add(tNewPasswordRepeated, 1, row);
    table.add(tiNewPasswordRepeated, 2, row);

    row++;
    table.setHeight(row, 12);

    row++;
    table.mergeCells(1, row, 2, row);
    table.setAlignment(1, row, Table.HORIZONTAL_ALIGN_RIGHT);

    table.add(Text.NON_BREAKING_SPACE, 1, row);
    table.add(sbUpdate, 1, row);

    add(form);
  }
  public UIComponent getOverviewForm() {
    Form myForm = new Form();
    myForm.setName(prmForm);
    Table T = new Table(3, 3);
    T.setCellpadding(0);
    T.setCellspacing(0);
    T.setBorder(0);
    T.setBorderColor("#000000");
    T.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_TOP);
    T.setVerticalAlignment(3, 1, Table.VERTICAL_ALIGN_TOP);
    // T.setVerticalAlignment(1, 4, Table.VERTICAL_ALIGN_BOTTOM);
    // T.add(getNavigationTree(iwc), 1, 1);
    T.add(getNavigationTree(), 1, 1);
    //	T.add(getInfoLayer(), 2, 1);

    T.add(new Break(3), 3, 1);
    //		T.setHeight(1, 3, "130");
    // T.setHeight(1, 4, "90");
    T.setWidth(2, 1, "40");
    myForm.add(T);

    Page pVisit = this.getParentPage();
    if (pVisit != null) {
      Script S = pVisit.getAssociatedScript();
      // pVisit.setOnLoad("setRowColor(document.getElementById('inf1_1'));");

      S.addFunction("setRowColor(obj)", setRowColorScript());
      S.addFunction("showHideLayer(obj)", showHideLayerScript());
      Script timeScript = myForm.getAssociatedFormScript();
      if (timeScript == null) {
        timeScript = new Script();
        myForm.setAssociatedFormScript(timeScript);
      }
    }

    ArrayList texts1 = new ArrayList();
    ArrayList texts2 = new ArrayList();

    if (age != null && age.getYears() >= 70) {
      texts1.add(localize(keySet1Text1U1, "Texten"));
      texts1.add(localize(keySet1Text2U1, "Texten"));
      texts1.add(localize(keySet1Text3U1, "Texten"));
      texts1.add(localize(keySet1Text4U1, "Texten"));
      texts1.add(localize(keySet1Text5U1, "Texten"));

      texts2.add(localize(keySet2Text1U1, "Texten"));
      texts2.add(localize(keySet2Text2U1, "Texten"));
      texts2.add(localize(keySet2Text3U1, "Texten"));
      texts2.add(localize(keySet2Text4U1, "Texten"));
      texts2.add(localize(keySet2Text5U1, "Texten"));

    } else {
      texts1.add(localize(keySet1Text1U2, "Texten"));
      texts1.add(localize(keySet1Text2U2, "Texten"));
      texts1.add(localize(keySet1Text3U2, "Texten"));
      texts1.add(localize(keySet1Text4U2, "Texten"));
      texts1.add(localize(keySet1Text5U2, "Texten"));

      texts2.add(localize(keySet2Text1U2, "Texten"));
      texts2.add(localize(keySet2Text2U2, "Texten"));
      texts2.add(localize(keySet2Text3U2, "Texten"));
      texts2.add(localize(keySet2Text4U2, "Texten"));
      texts2.add(localize(keySet2Text5U2, "Texten"));
    }

    Layer layerOut = new Layer(Layer.DIV);
    layerOut.setVisibility("visible");
    layerOut.setOverflow("scroll");
    layerOut.setPositionType("absolute");
    layerOut.setWidth("280");
    layerOut.setHeight("170");
    layerOut.setMarkupAttribute("class", "ehealth_div");

    Layer layer = new Layer(Layer.DIV);
    layer.setVisibility("hidden");
    layer.setOverflow("hidden");
    layer.setPositionType("absolute");
    layer.setWidth("250");
    layer.setHeight("145");
    layer.setMarkupAttribute("class", "ehealth_div_no_border");

    int theRow = 1;
    int i = 1;

    Iterator iter1 = texts1.iterator();
    Iterator iter2 = texts2.iterator();

    while (iter1.hasNext()) {
      Layer layers = (Layer) layer.clone();
      layers.setID("info" + i + "_" + theRow);
      String text = (String) iter1.next();
      layers.add(text);
      layerOut.add(layers);

      theRow++;
    }
    i++;
    theRow = 1;
    while (iter2.hasNext()) {
      Layer layers = (Layer) layer.clone();
      layers.setID("info" + i + "_" + theRow);
      String text = (String) iter2.next();
      layers.add(text);
      layerOut.add(layers);

      theRow++;
    }

    T.add(layerOut, 3, 1);
    return myForm;
  }
  private Layer getInfoLayer(int theCase) {
    Layer layerInfo = new Layer(Layer.DIV);
    // layerInfo.setOverflow("hidden");
    // layerInfo.setVisibility("hidden");
    layerInfo.setPositionType("relative");

    layerInfo.setWidth("270");
    layerInfo.setHeight("100");
    layerInfo.setStyleClass("ehealth_row_outer_div");

    Table tableInfo = new Table(1, 10);
    tableInfo.setNoWrap();
    tableInfo.setCellpadding(0);
    tableInfo.setCellspacing(0);
    tableInfo.setBorder(0);
    // tableInfo.setWidth(200);
    int column = 1;
    tableInfo.setWidth(column, 1, "200");
    // tableInfo.setWidth(column++, 1, "70");

    Image transpImg = Table.getTransparentCell(_iwc);
    transpImg.setWidth(15);
    transpImg.setHeight(16);

    Layer layer = new Layer(Layer.DIV);
    layer.setOnMouseOver("setRowColor(this);");
    layer.setPositionType("relative");
    // layer.setHeight(20);
    layer.setStyleClass("ehealth_row_div");

    Image corners = getBundle(_iwc).getImage("thirdLevel.gif");
    corners.setBorder(0);
    corners.setHeight(16);
    corners.setWidth(19);
    layer.setBackgroundImage(corners);

    int theRow = 1;

    ArrayList cases = new ArrayList();
    if (age != null && age.getYears() >= 70) {
      if (theCase == 1) {
        cases.add("Vårdplats:");
        cases.add("Journalanteckningar:");
        cases.add("Remisser och svar:");
        // cases.add("Läkemedel:");
      } else if (theCase == 2) {
        cases.add("Vårdplats:");
        cases.add("Journalanteckningar:");
        cases.add("Remisser och svar:");
      }
    } else {
      if (theCase == 1) {
        cases.add("Vårdplats:");
        cases.add("Journalanteckningar:");
        // cases.add("Läkemedel:");
      } else if (theCase == 2) {
        cases.add("Vårdplats:");
        cases.add("Journalanteckningar:");
        // cases.add("Läkemedel:");
      }
    }

    Iterator iter = cases.iterator();

    while (iter.hasNext()) {

      Layer layers = (Layer) layer.clone();
      layers.setID("inf" + theCase + "_" + theRow);
      String text = (String) iter.next();
      layers.add(text);
      tableInfo.add(layers, column, theRow);
      theRow++;
    }

    layerInfo.add(tableInfo);

    return layerInfo;
  }
  /*
   * (non-Javadoc)
   *
   * @see is.idega.idegaweb.member.presentation.UserEditor#presentateButtonRegister(com.idega.presentation.IWContext)
   */
  protected void presentButtonRegister(IWContext iwc) {
    try {
      int pageID = getParentPageID();
      Integer thisPageID = pageID > 0 ? new Integer(pageID) : null;
      Table bTable = new Table(9, 2);

      CommuneFamilyService logic = getFamilyService(iwc);
      Integer userID = (Integer) user.getPrimaryKey();
      Image addImage = iwb.getImage("shared/edit.gif", 12, 12);
      bTable.setWidth(3, 10);
      bTable.setWidth(6, 10);

      SubmitButton spouseButton =
          getConnectorButton(
              iwc,
              addImage,
              iwrb.getLocalizedString("mbe.register_spouse", "Register spouse"),
              userID,
              logic.getSpouseRelationType(),
              null,
              thisPageID);
      bTable.add(spouseButton, 1, 1);
      bTable.add(getText(iwrb.getLocalizedString("mbe.register_spouse", "Register spouse")), 2, 1);

      SubmitButton mateButton =
          getConnectorButton(
              iwc,
              addImage,
              iwrb.getLocalizedString("mbe.register_mate", "Register mate"),
              userID,
              logic.getCohabitantRelationType(),
              null,
              thisPageID);
      bTable.add(mateButton, 1, 2);
      bTable.add(getText(iwrb.getLocalizedString("mbe.register_mate", "Register mate")), 2, 2);

      SubmitButton parentButton =
          getConnectorButton(
              iwc,
              addImage,
              iwrb.getLocalizedString("mbe.register_parent", "Register parent"),
              userID,
              logic.getChildRelationType(),
              logic.getParentRelationType(),
              thisPageID);
      bTable.add(parentButton, 4, 1);
      bTable.add(getText(iwrb.getLocalizedString("mbe.register_parent", "Register parent")), 5, 1);

      SubmitButton custodianButton =
          getConnectorButton(
              iwc,
              addImage,
              iwrb.getLocalizedString("mbe.register_custodian", "Register custodian"),
              userID,
              logic.getChildRelationType(),
              logic.getCustodianRelationType(),
              thisPageID);
      bTable.add(custodianButton, 4, 2);
      bTable.add(
          getText(iwrb.getLocalizedString("mbe.register_custodian", "Register custodian")), 5, 2);

      SubmitButton childButton =
          getConnectorButton(
              iwc,
              addImage,
              iwrb.getLocalizedString("mbe.register_parential_child", "Register parential child"),
              userID,
              logic.getParentRelationType(),
              logic.getChildRelationType(),
              thisPageID);
      bTable.add(childButton, 7, 1);
      bTable.add(
          getText(
              iwrb.getLocalizedString("mbe.register_parential_child", "Register parential child")),
          8,
          1);

      SubmitButton custodyChildButton =
          getConnectorButton(
              iwc,
              addImage,
              iwrb.getLocalizedString("mbe.register_custody_child", "Register custody child"),
              userID,
              logic.getCustodianRelationType(),
              logic.getChildRelationType(),
              thisPageID);
      bTable.add(custodyChildButton, 7, 2);
      bTable.add(
          getText(iwrb.getLocalizedString("mbe.register_custody_child", "Register custody child")),
          8,
          2);
      addButton(bTable);
    } catch (RemoteException e) {
      e.printStackTrace();
    }
  }
  public PresentationObject getCatalog(
      ProductCatalog productCatalog, IWContext iwc, List productCategories)
      throws RemoteException, FinderException {
    this.localeID = iwc.getCurrentLocaleId();
    this.locale = iwc.getCurrentLocale();
    this.defaultLocale = iwc.getIWMainApplication().getSettings().getDefaultLocale();
    this.defaultLocaleID = ICLocaleBusiness.getLocaleId(this.defaultLocale);

    Table table = new Table();
    table.setWidth("100%");
    table.setCellspacing(1);
    table.setCellpadding(2);

    Collection products = productCatalog.getProducts(productCategories);
    Iterator iter = products.iterator();
    Iterator catIter = productCategories.iterator();

    int row = 1;
    int column = 1;
    int imageColumn = 1;

    Hashtable metaDataTypes = new Hashtable();

    table.add(
        productCatalog.getHeader(
            productCatalog.iwrb.getLocalizedString("product.product", "Product")),
        column++,
        row);
    List metadataKeys = new Vector();
    String[] metadata = new String[10 + column];

    while (catIter.hasNext()) {
      ICCategory element = (ICCategory) catIter.next();
      metaDataTypes.putAll(
          getCategoryService(iwc).getInheritedMetaDataTypes(element.getMetaDataTypes(), element));
    }

    if (!metaDataTypes.isEmpty()) {
      Set set = metaDataTypes.keySet();
      Iterator setIter = set.iterator();
      while (setIter.hasNext()) {
        String key = setIter.next().toString();
        if (!metadataKeys.contains(key)) {
          metadataKeys.add(key);
          metadata[column] = key;
          table.add(
              productCatalog.getHeader(productCatalog.iwrb.getLocalizedString(METADATA + key, key)),
              column++,
              row);
        }
      }
    }
    imageColumn = column;
    table.add(
        productCatalog.getHeader(
            productCatalog.iwrb.getLocalizedString("product.images", "Images")),
        column++,
        row);
    table.setRowColor(row, productCatalog.getHeaderBackgroundColor());

    Product product;
    String key;
    String meta;
    Locale localeInUse;
    int localeIDinUse;
    while (iter.hasNext()) {
      ++row;
      product = (Product) iter.next();

      if (null == product.getProductName(this.localeID, null)) {
        localeInUse = this.defaultLocale;
        localeIDinUse = this.defaultLocaleID;
      } else {
        localeInUse = this.locale;
        localeIDinUse = this.localeID;
      }

      if (productCatalog.hasEditPermission()) {
        table.add(productCatalog.getProductEditorLink(product), 1, row);
      }
      table.add(
          productCatalog.getNamePresentationObject(
              product, product.getProductName(localeIDinUse), false),
          1,
          row);
      for (int i = 0; i < metadata.length; i++) {
        key = metadata[i];
        if (key != null) {
          meta = product.getMetaData(METADATA + key + "_" + localeInUse.toString());
          if (meta != null) {
            table.add(productCatalog.getText(meta), i, row);
          }
        }
      }

      // Collection coll = getEditorBusiness(iwc).getFiles(product);
      Collection coll;
      try {
        coll = product.getICFile();
        Iterator images = coll.iterator();
        Image image;
        int counter = 0;
        while (images.hasNext()) {
          ++counter;
          try {
            image =
                new Image(
                    new Integer(((ICFile) images.next()).getPrimaryKey().toString()).intValue());
            Window window = new Window(image);

            Link link = new Link(productCatalog.getText(Integer.toString(counter)));

            if (productCatalog._iconPhoto != null) {
              link = new Link(productCatalog._iconPhoto);
            }

            link.setWindow(window);

            table.add(link, imageColumn, row);
            table.add(productCatalog.getText(Text.NON_BREAKING_SPACE), imageColumn, row);
          } catch (Exception e) {
            e.printStackTrace(System.err);
          }
        }
      } catch (IDORelationshipException e1) {
        e1.printStackTrace();
      }

      table.setRowColor(row, productCatalog.getBackgroundColor());
    }

    return table;
  }
  private Table getPlacementTable(IWContext iwc) throws RemoteException {
    Table table = new Table();
    // table.setColor("#DDDDDD");
    table.setBorder(0);
    table.setWidth(Table.HUNDRED_PERCENT);
    table.setCellpadding(1);
    table.setCellspacing(2);
    int col = 1;
    int row = 1;

    // *** HEADING Placements ***
    Text pupilTxt = new Text(localize(KEY_PLACEMENTS_HEADING, "Placements"));
    pupilTxt.setFontStyle(STYLE_UNDERLINED_SMALL_HEADER);
    table.add(pupilTxt, col++, row);
    table.setRowHeight(row, "40");
    table.setRowVerticalAlignment(row, Table.VERTICAL_ALIGN_BOTTOM);
    table.mergeCells(col, row, table.getColumns(), row);
    col = 1;
    row++;

    // empty space row
    table.add(this.transGIF, col, row);
    table.setRowHeight(row, "10");
    col = 1;
    row++;

    //  *** Column headings ***
    table.add(getLocalizedSmallHeader(KEY_NUMBER, "No."), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_SCHOOL_TYPE, "School type"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_PROVIDER, "Provider"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_SCHOOL_YEAR, "School year"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_STUDY_PATH, "Study path"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_SCHOOL_GROUP, "School group"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_START_DATE, "Start date"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_END_DATE, "End date"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_REGISTRATOR, "Registrator"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_REGISTRATION_CREATED_DATE, "Created date"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_PLACEMENT_PARAGRAPH_SHORT, "Par"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(getLocalizedSmallHeader(KEY_NOTES, "Notes"), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(Text.getNonBrakingSpace(), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
    table.add(Text.getNonBrakingSpace(), col, row);
    table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);

    table.setRowColor(row, getHeaderColor());

    table.setRowHeight(row, "18");
    row++;

    // Loop placements
    Collection placements = null;
    try {
      if (this.pupil != null) {
        placements =
            getSchoolBusiness(iwc)
                .getSchoolClassMemberHome()
                .findAllOrderedByRegisterDate(this.pupil);
      }
    } catch (FinderException e) {
    }

    if (placements != null && placements.size() > 0) {
      int zebra = 0;
      int rowNum = 0;
      table.add(new HiddenInput(PARAM_REMOVE_PLACEMENT, "-1"), 1, 1);
      for (Iterator iter = placements.iterator(); iter.hasNext(); ) {
        rowNum++;
        SchoolClassMember plc = (SchoolClassMember) iter.next();
        col = 1;

        // Row number
        table.add(getSmallText(String.valueOf(rowNum)), col++, row);
        // School type
        try {
          table.add(getSmallText(plc.getSchoolType().getName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Provider
        try {
          table.add(getSmallText(plc.getSchoolClass().getSchool().getName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // School year
        try {
          table.add(getSmallText(plc.getSchoolYear().getName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Study path
        try {
          if (plc.getStudyPathId() != -1) {
            SchoolStudyPathHome home =
                (SchoolStudyPathHome) IDOLookup.getHome(SchoolStudyPath.class);
            SchoolStudyPath sp = home.findByPrimaryKey(new Integer(plc.getStudyPathId()));
            table.add(getSmallText(sp.getCode()), col, row);
          }
        } catch (Exception e) {
        }
        col++;
        // School type
        try {
          table.add(getSmallText(plc.getSchoolClass().getSchoolClassName()), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Start date
        try {
          String dateStr =
              getCentralPlacementBusiness(iwc).getDateString(plc.getRegisterDate(), "yyyy-MM-dd");
          table.add(getSmallText(dateStr), col++, row);
        } catch (Exception e) {
          col++;
        }
        // End date
        try {
          String dateStr =
              getCentralPlacementBusiness(iwc).getDateString(plc.getRemovedDate(), "yyyy-MM-dd");
          table.add(getSmallText(dateStr), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Registrator
        try {
          int registratorID = plc.getRegistratorId();
          User registrator = getUserBusiness(iwc).getUser(registratorID);
          if (registrator != null) {
            Name name =
                new Name(
                    registrator.getFirstName(),
                    registrator.getMiddleName(),
                    registrator.getLastName());
            table.add(
                getSmallText(name.getName(iwc.getApplicationSettings().getDefaultLocale(), false)),
                col++,
                row);
          }
        } catch (Exception e) {
          col++;
        }
        // Created date
        try {
          String dateStr =
              getCentralPlacementBusiness(iwc)
                  .getDateString(plc.getRegistrationCreatedDate(), "yyyy-MM-dd");
          table.add(getSmallText(dateStr), col++, row);
        } catch (Exception e) {
          col++;
        }
        // Placement paragraph
        try {
          if (plc.getPlacementParagraph() != null) {
            table.add(getSmallText(plc.getPlacementParagraph()), col++, row);
          } else {
            col++;
          }
        } catch (Exception e) {
          col++;
        }
        // Notes
        try {
          if (plc.getNotes() != null) {
            table.add(getSmallText(plc.getNotes()), col++, row);
          } else {
            col++;
          }
        } catch (Exception e) {
          col++;
        }
        // Pupil overview button
        try {
          // Get Pupil overview button
          String plcId = ((Integer) plc.getPrimaryKey()).toString();
          String schClassId = String.valueOf(plc.getSchoolClassId());

          Link editButt =
              new Link(this.getEditIcon(localize(KEY_TOOLTIP_PUPIL_OVERVIEW, "Pupil overview")));
          editButt.setWindowToOpen(PlacementHistoryEditPlacement.class);
          editButt.setParameter(
              SchoolAdminOverview.PARAMETER_METHOD,
              String.valueOf(SchoolAdminOverview.METHOD_OVERVIEW));
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_METHOD,
              String.valueOf(SchoolAdminOverview.METHOD_OVERVIEW));
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SHOW_ONLY_OVERVIEW, "true");
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SHOW_NO_CHOICES, "true");
          editButt.addParameter(SchoolAdminOverview.PARAMETER_PAGE_ID, getParentPage().getPageID());
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_USER_ID, String.valueOf(plc.getClassMemberId()));
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SCHOOL_CLASS_ID, schClassId);
          editButt.addParameter(SchoolAdminOverview.PARAMETER_SCHOOL_CLASS_MEMBER_ID, plcId);
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_RESOURCE_PERMISSION,
              SchoolAdminOverview.PARAMETER_RESOURCE_PERM_VALUE_CENTRAL_ADMIN);
          editButt.addParameter(
              SchoolAdminOverview.PARAMETER_FROM_CENTRAL_PLACEMENT_EDITOR, "true");
          if (plc.getRemovedDate() != null) {
            editButt.addParameter(
                SchoolAdminOverview.PARAMETER_SCHOOL_CLASS_MEMBER_REMOVED_DATE,
                plc.getRemovedDate().toString());
          }

          table.add(editButt, col, row);
          table.setAlignment(col++, row, Table.HORIZONTAL_ALIGN_CENTER);
        } catch (Exception e) {
          col++;
        }
        // Remove button
        try {
          // Get remove button
          Image delImg = getDeleteIcon(localize(KEY_TOOLTIP_REMOVE_PLC, "Delete placement"));
          int plcID = ((Integer) plc.getPrimaryKey()).intValue();

          SubmitButton delButt = new SubmitButton(delImg);
          delButt.setValueOnClick(PARAM_REMOVE_PLACEMENT, String.valueOf(plcID));
          delButt.setSubmitConfirm(
              localize(
                  KEY_CONFIRM_REMOVE_PLC_MSG,
                  "Do you really want to erase this school placement and its resource placements?"));
          delButt.setToolTip(localize(KEY_TOOLTIP_REMOVE_PLC, "Delete school placement"));
          table.add(delButt, col, row);
          table.setAlignment(col, row, Table.HORIZONTAL_ALIGN_CENTER);
        } catch (Exception e) {
        }

        String zebraColor = zebra % 2 == 0 ? getZebraColor2() : getZebraColor1();
        table.setRowColor(row, zebraColor);
        col = 2;
        row++;

        // Resources
        String rscStr = getResourceBusiness(iwc).getResourcesStringXtraInfo(plc);
        if (!("".equals(rscStr))) {
          table.add(
              getSmallText("<i>" + localize(KEY_RESOURCES, "Resources") + ":</i> "), col, row);
          table.add(getSmallText("<i>" + rscStr + "</i>"), col, row);
          table.setRowColor(row, zebraColor);
          table.mergeCells(col, row, table.getColumns(), row);
          row++;
        }

        zebra++;
      }
    }

    col = 1;

    // empty space row
    table.add(this.transGIF, col, row);
    table.setRowHeight(row, "20");

    return table;
  }
  public Table getPupilTable(IWContext iwc, User pupil) {
    // *** Search Table *** START - the uppermost table
    Table table = new Table();
    table.setWidth("100%");
    table.setBorder(0);
    table.setCellpadding(2);
    table.setCellspacing(0);
    this.transGIF.setHeight("1");
    this.transGIF.setWidth("1");

    int row = 1;
    int col = 1;
    // add empty space row
    table.add(this.transGIF, col++, row);
    table.add(this.transGIF, col++, row);
    table.add(this.transGIF, col++, row);
    table.add(this.transGIF, col++, row);
    table.add(this.transGIF, col++, row);
    // Set COLUMN WIDTH for column 1 to 5
    table.setWidth(1, row, "100");
    // table.setWidth(2, row, "70");
    // table.setWidth(3, row, "70");
    // table.setWidth(4, row, "70");
    // table.setWidth(5, row, "104");

    row++;
    col = 1;

    // *** HEADING Pupil ***
    Text pupilTxt = new Text(localize(KEY_PUPIL_HEADING, "Pupil"));
    pupilTxt.setFontStyle(STYLE_UNDERLINED_SMALL_HEADER);
    table.add(pupilTxt, col++, row);
    table.setRowHeight(row, "20");
    table.setRowVerticalAlignment(row, Table.VERTICAL_ALIGN_BOTTOM);
    row++;
    col = 1;

    // empty space row
    table.add(this.transGIF, col, row);
    table.setRowHeight(row, "5");
    col = 1;
    row++;

    // Personal Id Number
    table.add(getSmallHeader(localize(KEY_PERSONAL_ID_LABEL, "Personal id: ")), col++, row);
    if (pupil != null) {
      table.add(getSmallText(pupil.getPersonalID()), col++, row);
    }
    row++;
    col = 1;
    // Last Name
    table.add(getSmallHeader(localize(KEY_LAST_NAME_LABEL, "Last name: ")), col++, row);

    Table nameTable = new Table();
    col = 1;
    nameTable.setCellpadding(0);
    nameTable.setCellspacing(0);
    if (pupil != null) {
      nameTable.add(getSmallText(pupil.getLastName()), col++, 1);
    }
    // First Name
    nameTable.add(getSmallHeader(localize(KEY_FIRST_NAME_LABEL, "First name: ")), col++, 1);
    if (pupil != null) {
      nameTable.add(getSmallText(pupil.getFirstName()), col++, 1);
    }
    nameTable.setWidth(1, 1, "100");
    nameTable.setWidth(2, 1, "100");
    nameTable.setWidth(3, 1, "100");
    table.add(nameTable, 2, row);
    table.mergeCells(2, row, 5, row);
    row++;
    col = 1;

    // Address and Phone
    table.add(getSmallHeader(localize(KEY_ADDRESS_LABEL, "Address: ")), col++, row);
    row++;
    col = 1;
    table.add(getSmallHeader(localize(KEY_PHONE_LABEL, "Phone: ")), col++, row);
    if (pupil != null) {
      try {
        // pupil address
        Address address = getUserBusiness(iwc).getUsersMainAddress(pupil);
        StringBuffer aBuf = new StringBuffer(address.getStreetAddress());
        aBuf.append(", ");
        aBuf.append(address.getPostalCode().getPostalAddress());
        row--;
        table.add(getSmallText(aBuf.toString()), col, row);
        row++;
        // Get pupil phones
        Collection phones = pupil.getPhones();
        int i = 0;
        int phonesSize = phones.size();
        StringBuffer pBuf = new StringBuffer();
        for (Iterator iter = phones.iterator(); iter.hasNext(); i++) {
          Phone phone = (Phone) iter.next();
          pBuf.append(phone.getNumber());
          if (i < phonesSize - 1) {
            pBuf.append(", ");
          }
        }
        pBuf.append("&nbsp;");
        table.add(getSmallText(pBuf.toString()), col, row);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    row++;
    col = 1;

    return table;
  }
  // public PresentationObject getVisitForm(IWContext iwc, User userVK) throws
  // java.rmi.RemoteException {
  public UIComponent getDoctorForm() {
    IWResourceBundle iwrb = this.getResourceBundle(_iwc);
    Form myForm = new Form();
    myForm.setName(prmForm);

    Table table = new Table(3, 3);
    table.setCellpadding(0);
    table.setCellspacing(0);
    table.setBorder(0);
    table.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_TOP);
    table.setVerticalAlignment(3, 1, Table.VERTICAL_ALIGN_TOP);
    table.setVerticalAlignment(1, 2, Table.VERTICAL_ALIGN_BOTTOM);
    table.setVerticalAlignment(1, 3, Table.VERTICAL_ALIGN_BOTTOM);

    table.setWidth(400);
    table.setWidth(2, 1, 15);
    table.setWidth(1, 1, 73);

    myForm.add(table);

    Age age = null;
    String doctorInfo = null;

    if (user != null && user.getDateOfBirth() != null) age = new Age(user.getDateOfBirth());
    else if (user != null && user.getPersonalID() != null)
      age = new Age(PIDChecker.getInstance().getDateFromPersonalID(user.getPersonalID()));

    int userIDDr = 45;

    if (age != null && age.getYears() >= 70) {
      userIDDr = 46; // 45   41047
    }

    PresentationObject picture = null;
    User doctor = null;

    int userImageID = -1;
    try {
      doctor =
          ((UserBusiness) IBOLookup.getServiceInstance(_iwc, UserBusiness.class)).getUser(userIDDr);
    } catch (Exception fe) {
      log(fe);
    }

    if (doctor != null) userImageID = doctor.getSystemImageID();

    if (userImageID == -1) {
      Table fakeImageTable = new Table(1, 1);
      fakeImageTable.setAlignment(1, 1, Table.HORIZONTAL_ALIGN_CENTER);
      fakeImageTable.setBorder(4);
      fakeImageTable.setHeight(140);
      fakeImageTable.setWidth(100);
      String fakeImageColor = "#CCCCCC";
      Text photoText = new Text(iwrb.getLocalizedString("managerview.photo_text", "Photo"));
      photoText.setBold();
      photoText.setFontColor(fakeImageColor);
      photoText.setFontSize(Text.FONT_SIZE_12_STYLE_TAG);
      fakeImageTable.add(photoText, 1, 1);
      fakeImageTable.setBorderColor(fakeImageColor);
      picture = fakeImageTable;
    } else {
      Image image = new Image();
      image.setImageID(userImageID);
      image.setWidth(73);

      picture = image;
    }
    table.add(picture, 1, 1);

    if (age != null && age.getYears() >= 70) {
      doctorInfo =
          "<b>Dr. Inga Pren</b><br>Allmänläkare<br>Telefon:<br>018-987624<br>Telefontid: Mån-ons, kl 08:30-10.00<br>Webbsida: <a href='http://www.flogsta.se' target='_new'>www.flogsta.se</a>";
    } else {
      doctorInfo =
          "<b>Dr. Magne Syhl</b><br>Allmänläkare<br>Telefon:<br>018-987654<br>Telefontid: Mån-ons, kl 08-10.00<br>Webbsida: <a href='http://www.gimovc.se' target='_new'>www.gimovc.se</a>";
    }

    table.add(doctorInfo, 3, 1);
    GenericButton message =
        getButton(new GenericButton("send_message", localize(prmSendMessage, "Send message")));
    if (_messagePage != null) message.setPageToOpen(_messagePage);

    table.add(message, 3, 2);
    table.setHeight(3, 2, "25");

    GenericButton visitbooking =
        getButton(new GenericButton("visit", localize(prmVisitBooking, "Book an appointment")));
    if (_appointmentPage != null) visitbooking.setPageToOpen(_appointmentPage);

    SubmitButton smb = new SubmitButton();
    smb.setStyleClass("ehealth_InterfaceButton");
    smb.setValue("Skicka meddelande >");
    smb.setPageToOpen(132);

    table.add(visitbooking, 3, 3);

    return myForm;
  }
  /*
   * (non-Javadoc)
   *
   * @see is.idega.idegaweb.member.presentation.UserEditor#presentateUserRelations(com.idega.presentation.IWContext)
   */
  protected void editUserRelations(IWContext iwc) throws RemoteException {
    Table relationsTable = new Table();
    relationsTable.setWidth(Table.HUNDRED_PERCENT);
    relationsTable.setCellspacing(4);
    int row = 1;

    if (user != null) {
      addSeperator(iwrb.getLocalizedString("mbe.user_relations", "User relations"));
      CommuneFamilyService familyService = getFamilyService(iwc);
      // partner handling
      relationsTable.add(getHeader(iwrb.getLocalizedString("mbe.spouse", "Spouse")), 1, row);
      User partner = null;
      try {
        partner = familyService.getSpouseFor(this.user);
      } catch (NoSpouseFound e) {
      } catch (Exception e) {
      }
      if (partner != null) {
        relationsTable.add(getRelatedUserLink(partner), 2, row);
        relationsTable.add(
            getDisconnectorLink(
                familyService.getSpouseRelationType(),
                null,
                (Integer) user.getPrimaryKey(),
                (Integer) partner.getPrimaryKey(),
                getDeleteIcon(
                    iwrb.getLocalizedString(
                        "mbe.remove_spouse_relation", "Remove spouse relationship"))),
            3,
            row);
      }

      // cohabitant handling
      relationsTable.add(
          getHeader(iwrb.getLocalizedString("mbe.cohabitant", "Cohabitant")), 5, row);
      User cohabitant = null;
      try {
        cohabitant = familyService.getCohabitantFor(this.user);
      } catch (NoCohabitantFound e) {
      }
      if (cohabitant != null) {
        relationsTable.add(getRelatedUserLink(cohabitant), 6, row);
        relationsTable.add(
            getDisconnectorLink(
                familyService.getCohabitantRelationType(),
                null,
                (Integer) user.getPrimaryKey(),
                (Integer) cohabitant.getPrimaryKey(),
                getDeleteIcon(
                    iwrb.getLocalizedString(
                        "mbe.remove_cohabitant_relation", "Remove cohabitant relationship"))),
            7,
            row);
      }
      row++;

      // parent handling
      int parentStartRow = row, custodianStartRow = row;
      relationsTable.add(getHeader(iwrb.getLocalizedString("mbe.parents", "Parents")), 1, row);
      Collection parents = null;
      try {
        parents = familyService.getParentsFor(user);
        if (parents != null && !parents.isEmpty()) {
          for (Iterator iter = parents.iterator(); iter.hasNext(); ) {
            User parent = (User) iter.next();
            relationsTable.add(getRelatedUserLink(parent), 2, parentStartRow);
            String relationType = familyService.getParentRelationType();
            relationsTable.add(
                getDisconnectorLink(
                    null,
                    relationType,
                    (Integer) user.getPrimaryKey(),
                    (Integer) parent.getPrimaryKey(),
                    getDeleteIcon(
                        iwrb.getLocalizedString(
                            "mbe.remove_parent_relation", "Remove parent relationship"))),
                3,
                parentStartRow);
            parentStartRow++;
          }
        }
      } catch (Exception e1) {
      }

      // custodians handling
      relationsTable.add(
          getHeader(iwrb.getLocalizedString("mbe.custodians", "Custodians")), 5, custodianStartRow);
      Collection custodians = null;
      try {
        custodians = familyService.getCustodiansFor(user, false);
        if (custodians != null && !custodians.isEmpty()) {
          for (Iterator iter = custodians.iterator(); iter.hasNext(); ) {
            User custodian = (User) iter.next();
            relationsTable.add(getRelatedUserLink(custodian), 6, custodianStartRow);
            String relationType = familyService.getCustodianRelationType();
            relationsTable.add(
                getDisconnectorLink(
                    null,
                    relationType,
                    (Integer) user.getPrimaryKey(),
                    (Integer) custodian.getPrimaryKey(),
                    getDeleteIcon(
                        iwrb.getLocalizedString(
                            "mbe.remove_custodian_relation", "Remove custodian relationship"))),
                7,
                custodianStartRow);
            custodianStartRow++;
          }
        }
      } catch (Exception e1) {
      }
      row = Math.max(custodianStartRow, parentStartRow) + 1;

      // biological children handling
      relationsTable.add(
          getHeader(iwrb.getLocalizedString("mbe.parential_children", "Parential children")),
          1,
          row);
      Collection children = null;
      int childrowstart = row;
      try {
        children = familyService.getChildrenFor(user);
        if (children != null && !children.isEmpty()) {
          for (Iterator iter = children.iterator(); iter.hasNext(); ) {
            User child = (User) iter.next();
            relationsTable.add(getRelatedUserLink(child), 2, row);
            relationsTable.add(
                getDisconnectorLink(
                    familyService.getParentRelationType(),
                    null,
                    (Integer) user.getPrimaryKey(),
                    (Integer) child.getPrimaryKey(),
                    getDeleteIcon(
                        iwrb.getLocalizedString(
                            "mbe.remove_child_relation", "Remove child relationship"))),
                3,
                row);
            row++;
          }
        }
      } catch (Exception e2) {
      }
      // custody children handling
      row = childrowstart;
      relationsTable.add(
          getHeader(iwrb.getLocalizedString("mbe.custody_children", "Custody children")), 5, row);
      try {
        children = familyService.getChildrenInCustodyOf(user);
        if (children != null && !children.isEmpty()) {
          for (Iterator iter = children.iterator(); iter.hasNext(); ) {
            User child = (User) iter.next();
            relationsTable.add(getRelatedUserLink(child), 6, row);
            relationsTable.add(
                getDisconnectorLink(
                    familyService.getCustodianRelationType(),
                    null,
                    (Integer) user.getPrimaryKey(),
                    (Integer) child.getPrimaryKey(),
                    getDeleteIcon(
                        iwrb.getLocalizedString(
                            "mbe.remove_child_relation", "Remove child relationship"))),
                7,
                row);
            row++;
          }
        }
      } catch (NoChildrenFound e3) {
        // e3.printStackTrace();
      } catch (RemoteException e3) {
        e3.printStackTrace();
      } catch (EJBException e3) {
        e3.printStackTrace();
      }
    }
    relationsTable.setWidth(2, "150");
    relationsTable.setWidth(6, "150");

    row++;
    relationsTable.mergeCells(1, row, relationsTable.getColumns(), row);
    relationsTable.setAlignment(1, row, Table.HORIZONTAL_ALIGN_RIGHT);
    relationsTable.add(getCancelButton(iwc), 1, row);

    addToMainPart(relationsTable);

    presentButtons(iwc);
    presentButtonRegister(iwc);
  }