
Cufon.replace('#menu a', { fontFamily: 'avalon' });
Cufon.replace('#about #desc h1', { fontFamily: 'aeroportal' });

$("#rotate").ready(function() {
  $("#rotate img").each(function() {
    $(this).attr("alt",$(this).attr("alt").replace(/(<|&lt;)br( )?(\/)?( )?(>|&gt;)/gi, '<span class="separator"></span><br/><span class="separator"></span>'));
  });
});
$(function() {
    $('#rotate').after('<div id="pager">').cycle({ 
	fx:     'fade', 
	speed:  'slow', 
	timeout: 9000, 
	pager:  '#pager',
	before:  onBefore
    });
});
  
function onBefore() {
  $('#desc').delay(200).html('<p style="position:relative;z-index:999;"><strong>' + $(this).children().attr("alt") + '</strong></p>'); 
  Cufon.replace('#desc strong', { fontFamily: 'aeroportal' });
}

$(document).ready(function() {

  if($.browser.opera) { $("#desc").addClass("opera"); }

  $(".kalkulacka .spocitat").click(function() {
    if(!$(this).hasClass("opened")) {
      $(this).parent().animate({ height: "115px" }, 500);
      $(this).addClass("opened");
    } else {
      $(this).parent().animate({ height: "44px" }, 500);
      $(this).removeClass("opened");
    }
  });
  
  $(".kalkulacka input").keyup(function() {
    $(this).val($(this).val().replace(/[^0-9,\.]+/gi, ""));
    pocetm = $(this).val().replace(/,/gi, ".");
    if(pocetm.length==0) { pocetm = 0; }
    plochabal = $(this).parent().parent().parent().find(".plochabaleni").text().replace(",", ".");
    cenazabal = $(this).parent().parent().parent().find(".cenazabal").text();
    vysledek = Math.ceil(parseFloat(pocetm) / parseFloat(plochabal));
    celkemkc = parseInt(vysledek * parseInt(cenazabal)) + " Kč";
    $(this).parent().find(".vysledek").text(vysledek);
    $(this).parent().find(".celkovacena").text(celkemkc);
  });
  
  $("#photos .minifoto").mouseover(function() {
    $(this).parent().find(".mainfoto").hide().attr("src", $(this).attr("rel")).show();
  });

});
