// Image rollover
function swapImage(imageID, imagePath) {
	var imgID;
	imgID = document.getElementById(imageID);
	imgID.src = imagePath;
}
//Homepage DHTML Menus
var timer;
function showDiv(divname1, divname2, divname3, divname4) {
	var divShow;
	var divHide;
	divShow = document.getElementById(divname1);
	divHide = document.getElementById(divname2);
	divHide2 = document.getElementById(divname3);
	divHide3 = document.getElementById(divname4);
	divShow.style.display = "block";
	divHide.style.display = "none";
	divHide2.style.display = "none";
	divHide3.style.display = "none";
}
function closeSolo (divname) {
	divHideSolo = document.getElementById(divname);
	timer = setTimeout("divHideSolo.style.display = 'none'", 850);
}
function closeAll(divname1, divname2, divname3, divname4) {
	divHide1 = document.getElementById(divname1);
	divHide2 = document.getElementById(divname2);
	divHide3 = document.getElementById(divname3);
	divHide4 = document.getElementById(divname4);
	divHide1.style.display = "none";
	divHide2.style.display = "none";
	divHide3.style.display = "none";
	divHide4.style.display = "none";
}
function clearTimer() {
	clearTimeout(timer);
}
//Random Stylesheets
var stylesheets = new Array();
	stylesheets[0] = "<style type=\"text/css\">@import url(styles/home1.css);</style>";
	stylesheets[1] = "<style type=\"text/css\">@import url(styles/home3.css);</style>";
	stylesheets[2] = "<style type=\"text/css\">@import url(styles/home1.css);</style>";
	stylesheets[3] = "<style type=\"text/css\">@import url(styles/home3.css);</style>";
//	stylesheets[1] = "<style type=\"text/css\">@import url(styles/home2.css);</style>";
var n = 3;
var Chg = Math.round(Math.random() * n);
var randomCSS = stylesheets[Chg];

// functions to output proper prev/next links for the weekly/monthly/yearly calendar displays
function calendarNavButton(month, day, year, interval,backornext) {
  var currentMilli, deltaMilli, newday, newmonth, newyear, buttonsrc;
  var currentDate = new Date(year,(month-1),day);
  var url = 'events_calendar.html';

  currentMilli = currentDate.getTime();
  deltaMilli = interval * 24 * 60 * 60 * 1000;

  if (backornext == "back") {
    currentDate.setTime(currentMilli - deltaMilli);
//    buttonsrc = '<<';
      buttonsrc = '<img src="../images/arrow_left.gif" alt="<<" />';
  } else {
    currentDate.setTime(currentMilli + deltaMilli);
//    buttonsrc = '>>';
      buttonsrc = '<img src="../images/arrow_right.gif" alt=">>" />';
  }


  newday = currentDate.getDate();
  newmonth = currentDate.getMonth() + 1;
  newyear = currentDate.getFullYear();


  document.write('<a href="');
  document.write(url+'?year='+newyear+'&month='+newmonth+'&day='+newday+'&range='+interval);
//  document.write('"><span class="timespan_buttonborder">'+buttonsrc+'</span></a>');
  document.write('">'+buttonsrc+'</a>');
}

function verboseMonth(month) {
  var monthArray = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'Octo\
ber', 'November', 'December');
  return monthArray[month];
}

function calendarNavTitle(month, day, year, interval) {
  var currentMilli, deltaMilli, newday, newmonth, newyear, buttonsrc;
  var currentDate = new Date(year,(month-1),day);
  var endDate = new Date();
  var startM, startD, startY, endM, endD, endY, combinedDateString;


  currentMilli = currentDate.getTime();
  deltaMilli = interval * 24 * 60 * 60 * 1000;
  endDate.setTime(currentMilli + deltaMilli);

  if (currentDate.getMonth() == endDate.getMonth()) {
      startM = verboseMonth(currentDate.getMonth());
      endM = '';
  } else {
      startM = verboseMonth(currentDate.getMonth());
      endM = verboseMonth(endDate.getMonth());
  }

  if (currentDate.getDate() == endDate.getDate()) {
      startD = currentDate.getDate();
      endD = endDate.getDate();
  } else {
      startD = currentDate.getDate();
      endD = endDate.getDate();
  }

  if (currentDate.getFullYear() == endDate.getFullYear()) {
      startY = '';
      endY = ', ' + currentDate.getFullYear();
  } else {
      startY = ', ' + currentDate.getFullYear();
      endM = verboseMonth(endDate.getMonth());
      endY = ', ' + endDate.getFullYear();
  }

  combinedDateString = startM + ' ' + startD + startY + ' to ' + endM + ' ' + endD + endY;
  document.write(combinedDateString);
}

function calendarRangeLink(month,day,year,range) {
  var today = new Date();
  var year, month, day;

  // the 't' is for 'today'
  tyear = today.getFullYear();
  tmonth = today.getMonth() + 1;
  tday = today.getDate();

  document.write('<a href="events_calendar.html?month='+month+'&day='+day+'&year='+year+'&range=7" class="timespan_menu">Weekly</a><br/>');
  document.write('<a href="events_calendar.html?month='+month+'&day='+day+'&year='+year+'&range=31" class="timespan_menu">Monthly</a><br/>');
//  document.write('<a href="events_calendar.html?month='+month+'&day='+day+'&year='+year+'&range=365" class="timespan_menu">Yearly</a><br/>');
  document.write('<a href="events_calendar.html?month='+tmonth+'&day='+tday+'&year='+tyear+'&range='+range+'" class="timespan_menu">Today</a>');
}