public int getAttachmentHost(byte type, int x, int y, Class c) {
		if (modelManager.frame == null)
			return -1;
		int zmin = Integer.MAX_VALUE;
		int imin = -1;
		switch (type) {
		case Attachment.ATOM_HOST:
			Atom[] atoms = modelManager.frame.atoms;
			if (SiteAnnotation.class == c) {
				int atomCount = modelManager.frame.atomCount;
				for (int i = 0; i < atomCount; i++) {
					if (atoms[i] == null)
						continue;
					if (atoms[i].annotationKey && atoms[i].pin != null && atoms[i].pin.withinHandle(x, y)) {
						if (atoms[i].screenZ < zmin) {
							zmin = atoms[i].screenZ;
							imin = i;
						}
					}
				}
			}
			else if (InteractionCenter.class == c) {
				for (int i = 0; i < modelManager.frame.atomCount; i++) {
					if (atoms[i].interactionKey && atoms[i].pin != null && atoms[i].pin.withinHandle(x, y)) {
						if (atoms[i].screenZ < zmin) {
							zmin = atoms[i].screenZ;
							imin = i;
						}
					}
				}
			}
			break;
		case Attachment.BOND_HOST:
			Bond[] bonds = modelManager.frame.bonds;
			int z;
			if (SiteAnnotation.class == c) {
				for (int i = 0; i < modelManager.frame.bondCount; i++) {
					if (bonds[i].annotationKey && bonds[i].pin != null && bonds[i].pin.withinHandle(x, y)) {
						z = (bonds[i].atom1.screenZ + bonds[i].atom2.screenZ) >> 1;
						if (z < zmin) {
							zmin = z;
							imin = i;
						}
					}
				}
			}
			else if (InteractionCenter.class == c) {
				for (int i = 0; i < modelManager.frame.bondCount; i++) {
					if (bonds[i].interactionKey && bonds[i].pin != null && bonds[i].pin.withinHandle(x, y)) {
						z = (bonds[i].atom1.screenZ + bonds[i].atom2.screenZ) >> 1;
						if (z < zmin) {
							zmin = z;
							imin = i;
						}
					}
				}
			}
			break;
		}
		return imin;
	}