Array+DOM aware indexOf function