  function addBankRows(tbody, items)
  {
      if (items == null) return;
      for (var i = 0; i < items.length; ++i)
      {
          var item = items[i];
          var row = tbody.appendChild(document.createElement("TR"));
          var cell = row.appendChild(document.createElement("TD"));
          cell.className = "t_label";
          cell.colSpan = 3;
          cell.innerHTML = item.label;
          var cell = row.appendChild(document.createElement("TD"));
          cell.className = "t_inp";
          var input = cell.appendChild(document.createElement("INPUT"));
          if (item.length != null) input.maxLength = item.length;
          item.name = item.target;
      }
  }

  function changeCountry(elem)
  {
	var countryID = elem.value;

	sendAjaxRequest({
	    url: "userStepTwoAndAHalf",
	    postdata: { countryID: countryID },
	    async: true,
	    func: changeCountryAfterAjax,
	    errFunc: changeCountryAfterAjax
	});
  }
  
  function changeCountryAfterAjax(xmlHttp)
  {
      var map = parseAjaxResponse(xmlHttp);
      if (map == null) return;
      var tbody = document.getElementById("countryBankTbody");
      var child;
      while ((child = tbody.lastChild) != null) tbody.removeChild(child);
      addBankRows(tbody, map.bankidentity);
      addBankRows(tbody, map.accountnumber);
      addBankRows(tbody, map.city);
  }

  function checkSecurePin() {
      var securePin = document.getElementById("securepinInput").value;
      var transactionID = document.getElementById("transactionIDInput").value;
      if(securePin != "" && transactionID != "") {
         sendAjaxRequest({
            "url":          "securepin",
            "postdata":     { "securepin": securePin, "transactionID":transactionID, "lgid":"en" },
            "async":        false,
            "func":         printSecurePinResult,
            "errFunc":      printSecurePinResult
		 });
      }
  }

  function printSecurePinResult(xmlHttp) {
      var securePinDiv = document.getElementById("securepinDiv");
      securePinDiv.innerHTML = xmlHttp.responseText;
  }
