
	// +-------------------------------------------------------------------------------------+
	// |  LondonTown.com HotelMap - Version 2.0                                              |
	// |  Copyright (C) 2008, All Rights Reserved, Globalvision Media                        |
	// +-------------------------------------------------------------------------------------+
	// |  File: Ajax.js                                                                      |
	// |  Vers: $Id: Ajax.js,v 1.1 2008/05/21 14:59:44 robin Exp $                                                                       |
	// |  Auth: James Holden (james_holden@londonmarketing.com)                              |
	// |  Last: $Auth: $                                                                     |
	// |  Desc: Implementation of the XMLHTTPRequest protocol                                |
	// +-------------------------------------------------------------------------------------+

	// Note: This object requires access to the Util.js script.

	/** MYJAVASCRIPT:(Static)JSON:DESC-JSON Static class to load remote information **/
	var JSON = {
		loadnumbers  : 0,
		total : 0,
		collector : null,

		/**
		 * Abort
		 * @desc Aborts the current request being carried out (if any)
		 * MYJAVASCRIPT:JSON.Abort:DESC-Aborts the current JSON operation
		 */

		Abort : function()
		{
			JSON.handle.abort();
		},


		/**
		 * Post
		 * @param url (string)
		 * @param post (string)
		 * @desc Sends a post request to the server.
		 * MYJAVASCRIPT:JSON.Post:PARM-url-string:PARM-post-string:DESC-Process a remote request and if post is given will send a post request
		 */
		Post : function(url,post) {
			JSON.loadnumbers++;
			JSON.total++;

			url = url + "keycode="+Math.random();
			var ajaxHandle;
			if ( window.XMLHttpRequest ) { ajaxHandle = new XMLHttpRequest(); }
			else if ( window.ActiveXObject ) { ajaxHandle = new ActiveXObject("Microsoft.XMLHTTP"); }
			else { alert("Your browser is not supported"); }
			if ( ajaxHandle ) {
				JSON.handle = ajaxHandle;
				ajaxHandle.onreadystatechange = function() { JSON.Parse(ajaxHandle); }
				ajaxHandle.open("POST", url, true);
				ajaxHandle.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				ajaxHandle.setRequestHeader("Content-length", post.length);
				ajaxHandle.setRequestHeader("Connection", "close");
				ajaxHandle.send(post);
			}
		},

		/**
		 * Load
		 * @param url (string)
		 * @desc Sends a get request to the server where url includes URL and Query
		 * MYJAVASCRIPT:JSON.Load:PARM-url-string:DESC-Loads a remote JSON request (GET request)
		 */
		Load : function(url) {

			url = url + "keycode="+Math.random();
			var ajaxHandle;
			if ( window.XMLHttpRequest ) { ajaxHandle = new XMLHttpRequest(); }
			else if ( window.ActiveXObject ) { ajaxHandle = new ActiveXObject("Microsoft.XMLHTTP"); }
			else { alert("Your browser is not supported"); }
			if ( ajaxHandle ) {
				JSON.handle = ajaxHandle;
				ajaxHandle.onreadystatechange = function() { JSON.Parse(ajaxHandle); }
				ajaxHandle.open("GET", url, true);
				ajaxHandle.send(null);
			}
		},

		/**
		 * Parse
		 * @param handle (XMLHttpRequest object)
		 * @desc Processes the return response sent by the server from a get or post
		 * MYJAVASCRIPT:JSON.Parse:PARM-handle-xmlhttprequestobject:DESC-Parse the content of the response using eval
		 */
		Parse : function( handle ) {
			try {
				if (handle.readyState == 4 && handle.status == 200){
					if (handle.responseText){
						var response = handle.responseText;
						if ( response ){
							try {

								eval( response );
								Util.kill(response);

							} catch ( e ) {
								alert("JSON Error:\n\n" + "Error: "+e.name+"\n"+e.message+"\n\n"+response);
							}
						}
					}
				}

			} catch ( e ) { }
		}

	};