I am having problems understanding the relationship between the concepts of Work and Energy in a electrostatic system.
As I know, the definition of Potential Energy is the ability to do work. In a gravitational field, that would be $$\mathrm{PE} = W(\mathrm{after}) = -W(\mathrm{before})$$ where $W(\mathrm{before})$ is the Work done to bring the object from infinity to a certain position in space, and $W(\mathrm{after})$ the contrary, from position to infinity.
Now, in the case of an electrostatic system, it seems that the Potential Energy is the Work required to bring the charges together (this is what most websites say, example). That would be $$\mathrm{PE} = W(\mathrm{before})$$ Does this mean that $\mathrm{PE} = -W(\mathrm{after})$? That would be for me minus the ability to do Work.
Am I completely missing the idea of $W(\mathrm{after})$ in a electrostatic system?