//Geocode stuff
function writeGeocodeXML(GCvalue) {
	var axl = '<ARCXML version="1.1">\n<REQUEST>\n<GET_GEOCODE maxcandidates="1" minscore="50">\n';
	axl += '<LAYER id="' + GCLayerId + '" />\n';
	axl += '<ADDRESS>\n';
	axl += '<GCTAG id="KEYFIELD" value="' + GCvalue + '"/>\n';
	axl += '</ADDRESS>\n</GET_GEOCODE>\n</REQUEST>\n</ARCXML>\n';
	http = getHTTPObject();
	if ((http != null)) {
	    http.open("POST", imsGeocodeURL, true);
	    http.onreadystatechange = parseGCResult;
	    http.send(axl);
  	}
}


function parseGCResult(){
	if (http.readyState == 4) {
		if (http.status == 200) {
			var result = http.responseText;
			processGCResult(result); 
		} else alert("Error retreiving address information");	          
	}
}

function processGCResult(theReply){
	var tempX;
	var tempY;
	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) {
		startpos2 = theReply.indexOf('name="ADDRESSFOUND"',lpos);
		startpos = theReply.indexOf("FIELDVALUE valuestring=",startpos2);
		startpos = startpos + 24;
		endpos = theReply.indexOf(dQuote,startpos);
		GCaddress = theReply.substring(startpos,endpos);
		startpos2 = theReply.indexOf('name="SHAPEFIELD"',lpos);
		startpos = theReply.indexOf("<POINT x=",startpos2);
		startpos += 10;
		endpos = theReply.indexOf(dQuote,startpos);
		tempX = theReply.substring(startpos,endpos);
		GCpointX= parseFloat(setDecimalString(tempX)); 
		startpos = theReply.indexOf("y=",endpos);
		startpos = startpos + 3;
		endpos = theReply.indexOf(dQuote,startpos);
		tempY = theReply.substring(startpos,endpos);
		GCpointY= parseFloat(setDecimalString(tempY)); 

		//highlight on the map
		showGC=true;
		sendIntQuery(GCpointX,GCpointY);

	} else {
		var layer = document.getElementById(mapDivId);
		layer.onmousemove=null;
		hideLayer('loadingMap');
		var idContent="<div class='noid'>< Could not find your address ><p>Try entering the full address, such as 123 Miller Drive. Do not use apartment or unit numbers.</div>";
		updateContent('lowercolumn', idContent);
		showGC=false;
	}
}
