	/*
		Populates the 'places' select option by loading an XML 
		depending on which place is selected	
		ptObj = place type
		pObj = place 
	*/
/*
	function PopulatePlaces(formName, ptObj, pObj, stEndPlace){
		document.getElementById(pObj).options.length = 0;
		document.getElementById(pObj).options[0] = new Option('Please select a place',0);

		var PlaceTypeID = document.getElementById(ptObj).options[document.getElementById(ptObj).selectedIndex].value;		
		
		if (PlaceTypeID == 1){//buildings
			var ai = new AJAXInteraction('../genxml.php?data=places&placetypeid='+PlaceTypeID, handleResponsePBuildings, pObj);
			ai.doGet();
			//loadXMLDoc('genxml.php?data=places&placetypeid='+PlaceTypeID, handleResponsePBuildings);
		}
		if (PlaceTypeID == 2){//parking lots
			var ai = new AJAXInteraction('../genxml.php?data=places&placetypeid='+PlaceTypeID, handleResponsePParkingLots, pObj);
			ai.doGet();
			//loadXMLDoc('genxml.php?data=places&placetypeid='+PlaceTypeID, handleResponsePParkingLots);
		}
		if (PlaceTypeID == 3){//bus stops
			var ai = new AJAXInteraction('../genxml.php?data=places&placetypeid='+PlaceTypeID, handleResponsePBusStops, pObj);
			ai.doGet();
			//loadXMLDoc('genxml.php?data=places&placetypeid='+PlaceTypeID, handleResponsePBusStops);
		}
		if (PlaceTypeID == 4){//departments
			var ai = new AJAXInteraction('../genxml.php?data=places&placetypeid='+PlaceTypeID, handleResponsePDepts, pObj);
			ai.doGet();
			//loadXMLDoc('genxml.php?data=places&placetypeid='+PlaceTypeID, handleResponsePDepts);
		}
		if (PlaceTypeID == 5){//mapClick
			if (pObj == "Place"){
				alert("function.js start 1111: " + stEndPlace);
				gCount = 1;
			}
			else{
				alert ("selected index: " + document.forms['search-form'].Place.selectedIndex);
				alert("function.js end 22222222: " + stEndPlace);
				gCount = 2;
			}
			//typeDropDown = stEndPlace;     
  			addListener(pObj);
			//var ai = new AJAXInteraction('../genxml.php?data=places&placetypeid='+PlaceTypeID+'&latitude='+thelat+'&longitude='+thelon, handleResponseMapClick, pObj);
			//ai.doGet();

				
				
                       

		}
	}
*/
		
	function AJAXInteraction(url, callback) {
	    var req = init();
	    req.onreadystatechange = processRequest;
	        
	    function init() {
	      if (window.XMLHttpRequest) {
	        return new XMLHttpRequest();
	      } else if (window.ActiveXObject) {
	        return new ActiveXObject("Microsoft.XMLHTTP");
	      }
	    }
	    
	    function processRequest () {
	      if (req.readyState == 4) {
	        if (req.status == 200) {
	          if (callback) callback(req.responseXML);
	        }
	      }
	    }
	
	    this.doGet = function() { 	
	      req.open("GET", url, true);
	      req.send(null);
	    }
	    
	    this.doPost = function(body) {
	      req.open("POST", url, true);
	      req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	      req.send(body);
	    }
	}

/*
	   function AJAXInteraction(url, callback, arg1) {
	   	 var req = init();
	    	req.onreadystatechange = processRequest;
	    	req.async = true;
	        
	    	function init() {
	      		if (window.XMLHttpRequest) {
	        		return new XMLHttpRequest();
	      		} else if (window.ActiveXObject) {
	        		return new ActiveXObject("Microsoft.XMLHTTP");
	      		}
	    	}
	    
	    	function processRequest () {
	      		if (req.readyState == 4) {
	        		if (req.status == 200) {
	          			if (callback) callback(req.responseXML, arg1);
			        } else {
	            			alert("There was a problem retrieving the XML data:\n" + req.statusText);
	        		}
	      		}
	    	}
	
	    	this.doGet = function() { 	
	      		req.open("GET", url, true);
	      		req.send(null);
	    	}
	    
	    	this.doPost = function(body) {
	      		req.open("POST", url, true);
	      		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	      		req.send(body);
	    	}
	}
*/

		// This converts a javascript array to a string in PHP serialized format.
		// This is useful for passing arrays to PHP. On the PHP side you can 
		// unserialize this string from a cookie or request variable. For example,
		// assuming you used javascript to set a cookie called "php_array"
		// to the value of a javascript array then you can restore the cookie 
		// from PHP like this:
		//    <?php
		//    session_start();
		//    $my_array = unserialize(urldecode(stripslashes($_COOKIE['php_array'])));
		//    print_r ($my_array);
		//    ?>
		// This automatically converts both keys and values to strings.
		// The return string is not URL escaped, so you must call the
		// Javascript "escape()" function before you pass this string to PHP.
		function js_array_to_php_array (a){
		  var a_php = "";
		  var total = 0;
		  for (var key in a)
		  {
	      ++ total;
	      a_php = a_php + "s:" +
	              String(key).length + ":\"" + String(key) + "\";s:" +
	              String(a[key]).length + ":\"" + String(a[key]) + "\";";
		  }
		  a_php = "a:" + total + ":{" + a_php + "}";
		  return a_php;
		}        		
