//Date switcher
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900;

function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "April" || WhichMonth == "June" || WhichMonth == "September" || WhichMonth == "November") DaysInMonth = 30;
  if (WhichMonth == "February" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "February" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}

function clearGlobalChecks(sender)
{
    if (!sender.checked)
    {
        document.forms[0].elements["selectAll"].checked = false;
    }
}


function ChangeOptionDays(Which)
{
  DaysObject = document.forms[0].elements[Which + "Day"];
  MonthObject = document.forms[0].elements[Which + "Month"];
  YearObject = document.forms[0].elements[Which + "Year"];

  Month = MonthObject.options[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;

  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length;
  
  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++)
    {
      NewOption = new Option(DaysObject.options.length + 1);
      DaysObject.add(NewOption);
    }
  }
  if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}



//Image Rollovers

function Rollover(objImg)
{
  var strImageSrc = objImg.src
  var strNewImage = ""
  if (strImageSrc.indexOf("_off") != -1)
  {
    strNewImage = strImageSrc.replace(/_off/ , "_on")
  }
  else
  {
    strNewImage = strImageSrc.replace(/_on/ , "_off")
  }
  objImg.src =  strNewImage
}


//Button Rollovers
function buttonOver(_o) {
	_o.className = _o.className.toString().replace(/buttonDefault/, "buttonOver");
}
           
function buttonOut(_o) {
	_o.className = _o.className.toString().replace(/buttonOver/, "buttonDefault");
}

function toggleAllCheckboxes(sender)
{
	var inputBoxes = document.forms[0].elements;
    for (i=0;i<inputBoxes.length;i++)
    {
       if (inputBoxes[i].type == "checkbox") inputBoxes[i].checked = sender.checked;
    }
}


function toggleAllCheckboxesOnLoad()
{
	var inputBoxes = document.forms[0].elements;
    for (i=0;i<inputBoxes.length;i++)
    {
       if (inputBoxes[i].type == "checkbox") inputBoxes[i].checked = document.getElementById('selectAll').checked;
    }
}


var removeList = new Array();

function addCheckBoxToRemoveList(chkBox, removeListItem) {
    removeList[removeListItem] += "|" +chkBox;
}

function clearSelectableCheckBoxes(childList) {
    for (i=0;i<document.forms[0].elements.length;i++) {
        if (document.forms[0].elements[i].id.indexOf(childList) >= 0) {
            document.forms[0].elements[i].checked = false;
        }
    }
}

function resetAllCheckBox(sender, clearCheckBox) {
    var clearChkBox;
    if (sender.id.indexOf("_") > 0) {
        var ctrlName = sender.id.substr(0, sender.id.indexOf("_"));
        
        clearChkBox = document.getElementById(ctrlName + "_" + clearCheckBox);
    } else {
        clearChkBox = document.getElementById(clearCheckBox);
    }
    if (sender.checked) {
        clearChkBox.checked = false;
    }
    addCheckBoxToRemoveList(sender.id, clearChkBox.id)
}