$(document).ready(function(){
    
    $('#lightbox a, .lightbox').lightBox({
        imageLoading:'/i/jquery/lightbox/images/lightbox-ico-loading.gif',
        imageBtnClose:'/i/jquery/lightbox/images/lightbox-btn-close2.gif',
        imageBtnPrev:'/i/jquery/lightbox/images/lightbox-btn-prev2.gif',
        imageBtnNext:'/i/jquery/lightbox/images/lightbox-btn-next2.gif',
        imageBlank:'/i/jquery/lightbox/images/lightbox-blank.gif',
        txtImage:'Изображение',
        txtOf:'из'
    });
    
    if ($('body').outerHeight()<$(window).height()) {
        $('#filler').attr('height', $(window).height()+$('#filler').parent().outerHeight()-$('body').outerHeight());
    }
    
    $('#captcha').click(function(){
        $(this).attr('src', '/captcha/rand-'+parseInt(Math.random()*999999999)+'/');
    });
    
    $('.menu').click(function(){
        location.href = $(this).children('a').attr('href');
    });
    
    $('#show_form').click(function(){
        $('#send_button').hide();
        $('#send_table').slideDown();
        return false;
    });
    
    $('#send_form').validate({
        rules:{
            name:'required',
            email:{required:true, email:true},
            text:'required',
            keystring:{required:true, remote:'/captcha/check/'}
        },
        submitHandler:function(){
            $.post($('#send_form').attr('action'), {
                theme:$('#send_form input[name="theme"]').val(),
                name:$('#send_form input[name="name"]').val(),
                email:$('#send_form input[name="email"]').val(),
                text:$('#send_form textarea[name="text"]').val(),
                keystring:$('#send_form input[name="keystring"]').val()
            }, function(){
                $('#send_table').html('<center><i>Ваш вопрос отправлен</i></center>');
            });
            $('#send_table').html('<center><img src="/i/ajax.gif" width="24" height="24" /></center>');
            return false;
        }
    });
    
});

