var position = 0;
var offset = 600;
var prods;
var currentProds = 1;

$(function() {
//	$("#accordion").accordion({
//		autoHeight: false,
//		navigation: true
//	});
	$("a.prod_next").click(nextProd);
	$("a.prod_prev").click(prevProd);
	countProds();
	if (photosMax > 1)
		setInterval('rotate();', 8000);
	for (var i=1; i<photosMax; i++) {
		var img = new Image(760, 348);
		img.src = 'default/images/' + currLang + '/' + i + '.jpg';
	}
});



function nextProd() {
	if (currentProds >= prods)
		return false;
	position -= offset;
	currentProds++;
	$(".products_holder").animate({
		left :	position 
	}, 'slow', 'easeInOutCubic');
	return false;
}

function prevProd() {
	if (position >= 0)
		return false;
	position += offset;
	if (currentProds > 0)
		currentProds--;
	$(".products_holder").animate({
		left :	position 
	}, 'slow', 'easeInOutCubic');
	return false;
}

function countProds() {
	prods = Math.ceil($(".two_prods").size() / 3);
}

var current = 1;
function rotate() {
	current++;
	if (current > photosMax) {
		current = 0;
		return;
	}
	var img = 'default/images/' + currLang + '/' + current + '.jpg';
	$("#rotate_main").fadeOut('slow', function() {
		$("#rotate_main").attr('src', img);
		$("#rotate_main").fadeIn('slow');
	});
	
	
}
