There could be several causes of such blackouts.
The most likely cause is a vasovagal attack. This occurs due to excessive strain, long periods of standing, sudden stress,etc. Link
Another cause is a similar condition called Postural hypotension. This is a sudden fall in BP which occurs with change of posture, such as standing up from a sitting position. It could also occur in long periods of sitting, such as in long drives or long flights, due to pooling of blood in the legs.
Such fainting episodes however could also be due to heart conditions. Many cardiac conditions like arrhythmias, etc could cause such fainting episodes called syncope.
Hence you need to see a doctor and get yourself checked up to rule out any cardiac conditions.
Consult your family doctor/primary care physician at the earliest for this. The likeliest cause for you though is vasovagal attack which is a benign condition and quite common at your age.
You may check up this site for some more info: http://circ.ahajournals.org/cgi/content/full/113/16/e715 http://www.clevelandclinic.org/heartcenter/pub/guide/disease/electric/syncope.htm
Hope this shows you the way forward - wish you good health and a quick recovery.
I trust my answer has helped you gain more knowledge and confidence about your problem and in knowing what to discuss with your doctor.
Please remember to rate my service once you have all the information you need. If you have any other questions, please ask me – I’ll be happy to respond. Bonus is always welcome - Thank you!