/**
 * Basic SOAP call in Javascript for test purposes
 */

/*
 * rootEmail = the "final destination" email address
 * pinType = 1 for sender known, 2 for unknown sender (this must expire)
 * expireTime = number of hours in which to expire
 * fromMail = sender address if known
 * authKey = authorisation key, fake sent in this test environment
 * elementName = the div id in which to show the PIN email
 */

function GetPIN(rootEmail,pinType,expireTime,fromMail,authKey,lockTime,elementName){ 
  var http = false;
  if(navigator.appName == "Microsoft Internet Explorer") {
	  http = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
	  http = new XMLHttpRequest();
  }	
  var docElement;
  docElement = document.getElementById(elementName);  
  http.abort();
  http.open("GET", "soap_call.php?r=" + rootEmail + "&pt=" + pinType + "&et=" + expireTime + "&f=" + fromMail + "&ak=" + authKey + "&l=" + lockTime, true);
  http.onreadystatechange=function() {
	  if(http.readyState == 4) {  
		  docElement.innerHTML = "<a href='mailto: " + http.responseText + "'>" + http.responseText + "</a>";  
	  }
  }
  http.send(null);
  
}

