(function($){
    $.fn.extend({
        defaultinput:function(options){
            
            var defaults = {
                defaultValue: ''
            };
             
            var o = $.extend(defaults, options);
            
            return this.each(function() {
                var obj = $(this);
                
                obj.focus(function() {
                    if(obj.val() == o.defaultValue) obj.val('')
                });
                obj.blur(function() {
                    if(obj.val() == '') obj.val(o.defaultValue)
                });
            });
        }
    });
})(jQuery);

function centerImage(img, container) {
    var w = container.width();
    var h = container.height();
    var imgW = img.width();
    var imgH = img.height();

    img.css('left', (w - imgW) / 2 + 'px');
    img.css('top', (h - imgH) / 2 + 'px');
}

$(document).ready(function() {
    $('#search-text').defaultinput({
        defaultValue: 'wpisz szukany tekst...'
    });
    
    $('#bottom-menu-1 ul li:nth-child(3n)').width('140px');
    $('#bottom-menu-2 ul li:nth-child(2)').width('60px');
    
    $('.menu-top ul li ul').each(function() {
       $(this).prepend('<li class="submenu-top"></li>');
       $(this).append('<li class="submenu-bottom"></li>');
    });
    
    $('#like-box').hover(function(){
        $(this).stop(true, false).animate({
            left:'0'
        },'medium');
    },function(){
        $(this).stop(true, false).animate({
            left:'-223'
        },'medium');
    },500);
    
    $('.calendar-select').click(function() {
       $('.calendar-select-list').toggle();
    });      
    
    $('.calendar-wrap-days a.event-info').click(function() {
        $('.event-desc-wrap').hide();
        $(this).next().show();
        return false;
    });
    
    $('.calendar-close-popup').click(function() {
        $(this).parent().css({display: 'none'});
    })
        
});
