﻿// JScript File
//============== Slideshow parameters ==================================================
header = "Basic Slide Show with a Timer";
showSpeed = 5000;
fadingEffect = 1;  // 0 = No; 1 = Yes

function list(src) {
	this.src = src;
}

//Load slides src to array
var img = new Array;
img[0] = new list("http://echoices.lausd.net/images/slides/IMG_0001.jpg");
img[1] = new list("http://echoices.lausd.net/images/slides/IMG_0002.jpg");
img[2] = new list("http://echoices.lausd.net/images/slides/IMG_0003.jpg");
img[3] = new list("http://echoices.lausd.net/images/slides/IMG_0004.jpg");
img[4] = new list("http://echoices.lausd.net/images/slides/IMG_0005.jpg");
img[5] = new list("http://echoices.lausd.net/images/slides/IMG_0006.jpg");
img[6] = new list("http://echoices.lausd.net/images/slides/IMG_0007.jpg");
img[7] = new list("http://echoices.lausd.net/images/slides/IMG_0008.jpg");
img[8] = new list("http://echoices.lausd.net/images/slides/IMG_0009.jpg");
img[9] = new list("http://echoices.lausd.net/images/slides/IMG_0010.jpg");
img[10] = new list("http://echoices.lausd.net/images/slides/IMG_0011.jpg");
img[11] = new list("http://echoices.lausd.net/images/slides/IMG_0012.jpg");
img[12] = new list("http://echoices.lausd.net/images/slides/IMG_0013.jpg");
img[13] = new list("http://echoices.lausd.net/images/slides/IMG_0014.jpg");
img[14] = new list("http://echoices.lausd.net/images/slides/IMG_0015.jpg");
img[15] = new list("http://echoices.lausd.net/images/slides/IMG_0016.jpg");
img[16] = new list("http://echoices.lausd.net/images/slides/IMG_0017.jpg");
img[17] = new list("http://echoices.lausd.net/images/slides/IMG_0018.jpg");
img[18] = new list("http://echoices.lausd.net/images/slides/IMG_0019.jpg");
img[19] = new list("http://echoices.lausd.net/images/slides/IMG_0020.jpg");
img[20] = new list("http://echoices.lausd.net/images/slides/IMG_0021.jpg");
img[21] = new list("http://echoices.lausd.net/images/slides/IMG_0022.jpg");
img[22] = new list("http://echoices.lausd.net/images/slides/IMG_0023.jpg");
img[23] = new list("http://echoices.lausd.net/images/slides/IMG_0024.jpg");
img[24] = new list("http://echoices.lausd.net/images/slides/IMG_0025.jpg");
img[25] = new list("http://echoices.lausd.net/images/slides/IMG_0026.jpg");
img[26] = new list("http://echoices.lausd.net/images/slides/IMG_0027.jpg");
img[27] = new list("http://echoices.lausd.net/images/slides/IMG_0028.jpg");
img[28] = new list("http://echoices.lausd.net/images/slides/IMG_0029.jpg");
img[29] = new list("http://echoices.lausd.net/images/slides/IMG_0030.jpg");

//
var myInterval = 0;

//
var showPause = 0;

//
var auto = false;

//Start slideshow with first slide
var currImg1 = 0;
var currImg2 = 6;
var currImg3 = 13;
var currImg4 = 20;

//
var Dir = 1;

//declare new array
var imgArray = new Array();

//construct image array
for (ii=0;ii<img.length;ii++)
{
	imgArray[ii] = new Image();
	imgArray[ii].src = img[ii].src;
}

//Generate HTML string	
function writeSlideShow1()
{
	var myStr1 = "";
	myStr1 += "<div id=tr2 style= " + "top: 0; left: 0; position: absolute; z-index: 1; width:115px; height:95px; visibility: visible;" + ">";
	myStr1 += "<img ID=myImg1 src= " + imgArray[0].src + " width=115" + " height=95" +">";
	myStr1 += "</div>";
	startAuto();
	document.write(myStr1);
}

function writeSlideShow2()
{	
	var myStr2 = "";
	myStr2 += "<div id=tr3 style= " + "top: 0; left: 0; position: absolute; z-index: 1; width:115px; height:95px; visibility: visible;" + ">";
	myStr2 += "<img ID=myImg2 src= " + imgArray[6].src + " width=115" + " height=95" +">";
	myStr2 += "</div>";
	
	document.write(myStr2);
}

function writeSlideShow3()
{	
	var myStr3 = "";
	myStr3 += "<div id=tr4 style= " + "top: 0; left: 0; position: absolute; z-index: 1; width:115px; height:95px; visibility: visible;" + ">";
	myStr3 += "<img ID=myImg3 src= " + imgArray[13].src + " width=115" + " height=95" +">";
	myStr3 += "</div>";
	
	document.write(myStr3);
}
function writeSlideShow4()
{	
	var myStr4 = "";
	myStr4 += "<div id=tr5 style= " + "top: 0; left: 0; position: absolute; z-index: 1; width:115px; height:95px; visibility: visible;" + ">";
	myStr4 += "<img ID=myImg4 src= " + imgArray[20].src + " width=115" + " height=95" +">";
	myStr4 += "</div>";
	
	document.write(myStr4);
}


//Displays content of Slideshow layer
function startShow()
{
	if (ready() == true)
	{		
		window.clearInterval(showPause);
		try {
		document.getElementById('tr2').style.display = "";
		document.getElementById('tr3').style.display = "";
		document.getElementById('tr4').style.display = "";
		document.getElementById('tr5').style.display = "";
		}
		catch (e) {
		}
	}
}


//Make sure all images are loaded
function ready()
{
	for (ii=0;ii<imgArray.length;ii++)
	{ 
		if (imgArray[ii].complete == false)
		{		
			return false;
			break;
		}
	}
	window.clearInterval(showPause);
	return true;
}
//////////////////////////////////////////////////////////////////////////////////////////
function switchPicture(dir)
{
	if (auto == false)
	{
		currImg1 = currImg1 + dir;
		if (currImg1 > imgArray.length - 1)
		{
			currImg1 = 0;
		}
		if (currImg1 < 0)
		{
			currImg1 = imgArray.length - 1;
		}
		
		currImg2 = currImg2 + dir;
		if (currImg2 > imgArray.length - 1)
		{
			currImg2 = 0;
		}
		if (currImg2 < 0)
		{
			currImg2 = imgArray.length - 1;
		}
		
		currImg3 = currImg3 + dir;
		if (currImg3 > imgArray.length - 1)
		{
			currImg3 = 0;
		}
		if (currImg3 < 0)
		{
			currImg3 = imgArray.length - 1;
		}
		
		currImg4 = currImg4 + dir;
		if (currImg4 > imgArray.length - 1)
		{
			currImg4 = 0;
		}
		if (currImg4 < 0)
		{
			currImg4 = imgArray.length - 1;
		}
		
		document.getElementById("myImg1").src = imgArray[currImg1].src;
		document.getElementById("myImg2").src = imgArray[currImg2].src;		
		document.getElementById("myImg3").src = imgArray[currImg3].src;
		document.getElementById("myImg4").src = imgArray[currImg4].src;	
		}
	else
	{
		Dir = dir;
	}
}
//////////////////////////////////////////////////////////////////////////////////////////////
//Sets display time for images/slides
function startAuto()
{
	if (auto == false)
	{	
		auto = true;
		myInterval = setInterval("switchPictureAuto()",showSpeed);
	}
}



function switchPictureAuto()
{
	currImg1 = currImg1 + Dir;
		if (currImg1 > imgArray.length - 1)
		{
			currImg1 = 0;
		}
		if (currImg1 < 0)
		{
			currImg1 = imgArray.length - 1;
		}

	currImg2 = currImg2 + Dir;
		if (currImg2 > imgArray.length - 1)
		{
			currImg2 = 0;
		}
		if (currImg2 < 0)
		{
			currImg2 = imgArray.length - 1;
		}
	currImg3 = currImg3 + Dir;
		if (currImg3 > imgArray.length - 1)
		{
			currImg3 = 0;
		}
		if (currImg3 < 0)
		{
			currImg3 = imgArray.length - 1;
		}
	
	    currImg4 = currImg4 + Dir;
		if (currImg4 > imgArray.length - 1)
		{
			currImg4 = 0;
		}
		if (currImg4 < 0)
		{
			currImg4 = imgArray.length - 1;
		}
	
	
	if (document.all)
	{
		if (fadingEffect == 1)
		{
			document.getElementById("myImg1").style.filter='blendTrans(duration=1.5)';
			document.getElementById("myImg1").filters.blendTrans.Apply();
			document.getElementById("myImg1").filters.blendTrans.Play();
			
			document.getElementById("myImg2").style.filter='blendTrans(duration=1.5)';
			document.getElementById("myImg2").filters.blendTrans.Apply();
			document.getElementById("myImg2").filters.blendTrans.Play();
			
			document.getElementById("myImg3").style.filter='blendTrans(duration=1.5)';
			document.getElementById("myImg3").filters.blendTrans.Apply();
			document.getElementById("myImg3").filters.blendTrans.Play();
			
			document.getElementById("myImg4").style.filter='blendTrans(duration=1.5)';
			document.getElementById("myImg4").filters.blendTrans.Apply();
			document.getElementById("myImg4").filters.blendTrans.Play();
		}
	}		
	document.getElementById("myImg1").src = imgArray[currImg1].src;
	document.getElementById("myImg2").src = imgArray[currImg2].src;
	document.getElementById("myImg3").src = imgArray[currImg3].src;	
	document.getElementById("myImg4").src = imgArray[currImg4].src;	
	
}

showPause = setInterval("startShow()",1);
