﻿﻿/*
 * Today's Hebrew Date
 * (c) Copyright 1996: Right to Left Software
 *
 * Reference: Understanding The Jewish Calendar / Rabbi Nathan Bushwick
 */

browserName = navigator.appName;
version = "";
     browserVer = parseInt(navigator.appVersion);
             if (browserName == "Netscape" && browserVer <= 4) version = "n3";

             if (version == "n3")
             {
document.write("דפדנך מיושן מדי. לא ניתן לצפות בתאריך העברי.");
             }
else
             {

var HebrewLeapYears = "0010010100100100101";
var Version = 1.00;
function IsHebrewLeapYear(year)
{
	var y = (year - 1) % 19;
	return parseInt(HebrewLeapYears.charAt(y));
}
function InitHebrewMonthsNames(isleap)
{
	this.length = (isleap) ? 13 : 12;
	this[0] = "תשרי";
	this[1] = "חשוון";
	this[2] = "כסלו";
	this[3] = "טבת";
	this[4] = "שבט";
	this[5] = "אדר";
	var incr = 0;
	if (isleap) {
		this[5] = "אדר א'";
		this[6] = "אדר ב'";
		incr = 1;
	}
	this[6+incr] = "ניסן";
	this[7+incr] = "אייר";
	this[8+incr] = "סיוון";
	this[9+incr] = "תמוז";
	this[10+incr] = "אב";
	this[11+incr] = "אלול";
}
var HebrewMonthsNames = new InitHebrewMonthsNames(false);
var HebrewMonthsNamesLeap = new InitHebrewMonthsNames(true);

function InitGlobalTable()
{
	this.length = 2002;
this[1980] = "11S0";
this[1981] = "29S2";
this[1982] = "18S3";
this[1983] = "08S3";
this[1984] = "27S2";
this[1985] = "16S0";
this[1986] = "04O3";
this[1987] = "24S2";
this[1988] = "12S0";
this[1989] = "30S3";
this[1990] = "20S2";
this[1991] = "09S3";
this[1992] = "28S0";
this[1993] = "16S3";
this[1994] = "06S2";
this[1995] = "25S3";
this[1996] = "14S0";
this[1997] = "02O2";
this[1998] = "21S3";
this[1999] = "11S3";
this[2000] = "30S0";
this[2001] = "18S2";
this[2002] = "07S3";
this[2003] = "27S3";
this[2004] = "16S0";
this[2005] = "04O2";
this[2006] = "23S3";
this[2007] = "13S0";
this[2008] = "30S2";
this[2009] = "19S3";
this[2010] = "09S3";
this[2011] = "29S2";
this[2012] = "17S0";
this[2013] = "05S3";
this[2014] = "25S2";
this[2015] = "14S3";
this[2016] = "03O0";
this[2017] = "21S2";
this[2018] = "10S3";
this[2019] = "30S3";
this[2020] = "19S0";
}

var GlobalTable = new InitGlobalTable();
/*
 * Convert Julian year to Hebrew year
 */
function JulianYearToHebrew(/* int */ year)
{
	return year + 3760;
}
function HebrewToJulianYear(/* int */ year)
{
	return year - 3760;
}
/*
 * Year length in days
 * indexed by the year type, given in GlobalTable
 */
function InitYearLength(isleap)
{
	this.length = 4;
	if (isleap) {
		this[0] = 383;
		//this[1] = ; error
		this[2] = 384;
		this[3] = 385;
	} else {
		this[0] = 353;
		//this[1] = ; error
		this[2] = 354;
		this[3] = 355;
	}
}
var HebrewYearLengthLeap = new InitYearLength(true);
var HebrewYearLength = new InitYearLength(false);
var Tishrei = 0;
var Cheshvan = 1;
var Kislev = 2;
var Adar1 = 5;
var Adar2 = 6;
var HebMonths30 =     "1010101010101";
var HebMonths30Leap = "10101011010101";
function DaysInHebrewFixedMonth(month, year)
{
	var incr;
	if (IsHebrewLeapYear(year))
		incr = parseInt(HebMonths30Leap.charAt(month));
	else
		incr = parseInt(HebMonths30.charAt(month));
	return 29 + incr; // 29 or 30
}


function DaysInCheshvan(hebyear)
{
	var ytype = GlobalTable[HebrewToJulianYear(hebyear)-1].charAt(3);
	if (ytype == 3)
		return 30;
	else
		return 29;
}

function DaysInKislev(hebyear)
{
	var ytype = GlobalTable[HebrewToJulianYear(hebyear)-1].charAt(3);
	if (ytype == 0)
		return 29;
	else
		return 30;
}

function DaysInHebrewMonth(month, year)
{
	if (month == Cheshvan)
		return DaysInCheshvan(year);
	else if (month == Kislev)
		return DaysInKislev(year);
	else
		return DaysInHebrewFixedMonth(month, year);
}





function DaysInHebrewYear(/* int */ year)
{
	var ytype = GlobalTable[year].charAt(3);
	if (IsHebrewLeapYear(year)) {
		return HebrewYearLengthLeap[ytype];
	} else {
		return HebrewYearLength[ytype];
	}
}

var MsecPerDay = 1000*3600*24;  // miliseconds per day

/*
 * Add days to a Julian date
 */
function	AddDays(
	/* date */ date,
	/* int */  days)
{
	var time = date.getTime();
	time += days*MsecPerDay;
	date.setTime(time);

	return date;
}


/*
 * given a Julian date of a holiday (e.g. rosh hashana),
 * returns the date that the same holiday occurred in the year 'toyear'
 */
function SameHolidayInJulianYear(
	/* date */ rosh_shana,
	/* int */  toyear)
{
	var fromyear = rosh_shana.getFullYear() + 1900;
	var incr = 1; // increment fromyear

	if (fromyear == toyear)
		return rosh_shana;
	else if (fromyear > toyear)
		incr = -1; // decrement from_year

	var days;
	for (days = 0 ; fromyear != toyear ; fromyear += incr) {
		days += DaysInHebrewYear(JulianYearToHebrew(fromyear));
	}
	AddDays(rosh_shana, incr*days);
	return rosh_shana;
}
// returns date when Rosh Hashana occurs on this year
function GetRoshHashana(/* int */ cvyear)
{
	var month;
	var day;
	var yearstr = GlobalTable[cvyear];
	var m = yearstr.charAt(2);
	month = 8; // usually September
	if (m == 'O')
		month = 9; // sometimes October
	day = parseInt(yearstr.charAt(0))*10 + parseInt(yearstr.charAt(1));
	return new Date(cvyear, month, day);
}

/*
 * The following functions are methods for
 * HebrewDate object
 */

// is last month of the year?
function IsHebLastMonth()
{
	if (this.month == 11 && !IsHebrewLeapYear(this.year))
		return true;

	if (this.month == 12 && IsHebrewLeapYear(this.year))
		return true;

	return false;
}

// go to next Hebrew month
function HebNextMonth()
{
	if (this.IsLastMonth()) {
		this.year++;
		this.month = 0;
	} else
		this.month++;

	this.DaysInThisMonth = DaysInHebrewMonth(this.month, this.year);
}

// next Hebrew day
function HebNextDay()
{
	this.day++;
	if (this.day > this.DaysInThisMonth) {
		this.day = 1;
		this.NextMonth();
	}
}

// add days to Hebrew date
function HebAddDays(days)
{
	while (days > 0) {
		if (this.day == 1 && days >= this.DaysInThisMonth) {
			days -= this.DaysInThisMonth;
			this.NextMonth();
		} else {
			days--;
			this.NextDay();
		}
	}
//document.write("Current date: " + this.day + ", " + this.month + ", " + this.year + "<br>");
}

// print Hebrew date
function HebPrint()
{
	var ThisMonthName = (IsHebrewLeapYear(this.year)) ?
										HebrewMonthsNamesLeap[this.month] :

											HebrewMonthsNames[this.month];
// לוח מועדים
  if (ThisMonthName == "תשרי") {
    if (this.day ==  1) { this.holiday = "א' דראש השנה"; }
    if (this.day ==  2) { this.holiday = "ב' דראש השנה"; }
    if (this.day ==  3) { this.holiday = "צום גדליה"; }
    if (this.day == 9) { this.holiday = "ערב יום הכיפורים"; }
    if (this.day == 10) { this.holiday = "יום הכיפורים"; }
    if (this.day == 15) { this.holiday = "סוכות"; }
    if (this.day == 16) { this.holiday = "א' דחול המועד סוכות"; }
    if (this.day == 17) { this.holiday = "ב' דחול המועד סוכות"; }
    if (this.day == 18) { this.holiday = "ג' דחול המועד סוכות"; }
    if (this.day == 19) { this.holiday = "ד' דחול המועד סוכות"; }
    if (this.day == 20) { this.holiday = "ה' דחול המועד סוכות"; }
    if (this.day == 21) { this.holiday = "ו' דחול המועד סוכות - הושענא רבא"; }
    if (this.day == 22) { this.holiday = "שמחת תורה"; }
  }

  if (ThisMonthName == "כסלו") { 
    if (this.day == 25) { this.holiday = "נר ראשון של חנוכה"; }
    if (this.day == 26) { this.holiday = "נר שני של חנוכה"; }
    if (this.day == 27) { this.holiday = "נר שלישי של חנוכה"; }
    if (this.day == 28) { this.holiday = "נר רביעי של חנוכה"; }
    if (this.day == 29) { this.holiday = "נר חמישי של חנוכה"; }
  }

  if (ThisMonthName == "טבת") { 
    if (this.day ==  1) { this.holiday = "נר שישי של חנוכה"; }
    if (this.day ==  2) { this.holiday = "נר שביעי של חנוכה"; }
    if (this.day ==  3) { this.holiday = "נר שמיני של חנוכה"; }
    if (this.day == 10) { this.holiday = "צום עשרה בטבת"; }
  }

  if (ThisMonthName == "שבט") {
    if (this.day == 15) { this.holiday = "חג האילנות"; }
  }

  // ימים מיוחדים בחודש אדר בהנחה שאין חודש אדר נוסף (שנה מעוברת)
  if (ThisMonthName == "אדר") {
    if (this.day == 13) { this.holiday = "תענית אסתר"; }
    if (this.day == 14) { this.holiday = "פורים"; }
    if (this.day == 15) { this.holiday = "שושן פורים"; }
  } 

  // ימים מיוחדים בחודש אדר ב' במידה והוא קיים
  if (ThisMonthName == "אדר ב'") {
    if (this.day == 13) { this.holiday = "תענית אסתר"; }
    if (this.day == 14) { this.holiday = "פורים"; }
    if (this.day == 15) { this.holiday = "שושן פורים"; }
  } 

  if (ThisMonthName == "ניסן") {
    if (this.day == 14) { this.holiday = "ותענית בכורות וערב הפסח"; }
    if (this.day == 15) { this.holiday = "חג ראשון של פסח"; }
    if (this.day == 16) { this.holiday = "א' חול המועד פסח"; }
    if (this.day == 17) { this.holiday = "ב' חול המועד פסח"; }
    if (this.day == 18) { this.holiday = "ג' חול המועד פסח"; }
    if (this.day == 19) { this.holiday = "ד' חול המועד פסח"; }
    if (this.day == 20) { this.holiday = "ה' חול המועד פסח"; }
    if (this.day == 21) { this.holiday = "חג שני של פסח"; }
  }   

  if (ThisMonthName == "אייר") {
     if (this.day == 18) { this.holiday = "ל\"ג בעומר - הדלקת מדורות"; }
  }

  if (ThisMonthName == "סיוון") {
    if (this.day ==  5) { this.holiday = "ערב שבועות"; }
    if (this.day ==  6) { this.holiday = "שבועות"; }
    if (this.day ==  7) { this.holiday = "שבועות"; }
  }

  if (ThisMonthName == "תמוז") {
    if (this.day == 17) { this.holiday = "צום י\"ז בתמוז"; }
  }

  if (ThisMonthName == "אלול") {
    if (this.day ==  29) { this.holiday = "ערב ראש השנה";}
  }



// הפכת היום במספר לעברית
if (this.day == "1") { this.day = "א'"; }
if (this.day == "2") { this.day = "ב'"; }
if (this.day == "3") { this.day = "ג'"; }
if (this.day == "4") { this.day = "ד'"; }
if (this.day == "5") { this.day = "ה'"; }
if (this.day == "6") { this.day = "ו'"; }
if (this.day == "7") { this.day = "ז'"; }
if (this.day == "8") { this.day = "ח'"; }
if (this.day == "9") { this.day = "ט'"; }
if (this.day == "10") { this.day = "י'"; }
if (this.day == "11") { this.day = "י\"א"; }
if (this.day == "12") { this.day = "י\"ב"; }
if (this.day == "13") { this.day = "י\"ג"; }
if (this.day == "14") { this.day = "י\"ד"; }
if (this.day == "15") { this.day = "ט\"ו"; }
if (this.day == "16") { this.day = "ט\"ז"; }
if (this.day == "17") { this.day = "י\"ז"; }
if (this.day == "18") { this.day = "י\"ח"; }
if (this.day == "19") { this.day = "י\"ט"; }
if (this.day == "20") { this.day = "כ'"; }
if (this.day == "21") { this.day = "כ\"א"; }
if (this.day == "22") { this.day = "כ\"ב"; }
if (this.day == "23") { this.day = "כ\"ג"; }
if (this.day == "24") { this.day = "כ\"ד"; }
if (this.day == "25") { this.day = "כ\"ה"; }
if (this.day == "26") { this.day = "כ\"ו"; }
if (this.day == "27") { this.day = "כ\"ז"; }
if (this.day == "28") { this.day = "כ\"ח"; }
if (this.day == "29") { this.day = "כ\"ט"; }
if (this.day == "30") { this.day = "ל'"; }	

// הפיכת השנה ממספרים לעברית
if (this.year == "5761") { this.year = "התשס\"א"; }
if (this.year == "5762") { this.year = "התשס\"ב"; }
if (this.year == "5763") { this.year = "התשס\"ג"; }
if (this.year == "5764") { this.year = "התשס\"ד"; }
if (this.year == "5765") { this.year = "התשס\"ה"; }
if (this.year == "5766") { this.year = "התשס\"ו"; }
if (this.year == "5767") { this.year = "התשס\"ז"; }
if (this.year == "5768") { this.year = "התשס\"ח"; }
if (this.year == "5769") { this.year = "התשס\"ט"; }
if (this.year == "5770") { this.year = "התש\"ע"; }
if (this.year == "5771") { this.year = "התשע\"א"; }
if (this.year == "5772") { this.year = "התשע\"ב"; }
if (this.year == "5773") { this.year = "התשע\"ג"; }
if (this.year == "5774") { this.year = "התשע\"ד"; }
if (this.year == "5775") { this.year = "התשע\"ה"; }
if (this.year == "5776") { this.year = "התשע\"ו"; }
if (this.year == "5777") { this.year = "התשע\"ז"; }
if (this.year == "5778") { this.year = "התשע\"ח"; }
if (this.year == "5779") { this.year = "התשע\"ט"; }
if (this.year == "5780") { this.year = "התש\"פ"; }


if (this.holiday) {

document.write(""+this.holiday+ ", " + this.day +" ב" + ThisMonthName + " " + this.year);
}

else {
document.write("" + this.day + " ב" + ThisMonthName + " " + this.year);
}
}

// constructor for HebrewDate object
function InitHebrewDate(day, month, year)
{
	// fields
	this.day = day;
	this.month = month;
	this.year = year;
	this.DaysInThisMonth = DaysInHebrewMonth(month, year);
	// methods
	this.IsLastMonth = IsHebLastMonth;
	this.NextMonth = HebNextMonth;
	this.NextDay = HebNextDay;
	this.AddDays = HebAddDays;
	this.Print = HebPrint;
}
// end of HebrewDate object definition
var Today = new Date();

var isnMonths=new Array("ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר");
var isnDays= new Array("יום ראשון","יום שני","יום שלישי","יום רביעי","יום חמישי","יום שישי","יום שבת");
todayG=new Date();

function getFullYear(d) {
    var y = d.getYear();
    if (y < 1000) {y += 1900};
    return y;
}

function ShowHebrewDate(date)
{
	//var MyRoshHashana = new Date(99, 8, 11); // sep 11, 1999
	var PrevYear = date.getFullYear() - 1;
	var PrevRoshHashana = GetRoshHashana(PrevYear);
	var DiffDays = Math.floor((date.getTime() - PrevRoshHashana.getTime()) / MsecPerDay);
	var HebrewYear = JulianYearToHebrew(PrevYear);
	var HebrewDate = new InitHebrewDate(1, 0, HebrewYear+1); // 1, Tishrei, year
	var Year = getFullYear(todayG);
	HebrewDate.AddDays(DiffDays);
   // date in English
document.write("<span dir='rtl'>");
document.write(""+isnDays[todayG.getDay()]+", ");
        HebrewDate.Print();
document.write(", ")
document.write(" "+todayG.getDate()+" ב"+isnMonths[todayG.getMonth()]+" "+Year);
document.write("<\/span>");
}

ShowHebrewDate(Today);

}


﻿//origenal code was made by Joel M. Hoffman from http://www.lashon.net/Parashah.html

var parshiyot = new Array(
new Array(2005,9,08,'Vayeilech','Deuteronomy 31:1 - 31:30','Hosea 14:2-10; Micah 7:18-20; Joel 2:15-27 (Shabbat Shuva)',
'Deuteronomy 31:1 - 31:3',
'Deuteronomy 31:4 - 31:6',
'Deuteronomy 31:7 - 31:9',
'Deuteronomy 31:10 - 31:13',
'Deuteronomy 31:14 - 31:19',
'Deuteronomy 31:20 - 31:24',
'Deuteronomy 31:25 - 31:30'),
new Array(2009,6,18,'מטות-מסעי'),
new Array(2009,6,18,'מטות-מסעי'),
new Array(2009,6,25,'דברים'),
new Array(2009,7,01,'ואתחנן'),
new Array(2009,7,08,'עקב'),
new Array(2009,7,15,'ראה'),
new Array(2009,7,22,'שופטים'),
new Array(2009,7,29,'כי תצא'),
new Array(2009,8,05,'כי תבוא'),
new Array(2009,8,12,'נצבים-וילך'),
new Array(2009,8,26,'האזינו'),
new Array(2009,9,17,'בראשית'),
new Array(2009,9,24,'נח'),
new Array(2009,9,31,'לך לך'),
new Array(2009,10,07,'וירא'),
new Array(2009,10,14,'חיי שרה'),
new Array(2009,10,21,'תולדות'),
new Array(2009,10,28,'ויצא'),
new Array(2009,11,05,'וישלח'),
new Array(2009,11,12,'וישב'),
new Array(2009,11,19,'מקץ'),
new Array(2009,11,26,'ויגש'),
new Array(2010,0,02,'ויחי'),
new Array(2010,0,09,'שמות'),
new Array(2010,0,16,'וארא'),
new Array(2010,0,23,'בא'),
new Array(2010,0,30,'בשלח'),
new Array(2010,1,06,'יתרו'),
new Array(2010,1,13,'משפטים'),
new Array(2010,1,20,'תרומה'),
new Array(2010,1,27,'תצוה'),
new Array(2010,2,06,'כי תשא'),
new Array(2010,2,13,'ויקהל-פקודי (שבת החודש)'),
new Array(2010,2,20,'ויקרא'),
new Array(2010,2,27,'צו (שבת הגדול)'),
new Array(2010,3,10,'שמיני'),
new Array(2010,3,17,'תזריע-מצורע'),
new Array(2010,3,24,'אחרי מות-קדושים'),
new Array(2010,4,01,'אמור'),
new Array(2010,4,08,'בהר-בחוקותי'),
new Array(2010,4,15,'במדבר'),
new Array(2010,4,22,'נשא'),
new Array(2010,4,29,'בהעלותך'),
new Array(2010,5,05,'שלח'),
new Array(2010,5,12,'קרח'),
new Array(2010,5,19,'חוקת'),
new Array(2010,5,26,'בלק'),
new Array(2010,6,03,'פנחס'),
new Array(2010,6,10,'מטות-מסעי'),
new Array(2010,6,17,'דברים'),
new Array(2010,6,24,'ואתחנן'),
new Array(2010,6,31,'עקב'),
new Array(2010,7,07,'ראה'),
new Array(2010,7,14,'שופטים'),
new Array(2010,7,21,'כי תצא'),
new Array(2010,7,28,'כי תבוא'),
new Array(2010,8,04,'נצבים-וילך'),
new Array(2010,8,11,'האזינו'),
new Array(2010,8,18,'יום כיפור'),
new Array(2010,8,25,'חול המועד סוכות'),
new Array(2010,9,02,'בראשית'),
new Array(2010,9,9,'בראשית'),
new Array(2010,9,16,'לך-לך'),
new Array(2010,9,23,'וירא'),
new Array(2010,9,30,'חיי שרה'),
new Array(2010,10,06,'תולדות'),
new Array(2010,10,13,'ויצא'),
new Array(2010,10,20,'וישלח'),
new Array(2010,10,27,'וישב'),
new Array(2010,11,04,'מקץ'),
new Array(2010,11,11,'ויגש'),
new Array(2010,11,18,'ויחי'),
new Array(2010,11,25,'שמות'),
new Array(2011,0,01,'וארא'),
new Array(2011,0,08,'בא'),
new Array(2011,0,15,'בשלח'),
new Array(2011,0,22,'יתרו'),
new Array(2011,0,29,'משפטים'),
new Array(2011,1,05,'תרומה'),
new Array(2011,1,12,'תצוה'),
new Array(2011,1,19,'כי תשא'),
new Array(2011,1,26,'ויקהל'),
new Array(2011,2,05,'פקודי'),
new Array(2011,2,12,'ויקרא'),
new Array(2011,2,19,'צו'),
new Array(2011,2,26,'שמיני'),
new Array(2011,3,02,'תזריע'),
new Array(2011,3,09,'מצורע'),
new Array(2011,3,16,'אחרי'),
new Array(2011,3,23,'חול המועד פסח'),
new Array(2011,3,30,'קדושים'),
new Array(2011,4,07,'אמור'),
new Array(2011,4,14,'בהר'),
new Array(2011,4,21,'בחוקותי'),
new Array(2011,4,28,'במדבר'),
new Array(2011,5,04,'נשא'),
new Array(2011,5,11,'בהעלותך'),
new Array(2011,5,18,'שלח'),
new Array(2011,5,25,'קרח'),
new Array(2011,6,02,'חקת'),
new Array(2011,6,09,'בלק'),
new Array(2011,6,16,'פנחס'),
new Array(2011,6,23,'מטות'),
new Array(2011,6,30,'מסעי'),
new Array(2011,7,06,'דברים'),
new Array(2011,7,13,'ואתחנן'),
new Array(2011,7,20,'עקב'),
new Array(2011,7,27,'ראה'),
new Array(2011,8,03,'שופטים'),
new Array(2011,8,10,'כי תצא'),
new Array(2011,8,17,'כי תבוא'),
new Array(2011,8,24,'נצבים וילך'),
new Array(2011,9,01,'האזינו'),
new Array(2011,9,08,'יום כיפור'),
new Array(2011,9,15,'חול המועד סוכות'),
new Array(2011,9,22,'בראשית'),
new Array(2011,9,29,'נח'),
new Array(2011,10,05,'לך-לך'),
new Array(2011,10,12,'וירא'),
new Array(2011,10,19,'חיי שרה'),
new Array(2011,10,26,'תולדות'),
new Array(2011,11,03,'ויצא'),
new Array(2011,11,10,'וישלח'),
new Array(2011,11,17,'וישב'),
new Array(2011,11,24,'מקץ'),
new Array(2011,11,31,'ויגש'),
new Array(2012,0,07,'ויחי'),
new Array(2012,0,14,'שמות'),
new Array(2012,0,21,'וירא'),
new Array(2012,0,28,'בא'),
new Array(2012,1,04,'וישלח'),
new Array(2012,1,11,'יתרו'),
new Array(2012,1,18,'משפטים'),
new Array(2012,1,25,'תרומה'),
new Array(2012,2,03,'תצוה'),
new Array(2012,2,10,'כי תשא'),
new Array(2012,2,17,'ויקהל-פקודי'),
new Array(2012,2,24,'ויקרא'),
new Array(2012,2,31,'צו'),
new Array(2012,3,07,'פסח'),
new Array(2012,3,14,'שמיני (ישראל)'),
new Array(2012,3,21,'תזריע-מצורע (ישראל)'),
new Array(2012,3,28,'אחרי קדושים (ישראל)'),
new Array(2012,4,05,'אמור (ישראל)'),
new Array(2012,4,12,'בהר (ישראל)'),
new Array(2012,4,19,'בחוקותי (ישראל)'),
new Array(2012,4,26,'במדבר'),
new Array(2012,5,02,'נשא'),
new Array(2012,5,09,'בהעלותך'),
new Array(2012,5,16,'שלח'),
new Array(2012,5,23,'קרח'),
new Array(2012,5,30,'חקת'),
new Array(2012,6,07,'בלק'),
new Array(2012,6,14,'פנחס'),
new Array(2012,6,21,'מטות מסעי'),
new Array(2012,6,28,'דברים'),
new Array(2012,7,04,'ואתחנן'),
new Array(2012,7,11,'עקב'),
new Array(2012,7,18,'ראה'),
new Array(2012,7,25,'שופטים'),
new Array(2012,8,01,'כי תצא'),
new Array(2012,8,08,'כי תבוא'),
new Array(2012,8,15,'נצבים'),
new Array(2012,8,22,'וילך'),
new Array(2012,8,29,'האזינו'),
new Array(2012,9,06,'חול המועד סוכות'),
new Array(2012,9,13,'בראשית'),
new Array(2012,9,20,'נח'),
new Array(2012,9,27,'לך-לך'),
new Array(2012,10,03,'וירא'),
new Array(2012,10,10,'חיי שרה'),
new Array(2012,10,17,'תולדות'),
new Array(2012,10,24,'ויצא'),
new Array(2012,11,01,'וישלח'),
new Array(2012,11,08,'וישב'),
new Array(2012,11,15,'מקץ'),
new Array(2012,11,22,'ויגש'),
new Array(2012,11,29,'ויחי'),
new Array(2013,0,05,'שמות'),
new Array(0,0));


function days_between(date1, date2) {

    var ONE_DAY = 1000 * 60 * 60 * 24

    var date1_ms = date1.getTime()
    var date2_ms = date2.getTime()

    var difference_ms = date2_ms - date1_ms
    
    return Math.round(difference_ms/ONE_DAY)
}

var i=1;
var nextweek = new Date();
var thisweek = new Date();
var done=0;

while ((parshiyot[i][0]>0)&&(done ==0))
 {nextweek.setFullYear(parshiyot[i][0],parshiyot[i][1],parshiyot[i][2]);
 if ((days_between(thisweek,nextweek) < 7)&&(days_between(thisweek,nextweek)>-1))
    {document.write(','+' '+'<a href="http://p.mylush.net">'+ 'פרשת השבוע' +'</a>'+ ':' + ' ');
     document.write(parshiyot[i][3]);
    
     document.write('');
     done=1;
    }
  i++;
 }
if (done==0)
 document.write(' ' + 'פרשה מיוחדת');
   