// Calendar scripts ------------------------------------------------------------------------------------------------------

function calendar(calendarDay)
	{
	if(calendarDay == null)
		{calDate = new Date();}
		else{calDate = new Date(calendarDay);}
	
	document.write("<table id='calendar_table'>");
	
	writeCalTitle(calDate);
	writeDayNames();
	writeCalDays(calDate);
	document.write("</table>");
	}
	




function writeCalTitle(calendarDay)
	{
	var monthName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	
	var thisMonth = calendarDay.getMonth();
	var thisYear = calendarDay.getFullYear();
	
	document.write("<tr>");
	document.write("<th id='calendar_head' colspan='7'>");
	document.write(monthName[thisMonth] + " " + thisYear);
	document.write("</th>");
	document.write("</tr>");
	}




function writeDayNames()
	{
	var dayName = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
	document.write("<tr>");
	for (var i = 0; i < dayName.length; i++)
		{
		document.write("<th class='calendar_weekdays'>" + dayName[i] + "</th>");
		}
	document.write("</tr>");
	}



function daysInMonth(calendarDay)
	{
	var thisYear = calendarDay.getFullYear();
	var thisMonth = calendarDay.getMonth();
	//set the number of days in each month of the year
	var dayCount = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	//determine if this year is a leap year
	if(thisYear % 4 == 0)
		{
		if((thisYear % 100 != 0) || (thisYear % 400 == 0))
			{
			dayCount[1] = 29; //February has 29 days
			}
		}
	
	return dayCount[thisMonth]; // Return the number of days in the month
	}




function writeCalDays(calendarDay)
	{
	var currentDay = calendarDay.getDate();
	//determine the starting day of the week
	var dayCount = 1;
	var totalDays = daysInMonth(calendarDay);
	calendarDay.setDate(1);  //set the date to the first day of the month
	var weekDay = calendarDay.getDay();  //the day fo the week of the first day of the month
	
	//write blank cells preceding the starting day
	document.write("<tr>");
	for(var i = 0; i < weekDay; i++)
		{
		document.write("<td></td>");
		}
		
	//write cells for each day of the month
	while(dayCount <= totalDays)
		{
		//write the table rows and cells
		if(weekDay == 0)
			{
			document.write("<tr>");
			}
		if(dayCount == currentDay)
			{
			//highlight the currrent day
			document.write("<td class='calendar_dates' id='calendar_today'>" + dayCount + "</td>");
			}
			else
				{
				//display as usual
				document.write("<td class='calendar_dates'>" + dayCount + "</td>");
				}
		if(weekDay == 6)
			{
			document.write("</tr>");
			}
			
		//move to the next day
		dayCount++;
		calendarDay.setDate(dayCount);
		weekDay = calendarDay.getDay();
		}
		document.write("</tr>");
	}
	
	
	
//End Calendar Scripts -------------------------------------------------------------------------------------------------------




//Btx scrolling text script ---------------------------------------------------------------------------------------------------

var msgArray = new Array(
"Kosho Mind!!!",
"Resource of Kosho Shorei Ryu Kenpo",
"Escaping Arts",
"Meditation",
"Shodo: Japanese Calligriaphy",
"Shiatsu",
"Japanese Yoga",
"Kata",
"Folding",
"Throwing",
"Female and Male Striking",
"Blocking",
"Kicking",
"Eye Training",
"Energy Collection",
"Settling",
"Seven / Ten",
"Always Move Twice: Bruce Juchnik, Hanshi",
"Holy Qabalah", 
"Tarot", 
"Esoteric Astrology",
"Javascript", 
"ASP (Active Server Pages)", 
"PHP Programming", 
"MySQL Database",
"Fun musical videos that Mike Likes!!!",
"May the Schwartz be with you..."
);
var speed = 50;
var cdel = 2500;
var maxfont = 20;

// Expanding and shrinking text banner Javascript
// copyright 24th July 2005, by Stephen Chapman http://javascript.about.com
// permission to use this Javascript on your web page is granted
// provided that this copyright notice is included
// Thanks Steven! Very cool script! -Mike Rondeau
var x = y = 0;
var msg;
function start()
	{
		bnr('1');
	}
function bnr(dir)
	{
		if (dir)
		{
			msg = msgArray[y];
			if (x < maxfont) 
			{
			x++;setTimeout("bnr(1)",speed);
			}
			else setTimeout("bnr(0)",cdel);
			} 
			else 
			{
				if (x > 1) 
			{
			x--;setTimeout("bnr(0)",speed);
			}
			else
			{
			setTimeout("bnr(1)",10);
			y++;
			if (y>=msgArray.length) y=0;
			}
			}
			document.getElementById('btx').innerHTML = msg;
			btx.style.fontSize=x+'px'
			}
//window.onload = start;
// commented out this window.onload method because it was conflicting with my onload in the body tag for the time display function. Instead I added the onload start function to the body tag.

//End Btx scrolling text script ---------------------------------------------------------------------------------------------






//Date and Time functions --------------------------------------------------------------------

// The following "today" variable and two functions are for the date and time display in the branding area
today = new Date();

function showTime(dateObj)
	{
	thisSecond = dateObj.getSeconds();
	thisMinute = dateObj.getMinutes();
	thisHour = dateObj.getHours();
	
	// Change thisHour from 24-hour time to 12-hour time by:
	// 1) if thisHour < 12 then set ampm to " am", otherwise set it to " pm"
	ampm = (thisHour < 12) ? " AM" : " PM";
	// subtract 12 from thisHour variable
	thisHour = (thisHour > 12) ? thisHour - 12 : thisHour;
	// if thisHour == 0, change it to 12
	thisHour = (thisHour == 0) ? 12 : thisHour;
	
	// Add leading zeros to minutes and seconds if value is less than 10.
	thisMinute = thisMinute < 10 ? "0" + thisMinute : thisMinute;
	thisSecond = thisSecond < 10 ? "0" + thisSecond : thisSecond;
	
	return thisHour + ":" + thisMinute + ":" + thisSecond + ampm;
	}

function display()
	{
	// the today variable contains the current date and time
	var today = new Date();
	// display the current date and time
	document.getElementById('time').innerHTML = showTime(today);
	}

//End Date and Time functions ------------------------------------------------------------------