//
//  Boy Scouts Troop 62
//  Villa Park, Illinois, USA
//
//  JavaScript Library
//
//  Author:  Kevin P. Wojdak (http://www.wojzworld.com)
//
//

// 
//  Global Variables and Constants
//
var scoutLaw = "A Scout is:\nTrustworthy\nLoyal\nHelpful\nFriendly\nCourteous\nKind\nObedient\nCheerful\nThrifty\nBrave\nClean\nReverent";

var scoutOath = "On my honor I will do my best\nTo do my duty to God and my country\nand to obey the Scout Law;\nTo help other people at all times;\nTo keep myself physically strong,\nmentally awake, and morally straight.";

//+----------------------------------------------------------------------------
//  Function:       callModalPlus
//  Author:         Kevin P. Wojdak, www.wojzworld.com
//  Description:    Launches centralized modal dialog but allows size to be passed in.
//                  
//  Arguments:      msg = HTML to load
//                  a = dialog arguments to be passed
//                  H = height of dialog
//                  W = width of dialog
//  Returns:        callVar = return value from the modal dialog
// 
//  Note:           
//+----------------------------------------------------------------------------
//
function callModalPlus(msg,a,H,W) {

	var callVar = window.showModalDialog(msg, a, "center=yes;dialogHeight="+H+"px;dialogWidth="+W+"px;resizable=no;status=no;help=no;scroll=no;");
	return callVar;
}

function popupMsg(msg) {
    var MsgHTML = "popup.html";
	var args = new Array();
	args[0] = msg;
	var modalConfirm = callModalPlus(MsgHTML,args, 150, 350);
	return false;
}

function mouseOn(btnObj) {
        btnObj.style.cursor = 'pointer';
        btnObj.style.backgroundColor = '#fff';
        btnObj.style.color = '#3c3c62';
        btnObj.style.borderBottom = '2px solid #c00';
        btnObj.style.borderTop = '2px solid #c00';
    }
    
function mouseOff(btnObj) {
        btnObj.style.cursor = 'default';
        btnObj.style.backgroundColor = '#3c3c62';
        btnObj.style.color = '#fff';
        btnObj.style.borderBottom = '2px solid #cccc7c';
        btnObj.style.borderTop = '2px solid #cccc7c';
    }
    
function mouseOnSub(btnObj) {
        mouseOn(btnObj);
    }
    
function mouseOffSub(btnObj) {
        btnObj.style.cursor = 'default';
        btnObj.style.backgroundColor = '#624f3c';
        btnObj.style.color = '#fff';
        btnObj.style.borderBottom = '2px solid #cccc7c';
        btnObj.style.borderTop = '2px solid #cccc7c';
    }


//+----------------------------------------------------------------------------
//   This True Date Selector script and many more are available free online at
//   The JavaScript Source!! http://javascript.internet.com
//   Created by: Lee Hinder, lee.hinder@ntlworld.com
//   Modified by: Kevin P. Wojdak, www.wojzworld.com
//
//+----------------------------------------------------------------------------
//  Function:       DaysInMonth
//  Description:    This function accepts a month and year argument and calculates
//                  the number of days in that month.  Calculations take leap year
//                  into account.
//                  
//  Arguments:      WhichMonth = Month selected to get number of days for
//                  WhichYear = the year to use for the calculation
//  Returns:        DaysInMonth = Int value
//
//  Additional Notes: 
//          See global variable declarations above for pertinent base variables
//+----------------------------------------------------------------------------
//
//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  
  if (WhichMonth == "04" || WhichMonth == "06" || WhichMonth == "09" || WhichMonth == "11") DaysInMonth = 30;
  if (WhichMonth == "02" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "02" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}


//+----------------------------------------------------------------------------
//  Function:       ChangeOptionDays
//  Description:    This function repopulates the days dropdown list based on the 
//                  year or month selected.
//                  
//  Arguments:      Which = reference to the dropdown field set to update
//  Returns:        none
//                  Function repopulates dropdown lists
//  Notes:          Global variables containing translated numbers are utilized by
//                  this function.
//+----------------------------------------------------------------------------
//
function ChangeOptionDays(Which)
{
  DaysObject = eval("document.forms[0].drp" + Which + "Day");
  MonthObject = eval("document.forms[0].drp" + Which + "Month");
  YearObject = eval("document.forms[0].drp" + Which + "Year");

  Month = MonthObject[MonthObject.selectedIndex].value;
  Year = YearObject[YearObject.selectedIndex].value;
  
  if (Year == "") {
  	YearObject[1].selected = true;
  	Year = YearObject[YearObject.selectedIndex].value;
	YearObject[0].selected = true;
  }
  
  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length - 1;
  
  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
	  newOptionValue = DaysObject.options.length;
	  newOptionText = DaysArray[newOptionValue]
      NewOption = new Option(newOptionText, newOptionValue);
      DaysObject.add(NewOption);
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//+----------------------------------------------------------------------------
//  Function:       SetToToday
//  Description:    Function sets the Y, M, and D dropdown lists to the current
//                  day.
//                  
//  Arguments:      Which = specifies which set of dropdown lists to affect
//  Returns:        none
//+----------------------------------------------------------------------------
//
//function to set options to today
function SetToToday(Which)
{
  DaysObject = eval("document.forms[0].drp" + Which + "Day");
  MonthObject = eval("document.forms[0].drp" + Which + "Month");
  YearObject = eval("document.forms[0].drp" + Which + "Year");

  YearObject[0].selected = true;
  MonthObject[0].selected = true;
  
  ChangeOptionDays(Which);

  DaysObject[0].selected = true;
}


// ***************** End of Date Selector code *******************

//+----------------------------------------------------------------------------
//  Function:       rand
//  Author:         Kevin P. Wojdak, www.wojzworld.com
//  Description:    Random number generator
//                  
//  Arguments:      none
//  Returns:        none
// 
//  Note:           The 100000 tells the function to return a 5-digit number.  
//                  Reduce or enlarge this number to return a lower or higher number.
//+----------------------------------------------------------------------------
//
function rand() {
	return Math.round(100000*Math.random());
}

// ********************************************
// ******  Image pre-load for Rollovers  ******
// ********************************************
//
// IMPORTANT:  Organized Alphabeticallly
//
if (document.images) {

	troop62groupup       = new Image();
    troop62groupup.src   = "images/cflTroop2006_3.jpg" ;
    troop62groupdown     = new Image() ;
    troop62groupdown.src = "images/cflTroop20063P.jpg" ;
}

//+----------------------------------------------------------------------------
//  Function:       imagedown
//  Author:         Matt Nolker, Kevin P. Wojdak
//  Description:    Used to display the correct rollover image when the mouse rolls  
//                  over a button or image.
//  Arguments:      imagename - name of the image to get
//  Returns:        none
//+----------------------------------------------------------------------------
//
function imagedown( imagename )
{
    if (document.images) {
      document.getElementById(imagename).src = eval( imagename + "down.src" );
    }
}


//+----------------------------------------------------------------------------
//  Function:       imageup
//  Author:         Matt Nolker, Kevin P. Wojdak
//  Description:    Used to display the original button image when the mouse rolls  
//                  away from a button.
//  Arguments:      imagename - name of the image to get
//  Returns:        none
//+----------------------------------------------------------------------------
//
function imageup ( imagename )
{
    if (document.images) {
      document.getElementById(imagename).src = eval( imagename + "up.src" );
    }
}