// 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 = 4000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 2;

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!
// Be sure to update the path and filenames that match your locally hosted environment.

 
 
Picture[1]  = '/MIRECC/visn19/images/rotating/visn19_rotating_simpson_lecture2.jpg';
Picture[2]  = '/MIRECC/visn19/images/rotating/visn19_rotating_simpson_lecture.jpg';
Picture[3]  = '/MIRECC/visn19/images/rotating/visn19_SDVCS_Toolkit.png';
Picture[4]  = '/MIRECC/visn19/images/rotating/visn19_rotating_mobileSDV.jpg';
Picture[5]  = '/MIRECC/visn19/images/rotating/visn19_rotating_ACE.png';
Picture[6]  = '/MIRECC/visn19/images/rotating/visn19_rotating_online_sdv.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!
// The links below need to be updated to the URLs of the sites you want each of your pictures to link to.

PicLink[1] = '/MIRECC/visn19/docs/Grahame_VA_Talk_Flier.pdf';
PicLink[2] = '/MIRECC/visn19/docs/Grahame_CU_Talk.pdf';
PicLink[3] = '/MIRECC/visn19/ordersdvcs/orderclipboard.asp';
PicLink[4] = 'http://www.mirecc.va.gov/apps/activities/sdv/';
PicLink[5] = '/MIRECC/visn19/orderace/orderace.asp';
PicLink[6] = '/MIRECC/visn19/education/sdvtree/sdv_tree.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!
// Be sure to update the picture titles for the accessible version below to properly reflect the picture titles you want to display.


PicTitle[1] = 'Lecture by Grahame Simpson Ph.D. - Preventing Suicide After TBI: What Do We Need to Know?';
PicTitle[2] = 'Lecture by Grahame Simpson Ph.D. - A Decade of Research into Suicidality after Traumatic Brain Injury: Progress, Controversies and the Road Ahead';
PicTitle[3] = 'Order the Self-Directed Violence Classification System (SDVCS) and Clinical Toolkit Clipboard - shipping is free';
PicTitle[4] = 'VISN 19 MIRECC SDV Classification Tool is now availble for your smartphone';
PicTitle[5] = 'Order a supply of the VA ACE Card- shipping is free';
PicTitle[6] = 'VISN 19 MIRECC SDV Classification Tool is now on-line';



// 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!

/*PicSnippet[1] = 'Circum-Locutions - the quarterly newsletter of the MIRECC';
PicSnippet[2] = 'Family Interventions for Serious Psychiatric Disorders in VA: Implementing a Continuum of Services';
PicSnippet[3] = '2nd Annual Traumatic Brain Injury (TBI) & Suicide Prevention Conference: Safety Planning for People with Brain Injuries';
PicSnippet[4] = 'Department of Veterans Affairs - Bibliotherapy';
*/
// 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!
// Be sure to update the captions below to the captions of your choice associated to each picture that will appear when a user mouse-overs the picture.


Caption508[1] = 'Lecture by Grahame Simpson Ph.D. - Preventing Suicide After TBI: What Do We Need to Know?';
Caption508[2] = 'Lecture by Grahame Simpson Ph.D. - A Decade of Research into Suicidality after Traumatic Brain Injury: Progress, Controversies and the Road Ahead';
Caption508[3] = 'Order the Self-Directed Violence Classification System (SDVCS) and Clinical Toolkit Clipboard - shipping is free';
Caption508[4] = 'VISN 19 MIRECC SDV Classification Tool is now availble for your smartphone';
Caption508[5] = 'Order a supply of the VA ACE Card- shipping is free';
Caption508[6] = 'VISN 19 MIRECC SDV Classification Tool is now on-line';



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();
}

