
Cufon.replace('#menuin ul a', { hover: true });
Cufon.replace('#sidebar h2');
Cufon.replace('#ftr h3');

var hledani = "Hledaná fráze";
var novinky = "Vepište Váš e-mail";
var poptavkajmeno = "jméno";
var poptavkaemail = "váš e-mail";
var poptavkatelefon = "telefon";
var poptavkatext = "poptávám ..."

$(function() {
    $('#galerie div').cycle({ 
	fx:     'fade', 
         speed:  300, 
         timeout: 0,
         before:  onBefore, 
         next:   '#nextgal', 
         prev:   '#prevgal'
    });
});

function onBefore() { 
    var popisek = $(this).children().attr("alt").split('|');
    $(this).parent().parent().find(".popisek").html("<h3>" + popisek[0] + "</h3>" + popisek[1]);
} 

$(document).ready(function() {

  if (jQuery.browser.opera) {
    $('ul#plusy li').css({"display" : "inline-table"});
  }

  $("input#search").focus(function () {
    if($(this).val()==hledani) { $(this).val(''); }
  }).blur(function () {
    if($(this).val()=="") { $(this).val(hledani); }
  });
  $("input#news").focus(function () {
    if($(this).val()==novinky) { $(this).val(''); }
  }).blur(function () {
    if($(this).val()=="") { $(this).val(novinky); }
  });
  $("input#poptavka-jmeno").focus(function () {
    if($(this).val()==poptavkajmeno) { $(this).val(''); }
  }).blur(function () {
    if($(this).val()=="") { $(this).val(poptavkajmeno); }
  });
  $("input#poptavka-email").focus(function () {
    if($(this).val()==poptavkaemail) { $(this).val(''); }
  }).blur(function () {
    if($(this).val()=="") { $(this).val(poptavkaemail); }
  });
  $("input#poptavka-telefon").focus(function () {
    if($(this).val()==poptavkatelefon) { $(this).val(''); }
  }).blur(function () {
    if($(this).val()=="") { $(this).val(poptavkatelefon); }
  });
  $("textarea#poptavka-text").focus(function () {
    if($(this).val()==poptavkatext) { $(this).val(''); }
  }).blur(function () {
    if($(this).val()=="") { $(this).val(poptavkatext); }
  });
  
  
  $(".tabcontrol a.active").each(function(i,e) {
    $("#tab-" + this.id).css({"display":"block"});
  });
  $("div[id^='tab-']:visible").each(function(i,e) {
    var match = this.id.split('tab-');
    $("#" + match[1]).addClass("active");
  });
  $(".tabcontrol a").click(function () {
    $(this).parent().find("a").each(function(i,e) {
      $(this).removeClass("active");
      $("#tab-" + this.id).css({"display":"none"});
    });
    $(this).addClass("active");
    $("#tab-" + this.id).css({"display" : "block"});
  });
  
  var xOffset2 = (25 + $("#popup_bubble").width());
  var yOffset2 = 13;  
  $("ul#plusy li").hover(function(e) {
    this.t = this.title;
    this.title = "";
    if($("#popup_bubble")) { $("#popup_bubble").remove(); }
    $("body").append("<div id='popup_bubble'></div>");
    $("#popup_bubble").fadeIn(125);
    $("#popup_bubble").append("<img src='" + this.t + "' alt=''/>");
    $("#popup_bubble")
    .css("left",(e.pageX - $("#popup_bubble").width() - xOffset2 - 8) + "px")
    .css("top",(e.pageY + 15) + "px");
  }, function () {
    this.title = this.t;
    $("#popup_bubble").fadeOut(75);
  });  
  $("ul#plusy li").mousemove(function(e) {
    var kompenzace = 0;		  
    if((e.pageX + xOffset2) >= $("body").width()) {
      kompenzace = $("body").width() - (e.pageX + $("#popup_bubble").width() + xOffset2);
    }		  
    $("#popup_bubble")
    .css("left",(e.pageX - $("#popup_bubble").width() - xOffset2 + kompenzace) + "px")
    .css("top",(e.pageY + 15) + "px");
  });
  
  $(function() {
    $('#galerie div a, #gallery div a').lightBox({
	imageLoading: 'img/lightbox/loading.gif',
	imageBtnClose: 'img/lightbox/close_grey.png',
	imageBtnPrev: 'img/lightbox/prev_grey.gif',
	imageBtnNext: 'img/lightbox/next_grey.gif',
	txtImage: 'Fotka',
	txtOf: 'z'
    });
  });


});

// IE6 print
window.onbeforeprint = function() { document.getElementById("logo").src = "img/travni-koberce_print.jpg"; }
window.onafterprint = function() { document.getElementById("logo").src ="img/travni-koberce.png"; }

