
        // <!CDATA[
    
//********************************************************************************
//ADDED CODE
//CREATED BY: Shmueli Englard
   
        /*  Adaption code:
            Replaces "<input>"s that existed in origanal file and are
            not need for diplay but are need for calculations.
        */
        
        var document_gregorian_year = "1998",    //Curent english year
            document_gregorian_month = new Array("January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"),    //English months
            document_gregorian_month_index = 0    //Curent english month
            document_gregorian_wday = "",    //Curent english day of the week
            document_gregorian_leap = "",    //Is the curent english year a leap year?
            document_gregorian_day = "",    //Curent english day of the month
            document_gregorian_hour = 0,    //Curent hour
            document_gregorian_min = 0,    //Curent minute
            document_gregorian_sec = 0,    //Curent second
            hebmonths = new Array("Nisan", "Iyar", "Sivan", "Tammuz", "Av", "Elul", "Tishri", "Heshvan", "Kislev", "Tevet", "Shevat", "Adar", "Adar II"),    //Hebrew months
            hebmonth = "",    //Curent hebrew month
            hebday = "",    //Curent hebrew day of the month
            hebyear = "",    //Curent hebrew year
            hebleap = "",    //Is the curent hebrew year a leap year?
            today = new Date(),    //Curent Date
            dayswk = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");    //English days of the week
        
        //Set the english variables    
        function gregorianSet() {
            document_gregorian_month_index = today.getMonth();    //Set month
            document_gregorian_wday = dayswk[today.getDay()];    //Set day of the week
            document_gregorian_leap = engleap(today.getFullYear());    //Set if its a leap year
            document_gregorian_year = today.getFullYear()    //Set year
            document_gregorian_day = today.getDate();    //Set day
            document_gregorian_hour = today.getHours();    //Set hours
            document_gregorian_min = today.getMinutes();    //Set minutes
            document_gregorian_sec = today.getSeconds();    //Set seconds
        }
        
        //Calculate if its a english leap year
        function engleap(year) {
            //Is the year divideable by 4?
            if ((year % 4) == 0) {
                //Is the year dividable by 100
                if ((year % 100) == 0) {
                    //Is the year dividable by 400
                    if ((year % 400) == 0){
                        return "Leap Year"    //Return that it is a leap year
                    }
                }
                else {
                    return "Leap Year"    //Return that it is a leap year
                }
            }
            else {
                return "Normal Year"    //Return that it is not a leap year
            }
        }
        
        //Write the english and hebrew dates
        function writedate() {
            var todaystr = document_gregorian_wday + ", " + document_gregorian_month[document_gregorian_month_index] + " " + document_gregorian_day + ", " + document_gregorian_year,    //Create the text to be out put for the english date
                hebstr = hebday + " " + hebmonth + " " + hebyear;    //Create the text to be out put for the hebrew date
            
                englishdate.innerText = todaystr;    //Out put the english date
                hebrewdate.innerText = hebstr;    //Out put the hebrew date
        }

//********************************************************************************
//
//********************************************************************************
//ORIGANAL CODE
//CREATED BY: John Walker
//NOTE: PARTS NOT NEED WERE DELETED OR COMMENTED OUT & CIRTAN LINES WERE ADDED FOR ADAPTION REASONS
//SRC: http://www.fourmilab.ch/documents/calendar/


        /*  You may notice that a variety of array variables logically local
            to functions are declared globally here.  In JavaScript, construction
            of an array variable from source code occurs as the code is
            interpreted.  Making these variables pseudo-globals permits us
            to avoid overhead constructing and disposing of them in each
            call on the function in which whey are used.  
        */

        var J0000 = 1721424.5;                // Julian date of Gregorian epoch: 0000-01-01
        var JMJD  = 2400000.5;                // Epoch of Modified Julian Date system

        var NormLeap = new Array("Normal year", "Leap year");

        //  LEAP_GREGORIAN  --  Is a given year in the Gregorian calendar a leap year ?

        function leap_gregorian(year) {
            return ((year % 4) == 0) &&
                (!(((year % 100) == 0) && ((year % 400) != 0)));
        }

        //  GREGORIAN_TO_JD  --  Determine Julian day number from Gregorian calendar date

        var GREGORIAN_EPOCH = 1721425.5;

        function gregorian_to_jd(year, month, day) {
            return (GREGORIAN_EPOCH - 1) +
                (365 * (year - 1)) +
                Math.floor((year - 1) / 4) +
                (-Math.floor((year - 1) / 100)) +
                Math.floor((year - 1) / 400) +
                Math.floor((((367 * month) - 362) / 12) +
                ((month <= 2) ? 0 :
                    (leap_gregorian(year) ? -1 : -2)
                ) +
                day);
        }

        //  PAD  --  Pad a string to a given length with a given fill character.

        function pad(str, howlong, padwith) {
            var s = str.toString();

            while (s.length < howlong) {
                s = padwith + s;
            }
            return s;
        }


        //  HEBREW_TO_JD  --  Determine Julian day from Hebrew date

        var HEBREW_EPOCH = 347995.5;

        //  Is a given Hebrew year a leap year ?

        function hebrew_leap(year) {
            return mod(((year * 7) + 1), 19) < 7;
        }

        //  How many months are there in a Hebrew year (12 = normal, 13 = leap)

        function hebrew_year_months(year) {
            return hebrew_leap(year) ? 13 : 12;
        }

        //  Test for delay of start of new year and to avoid
        //  Sunday, Wednesday, and Friday as start of the new year.

        function hebrew_delay_1(year) {
            var months, days, parts;

            months = Math.floor(((235 * year) - 234) / 19);
            parts = 12084 + (13753 * months);
            day = (months * 29) + Math.floor(parts / 25920);

            if (mod((3 * (day + 1)), 7) < 3) {
                day++;
            }
            return day;
        }

        //  Check for delay in start of new year due to length of adjacent years

        function hebrew_delay_2(year) {
            var last, present, next;

            last = hebrew_delay_1(year - 1);
            present = hebrew_delay_1(year);
            next = hebrew_delay_1(year + 1);

            return ((next - present) == 356) ? 2 :
                    (((present - last) == 382) ? 1 : 0);
        }

        //  How many days are in a Hebrew year ?

        function hebrew_year_days(year) {
            return hebrew_to_jd(year + 1, 7, 1) - hebrew_to_jd(year, 7, 1);
        }

        //  How many days are in a given month of a given year

        function hebrew_month_days(year, month) {
            //  First of all, dispose of fixed-length 29 day months

            if (month == 2 || month == 4 || month == 6 ||
                month == 10 || month == 13) {
                return 29;
            }

            //  If it's not a leap year, Adar has 29 days

            if (month == 12 && !hebrew_leap(year)) {
                return 29;
            }

            //  If it's Heshvan, days depend on length of year

            if (month == 8 && !(mod(hebrew_year_days(year), 10) == 5)) {
                return 29;
            }

            //  Similarly, Kislev varies with the length of year

            if (month == 9 && (mod(hebrew_year_days(year), 10) == 3)) {
                return 29;
            }

            //  Nope, it's a 30 day month

            return 30;
        }

        //  Finally, wrap it all up into...

        function hebrew_to_jd(year, month, day) {
            var jd, mon, months;

            months = hebrew_year_months(year);
            jd = HEBREW_EPOCH + hebrew_delay_1(year) +
                 hebrew_delay_2(year) + day + 1;

            if (month < 7) {
                for (mon = 7; mon <= months; mon++) {
                    jd += hebrew_month_days(year, mon);
                }
                for (mon = 1; mon < month; mon++) {
                    jd += hebrew_month_days(year, mon);
                }
            }
            else {
                for (mon = 7; mon < month; mon++) {
                    jd += hebrew_month_days(year, mon);
                }
            }

            return jd;
        }

        /*  JD_TO_HEBREW  --  Convert Julian date to Hebrew date
                              This works by making multiple calls to
                              the inverse function, and is this very
                              slow.  */

        function jd_to_hebrew(jd) {
            var year, month, day, i, count, first;

            jd = Math.floor(jd) + 0.5;
            count = Math.floor(((jd - HEBREW_EPOCH) * 98496.0) / 35975351.0);
            year = count - 1;
            for (i = count; jd >= hebrew_to_jd(i, 7, 1); i++) {
                year++;
            }
            first = (jd < hebrew_to_jd(year, 1, 1)) ? 7 : 1;
            month = first;
            for (i = first; jd > hebrew_to_jd(year, i, hebrew_month_days(year, i)); i++) {
                month++;
            }
            day = (jd - hebrew_to_jd(year, month, 1));// + 1;
            return new Array(year, month, day);
        }

        /*  updateFromGregorian  --  Update all calendars from Gregorian.
                                     "Why not Julian date?" you ask.  Because
                                     starting from Gregorian guarantees we're
                                     already snapped to an integral second, so
                                     we don't get roundoff errors in other
                                     calendars.  */

        function updateFromGregorian() {
            var j, year, mon, mday, hour, min, sec,
                weekday,hebcalhmindex;

            year = new Number(document_gregorian_year);
            mon = document_gregorian_month_index;
            mday = new Number(document_gregorian_day);
            hour = min = sec = 0;
            hour = new Number(document_gregorian_hour);
            min = new Number(document_gregorian_min);
            sec = new Number(document_gregorian_sec);
            
            //  Update Julian day

            j = gregorian_to_jd(year, mon + 1, mday) +
                ((sec + 60 * (min + 60 * hour)) / 86400.0);

            //  Update Hebrew Calendar

            hebcal = jd_to_hebrew(j);
            if (hebrew_leap(hebcal[0])) {
              //document.hebrew.month.options.length = 13;
                hebmonths.length = 13;
              //document.hebrew.month.options[11] = new Option("Adar I");
                hebmonths[11] = "Adar I";
              //document.hebrew.month.options[12] = new Option("Adar II");
                hebmonths[12] = "Adar II";
            }
            else {
              //document.hebrew.month.options.length = 12;
                hebmonths.length = 12;
              //document.hebrew.month.options[11] = new Option("Adar");
                hebmonths[11] = "Adar";
            }
          //document.hebrew.year.value = hebcal[0];
            hebyear = hebcal[0];
          //document.hebrew.month.selectedIndex = hebcal[1] - 1;
            hebmonth = hebmonths[hebcal[1] - 1];
          //document.hebrew.day.value = hebcal[2];
            hebday = hebcal[2];
            
            hmindex = hebcal[1];
            if (hmindex == 12 && !hebrew_leap(hebcal[0])) {
                hmindex = 14;
            }
            
            switch (hebrew_year_days(hebcal[0])) {
                case 353:
                    hebleap = "Common deficient (353 days)";
                    break;

                case 354:
                    hebleap = "Common regular (354 days)";
                    break;

                case 355:
                    hebleap = "Common complete (355 days)";
                    break;

                case 383:
                    hebleap = "Embolismic deficient (383 days)";
                    break;

                case 384:
                    hebleap = "Embolismic regular (384 days)";
                    break;

                case 385:
                    hebleap = "Embolismic complete (385 days)";
                    break;

                default:
                    hebleap = "Invalid year length: " +
                        hebrew_year_days(hebcal[0]) + " days.";
                    break;
            }
        }

        //  calcGregorian  --  Perform calculation starting with a Gregorian date

        function calcGregorian() {
            updateFromGregorian();
        }

//********************************************************************************

        // ]]>
