/* Proverb of the Day Script written by Joe Courtney for the Glenwood Bible Church website */
   var currentDate = new Date();
   var currentProverb = currentDate.getDate();

   function getProverb(isNew)
   {
      var verse;
      var reference;

      if(isNew == 0)
         currentProverb = currentDate.getDate();
      else if(isNew == -1 && currentProverb > 1)
         currentProverb--;
      else if(isNew == 1 && currentProverb < currentDate.getDate())
         currentProverb++;


      if(currentProverb == 1)
         document.getElementById("previous").innerHTML = "Previous";
      else
         document.getElementById("previous").innerHTML = '<a href="javascript:getProverb(-1)"><-Previous<\/a>'
      if(currentProverb == currentDate.getDate())
         document.getElementById("next").innerHTML = "Next";
      else
         document.getElementById("next").innerHTML = '<a href="javascript:getProverb(1)">Next-><\/a>'
      
      switch(currentProverb)
      {
         case 1:
            verse = "The fear of the Lord is the beginning of knowledge: but fools despise wisdom and instruction.";
            reference = "Proverbs 1:7";
            break;
         case 2:
            verse = "Yea, if thou criest after knowledge, and liftest up thy voice for understanding; if thou seekest her as silver, and searchest for her as for hid treasures; Then shalt thou understand the fear of the Lord, and find the knowledge of God.";
            reference = "Proverbs 2:3-5";
            break;
         case 3:
            verse = "Trust in the Lord with all thine heart; and lean not unto thine own understanding. In all thy ways acknowledge Him, and He shall direct thy paths.";
            reference = "Proverbs 3:5-6";
            break;
         case 4:
            verse = "Keep thy heart with all diligence; for out of it are the issues of life.";
            reference = "Proverbs 4:23";
            break;
         case 5:
            verse = "For the ways of man are before the eyes of the Lord, and he pondereth all his goings.";
            reference = "Proverbs 5:21";
            break;
         case 6:
            verse = "These six things doth the Lord hate: yea, seven are an abomination unto Him: A proud look, a lying tongue, and hands that shed innocent blood, An heart that deviseth wicked imaginations, feet that be swift in running to mischief, A false witness that speaketh lies, and he that soweth discord among brethren.";
            reference = "Proverbs 6:16-19";
            break;
         case 7:
            verse = "Keep My commandments, and live; and My law as the apple of thine eye.";
            reference = "Proverbs 7:2";
            break;
         case 8:
            verse = "Blessed is the man that heareth Me, watching daily at My gates, waiting at the posts of My doors.";
            reference = "Proverbs 8:34";
            break;
         case 9:
            verse = "The fear of the Lord is the beginning of wisdom: and the knowledge of the holy is understanding.";
            reference = "Proverbs 9:10";
            break;
         case 10:
            verse = "Hatred stirreth up strifes: but love covereth all sins.";
            reference = "Proverbs 10:12";
            break;
         case 11:
            verse = "Where no counsel is, the people fall: but in the multitude of counsellors there is safety.";
            reference = "Proverbs 11:14";
            break;
         case 12:
            verse = "The way of a fool is right in his own eyes: but he that hearkeneth unto counsel is wise.";
            reference = "Proverbs 12:15";
            break;
         case 13:
            verse = "He that walketh with wise men shall be wise: but a companion of fools shall be destroyed.";
            reference = "Proverbs 13:20";
            break;
         case 14:
            verse = "In the fear of the Lord is strong confidence: and his children shall have a place of refuge.";
            reference = "Proverbs 14:26";
            break;
         case 15:
            verse = "A soft answer turneth away wrath: but grevous words stir up anger.";
            reference = "Proverbs 15:1";
            break;
         case 16:
            verse = "Commit thy works unto the Lord, and thy thoughts shall be established.";
            reference = "Proverbs 16:3";
            break;
         case 17:
            verse = "A merry heart doeth good like a medicine: but a broken spirit drieth the bones.";
            reference = "Proverbs 17:22";
            break;
         case 18:
            verse = "The name of the Lord is a strong tower: the righteous runneth into it, and is safe.";
            reference = "Proverbs 18:10";
            break;
         case 19:
            verse = "He that getteth wisdom loveth his own soul: he that keepeth understanding shall find good.";
            reference = "Proverbs 19:8";
            break;
         case 20:
            verse = "Even a child is known by his doings, whether his work be pure, and whether it be right.";
            reference = "Proverbs 20:11";
            break;
         case 21:
            verse = "He that followeth after righteousness and mercy findeth life, righteousness, and honour.";
            reference = "Proverbs 21:21";
            break;
         case 22:
            verse = "A good name is rather to be chosen than great riches, and loving favor rather than silver and gold.";
            reference = "Proverbs 22:1";
            break;
         case 23:
            verse = "Labour not to be rich: cease from thine own wisdom.";
            reference = "Proverbs 23:4";
            break;
         case 24:
            verse = "A wise man is strong; yea, a man of knowledge increaseth strength.";
            reference = "Proverbs 24:5";
            break;
         case 25:
            verse = "If thine enemy be hungry, give him bread to eat; and if he be thirsty, give him water to drink: For thou shalt heap coals of fire upon his head, and the Lord shall reward thee.";
            reference = "Proverbs 25:21";
            break;
         case 26:
            verse = "Answer not a fool according to his folly, lest thou also be like unto him.";
            reference = "Proverbs 26:4";
            break;
         case 27:
            verse = "Open rebuke is better than secret love. Faithful are the wounds of a friend; but the kisses of an enemy are deceitful.";
            reference = "Proverbs 27:5-6";
            break;
         case 28:
            verse = "He that trusteth in his own heart is a fool: but whoso walketh wisely, he shall be delivered.";
            reference = "Proverbs 28:26";
            break;
         case 29:
            verse = "A man's pride shall bring him low: but hounour shall uphold the humble in spirit.";
            reference = "Proverbs 29:23";
            break;
         case 30:
            verse = "Every word of God is pure: He is a shield unto them that put their trust in Him.";
            reference = "Proverbs 30:5";
            break;
         case 31:
            verse = "Favour is deceitful, and beauty is vain: but a woman that feareth the Lord, she shall be praised.";
            reference = "Proverbs 31:30";
            break;
         default:
            verse = "Verse";
            reference = "Reference";
      }
      
      document.getElementById("proverb").innerHTML = verse;
      document.getElementById("reference").innerHTML = reference;
   }

/* Calendar Event Script written by Joe Courtney for the Glenwood Bible Church website */

   function getMonth()
   {
      var currentDate = new Date();

/*       Global variable to represent the current month
   -----------------------------------------------------------
  | January = 0          February = 1          March     = 2  |
  | April   = 3          May      = 4          June      = 5  |
  | July    = 6          August   = 7          September = 8  |
  | October = 9          November = 10         December  = 11 |
   -----------------------------------------------------------  
*/
      switch (currentDate.getMonth())
      {
         case 0: // January
            return "January";
            break;
         case 1: // February
            return "February";
            break;
         case 2: // March
            return "March";
            break;
         case 3: // April
            return "April";
            break;
         case 4: // May
            return "May";
            break;
         case 5: // June
            return "June";
            break;
         case 6: // July
            return "July";
            break;
         case 7: // August
            return "August";
            break;
         case 8: // September
            return "September";
            break;
         case 9: // October
            return "October";
            break;
         case 10: // November
            return "November";
            break;
         case 11: // December
            return "December";
            break;
         default:
            return " ";
       
      }

   }
   
   var CURRENTMONTH = 0; 
   var MONTH;

   function boldDate()
   {
      var currentDate = new Date();

 //     document.getElementById("monthname").innerHTML = '<a href="img/' + getFileName() + '">' + getMonth() + ' ' + currentDate.getFullYear() + '</a>';

      if (currentDate.getMonth() == CURRENTMONTH)
         document.getElementById("day" + currentDate.getDate()).innerHTML = '<b>' + currentDate.getDate() + "<\/b>";
      else
         document.getElementById("wp-calendar").innerHTML = "The calendar is currently being updated. <br /> Please check back soon.";
   }

   function getFileName()
   {
      var currentDate = new Date();

      switch (currentDate.getMonth())
      {
         case 0: // January
            return "jan" + currentDate.getFullYear() + ".jpg";
            break;
         case 1: // February
            return "feb" + currentDate.getFullYear() + ".jpg";
            break;
         case 2: // March
            return "march" + currentDate.getFullYear() + ".jpg";
            break;
         case 3: // April
            return "april" + currentDate.getFullYear() + ".jpg";
            break;
         case 4: // May
            return "may" + currentDate.getFullYear() + ".jpg";
            break;
         case 5: // June
            return "june" + currentDate.getFullYear() + ".jpg";
            break;
         case 6: // July
            return "july" + currentDate.getFullYear() + ".jpg";
            break;
         case 7: // August
            return "aug" + currentDate.getFullYear() + ".jpg";
            break;
         case 8: // September
            return "sept" + currentDate.getFullYear() + ".jpg";
            break;
         case 9: // October
            return "oct" + currentDate.getFullYear() + ".jpg";
            break;
         case 10: // November
            return "nov" + currentDate.getFullYear() + ".jpg";
            break;
         case 11: // December
            return "dec" + currentDate.getFullYear() + ".jpg";
            break;
         default:
            return " ";
       
      }

   }

   function showEvent(eventDate)
   {
      var event;
      var currentDate = new Date();
      if (currentDate.getMonth() == CURRENTMONTH)
      {
         switch(eventDate)
         {
            /* Each case is a date of an event, where: 1 is the first of the month, 2 is the second, ect use default for dates with no events */
            case 1:
               event = "<i>Communion Sunday</i> <br /> 9:30 AM Sunday School <br /> 11:00 AM Worship Service <br /> 6:00 PM Evening Service";
               break;

            case 4:
            case 11:
            case 18:
            case 25:
               event = "7:00 PM Prayer Meeting";
               break;
            case 5:
               event = "7:00 PM Dorcas Meeting";
               break;
            case 8:
            case 22:
            case 29:
               event = "9:30 AM Sunday School <br /> 11:00 AM Worship Service <br /> 6:00 PM Evening Service";
               break;
            case 14:
               event = "8:30 AM Executive Committee Meeting";
               break;
            case 15:
               event = "9:30 AM Sunday School <br /> 11:00 AM Worship Service <br /> 12:30 PM Potluck <br /> 1:30 PM Quarterly Business Meeting <br /> No Evening Service";
               break;          
            default:
               event = "No Events are scheduled for " + getMonth() + " " + eventDate;
               break;
         }

         if (currentDate.getDate() <= eventDate)
            document.getElementById('event').innerHTML = '<center style="text-decoration: none">' + event + '<\/center>';
         else
            document.getElementById('event').innerHTML = '<center style="text-decoration: line-through">' + event + '<\/center>';      
      }
   }

   function hideEvent()
   {
      document.getElementById('event').innerHTML = '';
   }
