﻿var global_cal_ids = new Array(); if (typeof (addEvent) == "undefined") { function addEvent(C, B, A) { if (document.addEventListener) { addEvent = function (F, E, D) { F.addEventListener(E, D, false) } } else { if (document.attachEvent) { addEvent = function (F, E, D) { F["e" + E + D] = D; F[E + D] = function () { F["e" + E + D](window.event) }; F.attachEvent("on" + E, D) } } } addEvent(C, B, A) } } function calendar(A) { this.init = function (B, C, D) { this.obj = A; if (C && D) { this.von = C.id; this.bis = D.id; this.extended = 100 } else { this.extended = 0; this.von = ""; this.bis = "" } this.months = ["ינואר", "פברואר", "מרץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "ספטמבר", "אוקטובר", "נובמבר", "דצמבר"]; this.days = ["א", "ב", "ג", "ד", "ה", "ו", "ש"]; this.date = this.parse_value(B); this.day = this.date.getDay(); this.month = this.date.getMonth(); this.monthday = this.date.getDate(); this.year = this.date.getFullYear(); this.work_date = this.parse_value(B); this.orig_date = this.parse_value(B, true); this.today = new Date(); this.getfirstday(); this.id = this.set_id(); this.show(); A.cal_id = this.id; window.clearTimeout(A.timeout); A.onblur = function () { A.timeout = window.setTimeout("document.getElementById('id_" + A.cal_id + "').style.display='none';", 300) } }; this.parse_value = function (B, E) { var D = new Date; if (!B || E == true) { B = this.obj.value } if (B && B.match(/\d+\.\d+\.\d\d\d\d/)) { var C = B.split("."); if (C[0] && C[1] && C[2]) { D.setDate(C[0]); D.setMonth((C[1]) - 1); D.setYear(C[2]) } } return D }; this.set_id = function () { if (this.obj.id) { this.id = this.obj.id } else { this.id = "cal_" + Date.parse(this.date); this.obj.id = this.id } return this.id }; this.findPosX = function () { var B = 0; if (this.obj.offsetParent) { xobj = this.obj; while (xobj.offsetParent) { B += xobj.offsetLeft; xobj = xobj.offsetParent } } else { if (this.obj.x) { B += this.obj.x } } return B }; this.findPosY = function () { var B = 0; if (this.obj.offsetParent) { yobj = this.obj; while (yobj.offsetParent) { B += yobj.offsetTop; yobj = yobj.offsetParent } } else { if (this.obj.y) { B += this.obj.y } } return B }; this.getfirstday = function () { if (this.work_date.getDay != 1) { this.work_date.setDate(1); this.work_date.setDate(1 - (7 + this.work_date.getDay() - 1) % 7) } }; this.prevmonth = function () { var B = 0; if ((this.month) < 1) { B = 1 } return this.monthday + "." + this.month + "." + (this.year - B) }; this.nextmonth = function () { var B = 0; if ((this.month) > 10) { B = 1 } return this.monthday + "." + (this.month + 2) + "." + (this.year + B) }; this.prevyear = function () { var B = 0; if ((this.year - 1) > 1970) { B = 1 } return this.monthday + "." + (this.month + 1) + "." + (this.year - B) }; this.nextyear = function () { var B = 0; if ((this.year + 1) < 2030) { B = 1 } return this.monthday + "." + (this.month + 1) + "." + (this.year + B) }; this.special_time = function (E) { var B = ""; var J = ""; var H = new Date(); var D = H.getMonth() + 1; var G = H.getFullYear(); var F = H.getDay(); var I = H.getDate(); switch (E) { case "heu": B = I + "." + (D) + "." + G; J = I + "." + (D) + "." + G; break; case "mo": var C = H; C.setDate(I + 1); B = C.getDate() + "." + (C.getMonth() + 1) + "." + C.getFullYear(); J = B; break; case "heumo": var C = H; B = C.getDate() + "." + (C.getMonth() + 1) + "." + C.getFullYear(); var C = H; C.setDate(I + 1); J = C.getDate() + "." + (C.getMonth() + 1) + "." + C.getFullYear(); break; case "wo": var C = H; C.setDate(I + (6 - F)); B = C.getDate() + "." + (C.getMonth() + 1) + "." + C.getFullYear(); C.setDate(C.getDate() + 1); J = C.getDate() + "." + (C.getMonth() + 1) + "." + C.getFullYear(); break; case "os": var C = this.parse_value(this.getEaster(this.today.getFullYear(), this.today.getMonth(), this.today.getDate())); J = C.getDate() + "." + (C.getMonth() + 1) + "." + C.getFullYear(); C.setDate(C.getDate() - 3); B = C.getDate() + "." + (C.getMonth() + 1) + "." + C.getFullYear(); break; case "hi": var C = this.parse_value(this.getEaster(this.today.getFullYear(), this.today.getMonth(), this.today.getDate())); C.setDate(C.getDate() + 38); B = C.getDate() + "." + (C.getMonth() + 1) + "." + C.getFullYear(); C.setDate(C.getDate() + 3); J = C.getDate() + "." + (C.getMonth() + 1) + "." + C.getFullYear(); break; case "pf": var C = this.parse_value(this.getEaster(this.today.getFullYear(), this.today.getMonth(), this.today.getDate())); C.setDate(C.getDate() + 47); B = C.getDate() + "." + (C.getMonth() + 1) + "." + C.getFullYear(); C.setDate(C.getDate() + 2); J = C.getDate() + "." + (C.getMonth() + 1) + "." + C.getFullYear(); break; case "ok": y = 0; if (D == 12 && I > 26) { y = 1 } B = "3.10." + (G + y); J = "3.10." + (G + y); break; case "wei": y = 0; if (D == 12 && I > 26) { y = 1 } B = "24.12." + (G + y); J = "26.12." + (G + y); break } return "document.getElementById('" + this.von + "').value=('" + B + "');document.getElementById('" + this.bis + "').value=('" + J + "');document.getElementById('id_" + this.id + "').style.display='none';return false;" }; this.getEaster = function (D, E, C) { var B = new Date(); a = D % 19; b = D % 4; c = D % 7; k = D / 100; q = k / 4; p = ((8 * k) + 13) / 25; Egz = (38 - (k - q) + p) % 30; M = (53 - Egz) % 30; N = (4 + k - q) % 7; d = ((19 * a) + M) % 30; e = ((2 * b) + (4 * c) + (6 * d) + N) % 7; if ((22 + d + e) <= 31) { C = 22 + d + e; E = 3 } else { C = d + e - 9; E = 4; if (C == 26) { C = 19 } else { if ((C == 25) && (d == 28) && (a > 10)) { C = 18 } } } C = Math.ceil(C); if ((E < B.getMonth() && D == B.getFullYear()) || (E == B.getMonth() && D == B.getFullYear() && C > B.getDate())) { easter = this.getEaster(D + 1, E, C) } else { easter = C + "." + E + "." + D } return easter }; this.build = function () { var B = '<div class="calendar" style="width:' + (200 + this.extended) + "px;top:" + (this.findPosY() + 25) + "px;left:" + (this.findPosX()) + 'px;"><div>'; B += '<a href="#" onclick="document.getElementById(\'id_' + this.id + '\').style.display=\'none\';return false;" class="close"><img src="http://www.berlin.de/.img/apps/mini_icons2/cross.gif" alt="X" /></a><a href="#" onclick="var cal = new calendar(document.getElementById(\'' + this.id + "'));cal.init('" + this.prevyear() + "', document.getElementById('" + this.von + "'), document.getElementById('" + this.bis + '\'));return false" class="b_link"><img src="http://www.berlin.de/.img/apps/16x16_mono/fast_back.gif" alt="&lt;&lt;" /></a><a href="#" onclick="var cal = new calendar(document.getElementById(\'' + this.id + "'));cal.init('" + this.prevmonth() + "', document.getElementById('" + this.von + "'), document.getElementById('" + this.bis + '\'));return false" class="b_link"><img src="http://www.berlin.de/.img/apps/16x16_mono/prev.gif" alt="&lt;" /></a> <strong>' + this.months[this.month] + " " + this.year + '</strong> <a href="#" onclick="var cal = new calendar(document.getElementById(\'' + this.id + "'));cal.init('" + this.nextmonth() + "', document.getElementById('" + this.von + "'), document.getElementById('" + this.bis + '\'));return false" class="b_link"><img src="http://www.berlin.de/.img/apps/16x16_mono/next.gif" alt="&gt;" /></a><a href="#" onclick="var cal = new calendar(document.getElementById(\'' + this.id + "'));cal.init('" + this.nextyear() + "', document.getElementById('" + this.von + "'), document.getElementById('" + this.bis + '\'));return false" class="b_link"><img src="http://www.berlin.de/.img/apps/16x16_mono/fast_forward.gif" alt="&gt;&gt;" /></a><table><tr><th>ב</th><th>ג</th><th>ד</th><th>ה</th><th>ו</th><th>ש</th><th>א</th>'; if (this.extended) { B += '<td rowspan="7" class="weekend special"><b>תקופות מיוחדות</b><ul><li><a href="#" onclick="' + this.special_time("heu") + '">היום</a></li><li><a href="#" onclick="' + this.special_time("heumo") + '">היום ומחר</a></li><li><a href="#" onclick="' + this.special_time("mo") + '">מחר</a></li><li><a href="#" onclick="' + this.special_time("wo") + '">סוף שבוע</a></li><li><a href="#" onclick="' + this.special_time("os") + '">חג הפסחא</a></li><li><a href="#" onclick="' + this.special_time("hi") + '">חג העליה</a></li><li><a href="#" onclick="' + this.special_time("pf") + '">חג השבועות</a></li><li><a href="#" onclick="' + this.special_time("ok") + '">3 לאוקטובר</a></li><li><a href="#" onclick="' + this.special_time("wei") + '">חג המולד</a></li></ul></td>' } B += "</tr>"; for (i = 1; i <= 6; i++) { B += ("<tr>"); for (var C = 0; C < 7; C++) { if ((this.work_date.getDate() == this.orig_date.getDate()) && (this.work_date.getMonth() == this.orig_date.getMonth()) && (this.work_date.getFullYear() == this.orig_date.getFullYear())) { B += ('<td class="days today">') } else { if (this.work_date.getDay() == 0 || this.work_date.getDay() == 6) { B += ('<td class="days weekend">') } else { B += '<td class="days workdays">' } } B += "<a"; if (this.work_date.getMonth() != this.date.getMonth()) { B += (' class="inactive"') } B += ' href="#" onclick="document.getElementById(\'' + this.id + "').value=('" + this.work_date.getDate() + "." + (this.work_date.getMonth() + 1) + "." + this.work_date.getFullYear() + "');document.getElementById('id_" + this.id + "').style.display='none';return false;\">"; B += (this.work_date.getDate() + "</a></td>"); this.work_date.setDate(this.work_date.getDate() + 1) } B += ("</tr>") } B += "</table></div></div>"; return B }; this.show = function () { if (document.getElementById("id_" + this.id)) { this.hideall(); document.getElementById("id_" + this.id).innerHTML = this.build(); document.getElementById("id_" + this.id).style.display = "block" } else { this.hideall(); this.calendar = document.createElement("div"); this.calendar.id = "id_" + this.id; global_cal_ids.push("id_" + this.id); this.calendar.innerHTML = this.build(); document.getElementsByTagName("body")[0].appendChild(this.calendar) } }; this.hideall = function () { for (var B = global_cal_ids.length; B >= 0; B--) { if (global_cal_ids[B] && document.getElementById(global_cal_ids[B]).style.display != "none") { document.getElementById(global_cal_ids[B]).style.display = "none" } } } } function init() { var A = new calendar(this); A.init(this.value) } function calendar_init() { var A = document.getElementsByTagName("input"); var C = false; if (A) { for (var B = A.length; B >= 0; B--) { if (A[B] && (A[B].getAttribute("type") == "date" || A[B].className.indexOf("date") != -1) && !A[B].onclick) { addEvent(A[B], "click", init) } } } } calendar_init(); 
