function Ajax($url,$method,$testmode){this.xmlHttp=null;this.result=null;this.url=typeof($url)!='undefined'?'http://'+server+'/tasks/'+$url+'.task.php':'';this.method=typeof($method)!='undefined'?$method.toUpperCase():'GET';this.testmode=typeof($testmode)!='undefined'&&$testmode?true:false;try{this.xmlHttp=new XMLHttpRequest();}
catch($e){try{this.xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch($e){try{this.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
catch($e){alert('Der Browser unterstützt leider kein Ajax.');this.xmlHttp=false;}}}
this.set_url=function($url){this.url='http://'+server+'/tasks/'+$url+'.task.php';}
this.set_method=function($method){this.method=$method;}
this.query=function($params,$callback){var $class=this;$params=typeof($params)!='undefined'?$params:'';if($class.url){$class.xmlHttp.onreadystatechange=function(){if($class.xmlHttp.readyState==4){if($class.xmlHttp.responseText){$class.result=$class.xmlHttp.responseText;$callback();}}}
$post_params=null;if($params){if($class.method.toLowerCase()=='post'){$post_params=$params;}
else{$class.url+='?'+$params;}}
if(this.testmode){alert($class.url);}
$class.xmlHttp.open($class.method,$class.url,true);if($class.method.toLowerCase()=='post'){$class.xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");$class.xmlHttp.setRequestHeader("Content-length",$post_params.length);$class.xmlHttp.setRequestHeader("Connection","close");}
$class.xmlHttp.send($post_params);}}}
