/***************************************************************************************************
*  This functions helps in obstrification of webforms from malicious spam bots by hiding the form from
*  the entry page of a site. user intervension is required in order to access the form. The Ajax call 
*  displays the form in a designated html element that support the innerHtml property(div is recommended)
*	@author lamenya@esri.com
* 	@date 	02/08/2007
***************************************************************************************************/

/**
* Requests a form or page content and displays it in the specified div
*  @param http_request	a pending or completed httpRequest 
*  @param div_id		the id of a div that is used to display the results of a the 
*  parameter httpRequest only when the status is OK/Success(200)
*/
 function requestForm(url,div_id) {
     var http_request = false;
     
	/**
	*  Helper Function: Displays the reponse of a httpRequest in the specified div
	*  @param http_request	a pending or completed httpRequest 
	*  @param div_id		the id of a div that is used to display the results of a the 
	*  parameter httpRequest only when the status is OK/Success(200)
	*/
	showForm = function(http_request,div_id) {

	     if (http_request.readyState == 4) {
	         if (http_request.status == 200) {
	         	var display=document.getElementById(div_id);	         	
	         	display.innerHTML=http_request.responseText;             
	         } else {         	 
	             alert('There was a problem with the request.');
	         }
	     }
	
	 }
	 
     if (window.XMLHttpRequest) { // Mozilla, Safari, ...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
             http_request.overrideMimeType('text/xml');
             // See note below about this line
         }
     } else if (window.ActiveXObject) { // IE
         try {
             http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
             try {
                 http_request = new ActiveXObject("Microsoft.XMLHTTP");
             } catch (e) {}
         }
     }

     if (!http_request) {
         alert('Giving up :( Cannot create an XMLHTTP instance');
         return false;
     }
     http_request.onreadystatechange = function() { showForm(http_request,div_id); };
     http_request.open('GET', url, true);
     http_request.send(null);

 }
