var month = 0, day = 0, year = 0;
var lat = 0, lng = 0; // sun’s location
var latd = -1, latm = 0;// lat on earth
var lngd = -1, lngm = 0;// long on earth
var ns = ‘N’, ew = ‘E’; // hemisphere
var dst = 0; // daylight saving time
var ampm = 0; // am/pm or 24 hour display
function leap(y) {
return ((y % 400 == 0) || (y % 100 != 0 && y % 4 == 0));
}
function civMonthLength(month, year) {
if(month == 2)
return 28 + leap(year);
else if(month == 4 || month == 6 || month == 9 || month == 11)
return 30;
else
return 31;
}
function set_dst() {
dst = document.data.dst.checked;
doit(“”);
}
function change_year(num) {
var y = parseInt(document.data.year.value);
y += num;
document.data.year.value = y;
year = y;
date_vars_doit();
}
function list_pos(w) {
var str, place, desc
var i;
i = w.options.selectedIndex;
with(document.data) { // reset all prior selections
//israel_city.options[0].selected = 1;
diaspora_city.options[0].selected = 1;
}
w.options[i].selected = 1; // restore current selection
with (w) {
desc = options[0].text;
str = options[options.selectedIndex].value;
place = options[options.selectedIndex].text;
//if(i == 0)
// document.data.placename.value = ”;
}
if (str == “nada”) {
return
}
i = str.indexOf(“,”);
ns = str.substring(0, i);
str = str.substring(i+1, str.length);
i = str.indexOf(“,”);
latd = eval(str.substring(0, i));
str = str.substring(i+1, str.length);
i = str.indexOf(“,”);
latm = eval(str.substring(0, i));
str = str.substring(i+1, str.length);
i = str.indexOf(“,”);
ew = str.substring(0, i);
str = str.substring(i+1, str.length);
i = str.indexOf(“,”);
lngd = eval(str.substring(0, i));
str = str.substring(i+1, str.length);
i = str.indexOf(“,”);
lngm = eval(str.substring(0, i));
var tz = eval(str.substring(i+1, str.length));
if((latd != -1) && (lngd != -1)) {
document.data.tz.value = 12 + tz;
//document.data.tz.options[12+tz].selected = 1;
doit(“(” + desc + “) ” + place);
}
}
function doit(title) {
var d, m, y;
var nsi, ewi;
var i;
var myDiv;
var newNode;
//if(title != “”)
// document.data.placename.value = title;
//document.data.latd.value = latd;
//document.data.latm.value = latm;
i = ns.indexOf(“N”);
nsi = (i != -1) ? 0 : 1;
//document.data.lats[nsi].checked = 1;
//document.data.lngd.value = lngd;
//document.data.lngm.value = lngm;
i = ew.indexOf(“W”);
ewi = (i != -1) ? 0 : 1;
//document.data.lngs[ewi].checked = 1;
d = day + 1;
m = month + 1;
y = year;
var adj = – (12 – document.data.tz.value);
//var adj = – (12 – document.data.tz.options.selectedIndex);
adj += dst;
var time;
var sunrise, sunset;
var shaa_zmanit;
time = suntime(d, m, y, 90, 50, lngd, lngm, ewi, latd, latm, nsi, adj);
if(time[1] == 0) {
sunrise = time[2];
sunset = time[3];
//document.data.hanetz.value = timeadj(sunrise, ampm);
//document.data.shkia.value = timeadj(sunset, ampm);
shaa_zmanit = (sunset + 24.0 – sunrise) / 12;
}
time = suntime(d, m, y, 106, 6, lngd, lngm, ewi, latd, latm, nsi, adj);
//if(time[1] == 0)
// document.data.alot.value = timeadj(time[2], ampm);
time = suntime(d, m, y, 101, 0, lngd, lngm, ewi, latd, latm, nsi, adj);
//if(time[1] == 0)
// document.data.misheyakir.value = timeadj(time[2], ampm);
time = suntime(d, m, y, 96, 0, lngd, lngm, ewi, latd, latm, nsi, adj);
//if(time[1] == 0)
// document.data.tzeit.value = timeadj(time[3], ampm);
//document.data.shema.value = timeadj(sunrise + shaa_zmanit * 3, ampm);
//document.data.tefillah.value = timeadj(sunrise + shaa_zmanit * 4, ampm);
//document.data.chatzot.value = timeadj(sunrise + shaa_zmanit * 6, ampm);
//document.data.minchag.value = timeadj(sunrise + shaa_zmanit * 6.5, ampm);
//document.data.minchak.value = timeadj(sunrise + shaa_zmanit * 9.5, ampm);
//document.data.plag.value = timeadj(sunrise + shaa_zmanit * 10.75, ampm);
var yom = new Date (y, m-1, d);
if(yom.getDay() == 0) {
//var yom2 = new Date (y, m-1, d);
var shabbos1 = new Date(yom.getTime() + (6 * 86400000));
var sd = shabbos1.getDate();
var sm = shabbos1.getMonth() + 1;
var sy = shabbos1.getYear();
// motzei shabbat (3 small stars)
time = suntime(sd, sm, sy, 98, 30, lngd, lngm, ewi, latd, latm, nsi, adj);
if(time[1] == 0){
//document.data.motzeiShabbat.value = timeadj(time[3], ampm);
myDiv = document.getElementById(“yetziat”);
newNode = document.createTextNode(timeadj(time[3], ampm));
myDiv.firstChild.data = newNode.data;
}
// knissat shabbat (sunset from day before)
var day_before = new Date(shabbos1.getTime() – 86400000);
db = day_before.getDate();
mb = day_before.getMonth() + 1;
yb = day_before.getYear();
if(yb < 1900)
yb += 1900;
time = suntime(db, mb, yb, 90, 50, lngd, lngm, ewi, latd, latm, nsi, adj);
//document.data.knissatShabbat.value = timeadj(time[3] – 20.0/60.0, ampm);
//document.writeln("Sexta-feira, " + day_before.getDate() + "/" + (day_before.getMonth() + 1) + "/" + day_before.getYear() );
myDiv = document.getElementById("knissat");
newNode = document.createTextNode(timeadj(time[3] – 20.0/60.0, ampm));
myDiv.firstChild.data = newNode.data;
}
if(yom.getDay() == 1) {
//var yom2 = new Date (y, m-1, d);
var shabbos1 = new Date(yom.getTime() + (5 * 86400000));
var sd = shabbos1.getDate();
var sm = shabbos1.getMonth() + 1;
var sy = shabbos1.getYear();
// motzei shabbat (3 small stars)
time = suntime(sd, sm, sy, 98, 30, lngd, lngm, ewi, latd, latm, nsi, adj);
if(time[1] == 0){
//document.data.motzeiShabbat.value = timeadj(time[3], ampm);
myDiv = document.getElementById("yetziat");
newNode = document.createTextNode(timeadj(time[3], ampm));
myDiv.firstChild.data = newNode.data;
}
// knissat shabbat (sunset from day before)
var day_before = new Date(shabbos1.getTime() – 86400000);
db = day_before.getDate();
mb = day_before.getMonth() + 1;
yb = day_before.getYear();
if(yb < 1900)
yb += 1900;
time = suntime(db, mb, yb, 90, 50, lngd, lngm, ewi, latd, latm, nsi, adj);
//document.data.knissatShabbat.value = timeadj(time[3] – 20.0/60.0, ampm);
//document.writeln("For Friday " + day_before.getDate() + "/" + (day_before.getMonth() + 1) + "/" + day_before.getYear() );
myDiv = document.getElementById("knissat");
newNode = document.createTextNode(timeadj(time[3] – 20.0/60.0, ampm));
myDiv.firstChild.data = newNode.data;
}
if(yom.getDay() == 2) {
//var yom2 = new Date (y, m-1, d);
var shabbos1 = new Date(yom.getTime() + (4 * 86400000));
var sd = shabbos1.getDate();
var sm = shabbos1.getMonth() + 1;
var sy = shabbos1.getYear();
// motzei shabbat (3 small stars)
time = suntime(sd, sm, sy, 98, 30, lngd, lngm, ewi, latd, latm, nsi, adj);
if(time[1] == 0){
//document.data.motzeiShabbat.value = timeadj(time[3], ampm);
myDiv = document.getElementById("yetziat");
newNode = document.createTextNode(timeadj(time[3], ampm));
myDiv.firstChild.data = newNode.data;
}
// knissat shabbat (sunset from day before)
var day_before = new Date(shabbos1.getTime() – 86400000);
db = day_before.getDate();
mb = day_before.getMonth() + 1;
yb = day_before.getYear();
if(yb < 1900)
yb += 1900;
time = suntime(db, mb, yb, 90, 50, lngd, lngm, ewi, latd, latm, nsi, adj);
//document.data.knissatShabbat.value = timeadj(time[3] – 20.0/60.0, ampm);
//document.writeln("For Friday " + day_before.getDate() + "/" + (day_before.getMonth() + 1) + "/" + day_before.getYear() );
myDiv = document.getElementById("knissat");
newNode = document.createTextNode(timeadj(time[3] – 20.0/60.0, ampm));
myDiv.firstChild.data = newNode.data;
}
if(yom.getDay() == 3) {
//var yom2 = new Date (y, m-1, d);
var shabbos1 = new Date(yom.getTime() + (3 * 86400000));
var sd = shabbos1.getDate();
var sm = shabbos1.getMonth() + 1;
var sy = shabbos1.getYear();
// motzei shabbat (3 small stars)
time = suntime(sd, sm, sy, 98, 30, lngd, lngm, ewi, latd, latm, nsi, adj);
if(time[1] == 0){
//document.data.motzeiShabbat.value = timeadj(time[3], ampm);
myDiv = document.getElementById("yetziat");
newNode = document.createTextNode(timeadj(time[3], ampm));
myDiv.firstChild.data = newNode.data;
}
// knissat shabbat (sunset from day before)
var day_before = new Date(shabbos1.getTime() – 86400000);
db = day_before.getDate();
mb = day_before.getMonth() + 1;
yb = day_before.getYear();
if(yb < 1900)
yb += 1900;
time = suntime(db, mb, yb, 90, 50, lngd, lngm, ewi, latd, latm, nsi, adj);
//document.data.knissatShabbat.value = timeadj(time[3] – 20.0/60.0, ampm);
//document.writeln("For Friday " + day_before.getDate() + "/" + (day_before.getMonth() + 1) + "/" + day_before.getYear() );
myDiv = document.getElementById("knissat");
newNode = document.createTextNode(timeadj(time[3] – 20.0/60.0, ampm));
myDiv.firstChild.data = newNode.data;
}
if(yom.getDay() == 4) {
//var yom2 = new Date (y, m-1, d);
var shabbos1 = new Date(yom.getTime() + (2 * 86400000));
var sd = shabbos1.getDate();
var sm = shabbos1.getMonth() + 1;
var sy = shabbos1.getYear();
// motzei shabbat (3 small stars)
time = suntime(sd, sm, sy, 98, 30, lngd, lngm, ewi, latd, latm, nsi, adj);
if(time[1] == 0){
//document.data.motzeiShabbat.value = timeadj(time[3], ampm);
myDiv = document.getElementById("yetziat");
newNode = document.createTextNode(timeadj(time[3], ampm));
myDiv.firstChild.data = newNode.data;
}
// knissat shabbat (sunset from day before)
var day_before = new Date(shabbos1.getTime() – 86400000);
db = day_before.getDate();
mb = day_before.getMonth() + 1;
yb = day_before.getYear();
if(yb < 1900)
yb += 1900;
time = suntime(db, mb, yb, 90, 50, lngd, lngm, ewi, latd, latm, nsi, adj);
//document.data.knissatShabbat.value = timeadj(time[3] – 20.0/60.0, ampm);
//document.writeln("For Friday " + day_before.getDate() + "/" + (day_before.getMonth() + 1) + "/" + day_before.getYear() );
myDiv = document.getElementById("knissat");
newNode = document.createTextNode(timeadj(time[3] – 20.0/60.0, ampm));
myDiv.firstChild.data = newNode.data;
}
if(yom.getDay() == 5) {
//var yom2 = new Date (y, m-1, d);
var shabbos1 = new Date(yom.getTime() + 86400000);
var sd = shabbos1.getDate();
var sm = shabbos1.getMonth() + 1;
var sy = shabbos1.getYear();
// motzei shabbat (3 small stars)
time = suntime(sd, sm, sy, 98, 30, lngd, lngm, ewi, latd, latm, nsi, adj);
if(time[1] == 0){
//document.data.motzeiShabbat.value = timeadj(time[3], ampm);
myDiv = document.getElementById("yetziat");
newNode = document.createTextNode(timeadj(time[3], ampm));
myDiv.firstChild.data = newNode.data;
}
// knissat shabbat (sunset from day before)
var day_before = new Date(shabbos1.getTime() – 86400000);
db = day_before.getDate();
mb = day_before.getMonth() + 1;
yb = day_before.getYear();
if(yb < 1900)
yb += 1900;
time = suntime(db, mb, yb, 90, 50, lngd, lngm, ewi, latd, latm, nsi, adj);
//document.data.knissatShabbat.value = timeadj(time[3] – 20.0/60.0, ampm);
//document.writeln("For Friday " + day_before.getDate() + "/" + (day_before.getMonth() + 1) + "/" + day_before.getYear() );
myDiv = document.getElementById("knissat");
newNode = document.createTextNode(timeadj(time[3] – 20.0/60.0, ampm));
myDiv.firstChild.data = newNode.data;
}
if(yom.getDay() == 6) {
// motzei shabbat (3 small stars)
time = suntime(d, m, y, 98, 30, lngd, lngm, ewi, latd, latm, nsi, adj);
if(time[1] == 0){
//document.data.motzeiShabbat.value = timeadj(time[3], ampm);
myDiv = document.getElementById("yetziat");
newNode = document.createTextNode(timeadj(time[3], ampm));
myDiv.firstChild.data = newNode.data;
}
// knissat shabbat (sunset from day before)
var day_before = new Date(yom.getTime() – 86400000);
db = day_before.getDate();
mb = day_before.getMonth() + 1;
yb = day_before.getYear();
if(yb = len) {
day = len – 1;
//document.data.day.selectedIndex = day;
}
}
// when the menu changs this is the function that is called
function date_vars_doit() {
set_date_vars();
doit(“”);
}
// called at the end of loading the document – this sets the default values for the day. e.g. todays date
function set_default_date() {
var now = new Date();
var d = now.getDate();
var m = now.getMonth();
year = now.getYear();
if(year < 1900)
year += 1900;
month = m;
document.data.month.selectedIndex = m;
day = d – 1;
document.data.day.selectedIndex = d – 1;
//document.data.year.value = year;
document.data.year.value = year;
set_date_vars("");
}
/* ksun.js – Kaluach suntimes Javascript routines
* Version 1.00 (initial release)
* Version 1.01 (fixed bug with time adjust – AM/PM and 24 hour clock)
* Version 1.02 (fixed bug with time adjust [again] – AM/PM and 24 hour clock)
* Copyright (C) 5760-5762 (2000,2001 CE), by Abu Mami and Yisrael Hersch.
* All Rights Reserved.
* All copyright notices in this script must be left intact.
* Based on:
* – the program SUN.C by Michael Schwartz
* – an algorithm contained in:
* Almanac for Computers, 1990
* published by Nautical Almanac Office
* United States Naval Observatory
* Washington, DC 20392
* Permission will be granted to use this script on your web page
* if you wish. All that's required is that you please ask.
* (Of course if you want to send a few dollars, that's OK too 🙂
* website: http://www.kaluach.net
* email: abumami@kaluach.org
*/
// ?? what is this for? this is the amount of days from the beginning of the year for the first day of the month – accessed by the month number in the index array
var monCount = new makeArray(1, 32, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366);
//?? neat little function creates an array with its arguments
function makeArray() {
this[0] = makeArray.arguments.length;
for (i = 0; i 2 && leap(y));
}
// ?? this apparantly is the main function takes 12 arguements
/* d = day
* m = month
* y = year
* zendeg = zenith degrees
* zenmin = zenith minutes
* londeg = longitude degrees
* lonmin = longitude in minutes
* ew = east or west
* latdeg = latitude degreees
* latmin = latitude minutes
* ns = north or south
* tz = ?
*/
function suntime(d, m, y, zendeg, zenmin, londeg, lonmin, ew, latdeg, latmin, ns, tz) {
var lonhr;
var longitude, latitude; // self explanatory
var coslat, sinlat, cosz;
var sindec, cosdec;
var xm_rise, xm_set;
var xl_rise, xl_set;
var a_rise, a_set;
var ahr_rise, ahr_set;
var h_rise, h_set;
var t_rise, t_set;
var ut_rise, ut_set;
var retval = 0; // NORMAL ?? – ?
// ?? this is the only place this function is used
// >> how many days have passes from the beginning of the year
var day = doy(d, m, y);
// ?? I don’t know what this does
cosz = Math.cos(0.01745 * todec(zendeg, zenmin));
// ?? or this
longitude = todec(londeg, lonmin) * ((ew == 0) ? 1 : -1);
lonhr = longitude / 15.0;
latitude = todec(latdeg, latmin) * ((ns == 0) ? 1 : -1);
coslat = Math.cos(0.01745 * latitude);
sinlat = Math.sin(0.01745 * latitude);
// ?? these two calculation depend on the day of the year
t_rise = day + (6.0 + lonhr) / 24.0;
t_set = day + (18.0 + lonhr) / 24.0;
xm_rise = M(t_rise);
xl_rise = L(xm_rise);
xm_set = M(t_set);
xl_set = L(xm_set);
a_rise = 57.29578 * Math.atan( 0.91746 * Math.tan(0.01745 * xl_rise) );
a_set = 57.29578 * Math.atan( 0.91746 * Math.tan(0.01745 * xl_set) );
if(Math.abs(a_rise + 360.0 – xl_rise) > 90.0)
a_rise += 180.0;
if(a_rise > 360.0)
a_rise -= 360.0;
if(Math.abs(a_set + 360.0 – xl_set) > 90.0)
a_set += 180.0;
if(a_set > 360.0)
a_set -= 360.0;
ahr_rise = a_rise / 15.0;
sindec = 0.39782 * Math.sin(0.01745 * xl_rise);
cosdec = Math.sqrt(1.0 – sindec * sindec);
h_rise = (cosz – sindec * sinlat) / (cosdec * coslat);
ahr_set = a_set / 15.0;
sindec = 0.39782 * Math.sin(0.01745 * xl_set);
cosdec = Math.sqrt(1.0 – sindec * sindec);
h_set = (cosz – sindec * sinlat) / (cosdec * coslat);
if(Math.abs(h_rise) <= 1.0)
h_rise = 57.29578 * Math.acos(h_rise);
else
retval |= 2; //NO_SUNRISE;
if(Math.abs(h_set) > end of main function
// ?? as far as I can tell this makes adjustments to a time element – used heavily in the zmanim functions
function timeadj(t, ampm) {
var hour;
var min;
var time = t;
var hour = Math.floor(time);
var min = Math.floor((time – hour) * 60.0 + 0.5);
if(min >= 60) {
hour += 1;
min -= 60;
}
if(hour 11) ? ‘ PM’ : ‘ AM’;
hour %= 12;
hour = (hour < 1) ? 12 : hour;
}
else
ampm_str = '';
var str = hour + ':' + ((min
Acendimento das velas
|
|||||||||
|