var slideShow;

function StableSlideshow(items) {
	this.numberOfItems = items;
	this.currentItem = 1;
	this.printMenu();
	$(".slide_click").click( function() {
		var image = $(this).attr('id');
		image = image.replace('item_','');
		slideShow.setCurrent(image);
		var fileName = $("#slideshow_" + image).attr('src');
		var bgCss = "#FFFFFF url('" + fileName + "') no-repeat scroll right 30px";
		$("#container").css('background',bgCss);
	});
}
StableSlideshow.prototype.setCurrent = function (itemNo) {
	this.currentItem = itemNo;
}

StableSlideshow.prototype.printMenu = function () {
	if (this.numberOfItems>1) {
		var htmlInfo = '<div class="menu">';
		var htmlInfo = htmlInfo + '<ul>';
		var htmlInfo = htmlInfo + '<li>&lt; more impressions &gt;</li>'
		for (i=1;i<=this.numberOfItems;i++) {
			htmlInfo = htmlInfo + '<li><a href="javascript:void(0);" id="item_' + i + '" class="slide_click">' + i + '</a></li>'; 
		}
		htmlInfo = htmlInfo + '</ul></div>';
		$("#slideshow-menu").html(htmlInfo);
	}
	this.setCurrent(1);
	var fileName = $("#slideshow_1").attr('src');
	var bgCss = "#FFFFFF url('" + fileName + "') no-repeat scroll right 30px"; 
	$("#container").css('background',bgCss);
	$("img.slideshow").css('display','none');
}

$(document).ready(function(){
	slideShow = new StableSlideshow($(".slideshow").length);
});