<!-- Hide

if (document.images) {
  initpics("front-1.jpg", "front-2.jpg", "front-3.jpg", "front-4.jpg", "arc.jpg", "sanctuary.jpg", "words.jpg")
}

function initpics(allpics) {
  if (document.images) {
    imgNames = new Array()
    for (i = 0;i < initpics.arguments.length; i++) {
      imgNames[i] = initpics.arguments[i]
    }
  }
}

if (document.images) {
  picarray = new Array()
  for(j = 0; j < imgNames.length; j++) {
    picarray[j] = new Image()
    picarray[j].src = "images/SynagogueShots/" + imgNames[j]
  }
}

var currentPic = 0
var delay = 1000
var secDelay = 2
var secs
var timerID = null
var timerRunning = false

function InitializeTimer()
{
  // Set the length of the timer, in seconds
  secs = secDelay
  StopTheClock()
  StartTheTimer()
}

function StopTheClock()
{
  if(timerRunning)
    clearTimeout(timerID)
  timerRunning = false
}

function StartTheTimer()
{
  if (secs==0) {
    document ["synagogue_pictures"].src = picarray [currentPic].src

    if (++currentPic == picarray.length)
      currentPic = 0
    secs = secDelay
    StartTheTimer()
  } else {
    secs = secs - 1
    timerRunning = true
    timerID = self.setTimeout("StartTheTimer()", delay)
  }
}




var AtlasData = "40 45 00 N  073 57 00 W EST   -5   *";

var HourRise, HourSet;
var AlphaSun, DeltaSun;

var T, T2, T3 ;
var ThetaSun, Rsun, LonE

var Drc = Math.PI/180. ;

function Sun(T) {
  T2=T*T
  T3=T2*T

  var L = 279.69668 + 36000.76892 * T + .0003025 * T2 ;
  var M = 358.47583 + 35999.04975 * T - .00015 * T2 - .0000033 * T3 ;
  MSun = M ;
  var E = .01675104 - .0000418 * T - .000000126 * T2 ;
  var C = (1.91964 - .004789 * T - .000014 * T2) * Math.sin(Drc * M) + (.020094 - .0001 * T) * Math.sin(2 * Drc * M) + .000293 * Math.sin(3 * Drc * M) ;
  var V = M + C ;
  var R = 1.0000002 * (1 - E * E) / (1 + E * Math.cos(Drc * V)) ;
  Rsun = R ;
  var Theta = L + C ;
  ThetaSun = Drc * Theta ;
  var Eps = 23.452294 - .0130125 * T - .00000164 * T2 + .000000503 * T3 ;
  var Yterm = Math.cos(Drc * Eps) * Math.sin(Drc * Theta) ;
  var Xterm = Math.cos(Drc * Theta) ;
  var Answer=Math.atan2(Yterm, Xterm) ;
  var Alfa = Answer ;
  var Arg = Math.sin(Drc * Eps) * Math.sin(Drc * Theta) ;
  Answer=Math.asin(Arg) ;
  Delta = Answer ;
  DeltaSun=Delta ;
  Yterm = Math.sin(Alfa) * Math.cos(Drc * Eps) + Math.tan(Delta) * Math.sin(Drc * Eps) ;
  Xterm = Math.cos(Alfa) ;
  Answer=Math.atan2(Yterm, Xterm) ;
  Lon = Answer / Drc ;
  if (Lon < 0) Lon = Lon + 360. ;
  var TERM1 = Math.sin(Delta) * Math.cos(Drc * Eps) ;
  var TERM2 = Math.cos(Delta) * Math.sin(Drc * Eps) * Math.sin(Alfa) ;
  Arg = TERM1 - TERM2 ;
  Answer=Math.asin(Arg) ;
  Lat = Answer / Drc ;

  Lat = Delta / Drc ;

// Mean Anomolies
  MMars = 319.51913 + 19139.85475 * T + .000181 * T2 ;
  MMercury = 102.27938 + 149472.51529 * T + .000007 * T2 ;
  MJupiter = 225.32833 + 3034.69202 * T - .000722 * T2 ;
  MVenus = 212.60322 + 58517.80387 * T + .001286 * T2 ;
  MSaturn = 175.46622 + 1221.55147 * T - .000502 * T2 ;

  return(Lon) ;
}

function SunAD(T, T2, T3) {
  var L = 279.69668 + 36000.76892 * T + 0.0003025 * T2 ;
  var M = 358.47583 + 35999.04975 * T - 0.00015 * T2 - 0.0000033 * T3 ;
  var E = 0.01675104 - 0.0000418 * T - 0.000000126 * T2 ;
  var C = (1.91964 - 0.004789 * T - 0.000014 * T2) * Math.sin(Drc * M) + (0.020094 - 0.0001 * T) * Math.sin(2 * Drc * M) + 0.000293 * Math.sin(3 * Drc * M) ;
  var v = M + C ;
  var R = 1.0000002 * (1. - E * E) / (1. + E * Math.cos(Drc * v)) ;
  var Rsun = R ;
  var Theta = L + C ;
  var ThetaSun = Drc * Theta ;
  var Eps = 23.452294 - 0.0130125 * T - 0.00000164 * T2 + 0.000000503 * T3 ;
  var Yterm = Math.cos(Drc * Eps) * Math.sin(Drc * Theta) ;
  var Xterm = Math.cos(Drc * Theta) ;
  Alpha=Math.atan2(Yterm, Xterm) ;
  AlphaSun=Alpha ;
  var Arg = Math.sin(Drc * Eps) * Math.sin(Drc * Theta) ;
}



function RiseSet(JD, UT, DeltaGMT, Geolat, Geolon) {
  var ASUN = new Array(4) ;
  var DSUN = new Array(4) ;
  var SmallH0, JD0, T, T2, T3 ;

  JD0 = JD - UT / 24 ;
  SmallH0=-.83333*Drc ;

  for(k = -1; k < 2; k++) {
  JD = JD0 + k ;
  T = (JD - 2415020.) / 36525. ;
  T2 = T * T ;
  T3 = T2 * T ;
  Sun(T, T2, T3) ;
  SunAD(T, T2, T3) ;
  ASUN[k + 2] = AlphaSun ;
  DSUN[k + 2] = DeltaSun ;

  CosH0 = (Math.sin(SmallH0) - Math.sin(Drc * Geolat) * Math.sin(DSUN[2])) / (Math.cos(Drc * Geolat) * Math.cos(DSUN[2])) ;
  }

  if (Math.abs(CosH0) > 1) {
  HourRise = 999 ;
  HourSet = 999 ;
  }

  var SinH0 = Math.sqrt(1. - CosH0*CosH0) ;
  var Xterm = CosH0 ;
  var Yterm = SinH0 ;
  var Answer=Math.atan2(Yterm, Xterm) ;
  var H0 = Answer / Drc ;

// Calculate Theta0
  T = (JD0 - 2415020.) / 36525. ;
  T2 = T * T ;
  T3 = T2 * T ;
  var T0 = T;  // Used for sunrise and sunset
  var Theta0 = 0.276919398 + 100.0021359 * T + 0.000001075 * T2 ;
  Theta0 = 360. * (Theta0 - Math.floor(Theta0)) ;

  var M0 = (ASUN[2] / Drc + Geolon - Theta0) / 360. ;
  var M1 = M0 - H0 / 360. ;
  var M2 = M0 + H0 / 360. ;

  if (M0 < 0) M0++ ;
  if (M1 < 0) M1++ ;
  if (M2 < 0) M2++ ;
  M0 = M0 - Math.floor(M0) ;
  M1 = M1 - Math.floor(M1) ;
  M2 = M2 - Math.floor(M2) ;

  for (k=0; k<3; k++) {
  Theta = Theta0 + 360.985647 * M1 ;
  T = T0 + M1 / 36525. ;
  T2 = T * T ;
  T3 = T2 * T ;
  //alert("In Loop:   M1: " + M1 + "  Theta0: " + Theta0 + " T0: " + T0 + "  T: " + T)

  Sun(T, T2, T3) ;
  SunAD(T, T2, T3) ;
  //alert("In Loop 2: Alpha: " + Alpha + "  Delta: " + Delta)
  H = Theta - Geolon - AlphaSun / Drc ;
  Arg = Math.sin(Drc * Geolat) * Math.sin(DeltaSun) + Math.cos(Drc * Geolat) * Math.cos(Delta) * Math.cos(Drc * H) ;
  Answer=Math.asin(Arg) ;
  SmallH = Answer / Drc ;
  DeltaM = (SmallH - SmallH0 / Drc) / (360. * Math.cos(DeltaSun) * Math.cos(Drc * Geolat) * Math.sin(Drc * H)) ;
  M1 = M1 + DeltaM ;
  }

  HourRise = 24. * M1 - DeltaGMT ;
  if (HourRise > 24.) HourRise = HourRise - 24. ;
  if (HourRise < 0.) HourRise = HourRise + 24. ;

  for (k=0; k<3; k++) {
  Theta = Theta0 + 360.985647 * M2 ;
  T = T0 + M2 / 36525. ;
  T2 = T * T ;
  T3 = T2 * T ;
  Sun(T, T2, T3) ;
  SunAD(T, T2, T3) ;
  H = Theta - Geolon - AlphaSun / Drc ;
  Arg = Math.sin(Drc * Geolat) * Math.sin(DeltaSun) + Math.cos(Drc * Geolat) * Math.cos(Delta) * Math.cos(Drc * H) ;
  Answer=Math.asin(Arg) ;
  SmallH = Answer / Drc ;
  DeltaM = (SmallH - SmallH0 / Drc) / (360. * Math.cos(DeltaSun) * Math.cos(Drc * Geolat) * Math.sin(Drc * H)) ;
  M2 = M2 + DeltaM ;
  }

  HourSet=24.*M2
  if (HourSet < 0.) HourSet += 24. ;
}


function getRiseSet(Month, Day, Year, Geolat, Geolon, DeltaGMT) {
  var Month=0, Day=0, Year;
  var UT;
  Today = new Date() ;

  Month=Today.getMonth() + 1
  Day=Today.getDate()
  Year=Today.getFullYear()

  Hr=Today.getHours()
  Mn=Today.getMinutes()
  Sc=Today.getSeconds()

  DeltaGMT=parseFloat(AtlasData.substr(30,3))
  if (AtlasData.substr(33,2) != "  ") DeltaGMT += parseFloat(AtlasData.substr(33,2))/60.

//=====================================//
// Longitude and Latitude of Hillcrest //
//=====================================//
  LatRef=parseFloat(AtlasData.substr(0,2)) + parseFloat(AtlasData.substr(3,2))/60. +  parseFloat(AtlasData.substr(6,2))/3600.
  LonRef=parseFloat(AtlasData.substr(12,3)) + parseFloat(AtlasData.substr(16,2))/60. +  parseFloat(AtlasData.substr(19,2))/3600.
//  LatRef = 40.75170
//  LonRef = 73.99420

  sLatRefDir=AtlasData.charAt(9)
  sLonRefDir=AtlasData.charAt(22)

  if (sLonRefDir == "E") LMT = UT + LonRef / 15.
  if (sLonRefDir == "W") LMT = UT - LonRef / 15.

  Geolat=LatRef
  if (sLatRefDir == "S") Geolat=-Geolat

  Geolon=LonRef
  if (sLonRefDir == "W") Geolon=-Geolon

  DeltaLonGMT=Geolon/15.

  CT = parseFloat(Hr) + parseFloat(Mn) / 60. + parseFloat(Sc)/3600.
  UT=15. ;
  Geolon=0.
  DeltaGMT=0.

  var JDS=JDCalc(Month, Day, Year, UT) ;
  DOW=GetDayOfWeek(JDS, UT)
  if (DOW < 6) JDS += 6 - DOW
  if (DOW == 7) JDS += 6

  RiseSet(JDS, UT, DeltaGMT, Geolat, Geolon) ;

  DeltaGMT=parseFloat(AtlasData.substr(30,3))
  if (AtlasData.substr(33,2) != "  ") DeltaGMT += parseFloat(AtlasData.substr(33,2))/60.

  HourSet += -DeltaLonGMT + DeltaGMT  // Conversion to local time
  HourSet += -.3              // Subtract 18 minutes for candle lighting time
  hh=Math.floor(HourSet)
  mm=Math.floor(60*(HourSet - hh))
  if (mm == 60) {
  mm=0
  hh += 1
  }
//==============================//
// Handle Daylight Savings Time //
// by adding one hour           //
//==============================//
  if (Today.toString().indexOf("EDT") > 0) {
  hh++;
  }
//=============================//
// Return Candle Lighting Time //
//=============================//
  if (mm < 10) {
   return (hh-12 + ":0" + mm + " PM");
  } else {
   return (hh-12 + ":" + mm + " PM");
  }
}


function GetDayOfWeek(JD, UT) {
  DOW = (JD - UT / 24. + 1.5) / 7.
  DOW = Math.floor(7 * (DOW - Math.floor(DOW)) + 1.00001)
  return(DOW)
}


// ****** JDCalc ******
function JDCalc (Mnth, Dy, Yr, UT) {
  var M, Y ;

  if (Mnth > 2) {
  Y = Math.floor(Yr) ;
  M = Math.floor(Mnth) ;
  }
  else {
  Y = Math.floor(Yr - 1) ;
  M = Math.floor(Mnth + 12) ;
  }

  A = Math.floor(Y / 100) ;
  B = Math.floor(2 - A) + Math.floor(A / 4) ;
  JD1 = Math.floor(365.25 * Y) ;
  JD2 = Math.floor(30.6001 * (M + 1)) ;
  JD = JD1 + JD2 + Dy + 1720994.5 + B ;
  JD = JD + UT / 24 ;
  T = (JD - 2415020.) / 36525 ;
  T2 = T * T ;
  T3 = T2 * T ;

  return JD ;
}



/***************************************************************
* This script was adapted from C sources written by
* Scott E. Lee, which contain the following copyright notice:
*
* Copyright 1993-1995, Scott E. Lee, all rights reserved.
* Permission granted to use, copy, modify, distribute and sell
so long as
* the above copyright and this permission statement are
retained in all
* copies. THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
*
* Bill Hastings
* RBI Software Systems
* bhastings@rbi.com <mailto:bhastings@rbi.com>
****************************************************************/
var GREG_SDN_OFFSET = 32045,
    DAYS_PER_5_MONTHS = 153,
    DAYS_PER_4_YEARS = 1461,
    DAYS_PER_400_YEARS = 146097;
var HALAKIM_PER_HOUR = 1080,
    HALAKIM_PER_DAY = 25920,
    HALAKIM_PER_LUNAR_CYCLE = ((29 * HALAKIM_PER_DAY) + 13753),
    HALAKIM_PER_METONIC_CYCLE = (HALAKIM_PER_LUNAR_CYCLE * (12 * 19 + 7));
var HEB_SDN_OFFSET = 347997,
    NEW_MOON_OF_CREATION = 31524,
    NOON = (18 * HALAKIM_PER_HOUR),
    AM3_11_20 = ((9 * HALAKIM_PER_HOUR) + 204),
    AM9_32_43 = ((15 * HALAKIM_PER_HOUR) + 589);
var SUN = 0,
    MON = 1,
    TUES = 2,
    WED = 3,
    THUR = 4,
    FRI = 5,
    SAT = 6;
var today = null,
    hebrewMonth = 0,
    hebrewDate = 0,
    hebrewYear = 0,
    metonicCycle = 0,
    metonicYear = 0,
    moladDay = 0,
    moladHalakim = 0;
var gWeekday = new weekdayarr("Sun","Mon","Tues","Wednes","Thurs","Fri","Satur");
var gMonth = new gregmontharr("January","February","March","April","May","June","July","August","September","October","November","December");
var hMonth = new hebrewmontharr("Tishri","Heshvan","Kislev","Tevet","Shevat","Adar I","Adar II","Nisan","Iyar","Sivan","Tammuz","Av","Elul");
var mpy = new monthsperyeararr(12,12,13,12,12,13,12,13,12,12,13,12,12,13,12,12,13,12,13);

function weekdayarr(d0,d1,d2,d3,d4,d5,d6) {
  this[0] = d0; this[1] = d1; this[2] = d2; this[3] = d3;
  this[4] = d4; this[5] = d5; this[6] = d6;
}

function gregmontharr(m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11) {
  this[0] = m0; this[1] = m1; this[2] = m2; this[3] = m3;
  this[4] = m4; this[5] = m5; this[6] = m6; this[7] = m7;
  this[8] = m8; this[9] = m9; this[10] = m10; this[11] = m11;
}

function hebrewmontharr(m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13) {
  this[0] = m0; this[1] = m1; this[2] = m2; this[3] = m3;
  this[4] = m4; this[5] = m5; this[6] = m6; this[7] = m7;
  this[8] = m8; this[9] = m9; this[10] = m10; this[11] = m11;
  this[12] = m12; this[13] = m13;
}

function monthsperyeararr(m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,m16,m17,m18) {
  this[0] = m0; this[1] = m1; this[2] = m2; this[3] = m3;
  this[4] = m4; this[5] = m5; this[6] = m6; this[7] = m7;
  this[8] = m8; this[9] = m9; this[10] = m10; this[11] = m11;
  this[12] = m8; this[13] = m13; this[14] = m14; this[15] = m15;
  this[16] = m16; this[17] = m17; this[18] = m18;
}

function getToday() {
  if(today == null)
   today = new Date();
}

function displayWeekday() {
  getToday();
  document.writeln(gWeekday[today.getDay()] + "day");
}

function displayGregorianDate() {
  getToday();
  document.writeln(gMonth[today.getMonth()] + " " +
  today.getDate() + ", " + (today.getYear()));
}

function displayHebrewDate() {
  if(hebrewDate != 0 && hebrewMonth != 0 && hebrewYear != 0)
    document.writeln(hebrewDate + " " + hMonth[hebrewMonth-1] + " " + hebrewYear);
}

function GregorianToSdn(inputYear,inputMonth,inputDay) {
  var year = 0,
      month = 0,
      sdn;

  getToday();
  // Make year a positive number
  if (inputYear < 0)
    year = inputYear + 4801;
  else
    year = inputYear + 4800;
  // Adjust the start of the year
  if (inputMonth > 2) {
    month = inputMonth - 3;
  }
  else {
    month = inputMonth + 9;
    year--;
  }
  sdn = Math.floor((Math.floor(year / 100) * DAYS_PER_400_YEARS) / 4);
  sdn += Math.floor(((year % 100) * DAYS_PER_4_YEARS) / 4);
  sdn += Math.floor((month * DAYS_PER_5_MONTHS + 2) / 5);
  sdn += inputDay - GREG_SDN_OFFSET;
  return sdn;
}

function SdnToHebrew(sdn) {
  var inputDay,
      tishri1 = 0,
      tishri1After = 0,
      yearLength = 0,
      inputDay = sdn - HEB_SDN_OFFSET;

  FindTishriMolad(inputDay);
  tishri1 = Tishri1(metonicYear,moladDay,moladHalakim);
  if (inputDay >= tishri1) {
    // It found Tishri 1 at the start of the year.
    hebrewYear = metonicCycle * 19 + metonicYear + 1;
    if (inputDay < tishri1 + 59) {
      if (inputDay < tishri1 + 30) {
        hebrewMonth = 1;
        hebrewDate = inputDay - tishri1 + 1;
      }
      else {
        hebrewMonth = 2;
        hebrewDate = inputDay - tishri1 - 29;
      }
      return;
    }
    // We need the length of the year to figure this out,so find Tishri 1 of the next year.
    moladHalakim += HALAKIM_PER_LUNAR_CYCLE * mpy[metonicYear];
    moladDay += Math.floor(moladHalakim / HALAKIM_PER_DAY);
    moladHalakim = moladHalakim % HALAKIM_PER_DAY;
    tishri1After = Tishri1((metonicYear + 1) % 19,moladDay,moladHalakim);
  }
  else {
    // It found Tishri 1 at the end of the year.
    hebrewYear = metonicCycle * 19 + metonicYear;
    if (inputDay >= tishri1 - 177) {
      // It is one of the last 6 months of the year.
      if (inputDay > tishri1 - 30) {
        hebrewMonth = 13;
        hebrewDate = inputDay - tishri1 + 30;
      }
      else if (inputDay > tishri1 - 60) {
        hebrewMonth = 12;
        hebrewDate = inputDay - tishri1 + 60;
      }
      else if (inputDay > tishri1 - 89) {
        hebrewMonth = 11;
        hebrewDate = inputDay - tishri1 + 89;
      }
      else if (inputDay > tishri1 - 119) {
        hebrewMonth = 10;
        hebrewDate = inputDay - tishri1 + 119;
      }
      else if (inputDay > tishri1 - 148) {
        hebrewMonth = 9;
        hebrewDate = inputDay - tishri1 + 148;
      }
      else {
        hebrewMonth = 8;
        hebrewDate = inputDay - tishri1 + 178;
      }
      return;
    }
    else {
      if (mpy[(hebrewYear - 1) % 19] == 13) {
        hebrewMonth = 7;
        hebrewDate = inputDay - tishri1 + 207;
        if (hebrewDate > 0)
          return;
        hebrewMonth--;
        hebrewDate += 30;
        if (hebrewDate > 0)
          return;
        hebrewMonth--;
        hebrewDate += 30;
      }
      else {
        hebrewMonth = 6;
        hebrewDate = inputDay - tishri1 + 207;
        if (hebrewDate > 0)
          return;
        hebrewMonth--;
        hebrewDate += 30;
      }
      if (hebrewDate > 0)
        return;
      hebrewMonth--;
      hebrewDate += 29;
      if (hebrewDate > 0)
        return;
// We need the length of the year to figure this out,so find Tishri 1 of this year.
      tishri1After = tishri1;
      FindTishriMolad(moladDay - 365);
      tishri1 = Tishri1(metonicYear,moladDay,moladHalakim);
    }
  }
  yearLength = tishri1After - tishri1;
  moladDay = inputDay - tishri1 - 29;
  if (yearLength == 355 || yearLength == 385) {
// Heshvan has 30 days
    if (moladDay <= 30) {
      hebrewMonth = 2;
      hebrewDate = moladDay;
      return;
    }
    moladDay -= 30;
  }
  else {
// Heshvan has 29 days
    if (moladDay <= 29) {
      hebrewMonth = 2;
      hebrewDate = moladDay;
      return;
    }
    moladDay -= 29;
  }
// It has to be Kislev.
  hebrewMonth = 3;
  hebrewDate = moladDay;
}

function FindTishriMolad(inputDay) {
// Estimate the metonic cycle number. Note that this may be an under
// estimate because there are 6939.6896 days in a metonic cycle not
// 6940,but it will never be an over estimate. The loop below will
// correct for any error in this estimate.
  metonicCycle = Math.floor((inputDay + 310) / 6940);
// Calculate the time of the starting molad for this metonic cycle.
  MoladOfMetonicCycle();
// If the above was an under estimate,increment the cycle number until
// the correct one is found. For modern dates this loop is about 98.6%
// likely to not execute,even once,because the above estimate is
// really quite close.
  while (moladDay < inputDay - 6940 + 310) {
    metonicCycle++;
    moladHalakim += HALAKIM_PER_METONIC_CYCLE;
    moladDay += Math.floor(moladHalakim / HALAKIM_PER_DAY);
    moladHalakim = moladHalakim % HALAKIM_PER_DAY;
  }
// Find the molad of Tishri closest to this date.
  for (metonicYear = 0; metonicYear < 18; metonicYear++) {
    if (moladDay > inputDay - 74)
      break;
    moladHalakim += HALAKIM_PER_LUNAR_CYCLE * mpy[metonicYear];
    moladDay += Math.floor(moladHalakim / HALAKIM_PER_DAY);
    moladHalakim = moladHalakim % HALAKIM_PER_DAY;
  }
}

function MoladOfMetonicCycle() {
  var r1,r2,d1,d2;

// Start with the time of the first molad after creation.
  r1 = NEW_MOON_OF_CREATION;
// Calculate gMetonicCycle * HALAKIM_PER_METONIC_CYCLE. The upper 32
// bits of the result will be in r2 and the lower 16 bits will be in r1.
  r1 += metonicCycle * (HALAKIM_PER_METONIC_CYCLE & 0xFFFF);
  r2 = r1 >> 16;
  r2 += metonicCycle * ((HALAKIM_PER_METONIC_CYCLE >> 16) & 0xFFFF);
// Calculate r2r1 / HALAKIM_PER_DAY. The remainder will be in r1,the
// upper 16 bits of the quotient will be in d2 and the lower 16 bits
// will be in d1.
  d2 = Math.floor(r2 / HALAKIM_PER_DAY);
  r2 -= d2 * HALAKIM_PER_DAY;
  r1 = (r2 << 16) | (r1 & 0xFFFF);
  d1 = Math.floor(r1 / HALAKIM_PER_DAY);
  r1 -= d1 * HALAKIM_PER_DAY;
  moladDay = (d2 << 16) | d1;
  moladHalakim = r1;
}

function Tishri1(metonicYear,moladDay,moladHalakim) {
  var tishri1 = moladDay;
  var dow = tishri1 % 7;
  var leapYear = metonicYear == 2 || metonicYear == 5 ||
                 metonicYear == 7 || metonicYear == 10 ||
                 metonicYear == 13 || metonicYear == 16 || metonicYear == 18;
  var lastWasLeapYear = metonicYear == 3 || metonicYear == 6 ||
      metonicYear == 8 || metonicYear == 11 ||
      metonicYear == 14 || metonicYear == 17 || metonicYear == 0;

// Apply rules 2,3 and 4
  if ((moladHalakim >= NOON) ||
      ((!leapYear) && dow == TUES && moladHalakim >= AM3_11_20) ||
      (lastWasLeapYear && dow == MON && moladHalakim >= AM9_32_43)) {
    tishri1++;
    dow++;
    if (dow == 7)
      dow = 0;
  }
// Apply rule 1 after the others because it can cause an additional delay of one day.
  if (dow == WED || dow == FRI || dow == SUN) {
    tishri1++;
  }
  return tishri1;
}
// end hiding contents from old browsers -->

//----------------COOKIE--------------------

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {  
  var arg = name + "=";  
  var alen = arg.length;  
  var clen = document.cookie.length;  
  var i = 0;  

  while (i < clen) {    
    var j = i + alen;    
    if (document.cookie.substring(i, j) == arg)      
      return getCookieVal (j);    
    i = document.cookie.indexOf(" ", i) + 1;    
    if (i == 0) break;   
  }  
  return null;
}

function SetCookie (name, value) {  
  var argv = SetCookie.arguments;  
  var argc = SetCookie.arguments.length;  
  var expires = (argc > 2) ? argv[2] : null;  
  var path = (argc > 3) ? argv[3] : null;  
  var domain = (argc > 4) ? argv[4] : null;  
  var secure = (argc > 5) ? argv[5] : false;  

  document.cookie = name + "=" + escape (value) + 
  ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
  ((path == null) ? "" : ("; path=" + path)) +  
  ((domain == null) ? "" : ("; domain=" + domain)) +    
  ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {  
  var exp = new Date();  
  exp.setTime (exp.getTime() - 1);  
  var cval = GetCookie (name);  
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function popupcookie()
{
  if (GetCookie("HillcrestPopup") == null) {
    //DeleteCookie("HillcrestPopup");
    //window.open("newsletter-popup.html", "_newsletter", "resizable=yes,toolbar=no,titlebar=no,status=no,width=410,height=410,toolbar=no,scrollbars=yes");

    window.open("israel_solidarity_rally.html", "israel_solidarity_rally", "resizable=yes,toolbar=no,titlebar=no,status=no,width=600,height=410,toolbar=no,scrollbars=yes");
    SetCookie("HillcrestPopup", "true");
  }
}


