// JavaScript Document

	programImages=null;		//array of images
	programListItems=null;	//list items to cycle
	image=null;		//new image to place in image-container
	imageContainer=null;
	images=null;
	currentSelection=0;

	cycleInterval=null;
	
	constantInterval=4000;	//intercal to move at a constant
	
	
	$(function(){
	   		//initialize program list items and images
		initProgramListItems();
		
			//show first instance
		cycleImageAndSelection();
		
			//begin cycling images and selections
		cycleInterval=setInterval("cycleImageAndSelection()",constantInterval);
	});

	function loadAllImages(){
		
		images=new Array();	//array of images
		
			//iterate through filenames and load
		for(var x=0; x<programImages.length; x++){		
				//load images
			images[x]=new Image();
			images[x].src="images/programImages/"+programImages[x];
		}
	}

		//METHOD:	INITIALIZE PROGRAM LIST ITEMS & IMAGES TO CYCLE
	function initProgramListItems(){
		
		image=new Image();		//new image instance on load
		imageContainer=$("#program-image-container");

			//images to cycle
		programImages=new Array('index00.jpg','index01.jpg','index02.jpg',
								'index03.jpg','index04.jpg','index05.jpg');

		programListItems=$("#program-list > *");		//list items <LI>
		
		loadAllImages();
	}


		//METHOD:	LOAD INITIAL ITEMS ON LOAD
	function cycleImageAndSelection(){
		
			//load image as function
		$(image).load(function(){
				//append loaded image to image container
			$(imageContainer).append(image);

			//append image w/ attributes of new image
		}).attr('src',"images/programImages/"+programImages[currentSelection]);

		$(programListItems[currentSelection]).addClass("selected");
	
			//update current and previous index
		previousSelection=(currentSelection==0)?5:(currentSelection-1);
		currentSelection= (currentSelection==5)?0:(currentSelection+1);

		$(programListItems[previousSelection]).removeClass("selected");	

	}
