// JavaScript Document
var bScrollLeft = false;
var bScrollRight = false;
var bSlideShow = true;
var nCounter = 0;
tss = setInterval('TimerEvent()', 10);

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 5000;

// 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 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] = 'images/homepage/VANCP_MOVE_IntBannerSmF.jpg';
Picture[2] = 'images/homepage/rotate_RuralHealth_v3_600x250.jpg';
Picture[3] = 'images/homepage/rotate_immunization_600x250.jpg';
Picture[4] = 'images/homepage/rotate_careersblog_600x250.jpg';
Picture[5] = 'images/homepage/rotate_CaregiverSupportLine_600x250.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] = '/health/redirects/VHA_banner1.asp';
PicLink[2] = '/health/redirects/VHA_banner2.asp';
PicLink[3] = '/health/redirects/VHA_banner3.asp';
PicLink[4] = '/health/redirects/VHA_banner4.asp';
PicLink[5] = '/health/redirects/VHA_banner5.asp';

// 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] = 'MOVE!';
PicTitle[2] = 'Rural Health';
PicTitle[3] = 'Immunizations';
PicTitle[4] = 'VA Careers Blog';
PicTitle[5] = 'Caregiver Support Line';

// 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] = 'Take the first step: MOVE!';
Caption508[2] = 'Rural Health: Going the Distance';
Caption508[3] = 'Got shots? Immunizations aren\'t just for kids.';
Caption508[4] = 'VA CAreers Blog: Learn more about careers at VA. Share your stories and ideas. Discover your professional calling.';
Caption508[5] = 'Caring for a Veteran? Call VA\'s Caregiver Support Line toll free: 1-855-260-3274';

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 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;
	
	var linkText = "";
	for (picNum = 1; picNum < Picture.length; picNum++)
	{
		if (picNum == pNbr) {
			linkText += '<a href="' + PicLink[picNum] +'" title="' + PicTitle[picNum] + '" style="margin-right:15px; font-weight:bold; border:1px solid #ffffff; color:#ffffff; padding-left:2px; padding-right:2px;">' + picNum + '<\/a>';
		} else if (picNum == Picture.length) {
			linkText += '<a href="javascript:manualSwap(' + picNum +')" title="' + PicTitle[picNum] + '" style="text-decoration:none; border:1px solid #808080; background-color:#585858; color:#ffffff; padding-left:2px; padding-right:2px; font-weight:bold;">' + picNum + '<\/a>';
		} else {
			linkText += '<a href="javascript:manualSwap(' + picNum +')" title="' + PicTitle[picNum] + '" style="margin-right:15px; text-decoration:none; border:1px solid #808080; background-color:#585858; color:#ffffff; padding-left:2px; padding-right:2px; font-weight:bold;">' + picNum + '<\/a>';
		}
	}
	if (document.getElementById) document.getElementById("va_Controls").innerHTML = linkText;
}

function runSlideShow()
{
	if (document.all&&!window.opera){
		document.images.va_PictureBox.style.filter="blendTrans(duration=2)";
		document.images.va_PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
		document.images.va_PictureBox.filters.blendTrans.Apply();
	}
	document.images.va_PictureBox.src = preLoad[jss].src;
	document.images.va_PictureBox.alt = Caption508[jss];
	document.images.va_PictureBox.title = Caption508[jss];
	document.getElementById("img_link").href = PicLink[jss];
	
	pictureText(jss);
	
	if (document.all&&!window.opera) document.images.va_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 (val.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.va_PictureBox.src = preLoad[nIndex].src;
	document.images.va_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();
}

