window.onload = function () { root = $('#root').attr('href'); if ($('.text_shema').html() == '') { $('.text_shema').remove(); } $(document).on('click', '.zab_parola', function () { close_djam(); open_wait() var email = prompt($(this).data('email')); $.ajax({ type: 'POST', url: root + 'ajax/zab_parola', data: { zab_parola: 1, email: email } }).done(function (data) { alert(data); refresh(); }).fail(function () { alert('Server eroor!!!'); }); }); $('.true_srch').keyup(function (key) { if (key.keyCode === 13) { true_srch(); } }); $('.true_lupa').click(function () { true_srch(); }); $('.help_text').hover(function () { $('body').append('' + $(this).data('title') + ''); }, function () { $('.help').remove(); }).bind('mousemove mouseenter', function (e) { $('.help').css({ left: e.pageX + 13, top: e.pageY + 13 }); }); $('#lang_bar img').click(function () { var val = $(this).data('lang'), url = window.location.href; $.ajax({ type: 'POST', url: root + 'ajax/lang', data: { lang: 1, val: val, url: url } }).done(function (data) { if (data == '0') { refresh(); } else { refresh(data); } }).fail(function () { alert('Server eroor!!!'); }); }); $('button.vhod').click(function () { $.ajax({ type: 'POST', url: root + 'ajax/login_form', data: { login_form: 1 } }).done(function (data) { djam(data); refresh_kap4a(); }).fail(function () { alert('Server eroor!!!'); }); }); $(document).on('click', '.refresh', function () { refresh_kap4a(); }); $(document).on('click', 'button.send_log', function () { var e = $('.e').val(), p = $('.p').val(), c = $('.c').val(); if (e.length > 4 && p.length > 5 && c.length > 1) { $.ajax({ type: 'POST', url: root + 'ajax/login', data: { lo: 1, e: e, p: p, c: c } }).done(function (data) { if (data != '0') { alert(data); } refresh(root); }).fail(function () { alert('Server eroor!!!'); }); } }); $('button.izhod').click(function () { var url = root + 'ajax/izhod'; $.ajax({ type: 'POST', url: url, data: { iz: 1 } }).done(function (data) { if (confirm(data)) { $.ajax({ type: 'POST', url: url, data: { iz: 2 } }).done(function () { refresh(root); }).fail(function () { alert('Server error!'); }); } }).fail(function () { alert('Server eroor!!!'); }); }); $('.main_lupa').click(function () { var tip = $('.main_tip').val(), mar = $('.main_marka').val(), mod = $('.main_model').val() if (tip > 0) { $.ajax({ type: 'POST', url: root + 'ajax/main_srch', data: { main_srch: 1, tip: tip, mar: mar, mod: mod } }).done(function (data) { if (data != '') { refresh(data); } }).fail(function () { alert('Server eroor!!!'); }); } }); $('select.main_marka').change(function () { open_wait(); $.ajax({ type: 'POST', url: root + 'ajax/main_marka', data: { main_marka: 1, id: $(this).val(), id_tip: $(this).find('option:last-child').data('tip') } }).done(function (data) { $('select.main_model').html(data); close_wait(); }).fail(function () { alert('Server eroor!!!'); close_wait(); }); }); $('select.main_tip').change(function () { open_wait(); $.ajax({ type: 'POST', url: root + 'ajax/main_tip', data: { main_tip: 1, id: $(this).val() } }).done(function (data) { var js = JSON.parse(data); $('select.main_marka').html(js[0]); $('select.main_model').html(js[1]); close_wait(); }).fail(function () { alert('Server eroor!!!'); close_wait(); }); }); $('.img_model').click(function () { djam1('Close

'); }); $('.text_shema').click(function () { openWin($('.shema_jpg').parent('a').attr('href')); }); $('input.tyrsene_model').bind('change, paste, click, keyup', function () { tyrsene_model(); }); $('img._lupa_').click(function () { tyrsene_model(); }); $('input.tyrsene_marki').bind('change, paste, click, keyup', function () { tyrsene_marki(); }); $('img.lupa_').click(function () { tyrsene_marki(); }); $('input.tyrsene_4asti').bind('change, paste, click, keyup', function () { tyrsene_4asti(); }); $('img.lupa').click(function () { tyrsene_4asti(); }); $(document).on('click', '.item_pic_click', function () { openWinMini({ url: $(this).attr('src'), width: 800, height: 500 }); }); $(document).on('click', '.down', function () { var height = parseInt($('.get_height').height()), position = parseInt($('.get_height').css('marginTop')); if ((height + position) > 200) { $('.get_height').stop().animate({ marginTop: "-=200" }, 100); } }); $(document).on('click', '.up', function () { var position = parseInt($('.get_height').css('marginTop')); if (position <= -200) { $('.get_height').stop().animate({ marginTop: "+=200" }, 100); } }); ////////////////////////////// $('#reg_forma button').click(function () { open_wait(); if (validate_email($('.email').val())) { $('.email').css('background-color', '#fff'); } else { $('.email').css('background-color', 'pink'); close_wait(); return false } if ($('.pass').val() == $('.pass1').val() && $('.pass1').val().length >= 7) { $('.pass').css('background-color', '#fff'); $('.pass1').css('background-color', '#fff'); } else { $('.pass').css('background-color', 'pink'); $('.pass1').css('background-color', 'pink'); close_wait(); return false; } if ($('input.captcha').val().length < 2) { $('input.captcha').css('background-color', 'pink'); close_wait($('input.captcha').val()); return false; } else { $('input.captcha').css('background-color', '#fff'); } $.ajax({ type: 'POST', url: root + 'registraciq/reg', data: { reg: 1, email: $('.email').val(), captcha: $('input.captcha').val(), pass: $('.pass1').val() } }).done(function (data) { alert(data); refresh(); }); }); $('.pass,.pass1').keyup(function () { var pass = $('.pass').val(), pass1 = $('.pass1').val(); if (pass != pass1 || pass.length < 7 && pass.length != 0) { $('.pass').css('background-color', 'pink'); $('.pass1').css('background-color', 'pink'); } else { $('.pass').css('background-color', '#fff'); $('.pass1').css('background-color', '#fff'); } }); $('.name,.subject,.msg,.captcha').keyup(function () { var len = get_lenght($(this)); if ($(this).val().length < len && $(this).val().length > 0) { $(this).css('background-color', 'pink'); } else { $(this).css('background-color', '#fff'); } }); $('.email').keyup(function () { if (validate_email($(this).val()) || $(this).val().length == 0) { $(this).css('background-color', '#fff'); } else { $(this).css('background-color', 'pink'); } }); $('table.kontakt_forma button').click(function () { open_wait(); var ime = $('.name'), imeil = $('.email'), tema = $('.subject'), msg = $('.msg'), kap = $('input.captcha'); if (ime.val().length < get_lenght(ime)) { ime.css('background-color', 'pink'); close_wait(); return false; } else { ime.css('background-color', '#fff'); } if (validate_email(imeil.val())) { imeil.css('background-color', '#fff'); } else { imeil.css('background-color', 'pink'); close_wait(); return false } if (tema.val().length < get_lenght(tema)) { tema.css('background-color', 'pink'); close_wait(); return false; } else { tema.css('background-color', '#fff'); } if (msg.val().length < get_lenght(msg)) { msg.css('background-color', 'pink'); close_wait(); return false; } else { msg.css('background-color', '#fff'); } if (kap.val().length < get_lenght(kap)) { kap.css('background-color', 'pink'); close_wait(); return false; } else { kap.css('background-color', '#fff'); } $.ajax({ type: 'POST', url: root + 'ajax/send_mail', data: { send_email: 1, name: ime.val(), email: imeil.val(), subject: tema.val(), text: msg.val(), captcha: kap.val() } }).done(function (data) { alert(data); refresh(); }).fail(function () { alert('Server eroor!!!'); close_wait(); }); }); }; function get_lenght(selektor) { var klas = selektor.attr('class'), len = 0; switch (klas) { case 'name': len = 3; break; case 'subject': len = 5; break; case 'msg': len = 10; break; default: len = 2; break; } return len; } function getNov(id) { $.ajax({ type: 'POST', url: root + 'ajax/getNov', data: { get_nov: 1, id: id } }).done(function (data) { djam1('Close
' + data); }).fail(function () { alert('Server eroor!!!'); }); } function getItem(id) { $.ajax({ type: 'POST', url: root + 'ajax/getItem', data: { get_item: 1, id: id } }).done(function (data) { djam1('Close
' + data); }).fail(function () { alert('Server eroor!!!'); }); } function tyrsene_4asti() { var srch = $('input.tyrsene_4asti').val().toLowerCase(), br = $('#item_content a').length; for (var a = 0; a < br; a++) { var str1 = $('#item_content a').eq(a).find('b').html().toLowerCase(), str2 = $('#item_content a').eq(a).find('span').html().toLowerCase(); if (str1.search(srch) >= 0 || str2.search(srch) >= 0) { $('#item_content a').eq(a).css('display', 'block'); } else { $('#item_content a').eq(a).css('display', 'none'); } } } function tyrsene_marki() { var srch = $('input.tyrsene_marki').val().toLowerCase(), br = $('#tip a.marka').length; for (var a = 0; a < br; a++) { var str1 = $('#tip a.marka').eq(a).data('title').toLowerCase(); if (str1.search(srch) >= 0) { $('#tip a.marka').eq(a).css('display', 'inline-block'); } else { $('#tip a.marka').eq(a).css('display', 'none'); } } } function tyrsene_model() { var srch = $('input.tyrsene_model').val().toLowerCase(), br = $('#tip a.model').length; for (var a = 0; a < br; a++) { var str1 = $('#tip a.model').eq(a).html().toLowerCase(); if (str1.search(srch) >= 0) { $('#tip a.model').eq(a).css('display', 'inline-block'); } else { $('#tip a.model').eq(a).css('display', 'none'); } } } function true_srch() { var val = $('.true_srch').val(); if (val.length > 1) { open_wait(); $.ajax({ type: 'POST', url: root + 'ajax/true_srch', data: { true_srch: 1, val: val } }).done(function (data) { refresh(root + data); }).fail(function () { alert('Server eroor!!!'); close_wait(); }); } } function refresh_kap4a() { var d = new Date(); $('.captcha').attr('src', root + 'ajax/captchaimage/' + '?' + d.getTime()); }