( function( $ )  {

    $.fn.footerHide = function( options ) {

       var settings = {
          'content' : 'Mapa strony',
          'howLong' : 700,
          'imgLocation' : './images/',
          'target' : '.sitemap',
          'wrapper' : '.realisation'
       };

       return this.each(function() {

           if ( options ) {
               $.extend( settings, options );
           }

           var me = $(this);
           var opt = settings;
           var targetHeight = $(opt.target).height();

           me.find(opt.wrapper).append(
               '<div class=\"footerHider\" diff=\"'+targetHeight+'\" id=\"showMeNow\"><a href=\"#showMeNow\">'+opt.content+'</a></div>'
           );

           // schowanie onload - poczatek
            if( targetHeight != $(opt.target).height() ) {
               $('.footerHider').attr( 'diff',$(opt.target).height() );
           }

           $('.footerHider').addClass('hidden');
           $(opt.target).hide();
           // koniec - schowanie onload


           $('.footerHider a').click(function (e) {
               e.preventDefault();

               var goTo = $(this).attr('href');
               if (!$('.footerHider').hasClass('hidden')) { 
                   if( targetHeight != $(opt.target).height() ) {
                       $('.footerHider').attr( 'diff',$(opt.target).height() );
                   }

                   $('.footerHider').addClass('hidden');
                   if ( !$.browser.opera ) {
                       $(opt.target).slideUp(opt.howLong, function() {
                            $('html, body').animate({scrollTop: '0px' }, 800);
                        });
                   } else {
                       $(opt.target).slideUp(opt.howLong, function() {
                            $('html, body').animate({scrollTop: '0px' }, 1);
                        });
                   }
               } else {
//                   me.animate({
//                       paddingTop : '-='+$('.footerHider').attr( 'diff')
//                   }, opt.duration);
                    if ( !$.browser.opera ) {
                       $(opt.target).slideDown(opt.howLong, function() {
                            $('html, body').animate({scrollTop: $('.whole').height()- $('.sitemap').height() }, 800);
                        });
                    } else {
                        $(opt.target).slideDown(opt.howLong, function() {
                            $('html, body').animate({scrollTop: $('.whole').height()- $('.sitemap').height() }, 1);
                        });
                    }
                   $('.footerHider').removeClass('hidden');

               }

               
           });

       });
    };

}) ( jQuery );
