function GetMarginTopText(box1, box2, MasterDiv) {
    /* GetMarginTopText by Jiri Mudroch */
    var box1H = $('#' + box1).height();
    var box2H = $('#' + box2).height();
    if (MasterDiv == 1) {
      var Vysledek = Math.ceil((box1H - box2H)/2);
      if (Vysledek < 0) {
        $('#' + box1).css("margin-top", (-1)*Vysledek);
      }else{
        $('#' + box2).css("margin-top", Vysledek);
      }
    }else{
      var Vysledek = Math.ceil((box2H - box1H)/2);
      if (Vysledek < 0) {
        $('#' + box2).css("margin-top", (-1)*Vysledek);
      }else{
        $('#' + box1).css("margin-top", Vysledek);
      }
    }
}
/* check div exists -> fu*k Xstand. editor */
$(document).ready(function(){

  if ($('#centertextindiv').length) {
    $(window).load(function() { 
      GetMarginTopText('JSbox1-left', 'JSbox1-right', 1);
      GetMarginTopText('JSbox2-left', 'JSbox2-right', 0);
      GetMarginTopText('JSbox3-left', 'JSbox3-right', 1);
      GetMarginTopText('JSbox4-left', 'JSbox4-right', 0);
      GetMarginTopText('JSbox5-left', 'JSbox5-right', 1);
      GetMarginTopText('JSbox6-left', 'JSbox6-right', 0);
    });
  }

// MENU BAR HEIGHT
  $("#apple-menu-bar").css("height", ( $("#apple-menu").height() + "px" ) );

// SKIN SWITCH
  $('#apple-menu-bar li').click(function() {
      var date = new Date();
      var skin = $(this).attr("class");
      date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000));
      $.cookie("skin", skin, { path: '/', expires: date });
      $("html").removeClass().addClass(skin);
      $('#apple-menu-bar').pngFix();
      //$('#apple-menu-bar li[class!='+skin+']').css("backgroundImage","none");
      return false;
  });
                
});
function theRotator() {

	//Set the opacity of all images to 0
	root.children('li').hide();
	
	//Get the first image and display it (gets set to full opacity)
	root.children('li:first').show().addClass('show');
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',3000);
	
}
 
function rotate() {	

	//Get the first image
	var current = (root.children('li.show')?  root.children('li.show') : root.children('li:first'));
 
	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? root.children('li:first') :current.next()) : root.children('li:first'));
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.fadeOut(1000)
	.addClass('show')
	.fadeIn(1000);
 
	//Hide the current image
	current.fadeOut(1000)
	.removeClass('show');
	
};


$(document).ready(function () {

  $(document).pngFix();

  $('#photo-cycl ul').innerfade({
  	timeout: 3000
  });

});
