
function updateBoxes()
{             
    //paticka pro boxiky
  var boxs = $("div.story");
  jQuery.each(boxs, function(){
    var val = $(this).html() + '<div class="story_bottom"></div>';
    if($(this).children('div.story_bottom').size() == 0){
        $(this).append('<div class="story_bottom"></div>');
    }
  
  });
  
  //$("div.story").append('<div class="story_bottom"></div>');
            
  //fixy pro IE6
  if(jQuery.browser.msie && jQuery.browser.version == 6){
    $("div.story h3").css({'width':'763'}); //box
    $("#texter").css({'float': 'none'}); //texter - fix pro IE6
    $(".story").css({'marginLeft': '3px'}); 
   
              
   //fixy homepage
   $("div.left div.story h3").css({'width' : '457'}); 
   //$("div.left div.story").css({'width' : '470'}); 
  }
  
  //centrovani menu v paticce
  var m = $("#footer ul");
  var p = m.parent();
  var ml = (p.width() - m.width()) /2;
  m.css({'paddingLeft': ml});
  
}

function footer(){  
               updateBoxes();
   var heel = $("#heel_bottom");
    if($("#copy").offset()){
        heel.css({
        'top': $("#copy").offset().top});
    }
    
    
}

/** ajax forms **/

    
           
    // odeslání na formulářích
    $("form.ajax").live("submit",function (e) {
        $('html').css({'cursor': 'wait'});
        $(this).ajaxSubmit(e);
        
    });

    $("form.ajax :submit").live("click",function (e) {
        $('html').css({'cursor': 'wait'});
        $(this).ajaxSubmit(e);
        
    });
    
    //loadery na formy
    $("form.loader").live('submit', function(e){
        $('#loader').dialog('destroy');
        $('#loader').dialog({
            'width': 500,
            'modal': true,
            //'autoOpen': false,
            'closeOnEscape': false,
            'draggable': false,
            'resizable': false,
            'height': 85
        });
       $('#loader-progress').progressbar({
            'value' : 100 
       });
    });
    
    //linky
    $("a").live('click', function(){
        $('html').css('cursor', 'wait');
        $.esenciaAjaxLink.click(this);
        return false;
    });



jQuery.ajaxSetup({
    success: $.esenciaAjaxLink.updateSnippets,
    dataType: "json",
    cache: false
    
});

$.esenciaAjaxLink.afterScroll = function(){
    footer();
}

$.esenciaLiveForm.afterAddError = function(el, message){
    footer();
}

$.esenciaLiveForm.afterRemoveError = function(el){
    footer();
}

$.esenciaAjaxLink.updateSnippet = function (id, html) {
    $("#" + id).fadeTo(150, 0.3, function () {
        //alert(html);
        $('html').css('cursor', 'default');
        $.esenciaAjaxLink.scrollTo(0, 500);
        $(this).html(html);
        $.esenciaAjaxLink.snippetUpdated(id);
        $(this).fadeTo(100, 1, function(){
            footer();
            //updateBoxes();
        });
        $("#loader").dialog('close');
    });
};
