// Check account is OK before starting tests
//

function startTests(itemcode) {
  var cid = getCustomID();
  var txt = fetchURL("checkAccount.php?a="+cid);

  if (txt.substr(0,2) == "OK") {
	var bits = txt.split(" ");
	var bcredits = bits[1];
	var acredits = bits[2];
	var ccredits = bits[3];

	if (itemcode=="basic" && bcredits > 0) {
	  setCookie("mq_authcode", itemcode, 1000);
	  window.open("../tests/page0.html", "tests",
				  "toolbar=0, location=0, menubar=0, scrollbars=0, width=800, height=700, top=100, right=100");
	}
	else if (itemcode=="advanced" && acredits > 0) {
	  setCookie("mq_authcode", itemcode, 1000);
	  window.open("../tests/page0.html", "tests",
				  "toolbar=0, location=0, menubar=0, scrollbars=0, width=800, height=700, top=100, right=100");
	}
	else if (itemcode=="consultation" && ccredits > 0) {
	  setCookie("mq_authcode", itemcode, 1000);
	  window.open("../tests/page0.html", "tests",
				  "toolbar=0, location=0, menubar=0, scrollbars=0, width=800, height=700, top=100, right=100");
	}
	else {
	  alert("Your account does not have credit to run the "+itemcode+" WMQ Tester");
	}
  }
  else {
	alert(txt);
  }
}
