// -------- cat popup -------- var cat_popup_this_id = {}; var cat_popup_time_show; var cat_popup_time_hide; function cat_popup_show(id) { if (!cat_popup_this_id[id]) cat_popup_this_id[id] = false; if (cat_popup_this_id[id] == true) { try { clearTimeout(cat_popup_time_hide); } catch (e) {} } else cat_popup_time_show = setTimeout(function(){ cat_popup_show_time(id); }, 300); } function cat_popup_show_time(id) { document.getElementById(id).style.display="block"; cat_popup_this_id[id] = true; } function cat_popup_hide(id) { if (cat_popup_this_id[id] == false) { try { clearTimeout(cat_popup_time_show); } catch (e) {} } else cat_popup_time_hide = setTimeout(function(){ cat_popup_hide_time(id); }, 300); } function cat_popup_hide_time(id) { document.getElementById(id).style.display="none"; cat_popup_this_id[id] = false; } function cat_popup_stop_hide(id) { try { clearTimeout(cat_popup_time_hide); } catch (e) {} } // -------- Add product in cart -------- function add_product(id_product) { var q = "-"; if (document.getElementById("prs_q_"+id_product)) q = document.getElementById("prs_q_"+id_product).value; document.getElementById("send_add_product_"+id_product).innerHTML = '
Подождите...
'; var request = false; var url = "https://parakord.com.ua/request.php?action=add_product&id_product="+id_product+"&q="+q; if (window.XMLHttpRequest) { // Mozilla, Safari,... request = new XMLHttpRequest(); if (request.overrideMimeType) request.overrideMimeType('text/html'); } else if (window.ActiveXObject) { // IE try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!request) { alert("Ваш браузер не поддерживает данную функцию!"); return false; } request.open("GET", url, true); request.onreadystatechange = function(){ add_product_answer(request, id_product); }; request.send(null); } function add_product_answer(request, id_product) { if (request.readyState == 4) { if (request.status == 200) { var text_array = request.responseText.split("[~~]"); document.getElementById("send_add_product_"+id_product).innerHTML = text_array[0]; document.getElementById("cart_content").innerHTML = text_array[1]; } } } // -------- Search -------- var search_str_input = ""; var search_wait_search_i = 0; var search_timeout; function input_focus(action) { if (action == true && document.getElementById("search").value == "Поиск") { document.getElementById("search").value = ""; document.getElementById("search").className = "search_input_focus"; } if (action == false && document.getElementById("search").value.length == 0) { document.getElementById("search").value = "Поиск"; document.getElementById("search").className = "search_input"; } if (action == false && document.getElementById("search_content").style.display == "block") { setTimeout(function(){document.getElementById('search_content').style.display="none";}, 200); } if (action == true && search_str_input != "") { setTimeout(function(){document.getElementById('search_content').style.display="block";}, 200); } } function search_request(cat) { try { clearTimeout(search_timeout); } catch (e) {} search_timeout = setTimeout(function(){ search_request_start(cat) }, 350); } function search_button() { if (document.getElementById("search").className == "search_input_focus") form_search.submit(); //else alert("Вы не ввели "); } function search_request_start(cat) { var request = false; var str = document.getElementById('search').value; //var cat = ""; //if (document.getElementById('cat')) cat = document.getElementById('cat').value; if (str.length < 4) { document.getElementById('search_content').style.display="none"; return false; } if (search_str_input != str) { search_str_input = str; var url = "https://parakord.com.ua/request.php?action=search&category="+cat+"&str="+encodeURIComponent(str); if (window.XMLHttpRequest) { // Mozilla, Safari,... request = new XMLHttpRequest(); if (request.overrideMimeType) { request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!request) { alert("Ваш браузер не поддерживает данную функцию!"); return false; } request.open("GET", url, true); request.onreadystatechange = function(){ search_answer(request); }; request.send(null); search_wait_search_i++; if (search_wait_search_i > 0) { document.getElementById('search_button').style.display="none"; document.getElementById('search_waiting').style.display="block"; } } } function search_answer(request) { if (request.readyState == 4) { if (request.status == 200) { if (request.responseText != "-") { document.getElementById("search_content").innerHTML = request.responseText; document.getElementById('search_content').style.display="block"; } else { document.getElementById('search_content').style.display="none"; } search_wait_search_i--; if (search_wait_search_i <= 0) { document.getElementById('search_button').style.display="block"; document.getElementById('search_waiting').style.display="none"; } } } } // -------- Compare products -------- function compare_product(id_product, category, action) { var request = false; var url = "https://parakord.com.ua/request.php?action=compare_"+action+"&id="+id_product+"&cat="+category; if (window.XMLHttpRequest) { // Mozilla, Safari,... request = new XMLHttpRequest(); if (request.overrideMimeType) { request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!request) { alert("Ваш браузер не поддерживает данную функцию!"); return false; } request.open("GET", url, true); request.onreadystatechange = function(){ compare_product_answer(request,id_product); }; request.send(null); } function compare_product_answer(request,id_product) { if (request.readyState == 4) { if (request.status == 200) { var text_array = request.responseText.split("[~~]"); document.getElementById("compare_"+id_product).innerHTML = text_array[0]; var rows = document.getElementsByTagName('span'); for (var i = 0; i < rows.length; i++) { if (rows[i] && rows[i].id == 'compare_link') rows[i].innerHTML = text_array[1]; } } } } // -------- Button up (page scroll) -------- function scroll_document() { var scrolled_y = window.pageYOffset || document.documentElement.scrollTop; var ob = document.getElementById("box_button_up").style; if (scrolled_y > 820) { if (ob.display == "none") { ob.display = "block"; animate_button_up(0); } } else if (ob.display == "block") ob.display = "none"; } function animate_button_up(opacity) { if (opacity == 0) opacity = 0; opacity += 10; if (opacity >= 100) opacity = 100; else button_up_timeout_id = setTimeout(function(){ animate_button_up(opacity); }, 10); var ob = document.getElementById("box_button_up").style; ob.opacity = opacity / 100; ob.filter = 'alpha(opacity='+ opacity +')'; } function animate_page_scroll(scroll_d, scroll) { if (scroll_d == 0) { scroll = window.pageYOffset || document.documentElement.scrollTop; scroll_d = scroll/10; } scroll -= scroll_d; if (scroll < 0) scroll = 0; else setTimeout(function(){ animate_page_scroll(scroll_d, scroll); }, 10); window.scrollTo(0,scroll); } window.onscroll = scroll_document; // -------- Show product box -------- function pr_box_d(id, act) { if (act == 'show') { $('.products_box_item_d').css({'display':'none'}); $('.products_box_item').css({'z-index':'1'}); document.getElementById('pr_box_d_'+id).style.display = "block"; document.getElementById('pr_box_s_'+id).style.zIndex = "2"; } if (act == 'hide') { document.getElementById('pr_box_d_'+id).style.display = "none"; document.getElementById('pr_box_s_'+id).style.zIndex = "1"; } } // -------- Input number -------- function input_number_control(input) { var i = document.getElementById(input); var n = i.value.replace(/[^0-9]/g, ''); n = parseInt(n) | 0; if (n < 1) n = 1; i.value = n; } function input_number_(c, input) { //input_number_control(input); var i = document.getElementById(input); if (c == 1) i.value = parseInt(i.value) + 1; if (c == -1 && parseInt(i.value) > 1) i.value = parseInt(i.value) - 1; }