



var tt = setTimeout(function(){
    shoRestMain();
}, 2000);
function shoRestMain() {

    clearTimeout(tt);
    $('.box_main_box').slideDown('slow');
    $('.box_main_box_first').slideDown('slow');
    $('.box_main_box_last').slideDown('slow');
}

var isiPad = navigator.userAgent.match(/iPad/i) != null;
  
if(isiPad){
  $('#ostc').addClass('ipad');
}


$(window).load(function(){
    $('.box_gallery a').each(function(){
        var w = $(this).find('img').width();
        var h = $(this).find('img').height();
        $(this).width(w);
        $(this).height(h);
        
        $(this).find('img').css('position', 'absolute');
          console.log(w);     
       $(this).hover(function(){
          var span = $('<span class="bordowanie"></span>');
          span.width(w);
          span.height(h);
          span.css('opacity', '0.3');    
           
          $(this).append(span);
       }, function(){
       
          $(this).find('span').remove();
       });
    
    });
    });

$(document).ready(function(){

  if( $.browser.msie){
  $('body, #ostc').addClass('ie');
}

    $('.box_show_main_box').click(function(){
        shoRestMain();
        return false;
    });
    
    $('.box_gallery a').lightBox();
    


    $('.box_main_box a,.box_main_box_last a,.box_col_5 a, .box_col_5_last a,.box_col_6 a, .box_col_6_last a').html('');
    $('.box_main_box, .box_col_6, .box_col_6_last,.box_col_5, .box_col_5_last').click(function(e){
        var loc=$(this).find('a').attr('href');
  
        if(typeof loc == 'undefined'){
          return false;
        }
  
  
        var target=$(this).find('a').attr('target');
        if(target == '_blank'){
            window.open(loc);
        }else{
            document.location = loc;
        }
  
  
        e.stopPropagation();
        return false
    });
    $('.box_col_5 a,.box_main_box_last a, .box_main_box a,.box_col_5_last a,.box_col_6 a, .box_col_6_last a').click(function(e){
        e.stopPropagation();
    });


    if($(document).height() > $(window).height()){
        $('body').append('<div id="up_fixed"><a onclick="javascript:$(window).scrollTop(0);" class="upp_div"></a></div>');

    };


    $('.storycontent li').each(function(){
        $(this).html('<span>'+$(this).html()+'</span>');

    });
    $('.special_table').each(function(){
    $(this).find('tr:first').addClass('firstrow');
    });


    $('.wpcf7-form').submit(function(){
      var error = false;
       if(typeof $('input[name=radio-420]:checked').val() == 'undefined'){
        error = true;
       }
       if(typeof $('input[name=radio-421]:checked').val() == 'undefined'){
        error = true;
       }
       if(typeof $('input[name=radio-422]:checked').val() == 'undefined'){
        error = true;
       }       
       if(typeof $('input[name=radio-423]:checked').val() == 'undefined'){
        error = true;
       }     
       if($('input[type=checkbox]:checked').size() == 0){
          error=true;
       }
       
         if(error){
          alert('Wypełnij wymagane pola');
       return false;
       }
    
    });

}); 
