function simpleReport(appDiv, defs, content, attribs)
{
	if(content == ''){return;}
	//alert ('attribs = '+attribs)
	var feats=0;
	feats = parseInt(defs.length / attribs);
	//alert('number of features = '+feats)
	//alert(content)
	if(feats <= 0) {alert('nothing to report'); return;}
	
	var holdingDiv = document.getElementById(appDiv);

	// if report is already there get its scree position
	var reptTop ='50px'; var reptLeft ='351px';
	if(document.getElementById('simpleReport'))
	{
		reptTop = document.getElementById('simpleReport').style.top;
		reptLeft =document.getElementById('simpleReport').style.left;
		checkRemoveObject('simpleReport');
	}
	
	// create the Report Div
	simpleReportDiv = document.createElement('div');
	simpleReportDiv.style.display='block';
	simpleReportDiv.style.zIndex='6100';
	simpleReportDiv.style.position='absolute';
	simpleReportDiv.style.top=reptTop;
	simpleReportDiv.style.marginLeft='auto';
	simpleReportDiv.style.marginRight='auto';
	simpleReportDiv.style.left=reptLeft;
	simpleReportDiv.style.width='400px';
	simpleReportDiv.id = 'simpleReport';
	simpleReportDiv.setAttribute("id", 'simpleReport');	
	
	// create the banner div
	var simpleReportDivBanner = document.createElement('div');
	simpleReportDivBanner.className = 'popupDDrapeHeader';
	simpleReportDivBanner.style.backgroundImage='url(images/banner_400.gif)';
	simpleReportDivBanner.id = 'appHolder';
	simpleReportDivBanner.style.zIndex='6200';
	
	// create the numaps logo symbol image tag
		var symbolImg = document.createElement('img');
		symbolImg.src='images/logo_symbol_small.gif';
		symbolImg.style.position='absolute';
		symbolImg.style.top='7px'; 
		symbolImg.style.left='8px';
		simpleReportDivBanner.appendChild(symbolImg);
		
		// now add the title in the Banner
		var spanTag = document.createElement('span');
		spanTag.style.position='absolute';
		spanTag.style.top='4px';
		spanTag.style.left='34px';
		var bannerText = document.createTextNode('Feature(s) Attribute Report');	
		spanTag.appendChild(bannerText);
		simpleReportDivBanner.appendChild(spanTag);

		// add the close button
		var symbolImg = document.createElement('img');
		symbolImg.src='images/close.gif';
		symbolImg.style.width='15px';
		symbolImg.style.cursor='pointer';
		symbolImg.style.position='absolute';
		symbolImg.style.top='5px'; 
		symbolImg.style.right='8px';
		bindEvent(symbolImg, 'click', closeMe, 'false');
		simpleReportDivBanner.appendChild(symbolImg);
	simpleReportDiv.appendChild(simpleReportDivBanner);

	
	// create the reportBody div
	var reportBody = document.createElement('div');
	reportBody.style.backgroundColor='#ECE9D8'; 
	reportBody.style.border='2px solid #0000D6';
	reportBody.style.borderBottom='none';
	reportBody.style.top='22px';
	reportBody.style.width='396px';
	reportBody.style.height='20px';
	reportBody.style.marginRight='auto';
	reportBody.style.marginLeft='auto';
	reportBody.id='reptBack';
	reportBody.setAttribute('id','reptBack');

	//create the layername report Div
	var reportHead = document.createElement('div');
	reportHead.style.position='relative';
	reportHead.style.top='5px';
	reportHead.style.width='396px';
	reportHead.style.height='25px';
	reportHead.style.fontSize = '12px';
	reportHead.style.fontWeight='bold';
	reportHead.style.textAlign='center';
	var cellText = document.createTextNode(layerName);
			reportHead.appendChild(cellText);
	reportBody.appendChild(reportHead);

	// create the two column table
	var reportTable = document.createElement('table');
	reportTable.id = 'simpleReportTable';
	reportTable.setAttribute("id", 'simpleReportTable');
	reportTable.style.position='absolute'; 
	reportTable.style.top='43px'; 
	reportTable.style.left='0px';
	//reportTable.style.margin='10px'; 
	reportTable.style.width='400px';
	//reportTable.style.maxHeight='360px';
	reportTable.style.backgroundColor='#ECE9D8';
	//reportTable.style.borderCollapse='collapse';
	//reportTable.style.border='1px solid gray';
	reportTable.style.borderLeft='2px solid #0000D6';
	reportTable.style.borderRight='2px solid #0000D6';

		// create the Table Body
		var tableBody = document.createElement('tbody');
		
			// create the headings Row
			var headingRow = document.createElement('tr');
			
				// create the Name Header Cell
				var headCell = document.createElement('th');
				headCell.style.minHeight='15px';
				headCell.style.fontSize = '9px';
				headCell.style.width='50%';
				//headCell.style.borderRight='1px solid gray';
				//headCell.style.backgroundColor='white';
				var cellText = document.createTextNode('Attribute Name');
				headCell.appendChild(cellText);
				headCell.style.textAlign='center';
			headingRow.appendChild(headCell);

				// create the Content Header Cell
				var headCell = document.createElement('th');
				headCell.style.minHeight='15px'; 
				headCell.style.fontSize = '9px';
				headCell.style.width='50%';
				//headCell.style.backgroundColor='white';
				var cellText = document.createTextNode('Attribute Value');
				headCell.appendChild(cellText);
				headCell.style.textAlign='center';
			headingRow.appendChild(headCell);
				
		tableBody.appendChild(headingRow);
	reportTable.appendChild(tableBody);
	simpleReportDiv.appendChild(reportTable);

	// create a div to hold the body of the report which shall be scrollable
	var reportDiv = document.createElement('div');
	//reportDiv.style.overflowX='auto'; 
	reportDiv.style.overflowY='scroll';
	reportDiv.style.position='absolute'; 
	reportDiv.style.top='59px'; 
	reportDiv.style.left='0px';
	reportDiv.style.width='396px';
	reportDiv.style.maxHeight='360px';
	reportDiv.style.backgroundColor='#FFFFFF';
	reportDiv.style.border='1px solid gray';
	reportDiv.style.borderLeft='2px solid #0000D6';
	reportDiv.style.borderRight='2px solid #0000D6';
	reportDiv.style.borderBottom='2px solid #0000D6';


	// create the two column table
	var reportTableMain = document.createElement('table');
	//reportTableMain.style.overflowX='scroll'; 
	//reportTableMain.style.overflowY='scroll';
	reportTableMain.style.width='100%';
	reportTableMain.style.maxHeight='360px';
	reportTableMain.style.backgroundColor='#FFFFFF';
	reportTableMain.style.borderCollapse='collapse';
	reportTableMain.setAttribute('border', 0);


		// create the Table Body
		var tableBody = document.createElement('tbody');
		// create a new row for each element in the array
		var rows = defs.length;
		var batchCount = 0;
		for (var i=1; i<rows; i++)
		{
			// check for the start of a new feature
			if(batchCount == attribs || batchCount == 0)
			{
				var reportRow = document.createElement('tr');
				//reportRow.style.border = '1px solid gray';
				
				//left filler cell
				var headCell = document.createElement('td');
				headCell.style.height='15px';
				headCell.style.width='10px';
				headCell.style.backgroundColor='#ECE9D8';
				headCell.style.borderTop='0px';
				reportRow.appendChild(headCell);
				
				// left header cell
				var headCell = document.createElement('td');
				headCell.style.height='15px';
				headCell.style.width='auto';
				headCell.style.fontSize = '10px';
				headCell.style.fontWeight = 'bold';
				headCell.style.backgroundColor='#FFFFD4';
				var cellText = document.createTextNode('New feature :');
				headCell.appendChild(cellText);
				headCell.style.textAlign='left';
				headCell.style.borderLeft = '1px solid gray';
				reportRow.appendChild(headCell);
				
				// right header cell
				var headCell = document.createElement('td');
				headCell.style.backgroundColor='#FFFFD4';
				headCell.style.borderRight = '1px solid gray';
				reportRow.appendChild(headCell);
				
				// append header row to table
				tableBody.appendChild(reportRow);
				batchCount  = 0;
			}
			if(defs[i] != 'GEOMETRY')
			{
				// build up a data row for the report
				var reportRow = document.createElement('tr');
						
					//left filler cell
					var headCell = document.createElement('td');
					headCell.style.minHeight='15px';
					headCell.style.width='10px';
					headCell.style.backgroundColor='#ECE9D8';
					headCell.style.borderTop='0px';
				reportRow.appendChild(headCell);
					
					// create the Name Header Cell
					var headCell = document.createElement('td');
					headCell.style.minHeight='15px';
					headCell.style.fontSize = '9px';
					headCell.style.width='50%';
					headCell.style.border='1px solid gray';
					var cellText = document.createTextNode(defs[i]);
					headCell.appendChild(cellText);
					headCell.style.textAlign='left';
					headCell.style.paddingLeft='5px';
				reportRow.appendChild(headCell);

					// create the Content Header Cell
					var headCell = document.createElement('td');
					headCell.id = 'reptCont:'+i;
					headCell.setAttribute('id','reptCont:'+i);
					headCell.style.minHeight='15px'; 
					headCell.style.fontSize = '9px';
					headCell.style.width='50%';
					headCell.style.border='1px solid gray'
					var cellText = document.createTextNode(content[i]);
					headCell.appendChild(cellText);
					headCell.value = content[i];
					headCell.style.textAlign='left';
					headCell.style.paddingLeft='5px';
					
					// check to see if this is a http link piece of content
					var linkLook = content[i].split('//');
					if(linkLook.length == 2)
					{	
						bindEvent(headCell, 'click', hyperlinkIt, 'false');
						headCell.style.textDecoration='underline';
						headCell.style.color='blue';
						headCell.style.cursor='pointer';
					}
				reportRow.appendChild(headCell);

				tableBody.appendChild(reportRow);
				
			}
			batchCount = batchCount + 1;
		}
		// add a spacer row at base of the table
		var reportRow = document.createElement('tr');
			//reportRow.style.border = '1px solid gray';
				
			//left filler cell
			var headCell = document.createElement('td');
			headCell.style.height='5px';
			headCell.style.width='10px';
			headCell.style.backgroundColor='#ECE9D8';
			headCell.style.border='0px';
			reportRow.appendChild(headCell);
				
			// left header cell
			var headCell = document.createElement('td');
			headCell.style.height='5px';
			headCell.style.backgroundColor='#ECE9D8';
			headCell.style.border='0px';
			reportRow.appendChild(headCell);
				
			// right header cell
			var headCell = document.createElement('td');
			headCell.style.height='5px';
			headCell.style.backgroundColor='#ECE9D8';
			headCell.style.border='0px';
			reportRow.appendChild(headCell);
				
		// append header row to table
		tableBody.appendChild(reportRow);

	reportTableMain.appendChild(tableBody);
	reportDiv.appendChild(reportTableMain);
	reportBody.appendChild(reportDiv);
	simpleReportDiv.appendChild(reportBody);
	//simpleReportDiv.style.height='auto';

	holdingDiv.appendChild(simpleReportDiv);
	//document.getElementById('reptBack').style.height='auto';
	Drag.init(simpleReportDivBanner, simpleReportDiv);

}
function hyperlinkIt(evt)
{
	var e_out = getThisId(evt);
	var link = document.getElementById(e_out).value;
	makePopup(link, 500, 500, 'resize')
	Event.stop(evt);
}

function toggleReport(buttObj)
{
	if (buttObj.title == 'Show Report')
	{
		document.getElementById("reportHolder").style.display="block";
		buttObj.title='Hide Report';
		report=true;
		depressedDiv(buttObj.id);
	}
	else
	{
		buttObj.title='Show Report';
		document.getElementById("reportHolder").style.display="none";
		normalDiv(buttObj.id);
	}
}
function closeMe(evt)
{
	defs = [];
	content = [];
	//alert(newCsvFile)
	if(newSld != ''){	deleteit(newSld);	}
	if(newCsvFile != ''){	deleteit(newCsvFile);	}
	document.getElementById('simpleReport').style.display="none";
	if(Highlight){Highlight.setVisibility(false);}
	if(DrapeHighlight){DrapeHighlight.setVisibility(false);}
	Event.stop(evt);
}
//---------------------------------- generic reporting function -------------------------------------------
function reportIt(ajaxRequest, feature, serviceBase, dataStore, typeName, showHighlight, searchType)
{
	// if this is a temporary edited SLD file strip back to real file in control file
	if(currentSldFile)
	{
		var SLD = currentSldFile;
		var fileParts = currentSldFile.split('_new');
		if(fileParts.length > 1)
		{	SLD = fileParts[0]+'.xml';	}
	}
	genLoadStatus('Compiling Report ...', true)
	
	// get the attributes required for reporting purposes	
	if(targetNames.length > 0)	{	numberAtts = getAttribsForLayer(SLD)	}
	else{	numberAtts = getAttribsForDrape(SLD);	}

	// check that we have attributes to report on
	if(!attributeInfo[0]) 
	{	alert('Attribute reporting not supported for this DemographicDrape');
		return false;
	}
	
	// this is a valid drag box candidate so proceed
	attName = attributeInfo[0][3]; 
	attLabel= attributeInfo[0][3];
	
	// kill off any orphan vectors
	if (numberAtts == 0 ) 
	{	if (vectorLayer)
		{	vectorLayer.addOptions({'displayInLayerSwitcher': false});
			vectorLayer.setVisibility(false);
		}
		return false;
	}
	// this will generate the body of the report
	reportHolderId = 'featureInfo'; bodyId = 'gfiData';
	if(!generateReportGrid(ajaxRequest, reportHolderId, bodyId)){return false; }

	// display the report launcher button	
	document.getElementById("reportopen").style.display='block';

	// table sorting library
	//initTable("tableId");
	
	// highlight the collection and zoom to extent
	if(showHighlight)
	{
		genLoadStatus('Highlighting Results ...', true);
		var plotToBounds = false;
		// Now scan through all features adding every Coordinate to bounds if needed
		if(searchType != 'Whithin') 
		{	getBbox(features); 
			if(bounds){var plotToBounds = true;}
		}
		
		// Now highlight the collection via SLD  
		var len=features.length;
		if(features.length > 1) 
		{
			sqlStringParts = sqlString.split(","); 
			var len = sqlStringParts.length	
		}
		if(len <= sldLimit)
		{		
			if(!highlightCollection(serviceBase, dataStore, typeName, sqlString, sldTitleData, nameData, attName, attLabel)){return false;}
		}
		if(plotToBounds)
		{
			
			map.setCenter(bounds.getCenterLonLat(),map.getZoomForExtent(bounds)-1);
			map.updateSize();
			//document.getElementById("eventsLogID").style.display = 'block';
		}

	}
	
	// setup the link to the XML file request for downloading
    buildDownloadLinks('downloadLink');
	
	// echo out how many objects found
	var countMess = features.length+ ' Objects Returned';
	genLoadStatus(countMess, false);
	return true;
}
	
function buildDownloadLinks(holderId)
{	
	if(gfiParams != '')
	{
		var downloadSpan = document.getElementById(holderId);
		//gfiParams += "&GET_GEOMETRIES=FALSE";
		gfiParams += "&zip=true";
		gfiParams += '&savefile=tempXml_'+new Date().getTime()+'.xml';
		var fullink = meshBlocksBase+gfiParams
		
		// create the internal HTML code
		checkRemoveObject(holderId+':downDivIdXml');
		var divEle = document.createElement('div');
		divEle.id = holderId+':downDivIdXml';
		divEle.setAttribute('id',holderId+':downDivIdXml')
		divEle.style.cursor='pointer';
		divEle.style.position='absolute';
		divEle.style.top='0px';
		divEle.style.left='0px';
		divEle.style.width='200px';
		divEle.style.height='20px';
		divEle.style.fontSize='10px';
		divEle.style.color=	'#000';
		divEle.style.fontWeight='bold';
		divEle.style.fontFamily='verdana';
		divEle.title='Click to download a ZIP-file version of GML formatted data';
		var aEle = document.createElement('a');
		aEle.href=fullink;
		aEle.setAttribute('href', fullink) ;
		aEle.target = '_blank';
		aEle.setAttribute('target','_blank');
		var textNode = document.createTextNode('Download GML File');
		aEle.appendChild(textNode);
		divEle.appendChild(aEle);
		downloadSpan.appendChild(divEle);

		// also build a link for the csv file download
		gfiParams += "&zip=true";
		gfiParams += '&savefile='+newCsvFile;
		//var fullink = meshBlocksBase+gfiParams
		
		checkRemoveObject(holderId+':downDivIdCsv');
		var divEle = document.createElement('div');
		divEle.id = holderId+':downDivIdCsv';
		divEle.setAttribute('id',holderId+':downDivIdCsv')
		divEle.style.cursor='pointer';
		divEle.style.position='absolute';
		divEle.style.top='0px';
		divEle.style.left='200px';
		divEle.style.width='200px';
		divEle.style.height='20px';
		divEle.style.fontSize='10px';
		divEle.style.fontFamily='verdana';
		divEle.style.color=	'#000';
		divEle.style.fontWeight='bold';
		divEle.title='Click to download a ZIP-file version of CSV formatted attribute data only';
		var aEle = document.createElement('a');
		aEle.href =  applicationBase+'inc/'+newCsvFile;
		aEle.setAttribute('href', applicationBase+'inc/'+newCsvFile) ;
		aEle.target = '_blank';
		aEle.setAttribute('target','_blank');
		var textNode = document.createTextNode('Download CSV File');
		aEle.appendChild(textNode);
		divEle.appendChild(aEle);
		downloadSpan.appendChild(divEle);
	}
}	
	
function generateReportGrid(ajaxRequest, reportHolderId, tableId)
{
	// get the attribute values for each attribute requested in the report
	// First parse the resultant xml delivered DOM object
	if (!ajaxRequest.responseXML.getElementsByTagName("FeatureCollection"))
		{	alert("no featureCollection returned in XML"); return false;}
	var featureCollection = ajaxRequest.responseXML.getElementsByTagName("FeatureCollection");
	if (featureCollection.length == 0) {alert("Zero features found"); return false;}
	var featureSet = featureCollection[0].getElementsByTagName("FeatureSet");
	if (featureSet.length == 0) {alert("No Features in XML"); return false;}
	var typename = featureSet[0].getAttribute('name');
	var definition = featureSet[0].getElementsByTagName("Properties");
	var properties = definition[0].getElementsByTagName("Property");
	features = featureSet[0].getElementsByTagName("Feature");
	//alert('no of features = '+features.length);

	// Create the report table
	//alert(reportHolderId)
	featureInfoObj = document.getElementById(reportHolderId);
	checkRemoveObject(tableId);
	var tableHolder = document.createElement('table');
	tableHolder.style.border='1px solid gray';
	tableHolder.style.minWidth = '100%';
	tableHolder.style.width = 'auto';
	tableHolder.style.height = 'auto';
	tableHolder.style.textAlign = 'center';
	tableHolder.style.backgroubdColor = '#FFFFFF';
	tableHolder.id = tableId;
	tableHolder.setAttribute('id', tableId);

	var table = document.createElement('tbody');	
	table.style.zIndex = '5600';
	table.style.backgroundColor='#ffffff';

	// initialise any summing variables
	var footRequired = false;
	var summVals = [];
	summVals[0] = '';
	var headNames= [];  
	headNames[0] = 'count';
	var dataVals = [];
	
	// Set up the summation arrays
	for (var i=0; i<numberAtts ; i++)
	{
		if (attributeInfo[i][2] == 'true'){summVals[i+1] = 0; footRequired = true;}
		else {summVals[i+1] = ''}
		headNames[i+1] = attributeInfo[i][1];
	}

	// Now go and build the report header
	if(browser == 'msie') {addRow1(table, 'head', headNames, null)	;} 
	else{	addRow2(table, 'head', headNames, null)	;}
	
	// now build the header row of the csv file
	if(newCsvFile != ''){	deleteit(newCsvFile);	}
	newCsvFile = 'data/tempCsv_'+new Date().getTime()+'.csv';
	
	// send this request off to the server to create a new header section in a new SLD file
	var url = "cf/createcsvfile.cfm";
	var query = "file=/inc/"+newCsvFile;	
	query+= "&valArray="+headNames;
	makeFile(url, query, false, 'POST');
	
	// Now run through all the Features picking off attribute values	
	var propVal =  new Array();
	sqlString='';
	var totalPoints=0;
	var len1 = features.length;

	//loop thru all features to generate each row in report
	for (var b = 0; b < features.length; b++)
	{
		// report on the progress of the process
		var percentDone = Math.round(b/features.length*100);
		genLoadStatus(percentDone+'% Complete ...', true);
		
		// Get the Value object for this feature
		var propertyVals = features[b].getElementsByTagName('Value');
		if (propertyVals.length == 0 ){return false;}
		
		// scan through each type of Property Value for this feature	
		var len2 = propertyVals.length
		for (var c = 0; c < propertyVals.length ; c++)
		{	
			// skip past GEOMETRY attribute for reports
			if (properties[c].getAttribute("name") != 'GEOMETRY')
			{
				//look in the report attribute IDs to find this property
				var len3 = attributeInfo.length;
				propVal[0]=b+1;
				for (var k=0; k < len3; k++)
				{
					
					var requestedAttribute = attributeInfo[k][3];
					if(properties[c].getAttribute("name") == requestedAttribute)
					{	
						// now get the value into a reporting array
						var dataType = properties[c].getAttribute("type");
						var linkit = false;
						if (dataType == 'double' || dataType == 'integer') 
						{	
							var tempval = parseFloat(propertyVals[c].firstChild.nodeValue);	
							propVal[k+1] = Math.round(tempval*1000)/1000;

							// sum the value if required
							if (attributeInfo[k][2] == 'true')
							{	
								var tempval = summVals[k+1] + propVal[k+1];	
								summVals[k+1] = Math.round(tempval*1000)/1000;
							}
						}
						else
						{	
							if(propertyVals[c].firstChild) 
							{	
								var temp = propertyVals[c].firstChild.nodeValue.replace(/,/g, ""); // remove commas
								// check if attribute value is a link
								var linkLook = temp.split('//');
								if(linkLook.value == 2){linkit=true;}
								//alert(propVal[k+1]+' linkit = '+linkit)
								propVal[k+1] = temp;
							}
						}
						
						
						// check if this attribute is required as a filter in SLD file
						if (attributeInfo[k][4] == 'true')// requires the xml control file filter attribute to be present
						{
						//	alert ("adding to sqlString")
							if (b == 0){sqlString = propVal[k+1];}
							else {sqlString += ","+propVal[k+1];}
						}
						break;
					}
				}
			}
		}
		// write out the row into the table report
		if(browser == 'msie') {addRow1(table, 'data', propVal, null)	;} 
		else{	addRow2(table, 'data', propVal, null)	;}

		//now add this row to the csv file
		var query = "file=/inc/"+newCsvFile;
		query+= "&valArray="+propVal;
		makeFile(url, query, false, 'POST');
	}

	// write out the footer if required
	if (footRequired)
	{
		if(browser == 'msie') {addRow1(table, 'foot', summVals, null)	;} 
		else{	addRow2(table, 'foot', summVals, null)	;}
	}
	tableHolder.appendChild(table)
	featureInfoObj.appendChild(tableHolder);
	return true;
}

//---------------------------------- generic listing function -------------------------------------------
function listIt(ajaxRequest, feature, serviceBase, dataStore, typeName)
{
	// if this is a temporary edited SLD file strip back to real file in control file
	var SLD = currentSldFile
	var fileParts = currentSldFile.split('_new');
	if(fileParts.length > 1)
	{	SLD = fileParts[0]+'.xml';	}

	// get the attribute contents for each attribute requested in the roport
	// First parse the resultant xml delivered DOM object
	if (!ajaxRequest.responseXML.getElementsByTagName("FeatureCollection"))
		{alert("no featureCollection returned in XML"); return false;}
	var featureCollection = ajaxRequest.responseXML.getElementsByTagName("FeatureCollection");

	//alert('collection length = '+featureCollection.length)
	if (featureCollection.length == 0) {alert("Zero features found"); return false;}
	var featureSet = featureCollection[0].getElementsByTagName("FeatureSet");

	//alert ('number in featureSet = '+featureSet.length)
	if (featureSet.length == 0) {alert("No Features in XML"); return false;}
	var typename = featureSet[0].getAttribute('name');
	
	var definition = featureSet[0].getElementsByTagName("Properties");
	var properties = definition[0].getElementsByTagName("Property");
	var features = featureSet[0].getElementsByTagName("Feature");

	
	if (features.length == 0) {alert("No Features in XML"); return false;}
	
	// Now run through all the Features picking off attributes	
	var sqlString = '';	
	var len1 = features.length

	// process each feature caught in GetFeature request return
	for (var b = 0; b < len1; b++)
	{		
		// report on the progress of the process
		var percentDone = Math.round(b/features.length*100);
		genLoadStatus(percentDone+'% Complete ...', true);
		
		//alert('processing feature No : '+b)
		var tempcontent = new Array();
		var propertyVals = features[b].getElementsByTagName('Value');
		if (propertyVals.length == 0 ){return false;}
		var len2 = properties.length;

		// now save all the PropertyDefs and PropertyVals into the collection/reporting arrays	
		var gotone=false;
		for (var xx=0; xx<len2; xx++)
		{
			if(properties[xx].getAttribute('name') == 'GEOMETRY')
			{
				defs[xx] = properties[xx].getAttribute('name');
				tempcontent[xx] = '';
			}
			else
			{
				defs[xx] = properties[xx].getAttribute('name');
				tempcontent[xx] = propertyVals[xx].firstChild.nodeValue;
				tempcontent[xx] = tempcontent[xx].replace(/,/g, "");	
			}	
		}
		
		// save temp local array to global array
		content = tempcontent
		
		// add this polygon to the collection
		addPolygonToCollection(tempcontent[1], true);		
	}
		
	return; 
}


//--------------- gets the bounding box of all DOM features by scanning through the geometry-----------------------
function getBbox(features)
{
	// Now scan through all features adding every Coordinate to bounds
	var prefix='gml:';
	if ((browser =='firefox' && version == '2') || (browser == 'safari'))
		{	prefix='';	}
	var pt = []; var bound =null;
	var loLat=999999999; var hiLat=-999999999; var loLng=99999999; var hiLng=-99999999;
	var points = '';
	//alert('prefix = '+prefix)
	
	var len1 = features.length;
	for (var b = 0; b < len1; b++)
	{
		// get the exterior elements only
		var element0 = prefix+'exterior';
		var exterior = features[b].getElementsByTagName(element0);
		//alert("Number of exterior elements = "+exterior.length);
		var len2 = exterior.length ;
		for (var b1=0; b1 < len2 ; b1++)
		{
			// get geometry within exterior elements only
			var element1 = prefix+'LinearRing'
			var linearRing = exterior[b1].getElementsByTagName(element1);
			//alert("feature No = "+b+" exterior No = "+b1)
			//alert("Number of geometry objects in exterior element = "+linearRing.length)
			for (c = 0; c < linearRing.length; c++)
			{
				// get each linearRing from gml object
				var element2 = prefix+'posList'; 
				//alert('element2 = '+element2);
				var posList = features[b].getElementsByTagName(element2);
				//alert("number of PosList = "+posList.length)
				var len3 = posList.length;
				for (var dd = 0; dd < len3; dd++)
				{
					if (browser =='firefox') { var points = posList[dd].textContent;} // handles 4096 byte limit in FF for variables
					else {	 var points = posList[dd].firstChild.nodeValue;}
					//alert('points string = '+points)
					pt = points.split(" ");
					//alert('No of ordinates = '+pt.length)
					var len4 = pt.length ;
					for (var ec = 0; ec < len4 ; ec=ec+2)
					{
						var lat = pt[ec+1]; 
						var lng = pt[ec];
						//alert(lat+", "+lng);
							// calculate bounding box of coords	
							if (lat < loLat) {loLat=lat;}
							if (lat > hiLat) {hiLat=lat;}
							if (lng < loLng) {loLng=lng;}
							if (lng > hiLng) {hiLng=lng;}

							//alert(" e = "+e+" coords = "+lat+", "+lon)
							//adjustBoundsExtent(lat, lng, ec);
							//bounds = new OpenLayers.Bounds(loLng,loLat,hiLng,hiLat);
					}
				}
				
			}
		}
	}
	//alert (loLng+", "+loLat+" "+hiLng+", "+hiLat)
	// centre the map over the collection of parcels
	bounds = new OpenLayers.Bounds(loLng,loLat,hiLng,hiLat);
	//alert(bounds.getCenterLonLat());
	//alert(map.getZoomForExtent(bounds))
	//map.setCenter(bounds.getCenterLonLat(),map.getZoomForExtent(bounds)-1);
	//map.updateSize();

}
// add a row to the report for Firefox clients
function addRow1(reportObj, recType, array, link)
{
	// add this object as a report line for Firefox clients
	var row = document.createElement('tr');
	var type='td';
	if (recType == 'head') {var type = 'th'}
	var colPercent = 100/parseInt(array.length);
	writeReportLine(reportObj, recType, array, colPercent, type, row, link);
}

// add a row to the report for IE clients
function addRow2(reportObj, recType, array, link)
{	
	// set up header, body and footer sections of report
	if (recType == 'head') 
	{
		var header = document.createElement('thead');
		reportObj.appendChild(header);
	}
	else if (recType == 'data')
	{
		var body = document.createElement('tbody');
		reportObj.appendChild(body);
	}
	else if (recType == 'foot') 
	{
		var footer = document.createElement('tfoot');
		reportObj.appendChild(footer);
	}

	// add the row and its table cell elements
	var row = document.createElement('tr');
	var type='td';
	if(recType == 'head'){	var type = 'th';	}
	var colPercent = 100/parseInt(array.length);
	writeReportLine(reportObj, recType, array, colPercent, type, row, link);

}

function writeReportLine(reportObj, recType, array, colPercent, type, row, link)
{
	// create the header row
	for( var j=0; j < array.length; j++)
	{
		// create each columns cell and populate it
		var cell = document.createElement(type);
		cell.style.fontSize='9px';
		cell.style.fontFamily='Verdana';
		
		var cellText = document.createTextNode(array[j]); 
		cell.appendChild(cellText);
		cell.style.fontWeight = 'normal';
		
		// check for attribute link on this row
		if(link != null)
		{
			var parts = link.split(':');
			if(j==parts[1])
			{
				var linkFunct = parts[3]; // decoding this = 'terr:0:showTerritory:'+folder+territoryFileName; 
				cell.id = linkFunct;
				cell.setAttribute('id',linkFunct);
				if(territoryFlag && parts[0] == 'terr')	{ bindEvent(cell, 'click', terrLink, 'false');}
				if(ddrapesFlag && parts[0] == 'ddrap')	{ bindEvent(cell, 'click', drapeLink, 'false');}
				cell.style.fontWeight = 'bold';
				cell.style.textDecoration='underline';
				cell.style.cursor='pointer';
			}
		}
				
		// dress up cell appropriately
		var colPer = colPercent+"%";
		cell.style.width = colPer;
		cell.style.border = '1px solid #b4b4b4';
		cell.style.backgroundColor='#E1E1E1';
		if (recType == 'head' || recType == 'foot') 
		{
			cell.style.fontWeight='bold'; 
			cell.style.border='2px solid gray';
			cell.style.backgroundColor='#d2d2d2';
		} 
		row.appendChild(cell);
	}
	reportObj.appendChild(row);
}
function terrLink(evt)
{
	var e_out = getThisId(evt)
	showTerritory(e_out);
	document.getElementById('listTerr').title='Show Report';
	Event.stop(evt);
}
function drapeLink(evt)
{
	var e_out = getThisId(evt)
	// need the specific function here
	Event.stop(evt);
}