f_m = { 'w': 'Подождите…', 'ic': 'В корзине', 'b': 'Купить', 'r': 'Оставить отзыв', 's': 'Сохранить данные', 'iwl': 'Добавлен в список желаний' } function catalogueFilters(ch_c) { if (ch_c === undefined) ch_c = false; document.location.href = $('#current_url').val() + '?page=' + ((ch_c) ? 1 : $('#current_page').val()) + '&by=' + $('#sortby').val() + '&ord=' + $('#ord').val() + '&onpage=' + $('#onpage').val(); } function addToCart(id) { $('#to_cart_'+id).html(f_m['w']); JsHttpRequest.query( "/backend.php", { "go": "add_to_cart", "id": id }, function(result) { if (document.getElementById('to_cart_'+id)) { $('#to_cart_'+id).html(f_m['ic']); } $('#to_cart_container_'+id).attr('class', $('#to_cart_container_'+id).attr('class') + ' incart'); document.getElementById('to_cart_link_'+id).setAttribute('onclick', "$('#l_cart_open').click(); return false;"); $('#cart_popup').css('display', 'block'); $('#cart_price').html(result['fprice']); $('#cart_count').html(result['fcount']); $('#cart_table').html($('#cart_table').html()+result['html']); }, true ); return false; } function updateCart() { var it = new Array; for (var i = 0; i < items.length; i++) { it[items[i]] = $('#count_'+items[i]).val(); } JsHttpRequest.query( "/backend.php", { "go": "update_cart", "items": it }, function(result) { $('#cart_submit').html(f_m['op']); $('#cart_block').html(result['html']); if (parseInt(result['count']) <= 0) { $('#cart_part').remove(); $('#order_div').html('

Ваш заказ пуст.

'); } else { $('#sum_price').html(result['sum']); $('#total_summ').html(result['sum']); for (var i = 0; i < items.length; i++) { $('#sum_item_price_'+items[i]).html(result['prices'][items[i]]); } } if ($('#order_delivering').val() == courier_delivering) { $('#delivery_price_div').css('display', 'block'); $('#delivery_price').css('font-size', '27px'); $('#delivery_price_div .currency').html(currency); $('#delivery_price').html(delivery_price); $('#total_summ').html(parseFloat(result['sum']) + parseFloat(delivery_price)); } else if ($('#order_delivering').val() != 'Самовывоз из офиса в Киеве') { $('#delivery_price').css('font-size', '17px'); $('#delivery_price_div').css('display', 'block'); $('#delivery_price').html('по тарифам перевозчика'); $('#delivery_price_div .currency').html(''); } else { $('#delivery_price_div').css('display', 'none'); } }, false ); } function cartCount(t, id, mc) { /*JsHttpRequest.query( "/backend.php", { "go": "cart_count", "t": t, "id": id, "mc": mc }, function(result) { $('#cart_price_'+id).html(result['price']); $('#cart_price').html(result['fprice']); $('#cart_count_input_div_'+id).html(''); }, true ); return false;*/ JsHttpRequest.query( "/backend.php", { "go": "cart_count", "t": t, "id": id, "mc": mc }, function(result) { $('#cart_price_'+id).html(result['price']); $('#cart_price').html(result['fprice']); $('#cart_count_input_div_'+id).html(''); }, true ); return false; } function deleteFromCart(id) { JsHttpRequest.query( "/backend.php", { "go": "delete_from_cart", "id": id }, function(result) { $('#cart_price').html(result['fprice']); $('#cart_count').html(result['fcount']); if (result['empty']) { $('#cart_popup').css('display', 'none'); } if (document.getElementById('to_cart_link_'+id)) { $('#to_cart_container_'+id).attr('class', $('#to_cart_container_'+id).attr('class').replace(' incart', '')); $('#to_cart_'+id).html(f_m['b']); document.getElementById('to_cart_link_'+id).setAttribute('onclick', "return addToCart("+id+");"); } }, true ); } function addProduct(id) { $('#count_' + id).val(parseInt($('#count_' + id).val()) + 1); } function removeProduct(id) { var count = parseInt($('#count_' + id).val()); if (count <= 1) { $('#count_' + id).val(1); } else { $('#count_' + id).val(--count); } } function deleteFromCartOrder(id) { JsHttpRequest.query( "/backend.php", { "go": "delete_from_cart", "id": id }, function(result) { if (result['fcount'] <= 0) { $('#cart_part').remove(); $('#order_div').html('

Ваш заказ пуст.

'); } else { $('#cart_tr_' + id).remove(); $('#sum_price').html(result['fprice']); } }, false ); return false; } function order() { var err = false; $('#email_error').css('display', 'none'); $('#email_error_2').css('display', 'none'); $('#name_error').css('display', 'none'); $('#phone_error').css('display', 'none'); $('#company_error').css('display', 'none'); $('#phone_error_2').css('display', 'none'); $('#name_div').attr('class', 'InputDiv'); $('#phone_div').attr('class', 'InputDiv'); $('#company_div').attr('class', 'InputDiv'); $('#email_div').attr('class', 'InputDiv'); if (!$('#order_name').val()) { $('#name_error').css('display', 'block'); $('#name_div').attr('class', 'InputDiv Error'); err = true; } var ereg = /^(\S+)@([a-z0-9-]+)(\.)([a-z]{2,4})(\.?)([a-z]*)+$/i; if (!$('#order_email').val()) { err = true; $('#email_error').css('display', 'block'); $('#email_div').attr('class', 'InputDiv Error'); } else if (!ereg.test($('#order_email').val())) { err = true; $('#email_error_2').css('display', 'block'); $('#email_div').attr('class', 'InputDiv Error'); } var preg = /^([0-9()+ ,-])+$/i; if (!$('#order_phone').val()) { $('#phone_error').css('display', 'block'); $('#phone_div').attr('class', 'InputDiv Error'); err = true; } else if (!preg.test($('#order_phone').val())) { $('#phone_error_2').css('display', 'block'); $('#phone_div').attr('class', 'InputDiv Error'); err = true; } if ($('#need_inv').is(':checked') && !$('#order_company').val()) { $('#company_error').css('display', 'block'); $('#company_div').attr('class', 'InputDiv Error'); err = true; } if (err) { return false; } $('#order_submit').val(f_m['w']); JsHttpRequest.query( "/backend.php", { "go": "order", "email": $('#order_email').val(), "name": $('#order_name').val(), "company": $('#order_company').val(), "phone": $('#order_phone').val(), "info": $('#order_info').val(), "city": $('#order_city').val(), "address": $('#order_address').val(), "need_inv": $('#need_inv').is(':checked'), "delivering": $('#order_delivering').val(), "payment": $('#order_payment').val() }, function(result) { $('#order_h1').html(result['h1']); $('#order_div').html(result['html']); $('#cart_part').html(''); $('#cart_popup').css('display', 'none'); }, false ); return false; } function login() { $('#u_error_e').css('display', 'none'); $('#u_error').css('display', 'none'); if (!$('#u_login').val() || !$('#u_password').val()) { $('#u_error_e').css('display', 'block'); return false; } $('#u_submit').val(f_m['w']); JsHttpRequest.query( "/backend.php", { "go": "login", "login": $('#u_login').val(), "password": $('#u_password').val() }, function(result) { if (result['ok']) { document.location.href = document.location.href; } else { $('#u_error').css('display', 'block'); } }, false ); return false; } function logout() { JsHttpRequest.query( "/backend.php", { "go": "logout" }, function(result) { document.location.href = document.location.href; }, false ); return false; } function response() { $('#response_error').css('display', 'none'); if (!$('#response_text').val()) { $('#response_error').css('display', 'block'); return false; } $('#response_submit').val(f_m['w']); JsHttpRequest.query( "/backend.php", { "go": "response", "text": $('#response_text').val(), 'item': $('#response_item').val() }, function(result) { $('#response_ok').css('display', 'block'); $('#response_text').val(''); $('#response_submit').val(f_m['r']); }, false ); return false; } function loadSupportDataByCat(cat) { $('#item_support').html(''); $('#item').html(''); if (!cat) { $('#cat_support').html(''); return false; } JsHttpRequest.query( "/backend.php", { "go": "load_support_data_by_cat", "cat": cat }, function(result) { $('#cat_support').html(result['html']); $('#item').html(result['select']); }, false ); } function loadSupportDataByItem(item) { if (!item) { $('#item_support').html(''); return false; } JsHttpRequest.query( "/backend.php", { "go": "load_support_data_by_item", "item": item }, function(result) { $('#item_support').html(result['html']); }, false ); } function account() { var err = false; $('#name_error').css('display', 'none'); $('#phone_error').css('display', 'none'); $('#company_error').css('display', 'none'); $('#phone_error_2').css('display', 'none'); $('#name_div').attr('class', 'InputDiv'); $('#phone_div').attr('class', 'InputDiv'); $('#company_div').attr('class', 'InputDiv'); $('#data_saved').css('display', 'none'); if (!$('#order_name').val()) { $('#name_error').css('display', 'block'); $('#name_div').attr('class', 'InputDiv Error'); err = true; } var preg = /^([0-9()+ ,-])+$/i; if (!$('#order_phone').val()) { $('#phone_error').css('display', 'block'); $('#phone_div').attr('class', 'InputDiv Error'); err = true; } else if (!preg.test($('#order_phone').val())) { $('#phone_error_2').css('display', 'block'); $('#phone_div').attr('class', 'InputDiv Error'); err = true; } if (err) { return false; } $('#order_submit').val(f_m['w']); JsHttpRequest.query( "/backend.php", { "go": "account", "name": $('#order_name').val(), "company": $('#order_company').val(), "phone": $('#order_phone').val(), "city": $('#order_city').val(), "address": $('#order_address').val() }, function(result) { if (result['nl']) { document.location.href = '/'; } else { $('#order_submit').val(f_m['s']); $('#data_saved').css('display', 'block'); } }, false ); return false; }; function addToFavorites(id, t) { t.innerHTML = f_m['w']; JsHttpRequest.query( "/backend.php", { "go": "add_to_favorites", "id": id }, function(result) { t.innerHTML = f_m['iwl']; t.href = '/account/favorites/'; t.removeAttribute('onclick'); }, true ); return false; } function deleteFromFavorites(id) { document.getElementById('ftbody').removeChild(document.getElementById('fav_'+id)); JsHttpRequest.query( "/backend.php", { "go": "delete_from_favorites", "id": id }, function(result) {}, true ); return false; } function toggleOrder(idnum) { var hrefName = "#show_details"+idnum; var hrefName2 = "#hide_details"+idnum; var toggleLink = function() { if ($(hrefName).hasClass("shown")) { $(hrefName).removeClass("shown").addClass("hidden"); $(hrefName2).removeClass("hidden").addClass("shown"); } else { $(hrefName).removeClass("hidden").addClass("shown"); $(hrefName2).removeClass("shown").addClass("hidden"); } }; $("#order_details"+idnum).slideToggle("normal"); toggleLink(this); return false; };