
var slideshow;
var page_number;
var sourcekey;
var categoryid;

$(document).ready(function()
{

	page_number = 0;
	slideshow = $('.slideshow');
	init_slideshow();
});
	
function init_slideshow()
{
	$.post("plug.php?r=medialibrary&m=slideshow", { x: sourcekey, page: page_number, category_id: categoryid  }, OnReturn_Pictures , "text");
}

function OnReturn_Pictures(data, textStatus)
{
	//alert(data);
	if(data.indexOf('SET0') >= 0)
	{
		page_number = 0;
		data = data.replace('SET0', '' );
	}

	slideshow.cycle('stop'); 
	slideshow.html(data);
	start_slideshow();
}

function start_slideshow()
{
	slideshow.cycle
	({ 
		fx:     'scrollUp', 
		before:  Cycle_OnBefore, 
		after:   Cycle_OnAfter,
		autostop: true,
		end:   Cycle_Finished,
		pause: true,
	 });
}

function Cycle_Finished()
{
	init_slideshow()
}
function Cycle_OnAfter()
{
	page_number++;
}
function Cycle_OnBefore()
{

}

