
//Day Schedule.js
var day_activity_time = new Array (0,
0,
540,
610,
710,
720,
800,
845,
900,
1130,
1200,
1230,
1300,
1400,
1500,
1630,
1645,
1745,
1800,
1900,
2000,
2100,
2400);
var day_activity = new Array (" ",
"The sisters will rise at 5:40 am this morning.",
"At this time, the sisters are waking up.<br/>Silent prayer will begin at 6:10 am.",
"At this time, the sisters are in silent prayer.<br/>Laudes (morning prayer) will start at 7:10 am.",
"At this time, the sisters are praying Laudes (morning prayer).<br/>Terce (midmorning prayer) will start at 7:20 am.",
"At this time, the sisters are praying Terce (midmorning prayer).<br/>Mass starts at 8:00 am.",
"At this time, the sisters are at Mass.<br/>Breakfast is at 8:45 am.",
"At this time, the sisters are having breakfast.<br/>Work time starts at 9:00 am.",
"At this time, the sisters are having work time.<br/>Sext and None (midday and midafternoon prayer) will be at 11:30 am.",
"At this time, the sisters are at Sext and None (midday and midafternoon prayer).<br/>Dinner will be at 12:00 pm.",
"At this time, the sisters are having dinner.<br/>Recreation will begin at 12:30 pm.",
"At this time, the sisters are having recreation time.<br/>Silent free time starts at 1:00 pm.",
"At this time, the sisters are having silent free time (rest, work, reading, etc.).<br/>Spiritual Reading hour will start at 2:00 pm.",
"At this time, the sisters are having one hour of spiritual reading.<br/>Prayers for the dying are at 3:00 pm and work time begins again.",
"At this time, the sisters are having work time.<br/>Vespers (evening prayer) will begin at 4:00 pm.",
"At this time, the sisters are having vespers (evening prayer).<br/>Silent prayer starts at 4:45 pm.",
"At this time, the sisters are having silent prayer.<br/>Matins (office of readings) will begin at 5:45 pm.",
"At this time, the sisters are having Matins (office of readings).<br/>The evening meal is at 6:00 pm.",
"At this time, the sisters are having their evening meal.<br/>Recreation time will begin at 7:00 pm.",
"At this time, the sisters are having recreation time.<br/>Compline (night prayer) begins at 8:00 pm.",
"At this time, the sisters are having Compline (night prayer).<br/>The sisters will rise again at 5:40 am.",
"The sisters will rise again at 5:40 am tomorrow morning. ",
"The sisters will rise again at 5:40 am tomorrow morning.");

// *******************************
//   END OF SCHEDULE
// *******************************

var Speed = 1000;

var websiteValueTime = 100;
var websiteValueDay;

var day_activity_display;
var next_day_activity;

var day_activity_display_time;
var day_activity_time_tempvalue;
var next_day_activity_time_tempvalue;
var next_day_activity_time;
var local_display_time;
var website_display_time;
var day_activity_display_date;
var next_day_activity_display_date;

var today = new Date();

var weekday = new Array()
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";

var monthvalue = new Array()
monthvalue[0] = "January";
monthvalue[1] = "February";
monthvalue[2] = "March";
monthvalue[3] = "April";
monthvalue[4] = "May";
monthvalue[5] = "June";
monthvalue[6] = "July";
monthvalue[7] = "August";
monthvalue[8] = "September";
monthvalue[9] = "October";
monthvalue[10] = "November";
monthvalue[11] = "December";

var weekday_fin = new Array()
weekday_fin[0] = "Sunnuntai";
weekday_fin[1] = "Maanantai";
weekday_fin[2] = "Tiistai";
weekday_fin[3] = "Keskiviikko";
weekday_fin[4] = "Torstai";
weekday_fin[5] = "Perjantai";
weekday_fin[6] = "Lauantai";

var monthvalue_fin = new Array()
monthvalue_fin[0] = "Tammikuu";
monthvalue_fin[1] = "Helmikuu";
monthvalue_fin[2] = "Maaliskuu";
monthvalue_fin[3] = "Huhtikuu";
monthvalue_fin[4] = "Toukkokuu";
monthvalue_fin[5] = "Kes&auml;kuu";
monthvalue_fin[6] = "Hein&auml;kuu";
monthvalue_fin[7] = "Elokuu";
monthvalue_fin[8] = "Syyskuu";
monthvalue_fin[9] = "Lokakuu";
monthvalue_fin[10] = "Marraskuu";
monthvalue_fin[11] = "Joulukuu";

var daylight_savings;


// This routine runs the local and web site location time for Karmelfin.org


function IfZero(num) {
return ((num <= 9) ? ("0" + num) : num);
}
function check24(hour) {
return (hour >= 24) ? hour - 24 : hour;
}
function checkDaylightSavings() {
// Europe time - Helsinki
var test_year = new Date();
var test;
var dst_test_start_06 = new Date();
var dst_test_end_06 = new Date();
var dst_test_start_07 = new Date();
var dst_test_end_07 = new Date();
var dst_start = new Date();
var dst_end = new Date();
var start;
var end;
var this_day;
var time_adjust;

//test_year.setFullYear(2006,2,25);
//test_year.setHours(17,1,0);

var def1 = test_year.getTimezoneOffset()/60;
var gmt1 = (test_year.getHours() + def1 + 3);

if (gmt1 > 23)
{time_adjust = 100 + gmt1 - 24;}
if (gmt1 < 0)
{time_adjust = -100 + 24 - gmt1;}
if (gmt1 >=0 && gmt1 <=23)
{time_adjust = gmt1;}
if (gmt1 == test_year.getHours())
{time_adjust == gmt1 + 1;}

var dst_start_time;
dst_start_time = 3;
var dst_end_time;
dst_end_time = 4;
dst_test_start_06.setFullYear(test_year.getFullYear(),2,31); // last sunday of march
dst_test_end_06.setFullYear(test_year.getFullYear(),9,31);   // last sunday of october
dst_test_start_07.setFullYear(test_year.getFullYear(),2,31); // last sunday of march
dst_test_end_07.setFullYear(test_year.getFullYear(),9,31);  // last sunday of october


if (test_year.getFullYear() < 2007)
{
dst_start.setFullYear(test_year.getFullYear(),dst_test_start_06.getMonth(),31-dst_test_start_06.getDay());
dst_end.setFullYear(test_year.getFullYear(),dst_test_end_06.getMonth(),31-dst_test_end_06.getDay());
}
else
{
dst_start.setFullYear(test_year.getFullYear(),dst_test_start_07.getMonth(),31-dst_test_start_06.getDay());
dst_end.setFullYear(test_year.getFullYear(),dst_test_end_07.getMonth(),31-dst_test_end_06.getDay());
}

start = dst_start.getFullYear()*1000000 + dst_start.getMonth()*10000 + dst_start.getDate()*100 + dst_start_time;
end = dst_end.getFullYear()*1000000 + dst_end.getMonth()*10000 + dst_end.getDate()*100 + dst_end_time;
this_day = test_year.getFullYear()*1000000 + test_year.getMonth()*10000 + (test_year.getDate())*100 + time_adjust;
if (this_day > start && this_day < end)
{test=1;}
else{test=0;}
return test;
}
function checkampm(hour) {
return (hour < 12) ? "am" : "pm";
}
function check12(hour) {
return (hour <= 12 && hour > 0) ? hour : Math.abs(hour - 12);
}




function websiteTimeValue (hour, minute) {
return hour*100 + minute;
}

function websiteDayValue (year, mnth, dy, hr, min) {
return year*100000000 + (mnth+1)*1000000 + dy*10000 + hr*100 + min;
}

function dayToday(year, month, date) {


var date_display;
var tempDate=new Date();

tempDate.setFullYear(year,month,date);
date_display = weekday[tempDate.getDay()] + " " + monthvalue[tempDate.getMonth()-1] + " " + tempDate.getDate();
return date_display;
}



function checkActivityTime(timevalue) {
activity_display_time = check12(Math.floor(timevalue/100)) + ":" +
IfZero(timevalue-Math.floor(timevalue/100)*100) + " " + checkampm(Math.floor(timevalue/100));
}
function checkActivityTimeNext(timevalue) {
next_activity_time = check12(Math.floor(timevalue/100)) + ":" +
IfZero(timevalue-Math.floor(timevalue/100)*100) + " " + checkampm(Math.floor(timevalue/100));
}


function checkActivityNow() {
var next = 0;
var thisday = new Date();
for (var i=0; i<day_activity.length; i++)
{
if (websiteValueTime >= day_activity_time[i] && websiteValueTime < day_activity_time[i+1])
{day_activity_display = day_activity[i];
if(i+1 >= day_activity.length){next=0;}else{next=i+1;}
next_day_activity = day_activity[next];
day_activity_display_time = day_activity_time[i];
next_day_activity_time = day_activity_time[next];
day_activity_display_date = thisday.getDate();
next_day_activity_display_date = thisday.getDate();
}
}
}

var year;
var month;
var date;
//year = (activity_time[i] - activity_time[i]%100000000)/100000000;
//month = (activity_time[i]%100000000 - activity_time[i]%1000000)/1000000;
//date = (activity_time[i]%1000000 - activity_time[i]%10000)/10000;
//dayToday(year,month,date);

