def printDocuementStart():
    areaList = []
    areaIDList = []
    for area in areas:
        areaList.append(area['name'])
        areaIDList.append("<option value=" + str(area['area_id']) + ">" + area['name'] + "</option>")

    documentStart = """
		<html>
			<head>
				<meta charset="UTF-8">
				<title>Select an Area</title>
			</head>
			<body>
				<form method="get" action="/cgi-bin/location_table.py">
				<h2>Select an Area</h2>
				<select name="area_id" size="10" multiple>
		"""

    listEnding = """
	</select>
		<div style="text-align: center;">
	<input type="submit" value="Submit" />   
	</div>
		</form>
	</body>
	</html>
	"""
    print(KJM_HTML_Utility.htmlHeader("Select an Area"))

    print(documentStart)

    for i in areaIDList:
        print("\t" + i)
    print(listEnding)
def printErrorMSG(formV):
	theMsg =""
	
	if isinstance(formV, list):
		errorMSG  = ''' 
		You may only select a single value.
		<br><p>Form data received:\t{}</p>'''.format(formV)
		
	elif formV.isdigit():
		errorMSG  = ''' 
		The location ID doesn't match any locations in the database.
		<br><p>Form data received:\t{}</p>'''.format(formV)
	
	elif formV == 'None':
		errorMSG = ''' 
			No data was received. 
			<br><p>Form data received:\t{}
			</p>'''.format(formV)
		
	elif str(formV).isalpha() or str(formV).isalnum():
		errorMSG = ''' 
		Only numerical values can be used to query data. 
		<br>Form data received:\t{}<p>
		</p>'''.format(formV)
	
	else:
		errorMSG = '''
		The location ID doesn't match any locations in the database.
		<br><p>Form data received:\t{}
		</p>'''.format(formV)

	print(KJM_HTML_Utility.htmlHeader("Error"))

	print('''
		<body> <form method="post" action="/cgi-bin/area_selection.py"><h2>''')
	print(errorMSG)
		
	print('''
		</h2></select>
			''')
	print('''
		<div style="text-align: center;">
		<input type="submit" value="formAreaID"/>
		</body>
		</html>
		''')	
	formAreaID = form.getvalue('area_id')

	if formAreaID is None:
		printErrorMSG('NoneType')
		
	elif isinstance(formAreaID, list):
		printErrorMsg(formAreaID)
		
	elif not db_access.get_area_by_id(formAreaID):
		printErrorMSG(formAreaID)
		
# ------------------------------------| HTML Page start |------------------------------------
	else:
		selectedArea = db_access.get_area_by_id(formAreaID)
				
		print(KJM_HTML_Utility.htmlHeader("Selected Area"))
		print('''
		<body>
		''')

		theAreaName = str()
		theAreaID = 0

		for i in selectedArea:
			theAreaName = i['name']
			theAreaID = i['area_id']
			print("<h1>Location information for " + theAreaName +"</h1>")
			
		area_locations = db_access.get_locations_for_area(theAreaID)
		if area_locations:
			# create a table for the location
		<th>ID</th>
		<th>Area Name</th>
		<th># of Locations</th>
		<th>Avg Value</th>
		<th>Category</th>
	  </tr>
      </thead>
        
       <tbody>
				""");
    return tableHeaderRowString



# ------------------------------------| Pretty Print |----------------------------------------------
print(KJM_HTML_Utility.htmlHeader("Area Table"))
print(getTableHeaderRow())

for area in areas:
    
    area_id = area['area_id']
    area_location = db_access.get_locations_for_area(area_id)
    area_category = db_access.get_categories_for_area(area_id)
    avgMeasurementString = str(db_utility.get_average_measurements_for_area(area_id))

    if not db_utility.get_average_measurements_for_area(area_id):
        avgMeasurementString = '--------'

    rowList = [area_id, area['name'], len(area_location), avgMeasurementString[1:5], getCategoryString(area_category)]

    for i in KJM_HTML_Utility.createTableFromList(rowList):