var Try={
    these:function(){
        var returnValue;
        for(var i=0;i<arguments.length;i++){
            var lambda=arguments[i];
            try{
                returnValue=lambda();
                break;
            }catch(e){}
        }
        return returnValue;
    }
}
var Ajax=Object.extend({},{
    AsyncPost:function(url,data,clientCallback){
        var xmlhttp=this.xmlhttp();
        if(xmlhttp){
            xmlhttp.open('POST',url,true);
            xmlhttp.setRequestHeader("Accept-charset","utf-8");                
            xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            
            xmlhttp.onreadystatechange=function(){
                if(xmlhttp.readyState==4) clientCallback(xmlhttp.responseText);
            }
            xmlhttp.send(data);
        }
    },
    SyncPost:function(url,data,clientCallback){
        var xmlhttp=this.xmlhttp();
        if(xmlhttp){
            xmlhttp.open('POST',url,false);
            xmlhttp.setRequestHeader("Accept-charset","utf-8");                
            xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            xmlhttp.send(data);
            if(clientCallback) clientCallback(xmlhttp.responseText);
        }        
    },
    doACall:function(url,clientCallback,errorHandle){
        var xmlhttp=this.xmlhttp();
        if(xmlhttp){
            xmlhttp.open('POST',url,true);
            xmlhttp.onreadystatechange=function(){
                if(xmlhttp.readyState==4) {
                    clientCallback(xmlhttp.responseText);
                }
            }
            xmlhttp.send(null);
        }
    },
    doCall:function(url,clientCallback){
        var xmlhttp=this.xmlhttp();
        if(xmlhttp){
            xmphttp.open('POST',url,false);
            xmlhttp.send(null);
            clientCallback(xmlhttp.responseText);
        }
    },
    xmlhttp:function(){
        return Try.these(
        function(){return new ActiveXObject('Msxml2.XMLHTTP')},
        function(){return new ActiveXObject('Microsoft.XMLHTTP')},
        function(){return new XMLHttpRequest()}
        ) || false
    }
}) 
    
