	var createDrillPage = false;
	var replyArray = new Array();
	var sendStats = false;
	var fieldStat = '';
	var theMin = 0;
	var theMax = 0;
    var theString;
	
	var fID = 1;
	var fEast;
	var fWest;
	var fSouth;
	var fNorth;
	
	
function doDrill(theReply) {
    //drill tool loop sequence

   replyArray[fID] = theReply;
   fID++;
   if (fID < (LayerID.length)) {
        theString = writeGetFeaturesDrill(fWest,fSouth,fEast,fNorth,fID);
	  sendToServer(imsQueryURL,theString,1004);
   }
   
   if (fID == (LayerID.length)) {
	createDrillPage = false;
	replyArray.reverse();
	displayAttributeDataforDrill(replyArray);
	var ActiveLayerIndex = 7;
   }
 }  //end doDrill()

function drillIdentify(e) {
      fID = 1;
	var ActiveLayerIndex = 1;
	highlightedOne="";
	var theX = mouseX;
	var theY = mouseY;
	getMapXY(theX,theY);
	searchTolerance = (xDistance/iWidth) * pixelTolerance;
	var tempWest = mapX - searchTolerance;
	var tempNorth = mapY + searchTolerance;
	var tempEast = mapX + searchTolerance;
	var tempSouth = mapY - searchTolerance;
	fSouth = tempSouth;
	fNorth = tempNorth;
	fWest = tempWest;
	fEast = tempEast;
	var theString = writeGetFeaturesDrill(tempWest,tempSouth,tempEast,tempNorth,1);
	//alert(theString);
	showRetrieveData();
	sendToServer(imsQueryURL,theString,1004);
}

// write XML to identify features for drill ID
function writeGetFeaturesDrill(west1,south1,east1,north1,thefID) {
	var reverseFieldList = selFieldList.reverse()
	selectFields=reverseFieldList[thefID];
	var useString = writeIdentifyXML(thefID,LayerType[thefID],selectFields,west1,south1,east1,north1,useLimitExtent);
	hightlightedOne="";
	return useString;
}

function pullValue (theStr, theList) {
  var theval="";
  var theindex=-1;
  var thelen=0;
  var thenum=0;
  var theright=0;

  thelst = theList.split("|");
  
  for (var i=0;i < thelst.length; i++) {
     theval = thelst[i];
     theindex = theval.indexOf(theStr, 0);
     //alert (theindex);
     if (theindex != -1)
        {                  
           thelen = theval.length;
           thenum = theval.indexOf (":", 0);
           theright = theval.substr(thenum + 1, (thelen - thenum));
           return theright;
  	}
  }
   //gets out and not found
   return "";
}

// parse XML response for drill functions
function displayAttributeDataforDrill(theReplyArray) {
   showRetrieveData();
	if ((useExternalWindow) || (!useTextFrame)) {
			Win1 = window.open("","QueryWindow","width=575,height=120,scrollbars=yes,resizable=yes");
			theFrame = "opener";
			if (parent.MapFrame!=null) theFrame = "opener.parent.MapFrame";
	} else {
			Win1 = parent.TextFrame;
			Win1.document.open();
			}
		Win1.document.open();
		Win1.document.writeln('<html><head><title>Query/Selection Results</title></head>');
		Win1.document.writeln('<body background="/GISWeb/elmgrove/images/cloud.jpg" text="Black" link="Blue" vlink="Blue" LEFTMARGIN=0 onload="window.focus()"><center>');

 for (b=0;b<(theReplyArray.length - 1);b++) {
    //alert(theReply);
	theReply = theReplyArray[b];
	setLayerFields(b);
	var theError = getXMLErrorMessage(theReply);
	var fList="";
	var lpos1 = 1;
	var lpos2 = 1;
	var epos = 1;
	var spos = 1;
	var morePoints=true;
	var moreFeatures=true;
	var featureCount = justGetFeatureCount(theReply);
	//alert(featureCount);
	var pos = 0;
	var startpos = 0;
	var endpos = xmlEndPos;
	var stillMore = false
	pos = theReply.indexOf('hasmore="true"',endpos);
	if (pos!=-1) stillMore = true;
	pos=0;
	var tempCount = 0;
	var selectedData="";
	var inData="";
	var xStr="";
	var yStr="";
	var eNorth="";
	var eSouth="";
	var eWest="";
	var eEast="";
	var fCount = featureCount;
	//alert("displayAttributeData()[featurecount=" + featureCount + "]");
	selectCount = 0;
	var tempString="";
	var Win1 = parent.TextFrame;
	var theFrame = "parent.MapFrame";
	if (featureCount > 0) {
		newSelectCount += 1;
		endpos = 1;
	Win1.document.writeln('<center><br><FONT FACE="Arial" SIZE="-1"><b>' + LayerName[b] + '</b><br>');
	Win1.document.writeln('<table border="1" size="95%" cellspacing="0" cellpadding="2" nowrap background="/GISWeb/elmgrove/images/cloud.jpg">');						
		for (var i=0;i<fCount;i++) {

			inData = parseRecordString(theReply, endpos);
			endpos = xmlEndPos;
			selectedData = clearLeadingSpace(inData);
			
			epos = theReply.indexOf("</FEATURE",endpos);
			if (showSelectedData) {
				//alert("2\n" + selectedData);
				var showHyper = false;
				if (hyperLinkLayers!=null) {
					for (var s1=0;s1<hyperLinkLayers.length;s1++) {
						if (hyperLinkLayers[s1] == LayerName[b]) showHyper=true;
					}
				}
					
				var fName1 = getFieldNames(selectedData);
				var fValue1 = getFieldValues(selectedData);
				selectPoints[selectCount] = getIdValue(fName1, fValue1);
					if (selectCount==0) {
					Win1.document.write('<tr><th><FONT FACE="Arial" SIZE="-2">Rec</FONT></a></th>');
					for (var f=0;f<fName1.length-2;f++) {
						var f2 = -1;
						if (useFieldAlias) {
							for (var f3=0;f3<AliasFieldName.length-2;f3++) {
								if (AliasFieldName[f3]==fName1[f]) f2 = f3;
							}
						}
						if (f2!=-1) {
							Win1.document.write('<th><FONT FACE="Arial" SIZE="-2">' + AliasFieldAlias[f2] + '</FONT></a></th>');
						} else {
							Win1.document.write('<th><FONT FACE="Arial" SIZE="-2">' + fName1[f] + '</FONT></a></th>');
						}
					}
					Win1.document.writeln('</tr>');
				}
				Win1.document.write('<tr><td>');
				Win1.document.write('<FONT FACE="Arial" SIZE="-2">' + (selectCount+queryStartRecord+1) + '</FONT>');
				Win1.document.writeln('</td>');
				for (var f=0;f<fName1.length-2;f++) {	
					Win1.document.write('<TD>');
					var isHyper=false;
					if (showHyper) {
						for (var s1=0;s1<hyperLinkFields.length;s1++) {
							if (hyperLinkFields[s1]==fName1[f]) {
								Win1.document.write('<a href="' + fValue1[f] + '" target="_blank">');
								isHyper=true;
							}
						}
					}
					var s2 = -1;
					for (var s1=0;s1<LayerFields.length;s1++) {
						if (fName1[f]==LayerFields[s1]) s2=s1;
					}
					if (LayerFieldType[s2]=="91") {
						//alert(fName1[f]);
						if (isNaN(fValue1[f])) {
							var theDate = fValue1[f];
						} else {
							//var theDate = new Date(parseInt(fValue1[f]));
							var theDateObj = new Date(parseFloat(fValue1[f]));
							var theDate = theDateObj.toGMTString();
						}
						Win1.document.write('<FONT FACE="Arial" SIZE="-2">' + theDate + '</FONT>');
						theDate=null;
					} else {
						Win1.document.write('<FONT FACE="Arial" SIZE="-2">' + fValue1[f] + '</FONT>');
					}
					if (isHyper) Win1.document.write('</a>');
					Win1.document.writeln('</td>');
				}
				Win1.document.writeln('</tr>');
				fName1 = null;
				fValue1 = null;
			}
			selectCount += 1;
			//					
		}

	} else {

        //Win1.document.writeln('<FONT FACE="Arial" SIZE="-1"><b>' + LayerName[b] + '</b>');
		//Win1.document.writeln('<br>No Features Found.<br><br></font>');
	}
     Win1.document.writeln('</table>');
  }//end for  
    Win1.document.writeln('</center></body></html>');
    Win1.document.close();
    Win1=null;
    hideRetrieveData();
} //end function