$(function(){

    if ($('.bg-main').html()) {
        setTimeout("$('#block1').slideUp(600);", 1200);
        setTimeout("$('#block2').hide('clip');", 1000);
    } else {
        $('.line-block').css('width', '1px').animate({
            width: '100%'
        }, 1000);
    }

    Cufon.replace('.f_helios');

    $('.ajax-content').click(function(){
        $('.service-content').html('').css('background', 'url(/images/ajax-loader.gif) no-repeat center');
        $('.service-most').remove();
        $('.service-menu').find('li').removeClass('service-link-active');
        $.ajax({
            url: $(this).attr('href'),
            success: function(datas){
                $('.service-content').css('background', '');
                $('.service-content').html(datas);
            }
        });
        $(document).attr('title', 'Услуги - ' + $(this).attr('title'));
        $(this).parent().addClass('service-link-active').append('<div class="service-most"></div>');
        return false;
    });

    $('#mail-form').ajaxForm({
        beforeSend: function(){

        },
        success: function(datas){
            if (datas.error) {
                alert("Сервер не может отправить сообщение попробуйте позже!");
                return;
            }
            if (datas.errorData) {
                alert("Мы не можем отправить сообщение! \n Проверьте введенные данные.");
                return;
            }
            alert('Ваше сообщение отправлено!');
            $('#mail-form').clearForm();
        }
    });

    $('.blog-links').find('img').hover(
        function(){ $(this).attr('src', '/images/' + $(this).attr('id') + '2.jpg'); },
        function(){ $(this).attr('src', '/images/' + $(this).attr('id') + '.jpg'); }
    );
});
