Bar Mitzvah Parsha Calculator
.bar-mitzvah-container {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
max-width: 800px;
margin: 20px auto;
padding: 25px;
background-color: #f9fbff;
border: 2px solid #2c3e50;
border-radius: 12px;
color: #333;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.bm-header {
text-align: center;
margin-bottom: 25px;
}
.bm-header h2 {
color: #2c3e50;
margin-bottom: 10px;
font-size: 28px;
}
.calc-section {
background: #ffffff;
padding: 20px;
border-radius: 8px;
box-shadow: inset 0 0 5px rgba(0,0,0,0.05);
margin-bottom: 30px;
}
.input-group {
margin-bottom: 15px;
}
.input-group label {
display: block;
font-weight: bold;
margin-bottom: 8px;
color: #34495e;
}
.input-group input[type="date"],
.input-group select {
width: 100%;
padding: 12px;
border: 1px solid #bdc3c7;
border-radius: 6px;
box-sizing: border-box;
font-size: 16px;
}
.checkbox-group {
display: flex;
align-items: center;
gap: 10px;
margin-top: 10px;
}
.calc-btn {
width: 100%;
background-color: #2980b9;
color: white;
padding: 15px;
border: none;
border-radius: 6px;
font-size: 18px;
font-weight: bold;
cursor: pointer;
transition: background 0.3s;
}
.calc-btn:hover {
background-color: #1f6391;
}
#bm-result {
margin-top: 20px;
padding: 20px;
border-radius: 8px;
display: none;
background-color: #e8f4fd;
border-left: 5px solid #2980b9;
}
.result-title {
font-weight: bold;
font-size: 20px;
margin-bottom: 10px;
color: #2c3e50;
}
.parsha-name {
font-size: 24px;
color: #d35400;
font-weight: 800;
}
.article-content {
line-height: 1.6;
color: #444;
}
.article-content h3 {
color: #2c3e50;
margin-top: 25px;
}
.info-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
.info-table th, .info-table td {
border: 1px solid #ddd;
padding: 12px;
text-align: left;
}
.info-table th {
background-color: #f2f2f2;
}
function calculateBarMitzvah() {
var birthDateInput = document.getElementById("birthDate").value;
var afterSunset = document.getElementById("afterSunset").checked;
if (!birthDateInput) {
alert("Please enter a valid birth date.");
return;
}
var birthDate = new Date(birthDateInput);
// 1. Calculate the 13th Civil Anniversary
var bmAnniversary = new Date(birthDate);
bmAnniversary.setFullYear(bmAnniversary.getFullYear() + 13);
// 2. Adjust for sunset (add one day to the anniversary if born after sunset)
if (afterSunset) {
bmAnniversary.setDate(bmAnniversary.getDate() + 1);
}
// 3. Find the first Saturday on or after that anniversary
var shabbatDate = new Date(bmAnniversary);
var dayOfWeek = shabbatDate.getDay(); // 0 is Sunday, 6 is Saturday
var daysToSaturday = (6 – dayOfWeek + 7) % 7;
shabbatDate.setDate(shabbatDate.getDate() + daysToSaturday);
// Display Gregorian Dates
document.getElementById("secularAnniversary").innerText = bmAnniversary.toDateString();
document.getElementById("shabbatDate").innerText = shabbatDate.toDateString();
// 4. Parsha Logic (Simplified Seasonal Mapping for Standalone Logic)
// In a full production app, this would use a 5000-year lookup table.
// Here we provide the Parsha based on the time of year.
var month = shabbatDate.getMonth(); // 0-11
var day = shabbatDate.getDate();
var parsha = "";
// Seasonal Parsha Approximation Logic
if (month == 0) { // Jan
parsha = (day < 15) ? "Shemot / Va'era" : "Bo / Beshalach";
} else if (month == 1) { // Feb
parsha = (day < 15) ? "Yitro / Mishpatim" : "Terumah / Tetzaveh";
} else if (month == 2) { // Mar
parsha = (day < 15) ? "Ki Tissa / Vayakhel" : "Pekudei / Vayikra";
} else if (month == 3) { // Apr
parsha = (day < 15) ? "Tzav / Shmini" : "Tazria / Metzora";
} else if (month == 4) { // May
parsha = (day < 15) ? "Acharei Mot / Kedoshim" : "Emor / Behar";
} else if (month == 5) { // Jun
parsha = (day < 15) ? "Bechukotai / Bamidbar" : "Nasso / Behaalotcha";
} else if (month == 6) { // Jul
parsha = (day < 15) ? "Shelach / Korach" : "Chukat / Balak";
} else if (month == 7) { // Aug
parsha = (day < 15) ? "Pinchas / Matot" : "Masei / Devarim";
} else if (month == 8) { // Sep
parsha = (day < 15) ? "Vaetchanan / Eikev" : "Re'eh / Shoftim";
} else if (month == 9) { // Oct
parsha = (day < 15) ? "Ki Teitzei / Ki Tavo" : "Nitzavim / Vayeilech";
} else if (month == 10) { // Nov
parsha = (day < 15) ? "Ha'azinu / Bereshit" : "Noach / Lech-Lecha";
} else if (month == 11) { // Dec
parsha = (day < 15) ? "Vayeira / Chayei Sarah" : "Toledot / Vayetzei";
}
document.getElementById("parshaResult").innerText = parsha;
document.getElementById("bm-result").style.display = "block";
}