/**
 * mAJAX - Simple Mini-AJAX function
 *
 * by Super Gwapong Marion Louis Tinio
 *
 * Date Started: August 07, 2009
 *
 *
**/

var mAjax = function() {

  return {
  
    XMLHttpRequestHandler : function() {
  
      var http;
  
      if (window.XMLHttpRequest) { 
  
        http = new XMLHttpRequest();
  
        if (http.overrideMimeType) {
  
          http.overrideMimeType('text/html');
  
        }
  
      } else if (window.ActiveXObject) { 
  
        try {
  
          http = new ActiveXObject("Msxml2.XMLHTTP");
  
        } catch (e) {
  
          try {
  
            http = new ActiveXObject("Microsoft.XMLHTTP");
  
          }
  
            catch (e) {}
  
        }
  
      }
  
      if (!http) {
  
          alert('I\'m afraid your browser might have not support for AJAX. Maybe it\'s about time for you to upgrade your browser. T_T');
          return false;
  
      }
  
          return http;
  
    },

    ReadyStateHandler : function(http) {

      http.onreadystatechange = function() {

        switch(http.readyState) {
				
          case 0: 
            eval(http.rs_Unitiated); 
            break;

          case 1: 
            eval(http.rs_Loading); 
            break;

          case 2: 
            eval(http.rs_Loaded);
            break;

          case 3: 
            eval(http.rs_Interactive);
            break;

          case 4: 
            eval(http.rs_Complete);
            http.responseHandler(http);
            break;
        
        }
                
      }

      
    },

    Process : function(method, target_uri, getVars, postVal, returnReadyState) {

      var http = mAjax.XMLHttpRequestHandler();

      var method = method.toUpperCase();

      switch( method ) {

        case 'POST':
          //to follow, coz I'm lazy to do so
        break;
        
        case 'GET':
          target_uri += getVars;
        break;
        
        default:
          method = 'GET';
        break;

      }

      http.open(method, target_uri, true);
      http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
      http.setRequestHeader('Content-length', postVal.length);

      if( postVal ) {

        http.send(postVal);

      } else {

        http.send(null);

      }

      
      /*if( returnReadyState ) {

        return mAjax.ReadyStateHandler(http);

      } */
    
        return http;
    
    }
  
  };
  
}();


/**
 * End of Javascript File
 * Last Modified: August 08, 2009 
 **/ 
