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;
   }
}


////////////////////////////////////////////////////////////////////////
// PROTOTYPES                                                         //
////////////////////////////////////////////////////////////////////////
   ContentObj = function()
   {
	  var cMain = null
	  var cCat = null;
	  
      this.OnSuccess = function()
      {
        document.getElementById('content').innerHTML = this.GetResponseText();
		try{
		document.getElementById('arrow'+this.cCat).innerHTML = '<img  src="assets/images/arrow.gif"  width="4" height="8"  />';
		document.getElementById('link'+this.cCat).className = 'burgandyLink';
		}catch(e){}
		setSlider();
      }

      this.GetData = function(main, cat, params)
      {
		  try{
			if(this.cCat != null){
				document.getElementById('arrow'+this.cCat).innerHTML = '';
				document.getElementById('link'+this.cCat).className = '';
			}
		
		
			document.getElementById('arrow'+$('cCat').value).innerHTML = '';
			document.getElementById('link'+$('cCat').value).className = '';
			$('cCat').value = "";
		}catch(e){}
		
		document.getElementById('content').innerHTML = '<table WIDTH="515"><tr><td align="center" valign="middle"><img  src="assets/images/loading.gif" /></td></tr></table>';
		
		this.cMain = main;
		this.cCat = cat;
		
		
		this.InitializeRequest('POST', 'content.php');
		var qStr = "main="+main+"&cat="+cat+"&"+params;
		this.Commit(qStr);
		
		document.getElementById('content').innerHTML = "";
	 }
   }
   ContentObj.prototype = new ajax();
   
   var content = new ContentObj();
   
   
   FranchiseMgrObj = function()
   {
	  var cOperation = null
	  var cType = null;
	  var cReturnPage = null;
	  
      this.OnSuccess = function()
      {
         document.getElementById('content').innerHTML = this.GetResponseText();
      }

      this.GetData = function(operation, type, returnPage)
      {
		this.cOperation = operation;
		this.cType = type;
		this.cReturnPage = returnPage;
		
		this.InitializeRequest('POST', 'franchises.php');
		var qStr = "op="+this.cOperation+"&type="+this.cType+"&ret="+this.cReturnPage;
		this.Commit(qStr);
      }
   }
   FranchiseMgrObj.prototype = new ajax();
   
   var FranchiseMgr = new FranchiseMgrObj();
   
   
   GalleryThumbsObj = function()
   {
	  var cMain = null
	  var cCat = null;
	  
      this.OnSuccess = function()
      {
         document.getElementById('gallery').innerHTML = this.GetResponseText();
      }

      this.GetData = function(main, cat, page)
      {
		cMain = main;
		cCat = cat;
		
		this.InitializeRequest('POST', 'thumb_gallery.php');
		var qStr = "main="+main+"&cat="+cat+"&page="+page;
		this.Commit(qStr);
      }
   }
   GalleryThumbsObj.prototype = new ajax();
   
   var GalleryThumbs = new GalleryThumbsObj();
   
   
   LocationsObj = function()
   {
	  var cMain = null;
	  var cCat = null;
	  var curDir = null;
	  var curStore = null;
	  var storeAdd = null;
	  var curID = null;
	  
	  this.OnViewDirections = function(id, img){
		  
		  if(curDir != null || curID == id){
			  document.getElementById('directions').innerHTML = "";
			  document.getElementById('directions').style.height = "1px";
			  document.getElementById('directions').style.display = "none";
		  }
		  
		  if(curID == id){
			  curID = null;  
			  return;
		  }
		  
		  if(img != ""){
			writeFlashObjToElement( 515, 325, 'image.swf', 'images/maps/'+img, 'image', 'transparent', '');
		  }
		  		  
		  curDir = document.getElementById("dir_"+id);
		  
		  document.getElementById('directions').innerHTML = curDir.innerHTML;
		  document.getElementById('directions').style.height = "300px";
		  document.getElementById('directions').style.display = "block";

		  curID = id;
		  
	  }
	  
      this.OnSuccess = function()
      {
		  try{
				var res = this.GetResponseText();
				
				curDir = curID = curStore = storeAdd = null;
				
				document.getElementById('province').innerHTML = null;
				document.getElementById('province').innerHTML = res;
				
				document.getElementById('arrow'+cMain+"_"+cCat).innerHTML = '<img  src="assets/images/arrow.gif"  width="4" height="8"  />';
				document.getElementById('link'+cMain+"_"+cCat).className = 'burgandyLink';
		 }catch(e){alert(e.message);}
      }

      this.GetData = function(main, cat, cid, pid)
      {
		try{
			
			if(cCat != null){
				document.getElementById('arrow'+cMain+"_"+cCat).innerHTML = '';
				document.getElementById('link'+cMain+"_"+cCat).className = '';
			}

			cMain = pid;
			cCat = cid;
			
			document.getElementById('province').innerHTML = '<table WIDTH="515"><tr><td align="center" valign="middle"><img  src="assets/images/loading.gif" /></td></tr></table>';
			
			this.InitializeRequest('POST', 'locations.php');
			var qStr = "main="+main+"&cat="+cat+"&cid="+cid+"&pid="+pid;
			this.Commit(qStr);
		}catch(e){alert(e.message);}
      }
   }
   LocationsObj.prototype = new ajax();
   
   var locationList = new LocationsObj();
   
   LocationsThumbsObj = function()
   {
	  var cMain = null;
	  var cCat = null;
	  var curDir = null;
	  var curStore = null;
	  var storeAdd = null;
	  var curID = null;
	  
	 
      this.OnSuccess = function()
      {
		  var res = this.GetResponseText();
		
         document.getElementById('province').innerHTML = res;
      }

      this.GetData = function(cid, pid, pg)
      {	
		this.InitializeRequest('POST', 'locations.php');
		var qStr = "cid="+cid+"&pid="+pid+"&page="+pg;
		this.Commit(qStr);
      }
   }
   LocationsThumbsObj.prototype = new ajax();
   
   var locationListThumbs = new LocationsThumbsObj();
   
   ImageGalleryObj = function()
   {
	  var cMain    = null;
	  var cCat     = null;
	  var curDir   = null;
	  var curStore = null;
	  var storeAdd = null;
	  var curID    = null;
	  
	 
      this.OnSuccess = function()
      {
		  var res = this.GetResponseText();
         document.getElementById('content').innerHTML = res;
		 
		 setSlider();
      }

      this.GetData = function(table, condition, img_field, id_field, dir, thmb_dir, ret, title)
      {	
	  try{
	  	var obj = new Object();
		
		obj.table = table;
		obj.condition = condition;
		obj.img_field = img_field;
		obj.id_field = id_field;
		obj.dir = dir;
		obj.thmb_dir = thmb_dir;
		obj.ret = ret;
		obj.title = title;
		
		var json_obj = JSON.stringify(obj);
		this.InitializeRequest('POST', 'image_gallery.php');
		var qStr = "json="+json_obj;//+"&pid="+pid+"&page="+pg;
		this.Commit(qStr);
	  }catch(e){alert(e.message);}
      }
   }
   ImageGalleryObj.prototype = new ajax();
   
   var imageGallery = new ImageGalleryObj();
   
