function test(a) {
  $('#iframeregisterlogin').css("height", a + 'px'); 
}
function HideLoader() {
  $('#souteze-loading').hide();
}
$(document).ready(function() {
  
//   /* fancybox sumbit problem */  
//   $('form#login').submit(function() {
//       parent.$.fancybox.showActivity();
//     
//       var data = null;
//       data = $('form#login').serialize();
//     
//       $.ajax({
//       type    : "POST",
//       cache   : false,
//       url     : "http://kaka.cz.dev/souteze-login/",
//       data    : data + "&__event_onclick[submitLogin]=Prihlasit",
//       success: function(msg){
//         parent.$.fancybox.hideActivity();
// 
//         var error = $("#error", msg).html();
//         $("#error").html(error);
// 
//         var callback = $("#myloginform", msg).html();
//         $("#myloginform").html(callback);
// 
//         myErrorCount = $('ul.NoticerError>li').length;        
// 
//         if (myErrorCount == '0') {
//           var redirectto = parseInt($('#idsoutez').val());
//           //alert(redirectto);
//           if (isNaN(redirectto) || redirectto == 0) {
//             parent.location.replace('/souteze/');
//           }else{
//             parent.location.replace('/souteze-detail/' + redirectto);
//           }
//           return false;
//         }
// 
//         if (myErrorCount > 0) {
//           myErrorCount = 150 + (20 * myErrorCount);
//           parent.$.fancybox.setheight(myErrorCount);
//         }
// 
//        return false;
// 
//       }
//     });
//     
//     return false;
//     
//   });
//    
//   /* fancybox sumbit problem */  
//   $('form#store_user').submit(function() {
//       parent.$.fancybox.showActivity();
//     
//       var data = null;
//       data = $('form#store_user').serialize();
//     
//       $.ajax({
//       type    : "POST",
//       cache   : false,
//       url     : "http://kaka.cz.dev/souteze-register/",
//       data    : data + "&__event_onclick[submitNewUser1]=Registrovat",
//       success: function(msg){
//         parent.$.fancybox.hideActivity();
// 
//         var registerok = $("div.ok", msg).html()
// 
//         if (registerok != null) {
//           parent.$.fancybox(registerok);
//           return false;  
//         }
// 
//         var error = $("#error", msg).html();
//         $("#error").html(error);
// 
//         var callback = $("#myregisterform", msg).html();
//         $("#myregisterform").html(callback);
// 
//         myErrorCount = $('ul.NoticerError>li').length;        
// 
//         if (myErrorCount > 0) {
//           myErrorCount = 330 + (20 * myErrorCount);
//           parent.$.fancybox.setheight(myErrorCount);
//         }
// 
//       }
//     });
//     
//     return false;
//     
//   });

  /* jquery rotator */
  if ($('.fotobox').length > 0) {
    $(window).load(function() {
      $('.foto').cycle({
        fx:'fade',
        speed:1500,
        timeout:1000
        });
    });
  }

  /* jquery rotator */
  if ($('#ceny').length > 0) {

    $('.ceny-foto img').hide();
   
    $(window).load(function() {
      var imgHeight = 0;
      var helpVar = 0;
      var divHeight = 130;
     
      $('.ceny-foto img').each(function() {
        
        imgHeight = $(this).height();
        
        if (imgHeight < divHeight) {
          helpVar = 0;
          helpVar = parseInt((divHeight - imgHeight) / 2);
          $(this).css("margin-top", helpVar + "px");    
        }  
      });
      $('.ceny-foto').cycle({
        fx:'fade',
        speed:500,
        timeout:0,
        next:   '#next-image', 
        prev:   '#prev-image' 
        });
    });
  }
  
  $('#souteze-register').click(function() {
    $('li.prvni').addClass('active');
    $('#souteze-loading').show();
    if ($('li.druhy').hasClass('active') == true) {
      $('li.druhy').removeClass('active');
    }
  });

  $('#souteze-login').click(function() {
    $('li.druhy').addClass('active');
    $('#souteze-loading').show();
    if ($('li.prvni').hasClass('active') == true) {
      $('li.prvni').removeClass('active');
    }
  });

});
