/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$(document).ready(function(){
    $('.gallery_section').hover(function(){
        $(this).children('a').children('.gallery_section_disc').addClass('gallery_more');
    }
    ,function(){
        $(this).children('a').children('.gallery_section_disc').removeClass('gallery_more');
    });

    $('.more_hover').hover(function(){
        $(this).addClass('gallery_more_h');
    },function(){
        $(this).removeClass('gallery_more_h')
    });

    $('.cover, .medium_thumbs').click(function(){
        $(".mask").fadeIn("slow");
        $(".preloader").fadeIn("slow");
        $('.overlay_image').remove();
        $('.overlay').append('<img class="overlay_image" src="'+$(this).parent('a').attr('href')+'"/>');
        $(".mask").fadeTo("slow",0.8,function(){});

        $(".overlay_image").load(function(){
            $(".overlay").removeAttr("margin-top");
            $(".overlay").removeAttr("margin-left");
            var wid = $(".overlay").width() /2;
            wid = wid *-1;
            wid = wid -10;
            var hi = $(".overlay").height() /2;
            hi = hi *-1;
            hi = hi-10;
            $(".overlay").css("margin-top",hi);
            $(".overlay").css("margin-left",wid);
            $(".overlay").fadeIn("slow");
            
        });
        return false;
    })
    
    $(".overlay").click(function(){
        $(this).fadeOut();
        $(".mask").fadeOut("slow");
        $(".overlay").removeAttr("margin-top");
        $(".overlay").removeAttr("margin-left");
        $(".preloader").fadeOut("fast");
    });

    $(".mask").click(function(){
        $(".overlay").fadeOut();
        $(".mask").fadeOut("slow");
        $(".overlay").removeAttr("margin-top");
        $(".overlay").removeAttr("margin-left");
        $(".preloader").fadeOut("fast");
    });

    $('.mnu_but').hover(function(){
        $('.'+$(this).attr('id')).fadeIn(10);
    },function(){
        $('.'+$(this).attr('id')).fadeOut(10);
    })

    $('.cover, .medium_thumbs').hover(function(){
        $(this).addClass('hov_thumbd');
    },function(){
        $(this).removeClass('hov_thumbd');
    })

    $('.in_shg').focus(function(){
        $(this).prevAll('.hide').fadeIn();
        $(this).css('color','#534a47');
        $(this).val('');
        
        
    })

    $('textarea').focus(function(){
        if($(this).val()=='Twoja wiadomość:'){
            $(this).val('');
        }
    })

    $('.in_shg').blur(function(){
        $(this).prevAll('.hide').fadeOut();
    })



    $('textarea').autoResize({
        // On resize:
   
        // Quite slow animation:
        animateDuration :500,
        // More extra space:
        extraSpace : 40
    });

    $('.but').hover(function(){
        $(this).children('.hide').fadeIn();
    },function(){
        $(this).children('.hide').fadeOut();
    })

    $('.but').click(function(){
        $(this).children('.hide').fadeOut('fast');
        $('#mes').submit();

    })
});

