$(document).ready(function(){
  $('#menu-bar li.act a').append('<span class="corner"></span>');
  $('#footer-bar #footer li:last').css('border','0');
  $('#submenu2 li:last, #featured ul.ui-tabs-nav li:last').css('background','none');


  var oldHref = $('#detail #img img').attr('src');  
  $('#detail #prevVzor li .img a').hover( function() {        
    var imgHref = $(this).attr('href');
    $('#detail #img img').attr('src',imgHref);  
  }, function() {
    $('#detail #img img').attr('src',oldHref);
  } );  
  
// 	$('.tooltip').hover(
// 		function(){ $('#tool:hidden').fadeIn(); },
// 		function(){ $('#tool:visible').fadeOut(); }
// 	);	  

  $("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});  
  
  $("#featured").tabs({ fx: [{opacity:'toggle', duration:'slow'},   // hide option
                        {opacity:'toggle', duration:'slow'}] }).tabs("rotate", 8000, true);
  
  
  var navHeight = $('#featured ul.ui-tabs-nav').height();
  var infoHeight = $('#featured .ui-tabs-panel .info').height();     
  $('#featured .ui-tabs-panel .info').css('top', (navHeight-infoHeight+7)+'px' );  
      
  
  $('#menu-bar li a').hover( function() {
    li = $(this).parent();

    if ( !li.hasClass('act') ) {
      $(this).append('<span class="corner"></span>');
    }
        
  }, function() {
    li = $(this).parent();
    
    if ( !li.hasClass('act') ) {
      $(this).find('span').remove();
    }
            
  } ); 
  
  $('.aShow').click( function(e) {
    e.preventDefault();
    $('#prevVzor').height( $('#ulVzor').height() );
  } );                  
  
  var slider = $('#info').bxSlider({
      mode: 'vertical',
      pager: false,
      auto:true,
      pause: 8000,
      autoHover: true                            
    });
    
  $('#news-bar #next').click(function() {
    slider.goToNextSlide();
  });
  
  $('#news-bar #prev').click(function() {
    slider.goToPreviousSlide();
  });  
  
  $('#poptavka').submit( function(e) {
    e.preventDefault();
    
    $.ajaxSetup({
        jsonp: null,
        jsonpCallback: null
    }); 
            
    $.ajax({
        type : 'POST',
        url : '../../ajax.php',
        dataType : 'json',
        data: {
            od  : $(this).find('input[name="od"]').val(),
            ddo : $(this).find('input[name="do"]').val(),
            po  : $(this).find('input[name="po"]').val(),
            jmeno  : $(this).find('input[name="jmeno"]').val(),
            email  : $(this).find('input[name="email"]').val(),
            tel  : $(this).find('input[name="tel"]').val(),
            pozn  : $(this).find('textarea[name="pozn"]').val(),
            hotel  : $(this).find('input[name="hotel"]').val()
        },
        success : function(data){
           $('#poptavka').remove();
           $('#content').find('.info').html(data.text);              
        },
        error : function(XMLHttpRequest, textStatus, errorThrown) { }
    });
    
  });  
     
});
                  
