var req = null;

function getXMLHttpRequest() {
	var httpReq = null;
	if (window.XMLHttpRequest) {
		httpReq = new XMLHttpRequest();
	} else if (typeof ActiveXObject != "undefined") {
		httpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return httpReq;
}

function sendRequest(url, handler, param) {
	req = getXMLHttpRequest();
	if (req) {
		req.onreadystatechange = handler;
		req.open("get", url + "?value=" + param, true);
		req.send(null);
	}
}

function checkCode(poststr) {
   sendRequest('http://www.petersteffan.de/wp-content/themes/zigzag3/access.php', accessValidation, poststr);
}

function get(obj) {
   var poststr = encodeURI( document.getElementById("TextAccessCode").value );
   sendRequest('http://www.petersteffan.de/wp-content/themes/zigzag3/access.php', accessValidation, poststr);
}

function accessValidation() {
	if (req.readyState == 4) {

		var str = req.responseText;
		var accessId = document.createElement("INPUT");
   	accessId.type = "hidden";
  	accessId.value = str;
  	accessId.name = "accessId";
  	accessId.id = "id";
  	var helper1 = document.getElementById("hiddenAccessId");
    helper1.appendChild(accessId);
  	var help2 = document.getElementById("hiddenAccessId").submit();
		//location.href=str;
	}
}

function entsub(myform) {
   if (window.event && window.event.keyCode == 13)
      myform.submit();
   else
    return true;
}

function printPage() {
   if (window.print) {
     jetztdrucken = confirm('Seite drucken ?');
     if (jetztdrucken) window.print();
   }
}

