function onCalcButtonClick()
{
  var clLeft = 0;
  var clTop = 0;
  if (document.documentElement && (document.documentElement.scrollTop))
  {
    clLeft = document.documentElement.scrollLeft;
    clTop = document.documentElement.scrollTop;
  } else {
    clLeft = document.body.scrollLeft;
    clTop = document.body.scrollTop;
  };
 
  document.getElementById("calc").style.top = clTop + 48 + "px";
  document.getElementById("calc").style.left = clLeft + 48 + "px";
//  document.getElementById("calc").style.top = clTop + 48;
//  document.getElementById("calc").style.left = clLeft + 48;
  toggleVisibility(document.getElementById("calc"));
};

function onCloseCalcButtonClick()
{
  toggleVisibility(document.getElementById("calc"));
};

function toggleVisibility(element)
{
  if (element.style.visibility == "visible") {element.style.visibility = "hidden";}
  else {element.style.visibility = "visible";}
  calcCost();
};

function calcCost()
{
  var type = document.getElementById("calc_type").value;
  var qnt = document.getElementById("calc_qnt").value;
  var len = document.getElementById("calc_len").value;
  var isTypeInt = /^\d+$/.test(type)
  var isQntInt = /^\d+$/.test(qnt)
  var isLenInt = /^\d+$/.test(len)
  if (isTypeInt && isQntInt && isLenInt) {document.getElementById("calc_cost").innerHTML = (type * qnt * len) + " ð.";}
  else {document.getElementById("calc_cost").innerHTML = "N/A";}
};