function popupimg(tag, width, height, title) {
  win = window.open("", "_blank", "width=" + width + ",height=" + height);
  win.document.write("<html><head><title>" + title + "</title></head>" +
    "<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>" +
    "<table cellpadding='0' cellspacing='0' border='0'><tr><td>" +
    "<img src='" + tag.href + "' border='0'></tr></td></table></body></html>");
  win.document.close();
  return false;
}
function swap(id) {
  if (document.getElementById("navitem" + id).style.display == 'none') {
    document.getElementById("navitem" + id).style.display = ''
  }
  else {
    document.getElementById("navitem" + id).style.display = 'none'
  }
}
function topBarToped() {
  if (document.body.pageYOffset != null) {
    document.getElementById('topBar').style.top = pageYOffset + 0;
    document.getElementById('topBar').style.visibility = 'visible';
	}
	else {
    document.getElementById('topBar').style.top = document.body.scrollTop + 0;
    document.getElementById('topBar').style.visibility = 'visible';
	}
}
function show_quantity(id) {
  document.getElementById('quantity' + id).innerHTML =
    "<img src=\"/images/btn_full_basket.gif\" width=\"15\" height=\"15\" border=\"0\" alt=\"Количество товара в корзине\" align=\"absmiddle\">&nbsp;" +
    "<input id='value" + id + "' value='1' onkeyup='change_quantity(\"" + id + "\");'> шт " +
    "<span class=\"text\" onclick=\"hide_quantity('" + id + "');\">" +
    "<img src=\"/images/btn_del_basket.gif\" width=\"15\" height=\"15\" border=\"0\" alt=\"Удалить из корзины\" align=\"absmiddle\"></span>";
  document.getElementById('value' + id).focus();
  change_quantity(id);
}
function hide_quantity(id) {
  document.getElementById('value' + id).value = "0";
  change_quantity(id);
  document.getElementById('quantity' + id).innerHTML =
    "<span class=\"text\" onclick=\"show_quantity('" + id + "');\">" +
    "<img src=\"/images/btn_add_basket.gif\" width=\"15\" height=\"15\" border=\"0\" alt=\"Добавить в корзину\" align=\"absmiddle\"></span>";
}
function change_quantity(id) {
  document.getElementById('changeQuantityFrame').src = "/index.php?c=catalog&a=add_to_basket&b[" + id + "]=" + 
    document.getElementById('value' + id).value;
}
function show_basket_quantity(id) {
  document.getElementById('quantity' + id).innerHTML =
    "<img src=\"/images/btn_full_basket.gif\" width=\"15\" height=\"15\" border=\"0\" alt=\"Количество товара в корзине\" align=\"absmiddle\">&nbsp;" +
    "<input id='value" + id + "' value='1' onkeyup='change_basket_quantity(\"" + id + "\");'> " +
    "<span class=\"text\" onclick=\"hide_basket_quantity('" + id + "');\">" +
    "<img src=\"/images/btn_del_basket.gif\" width=\"15\" height=\"15\" border=\"0\" alt=\"Удалить из корзины\" align=\"absmiddle\"></span>";
  document.getElementById('value' + id).focus();
  change_basket_quantity(id);
}
function hide_basket_quantity(id) {
  document.getElementById('value' + id).value = "0";
  change_basket_quantity(id);
  document.getElementById('quantity' + id).innerHTML =
    "<span class=\"text\" onclick=\"show_basket_quantity('" + id + "');\">" +
    "<img src=\"/images/btn_add_basket.gif\" width=\"15\" height=\"15\" border=\"0\" alt=\"Добавить в корзину\" align=\"absmiddle\"></span>";
}
function change_basket_quantity(id) {
  document.getElementById('changeQuantityFrame').src = "/index.php?c=catalog&a=update_basket&b[" + id + "]=" + 
    document.getElementById('value' + id).value;
}

