// JavaScript Document
var mdDaysText = "";
var mdHoursText = "";
var mdMinutesText = "";
var bScrollLeft = false;
var bScrollRight = false;
var bSlideShow = true;
var nCounter = 0;
tss = setInterval('TimerEvent()', 10);

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 15000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 3;

var Picture = new Array(); // don't change this
var PicLink = new Array(); // don't change this
var PicTitle = new Array(); // don't change this
var PicSnippet = new Array(); // don't change this
var Caption508 = new Array(); // don't change this
var Thumb = new Array(); // don't change this

// Specify the image files (Picture)... To add more images, just continue the pattern, adding to the array below.
// Caution: The number of Pictures *must* equal the number of Captions!

//Picture[1]  = 'http://www.mdgridiron.umd.edu/images/slideshow/lunch-with-fridge.jpg';
//Picture[1]  = 'http://www.mdgridiron.umd.edu/images/slideshow/nextGame.jpg';
Picture[1]  = 'http://www.mdgridiron.umd.edu/images/slideshow/radio-show.jpg';
Picture[2]  = 'http://www.mdgridiron.umd.edu/images/slideshow/renew-membership.jpg';
Picture[3]  = 'http://www.mdgridiron.umd.edu/images/slideshow/eft-sm.jpg';
Picture[4]  = 'http://www.mdgridiron.umd.edu/images/slideshow/mgn-mobile.jpg';
Picture[5]  = 'http://www.mdgridiron.umd.edu/images/slideshow/letterman-rings-sm.jpg';

// Specify the hyperlinks (PicLink)... To add more links, just continue the pattern, adding to the array below.
// Caution: The number of PicLink *must* equal the number of Pictures!

//PicLink[1] = 'http://www.umterps.com/gameday/';
//PicLink[1] = 'events/Lunch.html';
PicLink[1] = 'events/RadioShow/index.htm';
PicLink[2] = 'https://mdgridiron.umd.edu/membership/DuesRenew.html';
PicLink[3] = 'membership/EFTInformation.html';
PicLink[4] = 'Mobile.html';
PicLink[5] = 'docs/events/Lettermen-Ring-Order-Form.pdf';

// Specify the titles (PicTitle)... To add more titles, just continue the pattern, adding to the array below.
// Caution: The number of PicTitle *must* equal the number of Pictures!

//PicTitle[1] = 'Lunch With Fridge';
//PicTitle[1] = 'Countdown To Kickoff';
PicTitle[1] = 'Ralph Friedgen Radio Show';
PicTitle[2] = 'It\'s Time To Renew (or Join)';
PicTitle[3] = 'Pay Membership Dues Monthly';
PicTitle[4] = 'Take The MGN With You';
PicTitle[5] = 'Letterman Rings';

// Specify the short descriptions (PicSnippet)... To add more descriptions, just continue the pattern, adding to the array below.
// Caution: The number of PicSnippet *must* equal the number of Pictures!

getTime();
//<a href="http://www.umterps.com/gameday/" target="_blank" style="color:#FFFFFF">Gameday Central</a>
//PicSnippet[1] = 'The Fridge will go over the weekend\'s matchup and answer fan questions. Buffalo Wild Wings will be supplying FREE lunch to the first 200 people who attend!<p align="center"><a href="events/Lunch.htm" style="color:#FFFFFF">Details</a></p>';
//PicSnippet[1] = 'The Terps take on the James Madison Dukes in their home opener on Capital One Field at Byrd Stadium.  Terp Alley is at 3:45PM.<p align="center" style="font-family:Verdana, Arial; font-weight:bold; margin-top:5px">' + mdDaysText + ', ' + mdHoursText + ', ' + mdMinutesText + '<\/p><p align="center"><a href="http://www.umterps.com/gameday/" style="color:#FFFFFF; margin-top:0px">2009 Gameday Central</a></p>';
PicSnippet[1] = 'The 2009 season is upon us and that means it\'s time for the Ralph Friedgen Radio Show.  Come out to Outback on September 2nd and watch Johnny and Coach broadcast the show.<p align="center"><a href="events/RadioShow/index.htm" style="color:#FFFFFF">Details</a></p>';
PicSnippet[2] = 'If your membership has expired now is the time to renew.  New members can join the MGN today and enjoy the benefits of your membership through the 2010 season.<p align="center" style="margin-top:10px"><a href="https://mdgridiron.umd.edu/membership/DuesRenew.html" style="color:#FFFFFF">RENEW</a>&nbsp; &nbsp; &nbsp;<a href="https://mdgridiron.umd.edu/membership/NewMemApplication.html" style="color:#FFFFFF">JOIN</a></p>';
PicSnippet[3] = 'Become a member of the MGN for as little as $8.33 a month.  Once enrolled you don\'t have to do a thing except sit back, relax and enjoy all of the great benefits of being a member of the Maryland Gridiron Network.';
PicSnippet[4] = 'The MGN mobile web site is no longer limited to the iPhone and iPod Touch.  Many of today&rsquo;s phones can also enjoy the features of the MGN mobile web site.  Try out your phone today.<p align="center" style="margin-top:10px;"><a href="/mobile/index.cfm" style="color:#FFFFFF">www.mdgridiron.umd.edu/mobile/</a></p>';
PicSnippet[5] = 'Terps Lettermen can now order an official Maryland Football ring.  Just print, complete and return the form with your payment.  It\'s that easy to own your own Maryland Football Letterman ring.';

// Specify the captions (Caption508)... To add more captions, just continue the pattern, adding to the array below.
// Caution: The number of Caption508 *must* equal the number of Pictures!

//Caption508[1] = 'Lunch With Fridge';
//Caption508[1] = 'Countdown To Kickoff';
Caption508[1] = 'Ralph Friedgen Radio Show';
Caption508[2] = 'It\'s Time To Renew (or Join)';
Caption508[3] = 'Pay Membership Dues Monthly';
Caption508[4] = 'Decades Reunion - "Nines"';
Caption508[5] = 'Take The MGN With You';
//Caption508[5] = 'Letterman Rings';

var tss;
var iss;
var jss = 1;
var pss = Picture.length-1;

var preLoad = new Array();
for (iss = 1; iss < pss+1; iss++){
preLoad[iss] = new Image();
preLoad[iss].src = Picture[iss];}

function getTime() {
	
	now = new Date();

	//Maryland vs JMU - 9/12/2009 6:00 PM ET
	mdLater = new Date("Sep 12 2009 18:00:00");

	mdDays = (mdLater - now) / 1000 / 60 / 60 / 24;
	mdDaysRound = Math.floor(mdDays);
	mdHours = (mdLater - now) / 1000 / 60 / 60 - (24 * mdDaysRound);
	mdHoursRound = Math.floor(mdHours);
	mdMinutes = (mdLater - now) / 1000 /60 - (24 * 60 * mdDaysRound) - (60 * mdHoursRound);
	mdMinutesRound = Math.floor(mdMinutes);
	mdTot = (mdDaysRound * 10000) + (mdHoursRound * 100) + (mdMinutesRound);

	if (mdDaysRound > 1 || mdDaysRound == 0) {
		mdDaysText = mdDaysRound + " Days";
	} else {
		mdDaysText = "1 Day";
	}
	
	if (mdHoursRound > 1 || mdHoursRound == 0) {
		mdHoursText = mdHoursRound + " Hours";
	} else {
		mdHoursText = "1 Hour";
	}
	
	if (mdMinutesRound > 1 || mdMinutesRound == 0) {
		mdMinutesText = mdMinutesRound + " Minutes";
	} else {
		mdMinutesText = "1 Minute";
	}
}

function playNpause(cntrlStatus)
{
	if (cntrlStatus.length == 4) {
		if (cntrlStatus.toLowerCase() == "play") {
			if (!bSlideShow) {
				bSlideShow = true;
				manualSwap(jss);
			}
		}
	}

	if (cntrlStatus.length == 5) {
		if (cntrlStatus.toLowerCase() == "pause") {
			if (bSlideShow) {
				bSlideShow = false;
			}
		}
	}
}

function pictureText(pNbr)
{
	var linkText = "";
	/*linkText += '<a href="' + PicLink[pNbr] +'" style="font-weight:bold; text-decoration:underline;" title="' + PicTitle[pNbr] + '">' + PicTitle[pNbr] + '<\/a>';
	linkText += '<div style="color:#000000; margin:0px; width:365px;">' + PicSnippet[pNbr] + '<\/div>';*/
	linkText += '<\/div>';
	//if (document.getElementById) document.getElementById("va_CaptionBox").innerHTML= linkText;
	
	getTime();
//	PicSnippet[1] = 'The Terps take on the James Madison Dukes in their home opener on Capital One Field at Byrd Stadium.  Terp Alley is at 3:45PM.<p align="center" style="font-family:Verdana, Arial; font-weight:bold; margin-top:5px">' + mdDaysText + ', ' + mdHoursText + ', ' + mdMinutesText + '<\/p><p align="center"><a href="http://www.umterps.com/gameday/" style="color:#FFFFFF; margin-top:0px">2009 Gameday Central</a></p>';

	var tabText = "";
	for (picNum = 1; picNum < Picture.length; picNum++)
	{
		tabText = "picTab" + picNum;
		if (picNum == pNbr) {
			document.getElementById(tabText).className="picTab-active";
		} else {
			document.getElementById(tabText).className="picTab";
		}
	}
	
	var SnippetText = "";
	SnippetText += '<a href="' + PicLink[pNbr] +'" class="tabTitle" style="color:#FFFFFF; font-weight:bold; text-decoration:underline;" title="' + PicTitle[pNbr] + '">' + PicTitle[pNbr] + '<\/a>';
	SnippetText += '<div class="tabSnippet">' + PicSnippet[pNbr] + '<\/div>';
	if (document.getElementById) document.getElementById("CaptionBox").innerHTML = SnippetText;
}

function runSlideShow()
{
	if (document.all&&!window.opera){
		document.images.PictureBox.style.filter="blendTrans(duration=2)";
		document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
		document.images.PictureBox.filters.blendTrans.Apply();
	}
	document.images.PictureBox.src = preLoad[jss].src;
	document.images.PictureBox.alt = Caption508[jss];
	document.images.PictureBox.title = Caption508[jss];
	document.getElementById("img_link").href = PicLink[jss];
	
	pictureText(jss);
	
	if (document.all&&!window.opera) document.images.PictureBox.filters.blendTrans.Play();
	jss = jss + 1;
	if (jss > (pss)) jss=1;
//	tss = setTimeout('runSlideShow()', SlideShowSpeed);
}

function isNumber(parm)
{
	var numb = '0123456789';
	
	if (parm == "") return false;
	
	for (i=0; i<parm.length; i++) {
		if (parm.indexOf(parm.charAt(i),0) == -1) return false;
	}
	return true;
}

function manualSwap(nIndex)
{
	if (isNumber(nIndex)) {
		jss = nIndex;
	} else {
		jss = 1;
		nIndex = 1;
	}

	document.images.PictureBox.src = preLoad[nIndex].src;
	document.images.PictureBox.title = Caption508[nIndex];
	document.getElementById("img_link").href = PicLink[nIndex];

	pictureText(nIndex);

	//bSlideShow = false;
}

function TimerEvent()
{
	// Increment counter
	nCounter = nCounter + 10;

/*
	// Test for scroll event
	if (bScrollLeft)
	{
		// Scroll to the left
		document.getElementById('divContainer').scrollLeft -= 2;
	}
	else if (bScrollRight)
	{
		// Scroll to the right
		document.getElementById('divContainer').scrollLeft += 2;
	}
*/	
	// Test for slideshow change
	if ((nCounter % SlideShowSpeed == 0) && (bSlideShow))
		// Switch slideshow image
		runSlideShow();
}
