I attempted to install a new ceiling light in my living room today, something I have done on a dozen occasions, but when I removed the old fixture, I realized there were three separate cables with black, white and grounding wires in each.

Before I hastilly pulled the attached lamp down, I noticed that the neutral wires were all tied together, but the light was not attached to the bundle. The light was attached to two of the black wires. The grounding wires were tied up together up inside of the electrical box.

Wait, there's more! I checked the wires and only one set of wires is hot. The other two do not have power. I attempted to attach the new light to the hot wires, but when I did, the light stayed on constantly. I also noticed that this box seems to affect the front porch light and the back light. I'm sure this must be a junction of some kind, but now I don't know how to properly wire everything back. Can someone help me?