Bobcat = new Image(168,92) 
Bobcat.src = "images/bkgnd_bobcat.png" 
TigerCub = new Image(168,92) 
TigerCub.src = "images/bkgnd_tigercub.png" 
Wolf = new Image(167,92) 
Wolf.src = "images/bkgnd_wolf.png" 
Bear = new Image(167,91) 
Bear.src = "images/bkgnd_bear.png" 
Webelos = new Image(167,92) 
Webelos.src = "images/bkgnd_webelos.png" 

function GenerateMailToLink(name, domain, suffix, linkText) {
   var emailAddress = name + "\u0040" + domain + "." + suffix;
   var url = "mailto:" + emailAddress;

   if(! linkText){
      linkText = emailAddress;
   }
   document.write("<a href=\"" + url + "\">" + linkText + "</a>");
}

var arrNewsDate     = new Array()
var arrNewsHeadline = new Array()
var arrNews         = new Array()

function ShowAnyNewsEvents() { 
  var strNewsHeader = ""
  var strNewsEndTag = ""
  var strNewsEvents = ""
  var strNewsHeadlineStyle = "<DIV CLASS='newsheadertext' ALIGN='CENTER'>"
  var strNewsEventStyle = "<DIV CLASS='smallblack'>"
  var blHasEvents   = new Boolean(false)
  var TodayDate     = new Date()

  for(i=0;i<=arrNewsDate.length;i++) {
     if (arrNewsDate[i] > TodayDate) {
        strNewsEvents = strNewsEvents + strNewsHeadlineStyle + arrNewsHeadline[i] + "</DIV>" + strNewsEventStyle + arrNews[i] + "</DIV><P>"
        blHasEvents = true
     }
  }
  if (blHasEvents == true) {
     document.getElementById("News").innerHTML = strNewsHeader + strNewsEvents + strNewsEndTag
  }
}

var arrEvents           = new Array()
var dateRE = /^(\d{2})[\/\- ](\d{2})[\/\- ](\d{2})/;

function dmyOrdA(a, b){
  a = a.replace(dateRE,"$3$2$1");
  b = b.replace(dateRE,"$3$2$1");
  if (a>b) return 1;
  if (a <b) return -1;
  return 0;
}

function dmyOrdD(a, b){
  a = a.replace(dateRE,"$3$2$1");
  b = b.replace(dateRE,"$3$2$1");
  if (a>b) return -1;
  if (a <b) return 1;
  return 0; 
}

function mdyOrdA(a, b){
  a = a.replace(dateRE,"$3$1$2");
  b = b.replace(dateRE,"$3$1$2");
  if (a>b) return 1;
  if (a <b) return -1;
  return 0; 
}

function mdyOrdD(a, b){
  a = a.replace(dateRE,"$3$1$2");
  b = b.replace(dateRE,"$3$1$2");
  if (a>b) return -1;
  if (a <b) return 1;
  return 0; 
}

function ShowAnyUpcomingEvents() { 
  var strEventHeader = ""
  var strEventEndTag = ""
  var strAllEvents   = ""
  var strEventStyle  = ""
  var blHasEvents    = new Boolean(false)
  var TodayDate = new Date();
  var EventDate = new Date();
  var intNumOfEvents = 0;

  arrEvents.sort(mdyOrdA);

  for ( var i=0; i < arrEvents.length; i++ ) {
    EventDate.setYear("20"+arrEvents[i].substring(6,8));
    EventDate.setMonth(Number(arrEvents[i].substring(0,2))-1);
    EventDate.setDate(arrEvents[i].substring(3,5));
    if (EventDate > TodayDate) {
       strAllEvents = strAllEvents + strEventStyle + arrEvents[i] + "<P>"
       blHasEvents = true
       intNumOfEvents = intNumOfEvents + 1
       if (intNumOfEvents == 6)
          i = arrEvents.length + 1
    }
  }
  if (blHasEvents == true) {
     document.getElementById("Events").innerHTML = strEventHeader + strAllEvents + strEventEndTag
  }
}


function DisplayDate() {
 var mydate=new Date()
 var year=mydate.getYear()
 if (year < 1000)
    year+=1900
 var day=mydate.getDay()
 var month=mydate.getMonth()
 var daym=mydate.getDate()
 if (daym<10)
    daym="0"+daym
 var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
 var montharray=new                 
 Array("January","February","March","April","May","June","July","August","September","October","November","December")
 document.write(montharray[month]+" "+daym+", "+year)
}


function DisplayGroupText(group) {
  var grpText = ""
  switch (group) {
  case "Bobcat":
   grpText = "<DIV ALIGN=CENTER CLASS=rankheadertext>BOBCAT</DIV><P>No matter what  age or grade a boy joins Cub Scouting, he must earn \
his Bobcat Badge Before he can advance to the rank Of Wolf, Bear, or Webelos.  A boy must \
complete the Bobcat requirements, which include demonstrating his understanding of Scouting's core values. \
He must be able to recite the Cub Scout Promise, Law of the Pack, and motto and demonstrate the \
Cub Scout sign, handshake, and salute. He must also explain what each of these ideals means, in \
addition to demonstrating his understanding of the core values of honesty \
and trustworthiness, and explaining their importance.<BR><BR><BR><BR><BR><BR>"
   break
  case "TigerCub":
   grpText = "<DIV ALIGN=CENTER CLASS=rankheadertext>TIGER CUB</DIV><P>To begin his path to the Tiger Cub rank, the Tiger Cub (first grade) \
 must learn the Tiger Cub motto, the Cub Scout sign, and the Cub Scout salute.  When he \
has accomplished these tasks, he will be awarded his Tiger Cub immediate recognition \
emblem. This is a tiger paw with four strands for beads that he wears on the right \
pocket.  As a boy completes each part of the achievements, he will be awarded either an orange \
(den activities), white (family activities), or black (\"Go See It\") bead.  When the boy has \
earned five beads of each color, he is eligible to receive his Tiger Cub badge. The Tiger Cub badge is \
presented to the adult partner at the next pack meeting. In an impressive ceremony, \
 the adult partner in turn presents the badge to the boy.<BR><BR><BR>"
   break
  case "Wolf":
   grpText = "<DIV ALIGN=CENTER CLASS=rankheadertext>WOLF</DIV><P>The Wolf rank is for boys who are in the second grade. To earn the Wolf badge, a boy must pass 12 \
achievements involving simple physical and mental skills. His parent or guardian approves each achievement by \
signing his book. When all requirements are satisfied, the Wolf badge is presented to his parent or guardian \
at the next pack meeting in an impressive advancement ceremony, during which the parent or guardian in turn \
presents the badge to the boy.<BR><BR><BR><BR><BR><BR><BR><BR>"
   break
  case "Bear":
   grpText = "<DIV ALIGN=CENTER CLASS=rankheadertext>BEAR</DIV><P>The Bear rank is for boys who are in the third grade.  There are 24 Bear achievements in \
four categories; boys must complete 12 of these to earn the Bear badge.  These requirements are more \
difficult and challenging than those for the Wolf badge. When the boy has earned his Bear badge, he \
may work on electives for credit toward Arrow Points to be worn under the Bear badge. \
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>"
   break
  case "Webelos":
   grpText = "<DIV ALIGN=CENTER CLASS=rankheadertext>WEBELOS</DIV><P>The Webelos Program is a two year program \
   for Fourth and Fifth Grade Boys.   In both years, they work toward earning \
   <A HREF='http://www.usscouts.org/advance/cubscout/webbadges.html' TARGET='TOP'>Webelos Activity Badges</A> in \
   twenty different areas, arranged in five groups.  Fourth Grade Boys work toward the \
   <A HREF='http://www.usscouts.org/advance/cubscout/webelos.html' TARGET='TOP'>Webelos Badge</A>. \
   After earning the Webelos Badge, Fifth Graders, earn the \
   <A HREF='http://www.usscouts.org/advance/cubscout/arrowoflight.html' TARGET='TOP'>Arrow of Light</A>.\
   In addition to the two rank \
   badges, after earning the Webelos Badge, boys work toward the \
   <A HREF='http://www.usscouts.org/advance/cubscout/webelos.html#COMPASSPOINTS' TARGET='TOP'>Compass Point Emblem and Metal Compass</A> \
   Points as they earn additional Activity Badges.<BR><BR><BR><BR><BR><BR><BR>"
   break
  }
   document.getElementById("PageBody").innerHTML = "<BR>" + grpText
   //document.getElementById("PageBody").style.backgroundImage = "url('images/bkgnd_"+group+".png')"
   document.getElementById("PageBody").style.backgroundImage = "url('"+eval(group + ".src")+"')"
}
