//Doug Galaske created these calendars for St. Pius X Church

dayText = new Array();


// Define variables
var monthNames, monthDays, d, dy, yr, mo, tableCellWidth, tmo, tyr, tday, todayDate, todayDayColor, dayColor, dayLabelColor, titleColor, nonDayColor, tableCellPadding, tableCellSpacing, tableBorder, tableBorderColor, numberSize, apSize, dayLabelSize, titleSize, actualNumSize, numberTextColor, apTextColor, dayLabelTextColor, dayLabelBold, numberBold, titleTextColor, alertOnPageEnter, tdayow, tableHeight, tc = '', thecopy, setter="", background, titleBackground, dayLabelBackground, dayBackground, nonDayBackground;
var lt = "<";
// Find today's date's information
todayDate = new Date();
tmo = todayDate.getMonth();
tyr = todayDate.getYear();
tday = todayDate.getDate();
tdayow = todayDate.getDay();

// Make the arrays that make today's date into readable form
var dowa = new Array(7); // Day of the week array
dowa[0] = "Sunday";
dowa[1] = "Monday";
dowa[2] = "Tuesday";
dowa[3] = "Wednesday";
dowa[4] = "Thursday";
dowa[5] = "Friday";
dowa[6] = "Saturday";



// Define default variables
dayColor="#00FFFF"
tableCellWidth='1%';
dayLabelColor = '#00FFA0';
titleColor = 'A00FF40';
nonDayColor = '#C0C0C0';
tableCellPadding = '0';
tableCellSpacing = '3';
tableBorder = '2';
tableBorderColor = '#0000FF';
titleColor = '#55FFA0';
numberSize = '1';
apSize = '1';
titleSize = '1';
dayLabelSize = '2';
numberTextColor = '#0000A0';
apTextColor = '#112266';
titleTextColor = '#000000';
dayLabelTextColor = '#000033';
dayLabelBold = true;
numberBold = false;
alertOnEnter = true;
tableHeight = "100%";
background = '';
titleBackground = '';
dayLabelBackground = '';
nonDayBackground = '';
dayBackground = '';

function setCalendar(montho,yearo) {
montho=montho-1;
// Is it a leap year?
if( yearo/4 != Math.round(yearo/4) ) 
monthDays = new Array( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
else
monthDays = new Array( 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );

monthNames = new Array( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
mo = montho;
yr = yearo;
setMessageDates();
}
function setMessageDates() {
dayText[0] = "";
dayText[1] = "";
dayText[2] = "";
dayText[3] = "";
dayText[4] = "";
dayText[5] = "";
dayText[6] = "";
dayText[7] = "";
dayText[8] = "";
dayText[9] = "";
dayText[10] = "";
dayText[11] = "";
dayText[12] = "";
dayText[13] = "";
dayText[14] = "";
dayText[15] = "";
dayText[16] = "";
dayText[17] = "";
dayText[18] = "";
dayText[19] = "";
dayText[20] = "";
dayText[21] = "";
dayText[22] = "";
dayText[23] = "";
dayText[24] = "";
dayText[25] = "";
dayText[26] = "";
dayText[27] = "";
dayText[28] = "";
dayText[29] = "";
dayText[30] = "";
dayText[31] = "";

}

function showCalendar1() {
var nw = window.open('CalMaker.htm')
nw.document.dta.day1.value=dayText[1];
nw.document.dta.day2.value=dayText[2];
nw.document.dta.day3.value=dayText[3];
nw.document.dta.day4.value=dayText[4];
nw.document.dta.day5.value=dayText[5];
nw.document.dta.day6.value=dayText[6];
nw.document.dta.day7.value=dayText[7];
nw.document.dta.day8.value=dayText[8];
nw.document.dta.day9.value=dayText[9];
nw.document.dta.day10.value=dayText[10];
nw.document.dta.day11.value=dayText[11];
nw.document.dta.day12.value=dayText[12];
nw.document.dta.day13.value=dayText[13];
nw.document.dta.day14.value=dayText[14];
nw.document.dta.day15.value=dayText[15];
nw.document.dta.day16.value=dayText[16];
nw.document.dta.day17.value=dayText[17];
nw.document.dta.day18.value=dayText[18];
nw.document.dta.day19.value=dayText[19];
nw.document.dta.day20.value=dayText[20];
nw.document.dta.day21.value=dayText[21];
nw.document.dta.day22.value=dayText[22];
nw.document.dta.day23.value=dayText[23];
nw.document.dta.day24.value=dayText[24];
nw.document.dta.day25.value=dayText[25];
nw.document.dta.day26.value=dayText[26];
nw.document.dta.day27.value=dayText[27];
nw.document.dta.day28.value=dayText[28];
nw.document.dta.day29.value=dayText[29];
nw.document.dta.day30.value=dayText[30];
nw.document.dta.day31.value=dayText[31];
nw.document.dta.month.value = mo+1;
nw.document.dta.setter.value = setter;
nw.document.dta.year.value = tyr;
}
function showCalendar() {
actualNumSize = numberSize;
if(todayDayColor==undefined)
todayDayColor = dayColor;

// Set the new Date's year, month, and day
d = new Date(yr,mo,1);

// Find the day of the week of the 1st day of the month
dy = d.getDay();
tc+=("<center><table border='"+tableBorder+"' cellpadding='"+tableCellPadding+"' cellspacing='"+tableCellSpacing+"' bordercolor='"+tableBorderColor+"' height='"+tableHeight+"'><tr>")
tc+=("<td colspan=7 bgcolor='"+titleColor+"' background='images/"+titleBackground+"'><h"+titleSize+"><center><font color='"+titleTextColor+"'>"+monthNames[mo]+" "+yr+"</font></h"+titleSize+"></center></td></tr><tr>");

if(dayLabelBold)
var repeatItOver = "<font size='"+dayLabelSize+"' color='"+dayLabelTextColor+"'><b>"
else
var repeatItOver = "<font size='"+dayLabelSize+"' color='"+dayLabelTextColor+"'>"
//Show the Days of the Week
tc+=("<tr bgcolor='"+dayLabelColor+"'><td background='images/"+dayLabelBackground+"'>"+repeatItOver+"Sunday</font></td><td background='images/"+dayLabelBackground+"'>"+repeatItOver+"Monday</font></td><td background='images/"+dayLabelBackground+"'>"+repeatItOver+"Tuesday</font></td><td background='images/"+dayLabelBackground+"'>"+repeatItOver+"Wednesday</font></td><td background='images/"+dayLabelBackground+"'>"+repeatItOver+"Thursday</font></td><td background='images/"+dayLabelBackground+"'>"+repeatItOver+"Friday</font></td><td background='images/"+dayLabelBackground+"'>"+repeatItOver+"Saturday</font></td></tr>")


// Make the gray spaces in front of first day of month
if(dy>6)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");
if(dy>5)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");
if(dy>4)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");
if(dy>3)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");
if(dy>2)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");
if(dy>1)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");
if(dy>0)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");

var x = 1;
var dyo = dy;
while(x < (monthDays[mo]+1)) {
if(dyo==0 && x!=1)
tc+=("<tr>")

// Make a day cell
tc+=("<td width="+tableCellWidth+" align='top' height='13%' background='images/"+dayBackground+"'")
if(tmo==mo && tday==x && tyr==yr)
tc+=("bgcolor='"+todayDayColor+"'")
else
tc+=("bgcolor='"+dayColor+"'")
tc+=("><div align=top><font size='"+actualNumSize+"' color='"+numberTextColor+"'></div>");
if(numberBold)
tc+=("<b>"+x+"</b></font>");
else
tc+=(""+x+"</font>");
tc+=("&nbsp; &nbsp; <font size='"+apSize+"' color='"+apTextColor+"'>"+dayText[x]+"</font>")
tc+=("</td>")
if(dyo==6)
tc+=("</tr>")
x=x+1
if(x!=monthDays[mo]+1) {
if(dyo!=6)
dyo=dyo+1
else
dyo=0
}
}

// Make gray spaces after last day of month

if(dyo<6)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");
if(dyo<5)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");
if(dyo<4)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");
if(dyo<3)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");
if(dyo<2)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");
if(dyo<1)
tc+=("<td bgcolor='"+nonDayColor+"' width="+tableCellWidth+" background='images/"+nonDayBackground+"'></td>");
tc+=("</table>")
if(alertOnEnter==true && dayText[tday]!="<br><br>" && dayText[tday]!="" && mo==tmo && yr==tyr) {
alert(""+dowa[tdayow]+", "+monthNames[tmo]+" "+tday+", "+tyr+"\n\n"+dayText[tday]+"");
}
document.write(tc)
document.body.background='images/'+background;
}
function newTask(pd,pt) {
dayText[pd] = pt;
}