The subjunctive is most commonly used in expressions of doubt ("dudo que + subj", "no creo que + subj") and the negative and formal imperative ("no hagas eso!", "por favor, no te vayas", "venga usted conmigo"). The other common use of the subjuntive is for 'value judgements', like "me gusta que" and "es importante que". The subjuntive is also used to talk about the future when one event is dependent on another which hasn't happened yet, for example "cuando llegue a casa te llamaré" or "cuando vaya a la universidad tendré que llevar todas mis cosas conmigo". The imperfect subjunctive is used in all the same places you'd use the present subjunctive, but only when the sentence is in the past ("dudaba que ella fuera capaz de hacerlo", "era importante que tú vinieras"). The only exception to this is in 'if I could, I would..." phrases, such as "if I won/were to win the lottery, I'd buy a car" ("si me tocara la lotería, me compraría un coche"). In these cases the imperfect subjunctive is nicely signposted by the "if" and the presence of the conditional.