FirstYear=2009
FirstMonth=10
LastYear=2010
LastMonth=9
//  Find year,month and day
s=document.location.search
var k=s.indexOf("*")
var m=s.indexOf("$")

var year=s.substring(1,k)
var month=s.substring(k+1,m)
var day=s.substring(m+1)

function MakeArray(n){
	this.length = n
	return this
}
daysInMonth = new MakeArray(12)
daysInMonth[1]=31 ; daysInMonth[2]=28; daysInMonth[3]=31; daysInMonth[4]=30; daysInMonth[5]=31;
daysInMonth[6]=30; daysInMonth[7]=31; daysInMonth[8]=31; daysInMonth[9]=30; daysInMonth[10]=31;
daysInMonth[11]=30; daysInMonth[12]=31
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) daysInMonth[2] = 29

function showMonths() {
	url="calendar.html?"+year+"*"+month
	open(url,"_self")
}
function displayVerse(bc,Vb,Ve) {
bk=bc.substring(0,bc.indexOf('_'))
bk_Ch=bk+'/'+bc
location='../bible/'+bk_Ch+'.HTML?0*'+Vb+'$'+Ve+"^"+bk_Ch+'*'+location
}
function dv(bc,Vb,Ve) {
bk=bc.substring(0,bc.indexOf('_'))
bk_Ch=bk+'/'+bc
location='../bible/'+bk_Ch+'.HTML?0*'+Vb+'$'+Ve+"^"+bk_Ch+'*'+location
}
function dispRPG(year,month,day) {
	url=year+"_"+month+"_"+day+".HTML?"+year+"*"+month+"$"+day
	open(url,"_self")
}
function dispEvening(year,month,day) {
	url=year+"_"+month+"_"+day+"e.HTML?"+year+"*"+month+"$"+day
	open(url,"_self")
}
function yesterday() {
	if (day>1) {
		day = day -1
	}
	else {
		if (month>1) {
			month=month-1;
			day=daysInMonth[month]
			}
			else {
				year=1.0*year -1
				if (year<FirstYear) alert("RPG for the year "+year+" is not available")
				month=12
				day=31
			}
		}
	dispRPG(year,month,day)
}
function tomorrow() {
	maxday=daysInMonth[month]
	day = -(-day)
	if (day<maxday) {
		day =  day +1
	}
	else {
		if (month<12) {
			month=-(-month)+1;
			day=1
			}
			else {
				year=1.0*year +1
				month=1
				day=1
			}
		}

	dispRPG(year,month,day)
}
function dispLinks() {
	document.location="../bsk_common/links.html"
}
function dispDownload() {
	document.location="../bsk_common/BSKdownload.html"
}
function increaseFontSize() {
   var p = top.document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
       } 
      s += 8;
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
       } 
      s -= 8;
      p[i].style.fontSize = s+"px"
   }
}
function addToFavorites() { 
	if (window.external)  window.external.AddFavorite("http://www.calvarypandan.org/rpg","rpg") ;
	else  alert("Sorry! Your browser doesn't support this function."); 
}  
