function webLoadComplete() {
 
  $(".Loading").animate({marginTop: "-=0"}, 1000, function() {
    
    $(".Loading").animate({opacity: "0", marginTop: "-=40"}, 1000, function() {
    
      $(".Loading").css({display: "none"});
        
      $(".Header").animate({opacity: "1"}, 1000);
      $(".Content").animate({opacity: "1"}, 2000);
      $(".Footer").animate({opacity: "1"}, 1000);   
    });
  });
}

function changePage(page) {
  
  $(".Header").animate({opacity: "0.1", marginTop: "-=90", marginBottom: "+=90"}, 500, function() {
    
    $("#" + lastPage).css({background: "none"});
    $("#" + page).css({background: "url(img/black_alfa_back.png)"});
  }).animate({opacity: "1", marginTop: "+=90", marginBottom: "-=90"}, 500, function() {
  
    lastPage = page; 
  });
  
  $(".Footer").animate({opacity: "0.5", top: "+=60"}, 500)
  .animate({opacity: "1", top: "-=60"}, 500);
  
  if (page == "Index")
  {
    $(".ContentSlider").animate({marginTop: "0"}, 1000);
  }
  
  if (page == "OSalonu")
  {
    $(".ContentSlider").animate({marginTop: "-" + 1 * ($(window).height()-$(".Header").height()-$(".Footer").height()-41)}, 1000);
  }
  
  if (page == "Aktuality")
  {
    $(".ContentSlider").animate({marginTop: "-" + 2 * ($(window).height()-$(".Header").height()-$(".Footer").height()-41)}, 1000);
  }
  
  if (page == "Sluzby")
  {
    $(".ContentSlider").animate({marginTop: "-" + 3 * ($(window).height()-$(".Header").height()-$(".Footer").height()-41)}, 1000);
  }
  
  if (page == "Galerie")
  {
    $(".ContentSlider").animate({marginTop: "-" + 4 * ($(window).height()-$(".Header").height()-$(".Footer").height()-41)}, 1000);
  }
 
  if (page == "Kontakt")
  {
    $(".ContentSlider").animate({marginTop: "-" + 5 * ($(window).height()-$(".Header").height()-$(".Footer").height()-41)}, 1000);
  }
}

function ToMiddle() {

  var topIndent = ($(".Content").height() - $("#IndexBlock").height()) / 2 - 10; 
  $("#IndexBlock").css({marginTop: topIndent + "px"});
  
  topIndent = ($(".Content").height() - $("#OSalonuBlock").height()) / 2 - 10; 
  $("#OSalonuBlock").css({marginTop: topIndent + "px"});
  
  topIndent = ($(".Content").height() - $("#AktualityBlock").height()) / 2 - 10; 
  $("#AktualityBlock").css({marginTop: topIndent + "px"});
  
  topIndent = ($(".Content").height() - $("#SluzbyBlock").height()) / 2 - 10; 
  $("#SluzbyBlock").css({marginTop: topIndent + "px"});
  
  topIndent = ($(".Content").height() - $("#GalerieBlock").height()) / 2 - 10; 
  $("#GalerieBlock").css({marginTop: topIndent + "px"});
  
  topIndent = ($(".Content").height() - $("#KontaktBlock").height()) / 2 - 10; 
  $("#KontaktBlock").css({marginTop: topIndent + "px"});
}

function changeGalleryPage(page) {

  $(".SelectedPageBullet").addClass("PageBullet");
  $(".SelectedPageBullet").removeClass("SelectedPageBullet");
  
  $("#GalleryPageBullet" + page).addClass("SelectedPageBullet");
  $("#GalleryPageBullet" + page).removeClass("PageBullet");
  
  $(".PhotoLine").animate({marginLeft: "-" + page * 970}, 500)

}

function backGalleryPage() {
  
  var page = (parseInt($(".SelectedPageBullet").attr("title")) - 1);
  
  if (page > 0)
  {  
    $(".SelectedPageBullet").addClass("PageBullet");
    $(".SelectedPageBullet").removeClass("SelectedPageBullet");
    
    $("#GalleryPageBullet" + (page - 1)).addClass("SelectedPageBullet");
    $("#GalleryPageBullet" + (page - 1)).removeClass("PageBullet");

    $(".PhotoLine").animate({marginLeft: "+=970"}, 500);
  }

}

function nextGalleryPage() {
  
  var page = (parseInt($(".SelectedPageBullet").attr("title")) - 1);
  
  if (page < 8)
  { 
    $(".SelectedPageBullet").addClass("PageBullet");
    $(".SelectedPageBullet").removeClass("SelectedPageBullet");
    
    $("#GalleryPageBullet" + (page + 1)).addClass("SelectedPageBullet");
    $("#GalleryPageBullet" + (page + 1)).removeClass("PageBullet");

    $(".PhotoLine").animate({marginLeft: "-=970"}, 500);
  }
}

function setOpenedImage(number) {

  openedImage = number;
}

function prevImageClick() {

  openedImage--;
  
  if (openedImage == 0)
  {
    backGalleryPage();
    openedImage = 4;
  }
}

function nextImageClick() {

  openedImage++;
  
  if (openedImage == 5)
  {
    nextGalleryPage();
    openedImage = 1;
  }
}

function setContentHeight() {
  
    $(".Content").css({height:($(window).height()-$(".Header").height()-$(".Footer").height()-41-80) + "px"});
    $("#ContentContainer").css({height:($(window).height()-$(".Header").height()-$(".Footer").height()-41) + "px"});
}
function footerToBottom() {
  
  if ($("body").height() < $(window).height()) {	
    $(".Footer").css({position: "absolute", top:($(window).scrollTop()+$(window).height()-$(".Footer").height()-41)+"px", left: "0px", width: ($(window).width()-40)+"px"});
  }
}
