/// define the global yp namespace
          
ajax = function(){

  var ypsoc = null;
  this.wait = true;
  
  this.readyState = function(){
    if( ypsoc != null){
      return ypsoc.readyState;
    }
    return 0;
  }
  this.query = function(url,method,postdata,callback ){

    if(method == undefined){
      method = 'GET'; 
    }
    if(ypsoc && ypsoc.readyState!=0){
      ypsoc.abort()
    }  
    
    ypsoc = createsoc();

    if(ypsoc){
      if(this.wait){
        ypsoc.open(method,url,false);
      }else{
        ypsoc.open(method,url,true);
      }
      if(callback!= undefined){
        callback.caller = this;
        ypsoc.onreadystatechange = callback;
      }
      if(postdata == undefined){
        ypsoc.send(null);
      }else{
        ypsoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded' );
        ypsoc.send(postdata);
      }
      if(callback == undefined){
        return ypsoc.responseText;
      }
    }else{
      return null;
    }
  }

  this.responseText = function(){
    return ypsoc.responseText;  
  }
  
  
  function createsoc(){
    var C = null;
    try{
      C=new ActiveXObject("Msxml2.XMLHTTP")
    }catch(e){
      try{
        C=new ActiveXObject("Microsoft.XMLHTTP")
      }catch(sc){
        C=null
      }
    }
    if(!C&&typeof XMLHttpRequest!="undefined"){
      C=new XMLHttpRequest()
    }
    return C
  }
  
  function createDomParser(){
    if(document.all){
      ret =  new ActiveXObject('Microsoft.XMLDOM');
      ret.async = false;
    
    }else{
      ret = new DOMParser();
      
    }
    return ret;
    
  }

}


