function ajax()
{
   //---------------------
   // Private Declarations
   //---------------------
   var _request = null;
   var _this = null;
        
   //--------------------
   // Public Declarations
   //--------------------
   this.GetResponseXML = function()
   {
      return (_request) ? _request.responseXML : null;
   }
        
   this.GetResponseText = function()
   {
      return (_request) ? _request.responseText : null;
   }
        
   this.GetRequestObject = function()
   {
      return _request;
   }
        
   this.InitializeRequest = function(Method, Uri)
   {
      _InitializeRequest();
      _this = this;
                
      switch (arguments.length)
      {
         case 2:
            _request.open(Method, Uri);
            break;
                                
         case 3:
            _request.open(Method, Uri, arguments[2]);
            break;
      }
                
      if (arguments.length >= 4) _request.open(Method, Uri, arguments[2], arguments[3]);
      this.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   }
        
   this.SetRequestHeader = function(Field, Value)
   {
      if (_request) _request.setRequestHeader(Field, Value);
   }
        
   this.Commit = function(Data)
   {
      if (_request) _request.send(Data);
   }
        
   this.Close = function()
   {
      if (_request) _request.abort();
   }
        
   //---------------------------
   // Public Event Declarations.
   //---------------------------
   this.OnUninitialize = function() { };
   this.OnLoading = function() { };
   this.OnLoaded = function() { };
   this.OnInteractive = function() { };
   this.OnSuccess = function() { };
   this.OnFailure = function() { };
        
   //---------------------------
   // Private Event Declarations
   //---------------------------
   function _OnUninitialize() { _this.OnUninitialize(); };
   function _OnLoading() { _this.OnLoading(); };
   function _OnLoaded() { _this.OnLoaded(); };
   function _OnInteractive() { _this.OnInteractive(); };
   function _OnSuccess() { _this.OnSuccess(); };
   function _OnFailure() { _this.OnFailure(); };

   //------------------
   // Private Functions
   //------------------
   function _InitializeRequest()
   {
      _request = _GetRequest();
      _request.onreadystatechange = _StateHandler;
   }
        
   function _StateHandler()
   {
      switch (_request.readyState)
      {
         case 0:
            window.setTimeout("void(0)", 100);
            _OnUninitialize();
            break;
                                
         case 1:
            window.setTimeout("void(0)", 100);
            _OnLoading();
            break;
                                
         case 2:
            window.setTimeout("void(0)", 100);
            _OnLoaded();
            break;
                        
         case 3:
            window.setTimeout("void(0)", 100);
            _OnInteractive();
            break;
                                
         case 4:
            if (_request.status == 200)
               _OnSuccess();
            else
               _OnFailure();
                                        
            return;
            break;
      }
   }
        
   function _GetRequest()
   {
      var obj;
                
      try
      {
         obj = new XMLHttpRequest();
      }
      catch (error)
      {
         try
         {
            obj = new ActiveXObject("Microsoft.XMLHTTP");
         }
         catch (error)
         {
            return null;
         }
      }
                
      return obj;
   }
}

function create_request_string(theForm) 
{ 
var reqStr = ""; 

for(i=0; i < theForm.elements.length; i++) 
{ 
	var isFormObject = false; 
	
		switch (theForm.elements[i].tagName) 
		{ 
			case "INPUT": 
			
			switch (theForm.elements[i].type) 
			{ 
			case "text": 
			case "hidden": 
			reqStr += theForm.elements[i].name + "=" + encodeURIComponent(theForm.elements[i].value); 
			isFormObject = true; 
			break; 
			
			case "checkbox": 
			if (theForm.elements[i].checked) 
			{ 
			reqStr += theForm.elements[i].name + "=" + theForm.elements[i].value; 
			}else{ 
			reqStr += theForm.elements[i].name + "="; 
			} 
			isFormObject = true; 
			break; 
			
			case "radio": 
			if (theForm.elements[i].checked) 
			{ 
			reqStr += theForm.elements[i].name + "=" + theForm.elements[i].value; 
			isFormObject = true; 
			} 
			} 
			break; 
			
			case "TEXTAREA": 
			
			reqStr += theForm.elements[i].name + "=" + encodeURIComponent(theForm.elements[i].value); 
			isFormObject = true; 
			break; 
			
			case "SELECT": 
			var sel = theForm.elements[i]; 
			reqStr += sel.name + "=" + sel.options[sel.selectedIndex].value; 
			isFormObject = true; 
			break; 
		} 
	
		if ((isFormObject) && ((i+1)!= theForm.elements.length)) 
		{ 
		reqStr += "&"; 
		} 
	
	} 

return reqStr; 
} 
////////////////////////////////////////////////////////////////////////
// PROTOTYPES                                                         //
////////////////////////////////////////////////////////////////////////

   /*/////////////////////////////////////////////////////////////////////////////////////////////
   * AJAX image management objects
   *
   *
   *//////////////////////////////////////////////////////////////////////////////////////////////
   
   var current_output = null;
   
   ViewImageObj = function()
   {
	  var output = null; // used to designate where the result will be displayed
	  var page = null;
	  var page_count = null;
	  var timer = null;
	  	  
      this.OnSuccess = function()
      {
	//	 if(this.timer != null)window.clearTimeout(this.timer);
		 
		 var obj = document.getElementById(this.output);
	
         obj.innerHTML = this.GetResponseText();
		 
		 this.page = document.getElementById('page_count').value;
		 
		 current_output = this.output;
		 
		 this.timer = window.setTimeout("viewImage.GetData("+(this.page)+",'"+this.output+"')", 5000);
      }
	  this.OnFailure = function()
	  {
		 this.GetData(this.page, this.output);  
	  }
      this.GetData = function(data, recv, count)
      {
		if(count != null)this.page_count = count;
		
		var query = "page="+data
		var obj = document.getElementById(recv);
		
		this.page = data;
		
	//	try{
			obj.innerHTML = "";
	//	}catch(e){}
		
		this.output = recv;
		this.InitializeRequest('POST', 'view_image.php');
		this.Commit(query);
      }
   }
   ViewImageObj.prototype = new ajax();
   var viewImage = new ViewImageObj();