var xmlHttp;

function GetXmlHttpObject()	{
	var xmlHttp=null;
	try	{
	  	// Firefox, Opera 8.0+, Safari
	  	xmlHttp=new XMLHttpRequest();
  	}
	catch (e) {
  		// Internet Explorer
		try	{
			// assume IE6 or older
		    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
		                                    "MSXML2.XMLHTTP.5.0",
		                                    "MSXML2.XMLHTTP.4.0",
		                                    "MSXML2.XMLHTTP.3.0",
		                                    "MSXML2.XMLHTTP",
		                                    "Microsoft.XMLHTTP");
		    // try every id until one works
		    for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) {
		      try { 
		        // try to create XMLHttpRequest object
		        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
		      } 
		      catch (e) {} // ignore potential error
		    }
	    }
	  	catch (e)	{
	    	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
  	}
	return xmlHttp;
}

/*****************************************************
* Ajax for Activate/deactivate Properties
******************************************************/
function ajax_development(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	}
  	
  	try { 

		if(id == "" || id == 0) {
			alert("Error! Missing area id.");
			return false;
		}// proceed only if the xmlHttp object isn't busy 
		else if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {

			var url= "http://"+window.location.hostname+"/ajax/ajax_dev_dd.php?id=" + id;
			document.getElementById("td_development").innerHTML = "";
			// define the method to handle server responses 
			xmlHttp.onreadystatechange = activeServerResponse;
			xmlHttp.open("GET",url,true);
			// make the server request 
			xmlHttp.send(null);
		}
		else {	// if the connection is busy, try again after one second 
		setTimeout("ajax_publish(" + id + ")", 500);
		}
	}
	catch (e) {alert(e.message);}
}

function activeServerResponse() { 

	if (xmlHttp.readyState==4)	{
		var response =  xmlHttp.responseText;

        	// update the client display using the data received from the server 
			document.getElementById("td_development").innerHTML = response;
	}
}

