function onClickHinted(e, className) {
  if (e.hinted != "") {
    e.hinted = "";
    e.value = "";
    e.className = className;
  }
}

function maybeClassName(id, name) {
  var e = document.getElementById(id);
  if (e) {
    e.className = name;
  }
}

function onClickPrice(price, credits, position, plan, showZong) {
  var positions = ["left", "mid", "midright", "right"];
  for (i = 0; i < positions.length; ++i) {
    maybeClassName('buys-vert-' + positions[i], 'basic');
    maybeClassName('cb_' + positions[i], 'checkbox');
  }

  document.getElementById('buys-vert-' + position).className = 'basic selected';
  document.getElementById('cb_' + position).className = 'checkbox selected';

  document.forms["buys-form"].elements["price"].value= "" + price;
  document.forms["buys-form"].elements["credit"].value= "" + credits;
  document.forms["buys-form"].elements["plan"].value= "" + plan;

    if (showZong) {
        $("#zong-wrapper").fadeIn();
    } else {
        $("#zong-wrapper").fadeOut();
    }
}

function checkTransaction(z, tx, dest) {
  var isDone = false;

  setInterval(function () {
      if (!isDone) {
        $.get("/api/v2/tx/ping",
              {"z": z, "tx" : tx},
              function(data) {
                if ("1" == data) {
                  isDone = true;
                  window.location.href = dest;
                }
              });
      }
  }, 8000);
}

