<!--

	// FUNCTIONS --------------------------------------------------------
	
	// Creates a marker and associated info window from WGS84 coordinates.
	function createGeoTabMarker(lon, lat, icon, infoTabs) {
	  // Create a marker at the location specified, using the specified icon
	  var point = new GLatLng(lat, lon);	
	  var marker = new GMarker(point, icon);
	  // Add marker properties to the object for later use
	  marker.x = lon;
	  marker.y = lat;
	  marker.infoTabs = infoTabs;
	  // Show this marker's associated HTML in the info window when it is clicked.
	  GEvent.addListener(marker, 'click', function() {
		marker.openInfoWindowTabsHtml(infoTabs);
		resizeCallout();
	  });
	  return marker;
	}
	
	function resizeCallout(){
		var container = document.getElementById('infopanel-desc');
		container.parentNode.parentNode.parentNode.style.position = 'absolute';
		container.parentNode.parentNode.parentNode.style.width = '250px';
		container.parentNode.parentNode.parentNode.style.height = '130px';
		container.parentNode.className = 'infopanelIE6';	
	}
	

	// Scrolls and zooms map to a specific marker (based on an 'id' variable) and opens it's tab info window
	function openTabMarker(markers, index, zoom){
				var i
				for (i in markers)
				{
					if(markers[i].id == index) {
						var infoTabs = markers[i].infoTabs;
						map.setCenter(new GLatLng(parseFloat(markers[i].y), parseFloat(markers[i].x)), parseFloat(zoom), G_NORMAL_MAP);
						markers[i].openInfoWindowTabsHtml(infoTabs);
						resizeCallout();
					}
				}
	}
	
	// Build the search result list on the rhs
	function showResults(list, page, maxradius, postcode, session, pagesize, rowcount, searchState, sessionStr, rootID){
		//alert(postcode);
		//alert(session);
		
		var radius = 2;
		if(checkSession){
			radius = 5;
		}
		
		var pSize = pagesize;
		var pCount = Math.ceil(rowcount/pSize);
		var pStart = (pSize*(page-1));
		
		var lTitle = 'Search Results';
		if(maxradius){
			lTitle = 'From house to house';
		}
		
		var strResult = '<h1>'+lTitle+'</h1><dl>';
		if(maxradius){
			var strResult = strResult + '<p>Get directions to other buildings in the local area.</p>';
		}
		
		//show the total - added by juice 2009 08 11
		if (rowcount != 1) {strResult += '('+rowcount +' matches found)';}
		else {strResult += '(1 match found)';}

		if(list.length < 1){
			strResult = strResult + '<p>Sorry, there are no buildings that match your search.</p>';
		}


		// Build the results
		
		for(var i=0; i < list.length; i++){	
			if(!maxradius || rootID	!= list[i][0]){
				//&& (postcode.toLowerCase() != list[i][6].toLowerCase())
				var mileage = ""
				if(postcode != 'false'){
					mileage = '(<em>'+list[i][4]+' miles</em>)';
				}
				
				var strDetail, strLocate;
				
				if(maxradius){
					strDetail = 'detail.asp?loh_id='+list[i][0]+'&postcode='+list[i][6];
					strLocate = 'map.asp?loh_id='+list[i][0]; //+'&radius='+radius+'&postcode='+list[i][6];
					if(session){
						if(session[0] != ''){
							strLocate = strLocate + '&period='+session[0];
							strDetail = strDetail + '&period='+session[0];
						}
						if(session[1] != ''){
							strLocate = strLocate + '&building='+session[1];
							strDetail = strDetail + '&building='+session[1];
						}
						if(session[2] != ''){
							strLocate = strLocate + '&architect='+session[2];
							strDetail = strDetail + '&architect='+session[2];
						}
						if(session[3] != ''){
							strLocate = strLocate + '&resident='+session[3];
							strDetail = strDetail + '&resident='+session[3];
						}
						if(session[4] != ''){
							strLocate = strLocate + '&activities='+session[4];
							strDetail = strDetail + '&activities='+session[4];
						}
						if(session[5] != ''){
							strLocate = strLocate + '&day='+session[5];
							strDetail = strDetail + '&day='+session[5];
						}
						if(session[6] != ''){
							strLocate = strLocate + '&wheelchair='+session[6];
							strDetail = strDetail + '&wheelchair='+session[6];
						}
						if(session[7] != ''){
							strLocate = strLocate + '&name='+session[7];
							strDetail = strDetail + '&name='+session[7];
						}
						if(session[8] != ''){
							strLocate = strLocate + '&greenbuild='+session[8];
							strDetail = strDetail + '&greenbuild='+session[8];
						}
						if(session[9] != ''){
							strLocate = strLocate + '&advanced='+session[9];
							strDetail = strDetail + '&advanced='+session[9];
						}
					
					}
				}else{
					strDetail = 'javascript:openTabMarker(buildingMarkers,'+list[i][0]+','+map.getZoom()+');';
					strLocate = 'javascript:openTabMarker(buildingMarkers,'+list[i][0]+',17);';
				}
				strResult = strResult+'<dt><a href="'+strDetail+'" accesskey="" tabindex="">'+list[i][1]+'</a> '+mileage+'</dt>';
				strResult = strResult+'<dd>'+list[i][5];
				if(maxradius){
					/*
					var objDate = new Date();
					var yrMonth = objDate.getFullYear();
					if ((objDate.getMonth()+1) < 10){
						yrMonth = yrMonth + '0' + (objDate.getMonth()+1);
					}else{
						yrMonth = yrMonth + '' + (objDate.getMonth()+1);
					}
					*/
					var yrMonth = '200709';
					var dayofMonth = document.getElementById('date').value;
					var myTLF = 'http://journeyplanner.tfl.gov.uk/user/XSLT_TRIP_REQUEST2?name_origin='+postcode+'&itdTripDateTimeDepArr=dep&itdDateDay='+dayofMonth+'&itdDateYearMonth='+yrMonth+'&itdTimeHour=9&itdTimeMinute=0&language=en&execInst=&sessionID=0&ptOptionsActive=-1&place_origin=London&place_destination=London&type_origin=locator&type_destination=locator&name_destination='+list[i][6]+'&itdDateYearMonth='+yrMonth+'&itdTripDateTimeDepArr=dep';
				
					strResult = strResult+'<br /><a href="'+strLocate+'" accesskey="" tabindex="">Locate on the map</a> | <a href="'+myTLF+'" target="_blank" accesskey="" tabindex="">Plan my journey</a>';
				}else{
					strResult = strResult+'<br /><a href="'+strLocate+'" accesskey="" tabindex="">Street-level view</a>';
				}
				strResult = strResult+'</dd>';
			}
		}
		strResult = strResult + "</dl>";
		
		// Build paging navigation
		var paging = '<ul class="pagination">'
		for (var k=0; k < pCount; k++){
			paging = paging + '<li><a accesskey="" tabindex="" ';
			if(k == (page-1)){
				paging = paging + 'class="active" href="#">';
			}else{
				//paging = paging +  'href="javascript:showResults(buildingDetails,'+(k+1)+','+maxradius+',\''+postcode+'\',session,'+pSize+','+rowcount+')">';
				if(maxradius){
					paging = paging + 'href="javascript:loadDetail('+searchState+', \''+sessionStr+'\','+(k+1)+','+rootID+');">';
				}else{
					paging = paging + 'href="javascript:load('+(k+1)+');">';
				}
			}
			
			var count = k;
			if((count+1) < 10){
				count = '0'+(count+1);
			}else{
				count++;
			}
			paging = paging+count+'</a></li> ';
			if ((k+1)%8 < 1 && k > 0){
			//	paging = paging + '<br /><div class="spacer"></div>'; -- Removed by Evert, Cant have br's and divs in a ul tag!
			}
		}
		paging = paging + '</ul>';
		
		if(list.length < 2 && maxradius && pCount < 2){
			paging = '<p>Sorry, there are no local buildings that match this search.</p>'
		}
		strResult = strResult + paging;
		
		// Insert results into page
		document.getElementById('resultList').innerHTML = strResult;
	
	}

//-->