"Janabat" is a ritual impurity caused by the discharge of semen or by sexual intercourse; and the person on whom ghusl janabat becomes wajib is known as "junub". The Qur'an says:
O you who believe! Do not go near prayers (salat) when you are ... junub until you have washed yourselves. (4:43) O you who believe! When you stand up for prayers (salat) ... if you are junub, then purify (yourselves). (5:6)
B. THE CAUSES OF GHUSL JANABAT
There are two causes of janabat:
1. Discharge of semen. It does not make any difference whether this discharge is while awake or in a wet-dream, slight or profuse, intentionally or otherwise, in lawful way or unlawful (e.g., masturbation). In all these cases ghusl janabat becomes obligatory (wajib).
If a liquid comes out from a man and he does not know whether or not it is semen, then he should look for the following three signs: (1) emission with passion; (2) spurting discharge; (3) feeling relaxed after the discharge. If these signs are found together on him, then he should consider the liquid as semen, otherwise not.
If a secretion is discharged from a woman, then it is precautionary wajib for her to do ghusl janabat provided it came with sexual passion and she felt relaxed after it. But if the secretion comes without the sexual passion or without the feeling of relaxation after the discharge, then it is not najis and therefore ghusl is not wajib upon her.
2. Sexual Intercourse. It does not make any difference whether the intercourse was lawful or unlawful, and with or without discharge of semen. In Islamic laws, sexual intercourse is defined as the penetration of the glans into the vagina or anus of the woman. That is, for ghusl janabat to become wajib it is not necessary that full penetration or discharge of semen should take place.
In case of sexual intercourse, ghusl janabat becomes wajib on both the man and the woman.
C. THE THINGS WHICH ARE FORBIDDEN FOR A JUNUB
There are certain things in Islam which are so sacred that a Muslim cannot come into contact with them unless he or she is ritually pure and clean. Based on this concept of sacredness, a junub is forbidden from coming into contact, in various ways, with two of the most sacred things in Islam: the Qur'an and the mosque.
The following four acts are haram for the junub before performing the ghusl. Two are related to the Qur'an and the other two are related to mosques.
1. Touching the writing of the Qur'an, the names and attributes of Allah, the names of the Prophet, the Imams and Fatimah (the daughter of the Prophet). This has already been explained on page 48 of this book.
2. Reciting the verses of the Qur'an in which sajdah (prostration) is wajib. These verses are: verse 15 of chapter 32; verse 15 of chapter 41; verse 62 of chapter 53; and verse 19 of chapter 96. It is better not to recite even a single verse from these chapters.
3. Entering or staying in the mosque. The Qur'an says, "O you who believe! ...Nor (are you allowed to enter the masjid) if you are junub until you have washed yourself except passing through." (4:43) Based on this verse and relevant ahadith, the mujtahids have concluded that a junub is totally forbidden from staying in the mosque.
Of course, as the verse says, one can pass through the mosques (by entering from one door and leaving from the other). However, this exception of passing through does not apply to the following places: the Masjidu'l-Haram (the Sacred Mosque at Mecca), Masjidu'n-Nabi (the Mosque of the Prophet at Medina), and shrines of the Imams-a junub cannot even pass through them. Jamil asked Imam Ja'far as-Sadiq (as) whether or not a junub can sit in mosques? The Imam said, "No! But he may pass through all of them except the Sacred Mosque (at Mecca) and the Prophet's Mosque (at Medina)."  Bakr bin Muhammad narrates that once he and his friends were going towards the house of Imam Ja'far as-Sadiq, when they met Abu Basir in the way. When Abu Basir came to know that they were going to visit the Imam, he joined them. As Bakr and his friends came to know later on, Abu Basir was in the state of janabat at that time. When they entered the house of the Imam and greeted him, the Imam looked towards Abu Basir and said, "O Abu Basir! Do not you know that a junub person should not enter the houses of the prophets?"  Abu Basir himself has also narrated this incident and quotes the Imam as follows: "Do not you know that a junub should not enter the houses of the prophets and of their children..." 
4. Leaving something in or taking it out from a mosque.
The following things are makruh (disliked) for the junub:1. Eating and drinking is makruh for a junub except after doing wudu' or gargling or rinsing the nose. 2. Reciting more than seven verses from the Qur'an. This applies to other than the four chapters with wajib sajdah mentioned above. 3. Touching the cover of the Qur'an. 4. Sleeping except after doing wudu'.
D. THE ACTS WHOSE VALIDITY DEPEND ON GHUSL JANABAT
1. Salat (prayers) except salatu '1-mayyit (the prayer for a dead Muslim) which can be performed even in the state of janabat.
2. Wajib tawaf (the circumambulation of the Ka'bah in hajj). Allah says, "And We assigned Ibrahim and Isma'il to purify My House for the circumambulators (of the Ka`bah)..." (2:125; 22:26) It is not difficult to infer that if the House is to be cleaned and purified for tawaf, then the people who will be doing the tawaf must also be clean and pure. See also section H in wudu.
3. Fasting. If someone knowingly remains junub until dawn in Ramadan, his fasting will become invalid (batil)..
 Wasa'il, vol. 1, p. 485
 Wasa'il, vol. 1, p. 489.
 Ibid. p. 489-90.