v2monthNames = new Array(
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
);

var xmlHttp_v2;
function loadCalendar2_v2(mm, dd, yy, dt, hh, ll, tt, ss)
{
xmlHttp_v2=null;
if (window.XMLHttpRequest)
  {// code for Firefox, Opera, IE7, etc.
  xmlHttp_v2=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlHttp_v2=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
if (xmlHttp_v2!=null)
  {
  var par="v2staff/v2calendar.php";
  par=par+"?month="+mm + "&today="+dd + "&year="+yy + "&dt="+dt + "&header="+hh + "&lives="+ll + "&trp="+tt + "&scripture="+ss;
  par=par+"&sid="+Math.random();

  xmlHttp_v2.onreadystatechange=stateChanged2;

  xmlHttp_v2.open("GET", par,true);
  xmlHttp_v2.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}


function stateChanged2() 
{ 
if (xmlHttp_v2.readyState==4) // 4 = "loaded"
 {
   if (xmlHttp_v2.status==200) // 200 = "OK"
    {
 document.getElementById('T1').innerHTML=xmlHttp_v2.responseText 
    }
  else
    {
    alert("Problem retrieving data: " + xmlHttp_v2.statusText);
    }
 } 
}

//=========================================

var xmlHttp_v2_troparion;
function loadCalendar2_v2_troparion(mm, dd, yy, dt, hh, ll, tt, ss)
{
xmlHttp_v2_troparion=null;
if (window.XMLHttpRequest)
  {// code for Firefox, Opera, IE7, etc.
  xmlHttp_v2_troparion=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlHttp_v2_troparion=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
if (xmlHttp_v2_troparion!=null)
  {
  var par="v2staff/v2calendar.php";
  par=par+"?month="+mm + "&today="+dd + "&year="+yy + "&dt="+dt + "&header="+hh + "&lives="+ll + "&trp="+tt + "&scripture="+ss;
  par=par+"&sid="+Math.random();

  xmlHttp_v2_troparion.onreadystatechange=stateChanged2_troparion;

  xmlHttp_v2_troparion.open("GET", par,true);
  xmlHttp_v2_troparion.send(null);
  
  var myDate=new Date();
  var julian = new Date(myDate.setFullYear(yy,mm-1,dd) - 13*24*60*60*1000);
  var jm=julian.getMonth()+1;	// Get today's month
  var jd=julian.getDate();		// Get today's day
  var jy=julian.getFullYear(); 	// Get today's year
  document.getElementById('TroparionsKontakionsTitle').innerHTML = "Troparions/Kontakions &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + v2monthNames[mm-1] + ", " + dd + " " + yy + "/" + v2monthNames[jm-1] + ", " + jd + " " + jy;
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}


function stateChanged2_troparion() 
{ 
if (xmlHttp_v2_troparion.readyState==4) // 4 = "loaded"
 {
   if (xmlHttp_v2_troparion.status==200) // 200 = "OK"
    {
 	document.getElementById('TroparionsKontakionsText').innerHTML=xmlHttp_v2_troparion.responseText.replace("<span class=\"normaltext\">","<span style=\"font-family:Georgia, 'Times New Roman', Times, serif\">");
    }
  else
    {
    alert("Problem retrieving data: " + xmlHttp_v2_troparion.statusText);
    }
 } 
}

//=========================================

var xmlHttp_v2_IconOfTheDay;
function loadTitleIcon_v2(mm, dd, yy, img, pdate)
{
xmlHttp_v2_IconOfTheDay=null;
if (window.XMLHttpRequest)
  {// code for Firefox, Opera, IE7, etc.
  xmlHttp_v2_IconOfTheDay=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlHttp_v2_IconOfTheDay=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
if (xmlHttp_v2_IconOfTheDay!=null)
  {
  var par="v2staff/v2TitleIcon.php";
  par=par+"?month="+mm + "&today="+dd + "&year="+yy + "&img="+ img + "&pdate="+ pdate;
  par=par+"&sid="+Math.random();

  xmlHttp_v2_IconOfTheDay.onreadystatechange=stateChanged2_IconOfTheDay;

  xmlHttp_v2_IconOfTheDay.open("GET", par,true);
  xmlHttp_v2_IconOfTheDay.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}


function stateChanged2_IconOfTheDay() 
{ 
if (xmlHttp_v2_IconOfTheDay.readyState==4) // 4 = "loaded"
 {
   if (xmlHttp_v2_IconOfTheDay.status==200) // 200 = "OK"
    {
 document.getElementById('IconOfTheDay').innerHTML=xmlHttp_v2_IconOfTheDay.responseText 
    }
  else
    {
    alert("Problem retrieving data: " + xmlHttp_v2_IconOfTheDay.statusText);
    }
 } 
}

//=========================================
function callFeasts(y)
{

// Pascha Calculation
var r1 = y % 19;
var r2 = y % 4;
var r3 = y % 7;
var ra = 19 * r1 + 16;
var r4 = ra % 30;
var rb = 2 * r2 + 4 * r3 + 6 * r4;
var r5 = rb % 7;
var rc = 3 + r4 + r5;

if ( rc < 30) {
	pascha_m = 3; 	// Pascha is  in April
	pascha_d = rc;	// Pascha day in Aplil
}
else {
	pascha_m = 4; 	// Pascha is in May
	pascha_d = rc - 30;	// Pascha day in May
};

var pascha = new Date(y,pascha_m,pascha_d); 	// Set Pascha Date

var publican_and_Pharisee = new Date(y,pascha_m,pascha_d);
publican_and_Pharisee.setDate(pascha.getDate() - 70); 

var meatfare_Sunday = new Date(y,pascha_m,pascha_d);
meatfare_Sunday.setDate(pascha.getDate() - 56);

var forgiveness_Sunday = new Date(y,pascha_m,pascha_d);
forgiveness_Sunday.setDate(pascha.getDate() - 49);

var palm_sunday = new Date(y,pascha_m,pascha_d);
palm_sunday.setDate(pascha.getDate() - 7);

var mid_Pentecost = new Date(y,pascha_m,pascha_d);
mid_Pentecost.setDate(pascha.getDate() + 24);

var holy_Ascension  = new Date(y,pascha_m,pascha_d);
holy_Ascension.setDate(pascha.getDate() + 39);

var pentecost  = new Date(y,pascha_m,pascha_d);
pentecost.setDate(pascha.getDate() + 49);

var all_Saints  = new Date(y,pascha_m,pascha_d);
all_Saints.setDate(pascha.getDate() + 56);

document.getElementById("pascha").innerHTML = 
v2monthNames[pascha.getMonth()] + " " +  pascha.getDate() + ' –&nbsp;Great and Holy Pascha';

document.getElementById("PaschaliaTitle").innerHTML = "Paschalia " + y;
document.getElementById("PaschaliaText").innerHTML =
'<table width="100%" border="0" cellpadding="0" cellspacing="0">\n<tbody>\n<tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[publican_and_Pharisee.getMonth()] + " " +  publican_and_Pharisee.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Sunday of the Publican and Pharisee</td>\n</tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[meatfare_Sunday.getMonth()] + " " +  meatfare_Sunday.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Meatfare Sunday</td>\n</tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[forgiveness_Sunday.getMonth()] + " " +  forgiveness_Sunday.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Forgiveness Sunday</td>\n</tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[palm_sunday.getMonth()] + " " +  palm_sunday.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Palm Sunday</td>\n</tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif"><span style="color:#e00">' + v2monthNames[pascha.getMonth()] + " " +  pascha.getDate() + '</span></td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif"><span style="color:#e00">&nbsp;– Great and Holy Pascha<span></td>\n</tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[mid_Pentecost.getMonth()] + " " +  mid_Pentecost.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Mid-Pentecost (Prepolovenie)</td>\n</tr>\n' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[holy_Ascension.getMonth()] + " " +  holy_Ascension.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Holy Ascension</td>\n</tr>\n' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[pentecost.getMonth()] + " " +  pentecost.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Pentecost</td>\n</tr>\n' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[all_Saints.getMonth()] + " " +  all_Saints.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– All Saints</td>\n</tr>\n' +

'</tbody></table>';

document.getElementById("MovableTitle").innerHTML = "Movable Great Feasts " + y;
document.getElementById("MovableText").innerHTML = 
'<table width="100%" border="0" cellpadding="0" cellspacing="0">\n<tbody>\n<tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[palm_sunday.getMonth()] + " " +  palm_sunday.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Palm Sunday</td>\n</tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[holy_Ascension.getMonth()] + " " +  holy_Ascension.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Holy Ascension</td>\n</tr>\n' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[pentecost.getMonth()] + " " +  pentecost.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Pentecost</td>\n</tr>\n' +

'</tbody></table>';

var greatLentBegin = new Date(y,pascha_m,pascha_d);
greatLentBegin.setDate(pascha.getDate() - 48);

var greatLentEnd = new Date(y,pascha_m,pascha_d);
greatLentEnd.setDate(pascha.getDate() - 1);

var petrovLentBegin = new Date(y,pascha_m,pascha_d);
petrovLentBegin.setDate(pascha.getDate() + 57);

document.getElementById("FastingSeasonsTitle").innerHTML = "Fasting Seasons " + y;
document.getElementById("FastingSeasonsText").innerHTML = 
'<table width="100%" border="0" cellpadding="0" cellspacing="0">\n<tbody>\n<tr>' +

'\n<td valign="top" width="160" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[greatLentBegin.getMonth()] + " " +  greatLentBegin.getDate() + ' - ' + v2monthNames[greatLentEnd.getMonth()] + " " +  greatLentEnd.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Great Lent</td>\n</tr>' +

'\n<td valign="top" width="160" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[petrovLentBegin.getMonth()] + " " +  petrovLentBegin.getDate() + ' - July 11' + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Apostles\' (Peter & Paul) Fast</td>\n</tr>' +

'\n<td valign="top" width="160" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + 'August 14 - August 28' + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Dormition (Theotokos) Fast</td>\n</tr>' +

'\n<td valign="top" width="160" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + 'November 28 - January 6' + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Nativity (St. Philip\'s Fast)</td>\n</tr>' +

'</tbody></table>';

var meatfare_Saturday = new Date(y,pascha_m,pascha_d);
meatfare_Saturday.setDate(pascha.getDate() - 57);

secondSaturday = new Date(y,pascha_m,pascha_d);
secondSaturday.setDate(pascha.getDate() - 36);

thirdSaturday = new Date(y,pascha_m,pascha_d);
thirdSaturday.setDate(pascha.getDate() - 29);

fourthSaturday = new Date(y,pascha_m,pascha_d);
fourthSaturday.setDate(pascha.getDate() - 22);

radonitsa = new Date(y,pascha_m,pascha_d);
radonitsa.setDate(pascha.getDate() + 9);

trinitySaturday = new Date(y,pascha_m,pascha_d);
trinitySaturday.setDate(pascha.getDate() + 48);

demetriusSaturday  = new Date(y,pascha_m,pascha_d);
dS1 = new Date(y,9,28);
dS2 = new Date(y,10,1);
dS3 = new Date(y,10,2);
dS4 = new Date(y,10,3);
dS5 = new Date(y,10,5);
dS6 = new Date(y,10,6);
dS7 = new Date(y,10,7);
if ( dS1.getDay() == 6) {demetriusSaturday  = new Date(y,9,28)};
if ( dS2.getDay() == 6) {demetriusSaturday  = new Date(y,10,1)};
if ( dS3.getDay() == 6) {demetriusSaturday  = new Date(y,10,2)};
if ( dS4.getDay() == 6) {demetriusSaturday  = new Date(y,10,3)};
if ( dS5.getDay() == 6) {demetriusSaturday  = new Date(y,10,5)};
if ( dS6.getDay() == 6) {demetriusSaturday  = new Date(y,10,6)};
if ( dS7.getDay() == 6) {demetriusSaturday  = new Date(y,10,7)};

document.getElementById("TraditionaldaysofremembranceTitle").innerHTML = "Traditional days of remembrance " + y;
document.getElementById("TraditionaldaysofremembranceText").innerHTML = 
'<table width="100%" border="0" cellpadding="0" cellspacing="0">\n<tbody>\n<tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[meatfare_Saturday.getMonth()] + " " +  meatfare_Saturday.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Meat-fare Saturday</td>\n</tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[secondSaturday.getMonth()] + " " +  secondSaturday.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– 2<sup>nd</sup> Saturday of the Great Lent</td>\n</tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[thirdSaturday.getMonth()] + " " +  thirdSaturday.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– 3<sup>rd</sup> Saturday of the Great Lent</td>\n</tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[fourthSaturday.getMonth()] + " " +  fourthSaturday.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– 4<sup>th</sup> Saturday of the Great Lent</td>\n</tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[radonitsa.getMonth()] + " " +  radonitsa.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Radonitsa (Tuesday of the 2<sup>nd</sup> week of Pascha)</td>\n</tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[trinitySaturday.getMonth()] + " " +  trinitySaturday.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Trinity Saturday</td>\n</tr>' +

'\n<td valign="top" width="90" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[demetriusSaturday.getMonth()] + " " +  demetriusSaturday.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Demetrius Saturday</td>\n</tr>' +

'</tbody></table>';


phareseeBegin = new Date(y,pascha_m,pascha_d);
phareseeBegin.setDate(pascha.getDate() - 70);
phareseeEnd = new Date(y,pascha_m,pascha_d);
phareseeEnd.setDate(pascha.getDate() - 64);

maslenitsaBegin = new Date(y,pascha_m,pascha_d);
maslenitsaBegin.setDate(pascha.getDate() - 56);
maslenitsaEnd = new Date(y,pascha_m,pascha_d);
maslenitsaEnd.setDate(pascha.getDate() - 50);

brightWeekBegin = new Date(y,pascha_m,pascha_d);
brightWeekEnd = new Date(y,pascha_m,pascha_d);
brightWeekEnd.setDate(pascha.getDate() + 6);

trinityBegin = new Date(y,pascha_m,pascha_d);
trinityBegin.setDate(pascha.getDate() + 49);
trinityEnd = new Date(y,pascha_m,pascha_d);
trinityEnd.setDate(pascha.getDate() + 55);

document.getElementById("FastfreeWeeksTitle").innerHTML = "Fast-free Weeks " + y;
document.getElementById("FastfreeWeeksText").innerHTML = 
'<table width="100%" border="0" cellpadding="0" cellspacing="0">\n<tbody>\n<tr>' +

'\n<td valign="top" width="170" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + 'January 7 - January 17' + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Sviatki (Afterfeast of the Nativity of Christ to Theophany Eve)</td>\n</tr>' +

'\n<td valign="top" width="170" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[phareseeBegin.getMonth()] + " " +  phareseeBegin.getDate() + ' - ' + v2monthNames[phareseeEnd.getMonth()] + " " +  phareseeEnd.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Publican & Pharisee</td>\n</tr>' +

'\n<td valign="top" width="170" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[maslenitsaBegin.getMonth()] + " " +  maslenitsaBegin.getDate() + ' - ' + v2monthNames[maslenitsaEnd.getMonth()] + " " +  maslenitsaEnd.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Maslenitsa</td>\n</tr>' +

'\n<td valign="top" width="170" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[brightWeekBegin.getMonth()] + " " +  brightWeekBegin.getDate() + ' - ' + v2monthNames[brightWeekEnd.getMonth()] + " " +  brightWeekEnd.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Bright Week</td>\n</tr>' +

'\n<td valign="top" width="170" align="right" style="font-family:Georgia, \'Times New Roman\', Times, serif">' + v2monthNames[trinityBegin.getMonth()] + " " +  trinityBegin.getDate() + ' - ' + v2monthNames[trinityEnd.getMonth()] + " " +  trinityEnd.getDate() + '</td>\n<td valign="top" align="left" style="font-family:Georgia, \'Times New Roman\', Times, serif">&nbsp;– Trinity Week</td>\n</tr>' +

'</tbody></table>';

}

