var current = 0;
var slideshow_flag = 1;
var slideshow;
var total_images;

function init_num_images(num) {
	total_images = num;
}

$(document).ready(function(){
	get_data(0,1);
	if (slideshow_flag == 1) {
		slideshow = setTimeout("slideshow_go()", 10000);
	}
});

function slideshow_go() {
	clearTimeout(slideshow);
	get_next_data(total_images, 1);
	slideshow = setTimeout("slideshow_go()", 10000);
	return false;
}

function slideshow_stop() {
	clearTimeout(slideshow);
	return false;
}

function get_data(num, mode){
	$.get('data.php', {novost_id:num}, function(data){ 
		$('#my_data').html(data);
		current = num;
		$("div.pages a").removeClass("selected");
		$("#hh_"+num).addClass("selected");
	});
	if (mode == 0) slideshow_stop();
}

function get_next_data(total, mode) {
	current++;
	if (current >= total) current = 0;
	get_data(current, mode);
}

function get_previous_data(total, mode) {
	current--;
	if (current < 0) current = total-1;
	get_data(current, mode);
}