// JavaScript Document
var xmlHttp;
function createXMLHttpRequest(){
	try {
    xmlHttp = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        xmlHttp = false;
      }
    }
  }
  if (!xmlHttp)
    alert("Error initializing XMLHttpRequest!");
}

function startRequest() {
	var domain = document.getElementById('domain').value;
	var url = "gainDomain.php?domain="+escape(domain);
	createXMLHttpRequest();
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange = handleStateChange;
	xmlHttp.send(null);
}

function handleStateChange() {
	if(xmlHttp.readyState == 1) {
		document.getElementById('result').innerHTML = "Loading...";
	}
	if(xmlHttp.readyState == 4) {
		if(xmlHttp.status == 200) {
			var newP = document.getElementById("result");
			/*if (!newP) {
				var Parent = document.getElementById("in");
				var newP = document.createElement("p");
				newP.setAttribute("id","result");
				Parent.appendChild(newP);
			}*/
			newP.innerHTML = xmlHttp.responseText;
			//alert(newP.innerHTML);
		}
	}
}

function onSubmit() {     
var buttons=document.getElementById("callForm").elements["button1"]; 
buttons.click();
}
