


// ----- class global variables -----

var times = new Array();

//----- salat "class" definitions -----

function JammatTimes()
{
  this.Populate=Populate;
  this.FindSalatTimes=FindSalatTimes;
  this.GetTodaySalatTimes=GetTodaySalatTimes;
  this.ShowAll=ShowAll;
  this.Count=Count;
  this.GetIndex=GetIndex;
}

function GetIndex(i)
{
  //returns a specific element from times
  return(times[i]);
}

function Count()
{
  return(times.length);
}


function Salat(start,jammat)
{
 this.start=start;
 this.jammat=jammat;
}

function Day(date,ij,mj,aj,zj,fj,is,as,zs,sunrise,sehriend,lunar,dayname)
{
 this.date=date;
 this.day=1;
 this.fajr=new Salat(sehriend,fj);
 this.zuhr=new Salat(zs,zj);
 this.asr=new Salat(as,aj);
 this.maghrib=new Salat(mj,mj);
 this.isha=new Salat(is,ij);
 this.sunrise=sunrise;
 this.sehriend=sehriend;
 this.lunar=lunar; 
 this.dayname=dayname;
}

// ----- class helper functions -----

function GetTodaySalatTimes()
{
 var today;
 var s;

 today=GetTodayDate("dm"); 
 s=FindSalatTimes(today);
 return(s);
}

function ShowAll()
{
 var win;
 var i=0;
 var j=times.length;
 var SEP="   -- ";
 win = window.open("","Showall","height=500,width=500,resizable");
 
 for (i=0;i<j;i++)
 { 
  win.document.write("<HR>");
  win.document.write("<B>"+times[i].date+"</B><BR>");
  win.document.write(times[i].isha.jammat+SEP);
  win.document.write(+times[i].maghrib.jammat+SEP);
  win.document.write(+times[i].asr.jammat+SEP);
  win.document.write(+times[i].zuhr.jammat+SEP);
  win.document.write(+times[i].fajr.jammat+SEP);
  win.document.write(times[i].isha.start+SEP);
  win.document.write(+times[i].asr.start+SEP);
  win.document.write(+times[i].zuhr.start+SEP);
  win.document.write(+times[i].sunrise+SEP);
  win.document.write(+times[i].sehriend+SEP);
  win.document.write(+times[i].lunar);
 } 
 win.document.write("<HR>");
}

function FindSalatTimes(date)
{
 var i=0;
 var j=times.length;

 for (i=0;i<j;i++)
 {
  if (date==times[i].date)
  {
   return(times[i]);
  }
 }
}

function Populate(month)
{
 var i=0;
 var bAll=0;
 if (arguments.length==0)
 {
  bAll=1;
 }

times[i++] = new Day("01/02","7.30","4.54","3.30","1.00","7.15","6.52","3.00","12.23","7.55","5.54","8","WED");times[i++] = new Day("02/02","7.30","4.56","3.30","1.00","7.15","6.54","3.02","12.23","7.54","5.53","9","THURS");times[i++] = new Day("03/02","7.30","4.58","3.45","1.30","7.15","6.55","3.04","12.23","7.52","5.51","10","FRI");times[i++] = new Day("04/02","7.30","5.00","3.45","1.00","7.15","6.57","3.06","12.23","7.50","5.50","11","SAT");times[i++] = new Day("05/02","7.30","5.02","3.45","1.00","7.15","6.59","3.08","12.23","7.48","5.48","12","SUN");times[i++] = new Day("06/02","7.30","5.04","3.45","1.00","7.15","7.00","3.10","12.23","7.46","5.47","13","MON");times[i++] = new Day("07/02","7.30","5.06","3.40","1.00","7.15","7.02","3.11","12.23","7.45","5.45","14","TUES");times[i++] = new Day("08/02","7.30","5.08","3.45","1.00","7.15","7.04","3.13","12.23","7.43","5.44","15","WED");times[i++] = new Day("09/02","7.30","5.10","3.45","1.00","7.15","7.05","3.15","12.23","7.41","5.42","16","THURS");times[i++] = new Day("10/02","7.45","5.12","3.45","1.30","7.00","7.07","3.17","12.23","7.39","5.40","17","FRI");times[i++] = new Day("11/02","7.45","5.14","3.45","1.00","7.00","7.09","3.19","12.23","7.37","5.39","18","SAT");times[i++] = new Day("12/02","7.45","5.16","3.45","1.00","7.00","7.11","3.21","12.23","7.35","5.37","19","SUN");times[i++] = new Day("13/02","7.45","5.18","3.45","1.00","7.00","7.12","3.22","12.23","7.33","5.35","20","MON");times[i++] = new Day("14/02","7.45","5.20","3.45","1.00","7.00","7.14","3.24","12.23","7.31","5.33","21","TUES");times[i++] = new Day("15/02","7.45","5.22","3.45","1.00","7.00","7.16","3.26","12.23","7.29","5.31","22","WED");times[i++] = new Day("16/02","7.45","5.24","3.45","1.00","7.00","7.18","3.28","12.23","7.27","5.29","23","THURS");times[i++] = new Day("17/02","8.00","5.26","4.00","1.30","6.45","7.20","3.30","12.23","7.25","5.28","24","FRI");times[i++] = new Day("18/02","8.00","5.28","4.00","1.00","6.45","7.21","3.32","12.23","7.23","5.26","25","SAT");times[i++] = new Day("19/02","8.00","5.30","4.00","1.00","6.45","7.23","3.33","12.23","7.21","5.24","26","SUN");times[i++] = new Day("20/02","8.00","5.32","4.00","1.00","6.45","7.25","3.35","12.23","7.18","5.22","27","MON");times[i++] = new Day("21/02","8.00","5.34","4.00","1.00","6.45","7.27","3.37","12.23","7.16","5.20","28","TUES");times[i++] = new Day("22/02","8.00","5.36","4.00","1.00","6.45","7.29","3.39","12.23","7.14","5.18","29","WED");times[i++] = new Day("23/02","8.00","5.38","4.00","1.00","6.45","7.31","3.40","12.23","7.12","5.15","1","THURS");times[i++] = new Day("24/02","8.15","5.40","4.15","1.30","6.30","7.32","3.42","12.22","7.10","5.13","2","FRI");times[i++] = new Day("25/02","8.15","5.42","4.15","1.00","6.30","7.34","3.44","12.22","7.07","5.11","3","SAT");times[i++] = new Day("26/02","8.15","5.44","4.15","1.00","6.30","7.36","3.46","12.22","7.05","5.09","4","SUN");times[i++] = new Day("27/02","8.15","5.46","4.15","1.00","6.30","7.38","3.47","12.22","7.03","5.07","5","MON");times[i++] = new Day("28/02","8.15","5.48","4.15","1.00","6.30","7.40","3.49","12.22","7.01","5.05","6","TUES");times[i++] = new Day("29/02","8.15","5.50","4.15","1.00","6.30","7.42","3.51","12.21","6.58","5.02","7","WED");

}

  
