var page = 1;

var bNextPage = true;

function nextPage()
 {
  if (bNextPage)
   {
    bNextPage = false;
    IDsite = "#site" + page;
    if (page == 4) {$('#next').fadeOut('slow');}
    $(IDsite).fadeOut('slow', function() {
     if (page <= 4) {page++;}
     IDsite = "#site" + page;
     $(IDsite).fadeIn('slow');
     $('#prev').fadeIn('slow');
     bNextPage = true;
    });
   }
 }
 
function prevPage()
 {
  if (bNextPage)
   {
    bNextPage = false;
    IDsite = "#site" + page;
    if (page == 2) {$('#prev').fadeOut('slow');}
    $(IDsite).fadeOut('slow', function() {
     if (page >= 2) {page--;}
     IDsite = "#site" + page;
     $(IDsite).fadeIn('slow');
     $('#next').fadeIn('slow');
     bNextPage = true;
    });
   }
 }
 
function goHome()
 {
  window.location = "/";
 } 
 
$(document).ready(function() 
 {
  //$("h2").click(function() 
  // {
  //  $(this).hide("drop", {direction: "down"}, 1000);
  // }); 
  
  $("#prev").click(function() 
   {
    prevPage();
   });
   
  $("#next").click(function() 
   {
    nextPage();
   }); 
   
  $("#next").hover(function() 
   {
    document.getElementById("next").src = "sville.pl/images/next_glow.gif";
   });  
   
  $("#next").mouseout(function() 
   {
    document.getElementById("next").src = "sville.pl/images/next.png";
   });   
   
  $("#prev").hover(function() 
   {
    document.getElementById("prev").src = "sville.pl/images/prev_glow.gif";
   });  
   
  $("#prev").mouseout(function() 
   {
    document.getElementById("prev").src = "sville.pl/images/prev.png";
   });  
  
  document.getElementById("header").onclick = goHome;  
 }); 
