/* * http://hankrum.info */ $(document).ready(function () { root = $('.root').attr('href'); setTimeout(function () { $.ajax({ type: 'POST', url: root + 'home/checkcookies', data: { check_cookies: 1 } }).done(function (data) { if (data == '1') { $('#biskvitki').remove(); } else { $('#biskvitki').show(); } }); }, 5000); ///Центриране на бутоните $('.ikoni').css({'margin-left': ($(window).width() - 700) / 2 + 'px'}); $(window).resize(function () { $('.ikoni').css({'margin-left': ($(window).width() - 700) / 2 + 'px'}); }); ///Анимация на бутоните $('.ikoni div').hover(function () { var $cl = $(this).attr('class'); $('.' + $cl).stop().animate({marginTop: '-5'}, 200); $('.ikoni').stop().animate({'height': '170px'}, 200); }, function () { var $cl = $(this).attr('class'); $('.' + $cl).stop().animate({marginTop: '-115px'}, 200); $('.ikoni').stop().animate({'height': '60px'}, 200); }); ///Първоначално валидиране на формата за контакт $('#form_table input,#form_table textarea').bind('keyup input change', function () { checkForm(); }); ///Събмитване на формата за контакт $('#form_table button').click(function () { $.ajax({ type: 'POST', url: root + 'home/mail', data: { sendmail: 1, name: $('#name input').val(), email: $('#email input').val(), site: $('#site input').val(), subject: $('#subject input').val(), message: $('#message textarea').val(), captcha: $('#captcha_ input').val() } }).done(function (data) { alert(data); window.location.href = window.location.href; }); }); }); function checkForm() { if ($('#name input').val().length > 2) { $('#name b').css({'color': 'green'}); } else { $('#name b').css({'color': 'red'}); } if (models('email').test($('#email input').val())) { $('#email b').css({'color': 'green'}); } else { $('#email b').css({'color': 'red'}); } if (models('url').test($('#site input').val())) { $('#site b').css({'color': 'green'}); } else { $('#site b').css({'color': 'red'}); } if ($('#subject input').val().length > 4) { $('#subject b').css({'color': 'green'}); } else { $('#subject b').css({'color': 'red'}); } if ($('#message textarea').val().length > 8) { $('#message b').css({'color': 'green'}); } else { $('#message b').css({'color': 'red'}); } if ($('#captcha_ input').val().length > 0) { $('#captcha_ b').css({'color': 'green'}); } else { $('#captcha_ b').css({'color': 'red'}); } if ($('#name input').val().length > 2 && models('email').test($('#email input').val()) && $('#subject input').val().length > 4 && $('#message textarea').val().length > 8 && $('#captcha_ input').val().length > 0) { $('#form_table button').css({ 'color': 'green', 'cursor': 'pointer' }).attr('disabled', false); } else { $('#form_table button').css({ 'color': 'red', 'cursor': 'not-allowed' }).attr('disabled', true); } }