// JavaScript Document
function Carousel()
{
	
	this.carouselDiv = "Not set";
	this.spotlightDiv = "Not set";
	
	this.imageSource = new Array();
	this.imageLink = new Array();
	this.imageText = new Array();
	this.imageThumbnail = new Array();
	
	this.imageSource.push("http://media2.cincyschoolzone.com/html/widgets/ImageLibrary/Carousel/FreshmenAdvice.jpg");
	this.imageLink.push("www.cincyschoolzone.com/dpp/colleges_universities/college_news/College-tips-for-incoming-freshman");
	this.imageThumbnail.push("http://media2.cincyschoolzone.com/html/widgets/ImageLibrary/Carousel/tnFreshmenAdvice.jpg");
	this.imageText.push("College Tips for Freshmen");
	
	this.imageSource.push("http://media2.cincyschoolzone.com/html/widgets/ImageLibrary/Carousel/CrystalBall.jpg");
	this.imageLink.push("www.cincyschoolzone.com/dpp/high_school/high_school_news/12-secrets-of-successful-campus-visits");
	this.imageThumbnail.push("http://media2.cincyschoolzone.com/html/widgets/ImageLibrary/Carousel/tnCrystalBall.jpg");
	this.imageText.push("12 Secrets of Successful Campus Visits");
	
	this.imageSource.push("http://media2.cincyschoolzone.com/html/widgets/ImageLibrary/Carousel/CollegeRoadTrip.jpg");
	this.imageLink.push("www.cincyschoolzone.com/dpp/high_school/high_school_news/college-road-trip-get-the-most-out-of-your-visit");
	this.imageThumbnail.push("http://media2.cincyschoolzone.com/html/widgets/ImageLibrary/Carousel/tnCollegeRoadTrip.jpg");
	this.imageText.push("College Road Trip");
	
	this.imageSource.push("http://media2.cincyschoolzone.com/html/widgets/ImageLibrary/Carousel/SummerBlues.jpg");
	this.imageLink.push("www.cincyschoolzone.com/dpp/news/quick-tips-to-keep-kids-brains-sharp-this-summer");
	this.imageThumbnail.push("http://media2.cincyschoolzone.com/html/widgets/ImageLibrary/Carousel/tnSummerBlues.jpg");
	this.imageText.push("The Heat is On");
	
	this.imageSource.push("http://media2.cincyschoolzone.com/html/widgets/ImageLibrary/Carousel/Search.jpg");
	this.imageLink.push("www.cincyschoolzone.com/subindex/elementary_middle/elementary_search?state=oh");
	this.imageThumbnail.push("http://media2.cincyschoolzone.com/html/widgets/ImageLibrary/Carousel/tnSearch.jpg");
	this.imageText.push("2010 Schools Guide Search");
	
	//this.imageSource.push("/sites/cncsz/images/slideshow//Elementary.jpg");
	//this.imageLink.push("www.cincyschoolzone.com/content/elementary-search/default.aspx??gradesServed=elementary");
	//this.imageThumbnail.push("/sites/cncsz/images/slideshow//tnElementary.jpg");
	//this.imageText.push("How Does Your School Stack Up?");
	
	this.currentImage = -1;
	this.numberOfImages = this.imageSource.length;

}

Carousel.prototype = {
	
	constructor : Carousel,
	
	setCarouselDiv : function (value) 
	{
		
		this.carouselDiv = value;
		
	},
	
	getCarouselDiv : function ()
	{
		
		return this.carouselDiv;
		
	},
	
	setSpotlightDiv : function (value) 
	{
		
		this.spotlightDiv = value;
		
	},
	
	getSpotlightDiv : function ()
	{
		
		return this.spotlightDiv;
		
	},
	
	getElement : function(id)
	{
		
		if (document.getElementById)
		{
			
			return document.getElementById(id);
			
		}
		else if (document.all)
		{
			
			return document.all[id];
			
		}
		else
		{
			
			throw new Error("No way to retrieve the element " + id);
			
		}
		
	},
	
	render : function ()
	{
		
		this.currentImage += 1;
		if (this.currentImage > this.numberOfImages - 1)
		{
			
			this.currentImage = 0;
			
		}
		
		var _carouselContainer = this.getElement(this.carouselDiv);
		var _spotlightContainer = this.getElement(this.spotlightDiv);
		
		_carouselContainer.innerHTML = 
			"<a href=\"http://" + this.imageLink[this.currentImage] + "\">"		
			+ "<image id=\"moveableImage\" style=\"width:607px;\" src=\"" + this.imageSource[this.currentImage] + "\" alt=\"Image\" />"
			+ "</a>";
			
		var _previousImage = this.currentImage - 1;
		if (_previousImage < 0)
		{
		
			_previousImage = this.numberOfImages - 1;
			
		}

		var _nextImage = this.currentImage + 1;
		if (_nextImage > this.numberOfImages - 1)
		{
			
			_nextImage = 0;
		
		}
		
		var _nextNextImage = _nextImage + 1;
		if (_nextNextImage > this.numberOfImages - 1)
		{
			
			_nextNextImage = 0;
		
		}
		
		_spotlightContainer.innerHTML =
			"<table><tr>" 
			+ "<td style=\"background-color:#ffffff;\">"
			+ "<a href=\"javascript:slideShow.renderPrevious();\"><</a>"
			+ "</td>" 
			+ "<td>"
			+ "<a href=\"http://" + this.imageLink[this.currentImage] + "\">"		
			+ "<img src=\"" + this.imageThumbnail[this.currentImage] + "\" alt=\"Image\" class=\"spotlightImageCurrent\" />"
			+ "</a>"
			+ "</td>" 
			+ "<td>"
			+ "<span class=\"spotlightImageText\">" + this.imageText[this.currentImage] + "</span>"
			+ "</td>"
			+ "<td>"
			+ "<a href=\"http://" + this.imageLink[_nextImage] + "\">"		
			+ "<img src=\"" + this.imageThumbnail[_nextImage] + "\" style=\"border=2px;\" alt=\"Image\" class=\"spotlightImage\" />"
			+ "</a>"
			+ "</td>" 
			+ "<td>"
			+ "<span class=\"spotlightImageText\">" + this.imageText[_nextImage] + "</span>"
			+ "</td>"
			+ "<td>"
			+ "<a href=\"http://" + this.imageLink[_nextNextImage] + "\">"		
			+ "<img src=\"" + this.imageThumbnail[_nextNextImage] + "\" alt=\"Image\" class=\"spotlightImage\" />"
			+ "</a>"
			+ "</td>" 
			+ "<td>"
			+ "<span class=\"spotlightImageText\">" + this.imageText[_nextNextImage] + "</span>"
			+ "</td>"
			+ "<td style=\"background-color:#ffffff;\">"
			+ "<a href=\"javascript:slideShow.render();\">></a>"
			+ "</td>" 
			+ "</tr></table>";
			
		var _currentMoveableImage = document.getElementById("moveableImage");
		var _originalSize = _currentMoveableImage.style.width;
		//alert("Width: " + _originalSize);
		for (var looper=1; looper < 607; looper+=1)
		{
			//alert("Left: " + looper);
			_currentMoveableImage.style.left = looper;
		}
			
	},
	
	renderPrevious : function()
	{
			
		this.currentImage = this.currentImage - 2;
		
		if (this.currentImage < 0)
		{
			
			this.currentImage = 0;
			
		}

		this.render();
	
	}
	
};
