function slideshowBack()
{
	slideshowImg--;
	if(slideshowImg < 0)
	{
		slideshowImg = pictures[activeStyle].length - 1;
	}
	
	refreshSlideshow();
}

function slideshowFwd()
{				
	slideshowImg++;
	if(slideshowImg >= pictures[activeStyle].length)
	{
		slideshowImg = 0;
	}
	
	refreshSlideshow();
}

var maxSlideshowWidth=580;
function refreshSlideshow()
{	
	obj = returnObjById("slideshowCount");
	obj.innerHTML = "<img src=\"include/textToImg.php?text=" + (slideshowImg + 1) + " of " + pictures[activeStyle].length + 
					"&font_size=17&text_width=300&font_color=ffffff&background_color=000000&align=c\" />";
	
	var img = new Image();
	img.src=pictures[activeStyle][slideshowImg][IMAGE];
	
	var obj = returnObjById("slideshowImage");
	
	if(img.width==0 || img.height==0)
	{
		img.onload = slideshowCallback;
		
		obj.src = clockImg.src;
		obj.width = clockImg.width;
		obj.height = clockImg.height;
	}
	else
	{
		if(img.width > maxSlideshowWidth)
		{
			img.width = maxSlideshowWidth;
		}
		
		obj.src = img.src;
		obj.width = img.width;
		obj.height = img.height;
	}
	
	//preload
	var nextImg = slideshowImg + 1;
	if(nextImg < pictures[activeStyle].length)
	{
		var nextImage = new Image();
		nextImage.src=pictures[activeStyle][nextImg][IMAGE];
	}
}

function slideshowCallback()
{
	//alert("callback");
	if(this.width > maxSlideshowWidth)
	{
		this.width=maxSlideshowWidth;
	}
	
	var obj = returnObjById("slideshowImage");
	obj.src = this.src;
	obj.width = this.width;
	obj.height = this.height;
}