function init ( )
{
  timeDisplay = document.createTextNode ( "" );
  document.getElementById("clock").appendChild ( timeDisplay );
}

function updateClock ( )
{
  var currentTime = new Date ( );
  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );
  // Pad the minutes and seconds with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;

  // Compose the string for display
  var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
  //var currentTimeString = currentHours + ":" + currentMinutes + " " + timeOfDay;

  // Update the time display
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
  
}

function dispDate(dateVal) {
	DaystoAdd=dateVal
	TodaysDate = new Date();
	TodaysDay = new Array('Sun', 'Mon', 'Tue','Wed', 'Thu', 'Fri', 'Sat');
	TodaysMonth = new Array('Jan', 'Feb', 'Mar','Apr', 'May','Jun', 'Jul', 'Aug', 'Sep','Oct', 'Nov', 'Dec');
	DaysinMonth = new Array('31', '28', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31');
	function LeapYearTest (Year) {
		if (((Year % 400)==0) || (((Year % 100)!=0) && (Year % 4)==0)) {
			return true;
		}
		else {
			return false;
	}
}


CurrentYear = TodaysDate.getYear();
if (CurrentYear < 2000)
	CurrentYear = CurrentYear + 1900;
	currentMonth = TodaysDate.getMonth();
	DayOffset = TodaysDate.getDay();
	currentDay = TodaysDate.getDate();
	month = TodaysMonth[currentMonth];
	if (month == 'February') {
		if (((CurrentYear % 4)==0) && ((CurrentYear % 100)!=0) || ((CurrentYear % 400)==0)) {
			DaysinMonth[1] = 29;
		}
		else {
			DaysinMonth[1] = 28;
		}
}

days = DaysinMonth[currentMonth];
currentDay += DaystoAdd;
if (currentDay > days) {
	if (currentMonth == 11) {
		currentMonth = 0;
		month = TodaysMonth[currentMonth];
		CurrentYear = CurrentYear + 1
	}
	else {
	month =
	TodaysMonth[currentMonth+1];
	}
	currentDay = currentDay - days;
}
DayOffset += DaystoAdd;

function offsettheDate (offsetCurrentDay) {
		if (offsetCurrentDay > 6) {
			offsetCurrentDay -= 6;
			DayOffset = TodaysDay[offsetCurrentDay-1];
			offsettheDate(offsetCurrentDay-1);
		}
		else {
			DayOffset = TodaysDay[offsetCurrentDay];
			return true;
		}
}

offsettheDate(DayOffset);TheDate  = DayOffset + ', ';
TheDate += month + ' ';
TheDate += currentDay + ', ';

if (CurrentYear<100) CurrentYear="19" + CurrentYear;
	TheDate += CurrentYear;
	//document.write(' '+TheDate);
	document.getElementById("date").firstChild.nodeValue = TheDate;
}

function slideSwitch() {
    var $active = $('#myslides div.active');
    if ( $active.length == 0 ) $active = $('#myslides div:last');
    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next() : $('#myslides div:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );
    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
	dispDate(0); 
    //setInterval( "slideSwitch()", 1000 );
	//updateClock();
	setInterval( "updateClock()", 100 );
});