var i = 0;
var imageIndex = 1;
var slideshowTimer = 6000;
var slideshowOpacity = 0.1;
var slideshow = new Array();
var interval,totalimages;

function slideshowArray(src,title,href)
{
	this.src = src;
	this.title = title;
	this.href = href;
}

$(document).ready(function(){
	totalimages = slideshow.length;
	$("#hp_slideshow img:eq(0)").attr({"selected":"true","style":"opacity:1; filter:alpha(opacity=100);"});	
	$(".hp_thumbnails").click(function(){
		$.fn.swapImg($(this).attr("thumbIndex"));
		clearInterval(interval);
	});		
	interval = setInterval(function(){
		imageIndex = (imageIndex == totalimages) ? 0 : imageIndex;
		$.fn.swapImg(imageIndex);
		imageIndex++;
	},slideshowTimer);
});
$.fn.swapImg = function(imageIndex){
	var newThumb = $("#hp_slideshow img:eq("+imageIndex+")");
	var currentThumb = $("#hp_slideshow img[selected='true']");
	currentThumb.removeAttr("selected");
	currentThumb.removeAttr("style");
	newThumb.attr({"selected":"true","style":"opacity:1; filter:alpha(opacity=100);"});
	$("#theme-image-link").attr({"href":slideshow[imageIndex].href,"title":slideshow[imageIndex].title});
	$("#theme-image").fadeTo("normal",slideshowOpacity,function(){
		$("#theme-image").attr({src:slideshow[imageIndex].src, alt:slideshow[imageIndex].title}).fadeTo("slow",1);
	});
};