	//Map Specific
	var map = new GMap2(document.getElementById("map"));
	map.enableDoubleClickZoom(); 
	map.addControl(new GOverviewMapControl());
	var icon				= new GIcon();
	var iconVisited			= new GIcon();
	var iconNew				= new GIcon();
	var iconNewVisited		= new GIcon();
	var iconSold			= new GIcon();
	var iconSoldVisited		= new GIcon();
	var iconNewSold			= new GIcon();
	var iconNewSoldVisited	= new GIcon();
	var iconBranch			= new GIcon();
	var iconSchool			= new GIcon();
	var iconSchoolVisited	= new GIcon();
	var iconStation			= new GIcon();
	var strForm				= "";

	//var strIncomingType			= document.getElementById('mType').value
	//var intIncomingBedrooms		= document.getElementById('mBedrooms').value
	//var intIncomingPriceMin		= document.getElementById('mPriceMin').value
	//var intIncomingPriceMax		= document.getElementById('mPriceMax').value
	//var intIncomingPriceRentMin	= document.getElementById('mPriceRentMin').value
	//var intIncomingPriceRentMax	= document.getElementById('mPriceRentMax').value
	//var strIncomingKeywords		= document.getElementById('mKeywords').value

	/*var clusterer = new Clusterer( map );*/

	//Site Specific
	//var ran_number = document.getElementById('mLocation').value;
	//var ran_number = 1;

	//var ran_unrounded=Math.random()*3;
	//var ran_number=Math.round(ran_unrounded) + 1;
	//var ran_unrounded;
	//var ran_number;
	
	if (document.getElementById('fIncomingLocation').value == 'no')
	{var ran_unrounded=Math.random()*3;
	var ran_number=Math.round(ran_unrounded) + 1;
	}
	else
	{var ran_number = document.getElementById('mLocation').value;
	//var ran_number=document.getElementById('fIncomingLocation').value;
	}

	var arrLng= new Array;
	var arrLat= new Array;
	var arrZoomLevel = new Array;

	arrLng[1]		= -1.51239;		//Coventry City
	arrLat[1]		= 52.406097;	// 
	arrZoomLevel[1] = 14;			// 
	arrLng[2]		= -1.532882;	//Earlsdon
	arrLat[2]		= 52.398439;	//
	arrZoomLevel[2] = 14;			//
	arrLng[3]		= -1.578544;	//Kenilworth
	arrLat[3]		= 52.339322;	//
	arrZoomLevel[3] = 13;			//
	arrLng[4]		= -1.534545;	//Leamington
	arrLat[4]		= 52.288375;	//
	arrZoomLevel[4] = 14;			//
	arrLng[5]		= -1.587675;	//Warwick
	arrLat[5]		= 52.281695;	//
	arrZoomLevel[5] = 13;			//
	arrLng[6]		= -1.51239;		//Coventry North
	arrLat[6]		= 52.432097;	// 
	arrZoomLevel[6] = 13;			// 
	arrLng[7]		= -1.540882;	//Coventry West
	arrLat[7]		= 52.406097;	// 
	arrZoomLevel[7] = 14;			// 
	arrLng[8]		= -1.45539;		//Coventry East
	arrLat[8]		= 52.406097;	// 
	arrZoomLevel[8] = 13;			// 
	arrLng[9]		= -1.51239;		//Coventry South
	arrLat[9]		= 52.396097;	// 
	arrZoomLevel[9] = 14;			// 

	var propLink		= "/brianh/propertythumb.asp?propertyID=";
	var schoolLink		= "/brianh/schoolthumb.asp?schoolID=";
	var branchLink		= "/brianh/branchthumb.asp?branchID=";
	var intLng			= arrLng[ran_number];
	var intLat			= arrLat[ran_number];
	var intZoomLevel	= arrZoomLevel[ran_number];
	
	//var currLocation = map.setCenter(new GLatLng(intLat, intLng), 14);
	var currLocation = map.setCenter(new GLatLng(intLat, intLng), intZoomLevel);
	var currLocationLng = arrLng[ran_number];
	var currLocationLat = arrLat[ran_number];
	var currZoomLevel = map.getZoom();
	var ZoomLevelControl = map.getZoom();


	document.getElementById('mLocation').value = ran_number;
	//document.getElementById('mLocation').value = 4;
	
	function branches() {
		var point = new Array();
		var link = new Array();
		point[0] = new GPoint("-1.51239", "52.406097");  //Coventry City
		link[0] = "1";
		point[1] = new GPoint("-1.532882", "52.398439"); //Earlsdon
		link[1] = "2";
		point[2] = new GPoint("-1.578544", "52.342222"); //Kenilworth
		link[2] = "3";
		point[3] = new GPoint("-1.534545", "52.288375"); //Leamington
		link[3] = "4";

		for (i=0; i<4; i++)
		{
			branchMarker(point[i],link[i]);
		}

		return;
	}
  
	function showProp(propID, PropertyAddress) {
		document.getElementById('property').style.display = "block";
		document.getElementById('school').style.display = "none";
		document.getElementById('branch').style.display = "none";
		document.getElementById('propLink').innerHTML = '&nbsp;&nbsp;<a href="Javascript:propertyDetails('+propID+', %22'+PropertyAddress+'%22);">View Full Details</a>';
		document.getElementById('propframe').src = propLink + propID;
	}

	function showSchool(schoolID, SchoolAddress) {
		document.getElementById('school').style.display = "block";
		document.getElementById('property').style.display = "none";
		document.getElementById('branch').style.display = "none";
		document.getElementById('schoolLink').innerHTML = '<a href="Javascript:schoolDetails('+schoolID+', %22'+SchoolAddress+'%22);">&nbsp;&nbsp;&nbsp;View School Details</a>';
		document.getElementById('schoolframe').src = schoolLink + schoolID;
	}

	function showBranch(branchID) {
		document.getElementById('school').style.display = "none";
		document.getElementById('property').style.display = "none";
		document.getElementById('branch').style.display = "block";
		document.getElementById('branchLink').innerHTML = '<a href="Javascript:branchDetails('+branchID+', %22);">&nbsp;&nbsp;&nbsp;View Branch Details</a>';
		document.getElementById('branchframe').src = branchLink + branchID;
	}

	function markAsViewed(mapMarker, propID, point, status, PropertyNew, PropertyAddress) {
		map.removeOverlay (mapMarker);
		if (status == 3 || status == 2)
		{
			if (PropertyNew == 1)
			{
				var mapMarkerNew = new GMarker(point, iconNewSoldVisited, 0);
			}
			else
			{
			var mapMarkerNew = new GMarker(point, iconSoldVisited, 0);
			}
		}
		else
		{
			if (PropertyNew == 1)
			{
				var mapMarkerNew = new GMarker(point, iconNewVisited, 0);
			}
			else
			{
			var mapMarkerNew = new GMarker(point, iconVisited, 0);
			}
		}
		map.addOverlay(mapMarkerNew);
		GEvent.addListener(mapMarkerNew, "click",
			function() {
				showProp(propID, PropertyAddress);
			}
		);
		return;
	}
	
	function addMarker(point, propID, status, PropertyNew, PropertyAddress) {
		if (status == 3 || status == 2)
		{
			if (PropertyNew == 1)
			{
				var mapMarker = new GMarker(point, iconNewSold, 0);
			}
			else
			{
			var mapMarker = new GMarker(point, iconSold, 0);
			}
		}
		else
		{
			if (PropertyNew == 1)
			{
				var mapMarker = new GMarker(point, iconNew, 0);
			}
			else
			{
			var mapMarker = new GMarker(point, icon, 0);
			}
		}
		map.addOverlay(mapMarker);
		/*Clusterer.AddMarker(mapMarker, "fred" )*/
		GEvent.addListener(mapMarker, "click",
			function() {
				markAsViewed(mapMarker, propID, point, status, PropertyNew, PropertyAddress);
				showProp(propID, PropertyAddress);
			}
		);
		return;
	}

	function addSchoolMarker(point, SchoolID, SchoolName) {
		var mapSchoolMarker = new GMarker(point, iconSchool, 0);
		map.addOverlay(mapSchoolMarker);
		/*Clusterer.AddMarker(mapMarker, "fred" )*/
		GEvent.addListener(mapSchoolMarker, "click",
			function() {
				markAsSchoolViewed(mapSchoolMarker, point, SchoolID, SchoolName);
				showSchool(SchoolID, SchoolName);
			}
		);
		return;
	}

	function markAsSchoolViewed(mapSchoolMarker, point, SchoolID, SchoolName) {
		map.removeOverlay (mapSchoolMarker);
		var mapSchoolMarker = new GMarker(point, iconSchoolVisited, 0);
		map.addOverlay(mapSchoolMarker);
		GEvent.addListener(mapSchoolMarker, "click",
			function() {
				showSchool(SchoolID, SchoolName);
			}
		);
		return;
	}

	function addStationMarker(point, StationID, StationName) {
		var mapStationMarker = new GMarker(point, iconStation, 0);
		map.addOverlay(mapStationMarker);
		/*Clusterer.AddMarker(mapMarker, "fred" )*/
		//GEvent.addListener(mapStationMarker, "click",
		//	function() {
		//		markAsSchoolViewed(mapSchoolMarker, point, SchoolID, SchoolName);
		//		showSchool(SchoolID, SchoolName);
		//	}
		//);
		return;
	}

	function branchMarker(point, link) {
		var mapMarker = new GMarker(point, iconBranch, 0);
		map.addOverlay(mapMarker);
		GEvent.addListener(mapMarker, "click",
			function() {
				showBranch(link);
		//		document.getElementById('branchLink').innerHTML = '';
		//		document.getElementById('branch').style.display = "block";
		//		document.getElementById('branchframe').src = link;
			}
		);
		return;
	}

	function getData(intLat, intLng, strTicks) {
		currLocationLng = intLng;
		currLocationLat = intLat;
		currZoomLevel = map.getZoom();
		ZoomLevelControl = currZoomLevel;

		if (ZoomLevelControl < 12)
		{ZoomLevelControl = 12
		}

		if (ZoomLevelControl == 17)
		{ZoomLevelControl = 16
		}

		document.getElementById('zoomlevel16').src = "_gfx/zoom/zoom_off16.png"
		document.getElementById('zoomlevel15').src = "_gfx/zoom/zoom_off15.png"
		document.getElementById('zoomlevel14').src = "_gfx/zoom/zoom_off14.png"
		document.getElementById('zoomlevel13').src = "_gfx/zoom/zoom_off13.png"
		document.getElementById('zoomlevel12').src = "_gfx/zoom/zoom_off12.png"
		document.getElementById('zoomlevel'+ ZoomLevelControl).src = "_gfx/zoom/zoom_on" + ZoomLevelControl + ".png"

		document.getElementById('loading').style.display = "block";
		document.getElementById('loaded').style.display = "none";
		//document.getElementById('property').style.display = "none";

		var request = GXmlHttp.create();
		var file = 'getData.asp?lng='+intLng+'&lat='+intLat+'&ticks='+strTicks+strForm;

		request.open("GET", file, true);
		request.onreadystatechange = function() {
		  if (request.readyState == 4) {
			var xmlDoc			= request.responseXML;
			var xmlData			= xmlDoc.documentElement.getElementsByTagName("marker");
			var xmlDataCount	= xmlDoc.documentElement.getElementsByTagName("DataCount");
			var xmlSchoolData	= xmlDoc.documentElement.getElementsByTagName("schoolmarker");
			var xmlStationData	= xmlDoc.documentElement.getElementsByTagName("stationmarker");

			document.getElementById('loading').style.display = "none";
			document.getElementById('toomany').style.display = "none";
			document.getElementById('loaded').style.display = "block";

			if (xmlDataCount.length > 0)
			{
			document.getElementById('loading').style.display = "none";
			document.getElementById('toomany').style.display = "block";
			document.getElementById('loaded').style.display = "none";
			}
			else
			{
			//document.getElementById('loading').style.display = "none";
			//document.getElementById('loaded').style.display = "block";
				//document.getElementById('loaded').innerHTML = "Properties Loaded";
				map.clearOverlays();
				branches();

				for (var i = 0; i < xmlData.length; i++) {
				  var point = new GPoint(parseFloat(xmlData[i].getAttribute("lng")),
										 parseFloat(xmlData[i].getAttribute("lat")));
				  var propID = parseFloat(xmlData[i].getAttribute("propID"));
				  var status = parseFloat(xmlData[i].getAttribute("status"));
				  var PropertyNew = parseFloat(xmlData[i].getAttribute("PropertyNew"));
				  var PropertyAddress = xmlData[i].getAttribute("PropertyAddress");
				  addMarker(point, propID, status, PropertyNew, PropertyAddress);
				}

				for (var i = 0; i < xmlSchoolData.length; i++) {
				  var point = new GPoint(parseFloat(xmlSchoolData[i].getAttribute("lng")),
										 parseFloat(xmlSchoolData[i].getAttribute("lat")));
				  var SchoolID = parseFloat(xmlSchoolData[i].getAttribute("SchoolID"));
				  var SchoolName = xmlSchoolData[i].getAttribute("SchoolName");
				  addSchoolMarker(point, SchoolID, SchoolName);

				}

				for (var i = 0; i < xmlStationData.length; i++) {
				  var point = new GPoint(parseFloat(xmlStationData[i].getAttribute("lng")),
										 parseFloat(xmlStationData[i].getAttribute("lat")));
				  var StationID = parseFloat(xmlStationData[i].getAttribute("StationID"));
				  var StationName = xmlStationData[i].getAttribute("StationName");
				  addStationMarker(point, StationID, StationName);

				}
			}
		  }
		}
		request.send(null);
		return;
	}

	function eventMoveStart() {
	}

	function eventMoveEnd() {
		var strTicks = map.getBounds();
		var center = map.getCenter();
		var zoom = map.getZoom()

		intZoomDiff = (currZoomLevel - zoom);
		intMovementX = Math.abs(center.x - currLocationLng);
		intMovementY = Math.abs(center.y - currLocationLat);

		if (intMovementX >= 0.03 || intMovementY >= 0.03)
		{
			getData(center.lng(), center.lat(), strTicks);
		}

		if (intZoomDiff <= -1)
		{
			getData(center.lng(), center.lat(), strTicks);
		}
		return;
	}

	function generateMap()
	{		
		icon.image = "_gfx/icons/house.png";
		//icon.shadow = "_gfx/marker_shadow.png";
		icon.iconSize = new GSize(31, 17);
		//icon.shadowSize = new GSize(45, 37);
		icon.iconAnchor = new GPoint(7, 15);
		//icon.infoWindowAnchor = new GPoint(23, 10);

		iconVisited.image = "_gfx/icons/houseVisited.png";
		//iconView.shadow = "_gfx/marker_shadow.png";
		iconVisited.iconSize = new GSize(31, 17);
		//iconView.shadowSize = new GSize(45, 37);
		iconVisited.iconAnchor = new GPoint(7, 15);
		//iconView.infoWindowAnchor = new GPoint(23, 10);

		iconNew.image = "_gfx/icons/housenew.png";
		//iconView.shadow = "_gfx/marker_shadow.png";
		iconNew.iconSize = new GSize(31, 20);
		//iconView.shadowSize = new GSize(45, 37);
		iconNew.iconAnchor = new GPoint(7, 15);
		//iconView.infoWindowAnchor = new GPoint(23, 10);

		iconNewVisited.image = "_gfx/icons/housenewvisited.png";
		//iconView.shadow = "_gfx/marker_shadow.png";
		iconNewVisited.iconSize = new GSize(31, 20);
		//iconView.shadowSize = new GSize(45, 37);
		iconNewVisited.iconAnchor = new GPoint(7, 15);
		//iconView.infoWindowAnchor = new GPoint(23, 10);


		iconSold.image = "_gfx/icons/housesold.png";
		//iconSold.shadow = "/map/_gfx/marker_shadow.png";
		iconSold.iconSize = new GSize(31, 17);
		//iconSold.shadowSize = new GSize(45, 37);
		iconSold.iconAnchor = new GPoint(7, 15);
		//iconSold.infoWindowAnchor = new GPoint(23, 10);

		iconSoldVisited.image = "_gfx/icons/housesoldvisited.png";
		//iconSold.shadow = "/map/_gfx/marker_shadow.png";
		iconSoldVisited.iconSize = new GSize(31, 17);
		//iconSold.shadowSize = new GSize(45, 37);
		iconSoldVisited.iconAnchor = new GPoint(7, 15);
		//iconSold.infoWindowAnchor = new GPoint(23, 10);

		iconNewSold.image = "_gfx/icons/housenewsold.png";
		//iconSold.shadow = "/map/_gfx/marker_shadow.png";
		iconNewSold.iconSize = new GSize(31, 20);
		//iconSold.shadowSize = new GSize(45, 37);
		iconNewSold.iconAnchor = new GPoint(7, 15);
		//iconSold.infoWindowAnchor = new GPoint(23, 10);

		iconNewSoldVisited.image = "_gfx/icons/housenewsoldvisited.png";
		//iconSold.shadow = "/map/_gfx/marker_shadow.png";
		iconNewSoldVisited.iconSize = new GSize(31, 20);
		//iconSold.shadowSize = new GSize(45, 37);
		iconNewSoldVisited.iconAnchor = new GPoint(7, 15);
		//iconSold.infoWindowAnchor = new GPoint(23, 10);

		iconBranch.image = "_gfx/icons/brianhBranchIcon.gif";
		//iconBranch.shadow = "_gfx/marker_shadow.png";
		iconBranch.iconSize = new GSize(34, 34);
		//iconBranch.shadowSize = new GSize(45, 37);
		iconBranch.iconAnchor = new GPoint(17, 17);
		//iconBranch.infoWindowAnchor = new GPoint(23, 10);

		iconSchool.image = "_gfx/icons/School.png";
		//iconSchool.shadow = "_gfx/marker_shadow.png";
		iconSchool.iconSize = new GSize(25, 22);
		//iconSchool.shadowSize = new GSize(45, 37);
		iconSchool.iconAnchor = new GPoint(17, 17);
		//iconSchool.infoWindowAnchor = new GPoint(23, 10);

		iconSchoolVisited.image				= "_gfx/icons/schoolvisited.png";
		//iconSchoolVisited.shadow			= "_gfx/marker_shadow.png";
		iconSchoolVisited.iconSize			= new GSize(25, 22);
		//iconSchoolVisited.shadowSize		= new GSize(45, 37);
		iconSchoolVisited.iconAnchor		= new GPoint(17, 17);
		//iconSchoolVisited.infoWindowAnchor = new GPoint(23, 10);

		iconStation.image = "_gfx/icons/train.png";
		//iconSchool.shadow = "_gfx/marker_shadow.png";
		iconStation.iconSize = new GSize(31, 19);
		//iconSchool.shadowSize = new GSize(45, 37);
		iconStation.iconAnchor = new GPoint(12, 10);
		//iconSchool.infoWindowAnchor = new GPoint(23, 10);

		//map.addControl(new GLargeMapControl());
		//map.addControl(new GSmallMapControl());
		//map.addControl(new GMapTypeControl());

		var strTicks = map.getBounds();

		GEvent.addListener(map, "movestart", eventMoveStart);
		GEvent.addListener(map, "moveend", eventMoveEnd);

		getData(intLat, intLng, strTicks);
		return;
	}

generateMap();
