$(function(){
    var checkHashHRef = function(e){
        if ($(this).attr('href') == '#') {
            e.preventDefault();
        }
    }
    
    $('.js_increasable').each(function(i, item){
        increasable = $(item);
        container = $(item).parent();
        
        if (typeof(console) != 'undefined' && container[0].tagName.toLowerCase() != 'a') {
            console.warn('.js_increasable can be used only inside `a`-tag');
            console.warn('Skipping .js_increasable: %o', item);
            
            return true;
        }
        
        $('<img />').css({
            'z-index': 50,
            'position': 'absolute',
            'width': '77px',
            'height': '77px',
            'top': 1,
            'left': 1
        }).attr({
            'src': $(this).attr('to'),
            'className': 'js_increasable_b'
        }).appendTo(container).hide();
        
        container.click(checkHashHRef).bind('mouseenter', function(){
            container = $(this);
            increasable = $('.js_increasable', container);
            increased_image = $('.js_increasable_b', container);

            increased_image.click(checkHashHRef).css({
                'top': increasable.offset().top,
                'left': increasable.offset().left,
                'width': '77px',
                'height': '77px'
            }).stop().animate({
                'width': '210px',
                'height': '210px',
                'top': increasable.offset().top - 66,
                'left': increasable.offset().left - 66
            }, 300).bind('mouseleave', function(){
                increasable = $('.js_increasable', $(this).parent());

                $(this).stop().animate({
                    'width': '77px',
                    'height': '77px',
                    'top': increasable.offset().top,
                    'left': increasable.offset().left
                }, 300, function(){
                    $(this).hide();
                });
            });
        });
    });
});