var RHandle;
function loadRequest() {
var result;
if(window.ActiveXObject) {
try {
result = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(Error) {
try {
result = new ActiveXObject('MSXML2.XMLHTTP');
}
catch(Error) {
alert('Unknown IE-Version - unable to use AJAX');
}
}
}
else if(window.XMLHttpRequest) result = new XMLHttpRequest();
else alert('Unknown Browser - unable to use AJAX');
return result;
}
function httpQuery(httpObject,httpURL,httpMethod,responseFunction) {
if(responseFunction.indexOf('(') < 1) responseFunction+='(';
httpObject.open(httpMethod, httpURL,true);
httpObject.onreadystatechange = function() {
if(httpObject.readyState == 4) eval(responseFunction+'httpObject.responseText);');
};
httpObject.send(null);
}
function writeIt(str,toFile) {
httpQuery(RHandle,'writeit.php?file='+toFile+'&write='+str,'get','writeError');
}
function writeError(error) {
if(error) alert('Error while writing file!');
}
function readIt(fromFile,toId) {
httpQuery(RHandle,fromFile,'get','innerId(\''+toId+'\',');
}
function innerId(toId,str) {
document.getElementById(toId).innerHTML = str;
}
window.onload = function() {
RHandle = loadRequest();
};