function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
var __packsInterval__ = null;
var __packsSpeed__ = 100;
var __packsStep__ = 4;
var __packsDirection__ = true;
addLoadEvent(function() {
  if(document.getElementById('balicek_strip')) {
  	__packsInterval__ = window.setInterval('movePacks()', __packsSpeed__);
  	document.getElementById('balicek_strip').onmouseover = function() {
  		window.clearInterval(__packsInterval__);
  	}
  	document.getElementById('balicek_strip').onmouseout = function() {
  		__packsInterval__ = window.setInterval('movePacks()', __packsSpeed__);
  	}
  }
});

function movePacks() {
	var strip = document.getElementById('balicek_strip');
	var l = parseInt(strip.style.left);
	var w = parseInt(strip.style.width);
	if(l > 0) {
		strip.style.left = -w/2 + 2*__packsStep__ + 'px';
	} else if(l > -w/2) {
		l -= (__packsDirection__?1:-1) * __packsStep__;
		strip.style.left = l + 'px';
	} else 
		strip.style.left = ((__packsDirection__?-1:1) * __packsStep__) + 'px';
}

function packsLeftOver() {
	__packsDirection__ = true;
	__packsStep__ = 12;
}

function packsRightOver() {
	__packsDirection__ = false;
	__packsStep__ = 12;
}

function packsOut() {
	__packsDirection__ = true;
	__packsStep__ = 4;
}

var currentMonth = 0;

function nextMonth() {
	currentMonth += 1;
	$("#ajaxKalendar").load("kalendar.php?month=" + currentMonth.toString());
	return true;
}

function previousMonth() {
	currentMonth -= 1;
	$("#ajaxKalendar").load("kalendar.php?month=" + currentMonth.toString());
	return true;
}
