function sendIntQuery(xPoint,yPoint){
	var axl = getIntQueryString(xPoint,yPoint);
	http = getHTTPObject();
	if ((http != null)) {
            http.open("POST", imsQueryURL, true);
	    http.onreadystatechange = parseIntString;
	    http.send(axl);
	}
}

function getIntQueryString(xPoint,yPoint) {
	var searchTolerance=2;
	var tempLeft = xPoint-searchTolerance;
	var tempTop = yPoint+searchTolerance;
	var tempRight = xPoint+searchTolerance;
	var tempBottom = yPoint-searchTolerance;
	var theEnv = 'maxy="' + tempTop + '" maxx="' + tempRight + '" miny="' + tempBottom + '" minx="' + tempLeft + '"';
	var theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_FEATURES outputmode="xml" geometry="false" envelope="true" checkesc ="true"';
	theString += ' featurelimit="'+maxFeaturesReturned+'" beginrecord="1">\n';
	theString += '<LAYER id="2" />\n';
	theString += '<SPATIALQUERY subfields="LOCATION TIME TYPE SPONSOR CONTACT" >\n';
	theString += '<SPATIALFILTER relation="area_intersection" >\n';
	theString += '<ENVELOPE ' + theEnv + ' />\n';
	theString += '</SPATIALFILTER>\n';
	theString += '</SPATIALQUERY>\n';
	theString += '</GET_FEATURES>\n';
	theString += '</REQUEST>\n';
	theString += '</ARCXML>';
	return theString;
}

function parseIntString(){
 	if (http.readyState == 4) {
		if (http.status == 200) {
			var result = http.responseText;
			parseShapeReply(result);
		} else alert("Error retreiving menu names");     
	} else {
		var idContent="<div class='noid'>< No <b>Neighbors Night Out</b> event found for this address. ></div>";
		updateContent('lowercolumn', idContent);
	} 
}

// parse layer field value samples
function parseShapeReply(theReply) {
	var pos = theReply.indexOf("<GCCOUNT count=");
	var lpos = 0;
	var startpos = pos + 16;
	var startpos2=0;
	var endpos = theReply.indexOf(dQuote,startpos);
	var fString = theReply.substring(startpos,endpos);
	var GCcount=parseInt(fString);
	if (GCcount > 0) {
		processIdResult(theReply);
	} else {
		var idContent="<div class='noid'>< No <b>Neighbors Night Out</b> event found for this address. ></div>";
		updateContent('lowercolumn', idContent);
	}
}

//---------

function sendLocQuery(loc){
	var axl = getLocQueryString(loc);
	http = getHTTPObject();
	if ((http != null)) {
            http.open("POST", imsQueryURL, true);
	    http.onreadystatechange = parseLocString;
	    http.send(axl);
	}
}

function getLocQueryString(loc) {
	var qry="'"+loc+"'";
	var theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_FEATURES outputmode="xml" geometry="false" envelope="true" checkesc ="true"';
	theString += ' featurelimit="'+maxFeaturesReturned+'" beginrecord="1">\n';
	theString += '<LAYER id="2" />\n';
	theString += '<SPATIALQUERY subfields="LOCATION TIME TYPE SPONSOR CONTACT" where="LOCATION='+qry+'" >\n';
	theString += '</SPATIALQUERY>\n';
	theString += '</GET_FEATURES>\n';
	theString += '</REQUEST>\n';
	theString += '</ARCXML>';
	return theString;
}


function parseLocString(){
 	if (http.readyState == 4) {
		if (http.status == 200) {
			var result = http.responseText;
			parseLocReply(result);
		} else alert("Error retreiving menu names");     
	} else {
		var idContent="<div class='noid'>< No <b>Neighbors Night Out</b> event found for this address. ></div>";
		updateContent('lowercolumn', idContent);
	} 
}

function parseLocReply(theReply) {
	var pos = theReply.indexOf("<GCCOUNT count=");
	var lpos = 0;
	var startpos = pos + 16;
	var startpos2=0;
	var endpos = theReply.indexOf(dQuote,startpos);
	var fString = theReply.substring(startpos,endpos);
	var GCcount=parseInt(fString);
	if (GCcount > 0) {
		processIdResult(theReply);
	} else {
		var idContent="<div class='noid'>< No <b>Neighbors Night Out</b> event found for this address. ></div>";
		updateContent('lowercolumn', idContent);
	}
}