
function getXMLObject() {
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            http_request.overrideMimeType('text/xml');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      return http_request;
}

queue = new Array();
xmlHttp = getXMLObject();


function getRequestObj(){
  try{return new ActiveXObject("Msxml2.XMLHTTP");}catch(e){}
  try{return new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}
  try{return new XMLHttpRequest();}catch(e){}
  alert("XMLHttpRequest wird von Deinem Browser nicht unterstützt.");
  return false;
}

function makePOSTRequest(url,query){
  var request= getRequestObj();
  request.onreadystatechange=function(){alertContents(request)};
  request.open('POST',url,true);
  request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  request.send(query);
}


function getValue( name, xmlHttp ) {
  var responseElement = xmlHttp.responseXML.getElementsByTagName( 'response' )[0];
  var element = responseElement.getElementsByTagName( name )[0];

  if ( (element != undefined) && (element.childNodes[0] != undefined) ) {
    return element.childNodes[0].nodeValue;
  } else {
    return null;
  }
}

function alertContents(xmlHttp) {
  if(xmlHttp.readyState!=4) return;  
  var valid = getValue( 'valid', xmlHttp );
           var id = getValue( 'id', xmlHttp );
           var value = getValue( 'value', xmlHttp );
           var execute = getValue( 'execute', xmlHttp );
           var element = document.getElementById(id);
 
           if ( (id != null) && (value != null) ) {
             element.innerHTML = value;      
           } 
          
           if ( execute != null ) {
             eval( execute );
           }
            
}
   
function handle_update(handler, id, params) {
     el = document.getElementById(id + '_input');
     if (el != null ) {
       value = el.value;
     } else {
       value = '';
     }
      
      
      var poststr = "value=" + encodeURI( value ) +
                    "&id=" + encodeURI( id ) +
                    "&ajax=true" +
                    "&" + params;
      
      makePOSTRequest(handler, poststr);
}