// call classes \\
var theImages = new Images();
var slideshowItem1 = new SlideshowListClick(0);
var slideshowItem2 = new SlideshowListClick(1);
var slideshowItem3 = new SlideshowListClick(2);
var slideshowItem4 = new SlideshowListClick(3);
var slideshowItem5 = new SlideshowListClick(4);
/*var slideshowItem6 = new SlideshowListClick(5);
var slideshowItem7 = new SlideshowListClick(6);
var slideshowItem8 = new SlideshowListClick(7);*/
//.\\

// initial image \\
var num = Math.floor(Math.random() * 5);
with(theImages) {
	$("#slideshowImage").css({"background": "url("+ images[num] +") no-repeat"});
}
resetSlideshowLinks();
$("#slideshow"+ num +"").css({"color": "#ff6600"});
//.\\

// slideshow timer \\
$.timer(10000, function(timer) {
	var randNum = Math.floor(Math.random() * 5);
	with(theImages) {
		$("#slideshowImage").css({"background": "url("+ images[randNum] +") no-repeat"});
	}
	resetSlideshowLinks();
	$("#slideshow"+ randNum +"").css({"color": "#ff6600"});
	$("#slideshow ul li").each(function() {
		$(this).click(function() {
			timer.stop();
			timer.reset(10000);
		});
	});
});
//.\\

// declare classes \\
function Images() {
	this.images = new Array();
	this.images[0] = "images/home/slideshow/home_feb10_3.jpg";
	this.images[1] = "images/home/slideshow/home_feb10_2.jpg";
	this.images[2] = "images/home/slideshow/home_feb10_1.jpg";
	this.images[3] = "images/home/slideshow/january_09.jpg";	
	this.images[4] = "images/home/slideshow/jan_10.jpg";
	this.images.sort(sortSlideshow);
}
function SlideshowListClick(num) {
	$("#slideshow"+ num +"").click(function() {
		with(theImages) {
			$("#slideshowImage").css({"background": "url("+ images[num] +") no-repeat"});
		}
		resetSlideshowLinks();
		$("#slideshow"+ num +"").css({"color": "#ff6600"});
	});
}
//.\\

// functions \\
function resetSlideshowLinks() {
	$("#slideshow0").css({"color": "#EBEBEB"});
	$("#slideshow1").css({"color": "#EBEBEB"});
	$("#slideshow2").css({"color": "#EBEBEB"});
	$("#slideshow3").css({"color": "#EBEBEB"});
	$("#slideshow4").css({"color": "#EBEBEB"});
	/*$("#slideshow5").css({"color": "#EBEBEB"});
	$("#slideshow6").css({"color": "#EBEBEB"});
	$("#slideshow7").css({"color": "#EBEBEB"});*/
}
function sortSlideshow() {
	return 0.5 - Math.random();
}
//.\\

/*$(document).ready(function() {
	alert(theImages.size());
});*/