function MLM_Ajax()
{

     this.mlmAjax     = null;
     this.method      = "POST";        /* request method */
     this.response    = "";            /* response */  
     this.URL         = "";            /* requested URL */
     this.UrlParams   = new Array();   /* requested parametres */
     this.paramString = "";            /* comleted requested url */

     this.onLoad      = function(){};  /* called when readyState is 4 completed */
     this.loading     = function(){};  /* called when readyState is 1 loading */
     this.loaded      = function(){};  /* called when readyState is 2 loaded */     
     this.interactive = function(){};  /* called when readyState is 3 */
    
    try
    {
        this.mlmAjax = new XMLHttpRequest();
    } 
    catch( e )
    {
         try
	 {
	      this.mlmAjax = new ActiveXObject("Msxml2.XMLHTTP");
	 }
	 catch( e )
	 {
	      try
	      {
	           this.mlmAjax = new ActiveXObject("Microsoft.XMLHTTP")
	      }
	      catch( e )
	      {
	         alert("Your browser does not support AJAX!");
	         return false;
	      } 
	 }    
    }
    
   
    this.sendRequest = function( ReqeustedUrl )
    {
    
	    this.URL =  ReqeustedUrl;
	    this.prepareParams();
	    
	    if( this.method == "POST" )
	    { 
	       this.mlmAjax.open( this.method, this.URL , true);
	       
	       try
	       {
	           this.mlmAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
	       }
	       catch( e ){}
	       
	       
	       this.mlmAjax.send( this.paramString );  
	    }
	    else
	    {
	       this.mlmAjax.open( this.method, this.URL + this.paramString , true);
	       this.mlmAjax.send( false );  
	    }   
	        

	    
        var selfObj = this;
	    
	    this.mlmAjax.onreadystatechange = function()
        {                  

	        switch( selfObj.mlmAjax.readyState )  
	        {
           	    case 1:
	                selfObj.loading();
                break;
			    case 2: 
			          selfObj.loaded();
			       break;    	   
			    case 3:
			          selfObj.interactive();
			       break;   
                   	    case 4: 
                 	          
			       try
			       {
			         switch( selfObj.mlmAjax.status )
				     {
				        case 200:
							selfObj.response = selfObj.mlmAjax.responseText;          
					    break;
						case 404:
							selfObj.response = "Server not found. Try refresh !!!" ;          
					    break    
				     }				
				
				}   
				catch( e )
				{
				      selfObj.response = "Server not found. Try refresh !!!" ;          				     			  
				}
                   		   selfObj.onLoad();
                      	       break;
	              }
             }
     };
     
     
     this.AddParam  = function( ParamName, ParamValue )
     {
          this.UrlParams[ ParamName ] = ParamValue;
     };
     
     this.prepareParams = function()
     {         
         var firstDecimer = "";
	 
	 if( this.method == "GET")
	 {
	    firstDecimer = "?";
	 }
	 
         if( this.URL.indexOf("?") > -1 )
	 {
	     firstDecimer = "&";
	 }

    for( paramKey in this.UrlParams )
	{
	     if( this.paramString.length == 0 )
	     {
	        this.paramString = this.paramString + firstDecimer + paramKey + "=" + this.UrlParams[ paramKey ];
	     }
	     else
	     {
	        this.paramString = this.paramString + "&" + paramKey + "=" + this.UrlParams[ paramKey ];
	     }	
	}

    };
}

