<!--var map;var geoxml;var othershape;var otherArray;var goverlays;var kmlFile;var geoArray;var directions;function doSearch(terms) {	//alert(terms);	ur = server_root+'search.php?search_type=normal&'+terms;	$('#searchresults').load(ur);	tabSet.tabs("enable", 1);	tabSet.tabs("select", 1);}function showDirections(key) {	//takes 2 latlngs as args	//alert(key);	//clear();	pinLoc = pins[key].getLatLng()	//alert (pinLoc);	from = 'shortland st, auckland';	//directions.clear();	//directions.clear();	dirStr = "from: " + from +  " to: " + pinLoc.lat() + "," + pinLoc.lng();	//alert (dirStr);	directions.load( dirStr );	GEvent.addListener(directions, "load", writeDirs);//GEvent.addListener(directions, "error", deBug);}function writeDirs() {	//alert ("s" + directions.getSummaryHtml());	//alert ("d" + directions.getDistance().html);	//alert ("du" + directions.getDuration().html );	infoPanel();}function deBug() {	alert (directions.getStatus());}function addLayer(layer, return_type, dynamic_load, zoomTo) {	//alert(zoomTo);	return_type = typeof(return_type) != 'undefined' ? return_type : json_kml_switch;	dynamic_load = typeof(dynamic_load) != 'undefined' ? dynamic_load : false;	zoomTo = typeof(zoomTo) != 'undefined' ? zoomTo : false;	if(dynamic_load){		$.ajax({			url: server_root+'search.php?search_type=json_only&'+layer,			dataType: "json",			success: function(data) {				geojson2google(data,'dynamic',dynamic_load);			},			error: function(XMLHttpRequest, textStatus, errorThrown){}		});	}else if(return_type == 'json'){		$.ajax({			url: server_root+'search.php?search_type=json_only&'+layer,			dataType: "json",			success: function(data) {				geojson2google(data,'json_temporary',dynamic_load);				if (zoomTo) {					zoomToMarkers();				}			},			error: function(XMLHttpRequest, textStatus, errorThrown){}		});	}else if(return_type == 'json_reset' || $('#searchresults').length == 0){		$.ajax({			url: server_root+'search.php?search_type=json_only&'+layer,			dataType: "json",			success: function(data) {				geojson2google(data,'json_reset',dynamic_load);			},			error: function(XMLHttpRequest, textStatus, errorThrown){}		});	}else if(return_type == 'normal'){		ur = server_root+'search.php?search_type=normal&'+layer;		$('#searchresults').load(ur);		tabSet.tabs("enable", 0);		tabSet.tabs("select", 0);	}else{		// Google Maps caches KML files -- use a random query string parameter set to Date.		//var map = new GMap2(document.getElementById("map"));		// Add controls		map.removeOverlay(geoxml);		geoArray = [];		var url_end = "&nocache=" + (new Date()).valueOf();		kmlFile = server_root +"kml.php?"+ layer + url_end;		getKML(layer);		var zl = 6;		/*map.setCenter(new GLatLng(-41.283281567147206,174.76953405028956),zl);*/		//alert (kmlFile);		geoxml = new GGeoXml(kmlFile);		map.addOverlay(geoxml);		GEvent.addListener(geoxml, "load", handleGeoXMLLoad);		geoxml.gotoDefaultViewport(map);	}}var recent_latlng = new Array();var pins = new Array();var shapes = new Array();var shapesHighlighted = new Array();var recentPins = new Array();var recentShapes = new Array();var geo_json;var centre_pin = '';var centre_pin_name = '';var testPoly;var debug;function geojson2google(geoJson, result_type, dynamic_load){	var cords = '';	var temp_results = false;	var tempPoly = createPolygon();	geo_json = eval(geoJson);	dynamic_load = typeof(dynamic_load) != 'undefined' ? dynamic_load : false;	if(typeof(result_type) != 'undefined' && result_type == 'json_reset'){		map.clearOverlays()		recent_latlng = new Array();		pins = new Array();		shapes = new Array();		recentShapes = new Array();		recentPins = new Array();	}else if(typeof(result_type) != 'undefined' && result_type == 'json_temporary'){		for(var j = 0; j < recentPins.length; j++){			map.removeOverlay(pins[ recentPins[j] ]);		}		for(var j = 0; j < recentShapes.length; j++){			map.removeOverlay(shapes[ recentShapes[j] ]);		}		temp_results = true;		recentShapes = new Array();		recentPins = new Array();	}	var shape_json = geo_json['records'];	for(var j = 0; j < shape_json.length; j++){		tempPoly = '';		// CHECK THE PIN DOESNT ALREADY EXIST		testPoly = shapes[shape_json[j].type+'.'+shape_json[j].id];		if((dynamic_load && typeof(testPoly) == 'undefined') || !dynamic_load){			// MAKE THE SHAPE			if(typeof(shape_json[j].geo_json['type']) != 'undefined' && shape_json[j].geo_json['type'] != ''){				shapes[shape_json[j].type+'.'+shape_json[j].id] = new Array();				if(shape_json[j].geo_json['type'] == 'MultiPolygon'){					for(var k = 0; k < shape_json[j].geo_json['coordinates'].length; k++){						cords = shape_json[j].geo_json['coordinates'][k][0];						var llArray = new Array();						for(var i = 0; i < cords.length; i++){							llArray.push(new GLatLng(cords[i][1], cords[i][0]));						}						tempPoly = createPolygon(llArray,shape_json[j],k);						tempPoly.mf_id = shape_json[j].id;						tempPoly.mf_type = shape_json[j].type;						if(shape_json[j].shape_on_select == 't'){							tempPoly.shape_on_select = true;						//alert('hidea');						}else{							tempPoly.shape_on_select = false;						//alert('showb');						}						if(temp_results){							recentShapes.push(tempPoly.mf_type+'.'+tempPoly.mf_id);						}												map.addOverlay(tempPoly);						shapes[shape_json[j].type+'.'+shape_json[j].id].push(tempPoly);					}				}else{					cords = shape_json[j].geo_json['coordinates'][0];					//alert(cords);					var llArray = new Array();					for(var i = 0; i < cords.length; i++){						llArray.push(new GLatLng(cords[i][1], cords[i][0]));					//alert(i +' '+ cords[i][1] + ' ' + cords[i][0]);					}					tempPoly = createPolygon(llArray,shape_json[j]);					tempPoly.mf_id = shape_json[j].id;					tempPoly.mf_type = shape_json[j].type;					if(shape_json[j].shape_on_select == 't'){						tempPoly.shape_on_select = true;					//alert('hideb');					}else{						tempPoly.shape_on_select = false;					//alert('showb');					}					map.addOverlay(tempPoly);					shapes[shape_json[j].type+'.'+shape_json[j].id].push(tempPoly);				}				if(temp_results){					recentShapes.push(tempPoly.mf_type+'.'+tempPoly.mf_id);				}			}		}		testPoly = pins[shape_json[j].type+'.'+shape_json[j].id];		if((dynamic_load && typeof(testPoly) == 'undefined') || !dynamic_load){			//MAKE THE POINT			if(shape_json[j].geo_json_pt != ''){				//centre on this pin				if(temp_results){					recentPins.push(shape_json[j].type+'.'+shape_json[j].id);				}				var temp = createMarker(shape_json[j],shapes[shape_json[j].type+'.'+shape_json[j].id]);				if (shape_json[j].central_pin == 't') {					centre_pin = temp;					centre_pin_name = shape_json[j].type+'.'+shape_json[j].id;				//alert (centre_pin);				}				pins[shape_json[j].type+'.'+shape_json[j].id] = temp;				temp.title = shape_json[j].title;				if(typeof(shape_json[j].hide_pin) == 'undefined' || shape_json[j].hide_pin == 'f'){					temp.mf_id = shape_json[j].id;					temp.mf_type = shape_json[j].type;					//map.addOverlay(temp, tempPoly);					map.addOverlay(temp);				}else{					temp.pin_disabled = true;				}				if(tempPoly != '' &&  shapes[shape_json[j].type+'.'+shape_json[j].id][0].shape_on_select){					for(k in shapes[shape_json[j].type+'.'+shape_json[j].id]){						shapes[shape_json[j].type+'.'+shape_json[j].id][k].hide();					}				}				else {			//alert ('no hide ' + temp.mf_id);			}			}		}			}        	if(!dynamic_load){		checkZoomAfterJSON();	}	function createPolygon(coords, result, multipolygon_offset) {		if(typeof(multipolygon_offset) != 'undefined' && multipolygon_offset != ''){			multipolygon_offset = 0;		}		var poly = new GPolygon(coords, "#f33f00", 1, 1, "#ff0000", 0.2);		if(typeof(result) == 'undefined'){			return poly;		}else{			poly = new GPolygon(coords, result['bc'], 1, 1, result['fc'], result['op']);		//alert(poly);		}		if(typeof(result['stroke']) != 'undefined'){			poly.defaultStroke = result.stroke;		}else{			poly.defaultStroke = {				color:result['bc'],				weight:1,				opacity:1			};		}		if(typeof(result['highlight_stroke']) != 'undefined'){			poly.highlightStroke = {				color:"#000000",				weight:2,				opacity:0.7			};		}else{			poly.highlightStroke = {				color:"#000000",				weight:2,				opacity:0.7			};		}		if(typeof(result.hide_pin) != 'undefined' && result.hide_pin == 't' && shape_json[j].geo_json_pt != ''){			GEvent.addListener(poly, 'click', function() {				var latlng = new GLatLng(result.geo_json_pt.coordinates[1], result.geo_json_pt.coordinates[0]);				map.openInfoWindowHtml(latlng,'<h3>' +  result.title  + '</h3><br/>'+ result.panelText);				if(multipolygon_offset>0){					shapesHighlighted.push(poly.mf_type+'.'+poly.mf_id+'.'+multipolygon_offset);				}else{					shapesHighlighted.push(poly.mf_type+'.'+poly.mf_id);				}				poly.setStrokeStyle(poly.highlightStroke);				if(poly.shape_on_select){					poly.show();				}			});		}		return poly;	}	function createMarker(result, polyArray) {		var icon = new GIcon(G_DEFAULT_ICON);		var title = '';		if(typeof(result.pin) != 'undefined' && result.pin != ''){			icon.image = result.pin;			//alert(result.pin_width + ' ' + result.pin_height );			icon.iconSize = new GSize (result.pin_width,result.pin_height) ;			icon.iconAnchor  = new GPoint(result.x_off*-1, result.y_off*-1);			if(result.shadow != ''){				icon.shadow = result.shadow;				icon.shadowSize = new GSize (result.shadow_width,result.shadow_height) ;			}if(result.pin_map != ''){				icon.imageMap = [result.pin_map];			}		}		if(typeof(result.pin_mouseover) != 'undefined' && result.pin_mouseover == 't'){			title = result.title;		}		var latlng = new GLatLng(result.geo_json_pt.coordinates[1], result.geo_json_pt.coordinates[0]);		var marker = new GMarker(latlng, {			icon: icon,			title:title		});		recent_latlng.push(latlng);		if(typeof(polyArray) != 'undefined' && polyArray != ''){			//if a poly add bounds			for(k in polyArray){				pb = polyArray[k].getBounds();				if(!polyArray[k].shape_on_select) {					recent_latlng.push(pb.getSouthWest());					recent_latlng.push(pb.getNorthEast());				}			}		}		GEvent.addListener(marker, 'click', function() {			removeShapeHighlights();			marker.openInfoWindowHtml('<h3>' +  result.title  + '</h3><br/>'+ result.panelText);			if(typeof(polyArray) != 'undefined' && polyArray != ''){				shapesHighlighted.push(polyArray[0].mf_type+'.'+polyArray[0].mf_id);				for(k in polyArray){					if(polyArray[0].shape_on_select){						polyArray[k].show();					//alert(k);					}					polyArray[k].setStrokeStyle(polyArray[k].highlightStroke);				}			}			if(result.streetview_onclick == 't'){				//alert ('fut');				showStreetView(result.type+'.'+result.id);			//map.setCenter(latlng);			}		});		if(result.shape_on_hover == 't'){			GEvent.addListener(marker, 'mouseover', function() {				removeShapeHighlights();				if(typeof(polyArray) != 'undefined' && polyArray != ''){					shapesHighlighted.push(polyArray[0].mf_type+'.'+polyArray[0].mf_id);					for(k in polyArray){						polyArray[k].show();						polyArray[k].setStrokeStyle(polyArray[k].highlightStroke);					}				}			});			GEvent.addListener(marker, 'mouseout', function() {				removeShapeHighlights();			});		}		return marker;	}	initSearchShapeHover();	return;}function mapFinderToggleSchools(){	toggleType(25)	};var hidden = new Array();function toggleType(type_id, override){	override = typeof(override) != 'undefined' ? override : false;	var act = '';	if (hidden.indexOf(type_id) != -1) {		act = 'show';	}	else {		act = 'hide';	}	if (override != false) {		act = override;	}	if(act == 'show'){		for(j in pins){			if(pins[j].mf_type == type_id){				pins[j].show();			}		}		for(j in shapes){			var test = j.split(".");			if(test[0] == type_id){				for(k in shapes[j]){					shapes[j][k].hide();				}			}		}		hidden.splice(hidden.indexOf(type_id),1);	}else{		for(j in pins){			if(pins[j].mf_type == type_id){				pins[j].hide();			}		}		for(j in shapes){			var test = j.split(".");			if(test[0] == type_id){				for(k in shapes[j]){					shapes[j][k].hide();				}			}		}		hidden.push(type_id);	}}var hiddenShape = new Array();function toggleShape(type_id){	if(hiddenShape.indexOf(type_id) != -1){		for(j in shapes){			if(shapes[j].mf_type == type_id){				shapes[j].show();				shapes[j].shape_on_select = false;			}		}		hiddenShape.splice(hiddenShape.indexOf(type_id),1);	}else{		for(j in shapes){			if(shapes[j].mf_type == type_id){				shapes[j].hide();			}		}		hiddenShape.push(type_id);	}}// REMOVE ALL SHAPE HIGHLIGHTS ON PANEL CLOSEfunction removeShapeHighlights(){	for(var j = 0; j < shapesHighlighted.length; j++){		if(typeof(shapes[ shapesHighlighted[j] ]) != 'undefined'){			for(k in shapes[shapesHighlighted[j]]){				if(shapes[shapesHighlighted[j]][k].shape_on_select){					shapes[shapesHighlighted[j]][k].hide();				}				shapes[shapesHighlighted[j]][k].setStrokeStyle( shapes[shapesHighlighted[j]][k].defaultStroke);			}		}	}	shapesHighlighted = new Array();}function openPanel(key){	//alert (pins[key]);	if(pins[key].pin_disabled != true){		GEvent.trigger(pins[key], "click");	}else{		GEvent.trigger(shapes[key][0], "click");	}}function openPanelShape(key){	//alert (pins[key]);	GEvent.trigger(shape[key], "click");}function initSearchShapeHover(){	$('.list_title').mouseover(function(){		if(typeof(shapes[$(this).attr('mf_id')]) != 'undefined'){			shapesHighlighted.push($(this).attr('mf_id'));			for(j in shapes[$(this).attr('mf_id')]){				shapes[$(this).attr('mf_id')][j].setStrokeStyle(shapes[$(this).attr('mf_id')][j].highlightStroke);			}		}	}, function(){		removeShapeHighlights();	});	$(".list_title").mouseout(function(){		removeShapeHighlights();	});}function checkZoomAfterJSON(){	// RESIZE	var latlngbounds = new GLatLngBounds( );	if(typeof(recent_latlng) == 'undefined' || recent_latlng.length == 0){		//alert('recent undefined');		return;	}	//alert(recent_latlng.length);	for ( var i = 0; i < recent_latlng.length; i++ ){		latlngbounds.extend( recent_latlng[i]);	}	if (centre_pin != '') {		setMaxZoomCenter(map, centre_pin.getLatLng(),map.getBoundsZoomLevel( latlngbounds )+1 );	}	else if  (map.getBoundsZoomLevel( latlngbounds ) == 17 && map.getCurrentMapType().getName() == 'Map') {		//alert('123 test');		map.setCenter( latlngbounds.getCenter( ), 14 );	}else{		setMaxZoomCenter(map, latlngbounds.getCenter( ),map.getBoundsZoomLevel( latlngbounds ) );	}//alert('321 test'+map.getZoom());}function setMaxZoomCenter(map, latlng, fits) {	map.getCurrentMapType().getMaxZoomAtLatLng(latlng, function(response) {		if (response && response['status'] == G_GEO_SUCCESS) {			//alert(response['zoom']);			//alert (map.getCurrentMapType().getName());			//max zoom			if (response['zoom'] < fits) {				fits = response['zoom'];			}			if (fits == 19 && map.getCurrentMapType().getName() == 'Satellite') {				map.setCenter(latlng, response['zoom']-1);			}			else {				map.setCenter(latlng, fits);			}		}	});}function mainSV() {	showStreetView(centre_pin_name);}function zoomToMarkers(marker){	// RESIZE	var latlngbounds = new GLatLngBounds( );	if(typeof(marker) != 'undefined' && marker != ''){		latlngbounds.extend( pins[marker].getLatLng());		map.setCenter( latlngbounds.getCenter( ), 16 );	}else if( typeof(recentPins) != 'undefined' && recentPins.length > 0 ){		for ( var i = 0; i < recentPins.length; i++ ){			latlngbounds.extend( pins[ recentPins[i] ].getLatLng());		}		map.setCenter( latlngbounds.getCenter( ), map.getBoundsZoomLevel( latlngbounds ));	}else{		return true;	}}/*var tab_count = 3;var tabSet;function loadAdminMenu(){	if(tab_count < 8){		tabSet.tabs('add','#donothing', '&nbsp;&nbsp;&nbsp;');		tabSet.tabs('add','/admin/uploadCSV.php', '1. Upload Files');		tabSet.tabs('add','#chooseFields', '2. Choose Fields');		tabSet.tabs('add','#commitChanges', '3. Commit Changes');		tabSet.tabs('add','/admin/searchResults.php', 'Browse Data');		tabSet.tabs('add','/admin/display_settings.php', 'Configure Display');		tabSet.tabs('add','/admin/_change_password.php', 'Change Password');		tabSet.tabs('add',"/admin/index.php?logout=t", 'Logout');		tab_count += 8;		tabSet.tabs("disable", 3);		tabSet.tabs("disable", 5);		tabSet.tabs("disable", 6);	}}function removeAdminMenu(){	if(tab_count > 8){		tab_count -= 8;		tabSet.tabs('remove',3);		tabSet.tabs('remove',3);		tabSet.tabs('remove',3);		tabSet.tabs('remove',3);		tabSet.tabs('remove',3);		tabSet.tabs('remove',3);		tabSet.tabs('remove',3);		tabSet.tabs('remove',3);	}}*/var initLeftColSize;var initAdmin = true;var originalLeftColSize = 0;var tststr;var dynamicPinTiles;var debug;$(document).ready(function(){	//alert('here');	var iceLeftColWidth = 0;	var iceMapPadding = 0;	var iceLeftColMargin = 0;	if(!isNaN($('#iceLeftCol').outerWidth(true))){		iceLeftColWidth = $('#iceLeftCol').outerWidth(true);	}	if(!isNaN(parseInt($('#iceMap').css('padding-right')) )){		iceMapPadding = parseInt($('#iceMap').css('padding-right'))*2;	}	if(!isNaN( parseInt($('#iceLeftCol').css('margin-right')) )){		iceLeftColMargin = parseInt($('#iceLeftCol').css('margin-right'))*2;	}	$('#iceLeftCol').height($(window).height() - 12);	initLeftColSize = $('#iceLeftCol').width();	tabSet = $("#iceLeftCol").tabs(			{				show:function (event,ui){					$('#searchAgainButton').hide();					autoSizeSearchResult();				},				select:function (event,ui){					$('#iceSearch').show(0);					$('#iceAdvSearch').show(0);					autoSizeSearchResult();					/*ui.tab     // anchor element of the selected (clicked) tab					ui.panel   // element, that contains the selected/clicked tab contents					ui.index   // zero-based index of the selected (clicked) tab*/					//alert($('#iceMap').height);				}			});	if(typeof(mapAdmin) != 'undefined' && mapAdmin){		$('#map').hide(0);		$('#iceMap').hide(0);	}else{		$('#iceMap').width($(window).width() - 5 - iceLeftColWidth - iceMapPadding - iceLeftColMargin);		$('#iceMap').height($(window).height() - parseInt($('#iceMap').css('padding-top'))*2 - 2 - $('#other').height());		$('#map').width($('#iceMap').width());		$('#map').height($('#iceMap').height());		loadGMap();	}	initMenus();});function showAdminMapWithSearch(){	$('#map').show(0);	$('#iceMap').show(0);	var iceLeftColWidth = 0;	var iceMapPadding = 0;	var iceLeftColMargin = 0;		$('#adminTabs').height($(window).height() - 12 - headerOffset);	originalLeftColSize = $('#adminTabs').width();	$('#adminTabs').width(300);	if(!isNaN($('#adminTabs').outerWidth(true))){		iceLeftColWidth = $('#adminTabs').outerWidth(true);	}	if(!isNaN(parseInt($('#iceMap').css('padding-right')) )){		iceMapPadding = parseInt($('#iceMap').css('padding-right'))*2;	}	if(!isNaN( parseInt($('#iceLeftCol').css('margin-right')) )){		iceLeftColMargin = parseInt($('#iceLeftCol').css('margin-right'))*2;	}	$('#iceMap').width($(window).width() - 5 - iceLeftColWidth - iceMapPadding - iceLeftColMargin);	$('#iceMap').height($(window).height() - parseInt($('#iceMap').css('padding-top'))*2 - 2 - $('#other').height() - headerOffset);	$('#map').width($('#iceMap').width());	$('#map').height($('#iceMap').height());}// MENU MANAGEMENTvar menuInit = false;function initMenus() {	if(menuInit){		return;	}	menuInit = true;	$('div.menu div.content').hide();		$('div.menu a.headerref').click(function() {		var checkElement = $(this).next();		var parent = this.parentNode.parentNode.id;					if($('#' + parent).hasClass('noaccordion')) {			$(this).next().toggle(0);			setTimeout('autoSizeSearchResult()',100);			return false;		}		if((checkElement.hasClass('content')) && (checkElement.is(':visible'))) {			if($('#' + parent).hasClass('collapsible')) {				$('#' + parent + ' div:visible').hide(0);				setTimeout('autoSizeSearchResult()',100);			}			return false;		}		if((checkElement.hasClass('content')) && (!checkElement.is(':visible'))) {			$('#' + parent + ' div.menuitem div.content:visible').hide(0);			checkElement.show(0);			setTimeout('autoSizeSearchResult()',100);			return false;		}	}	);}var panoDesc;var myPano;var pov;var previousViewChangeID = 0;var toggleViewID = 0;function showStreetView(ref_id){	if(toggleViewID != ref_id || myPano.mf_sv_enabled == false ){		initStreetView(true);		toggleViewID = ref_id;		myPano.currentViewChangeID = ref_id;		myPano.origlatlng = pins[ref_id].getLatLng();		myPano.setLocationAndPOV(pins[ref_id].getLatLng());		GEvent.addListener(myPano, 'initialized', OnStreetViewChanged);		GEvent.addListener(myPano, 'error', streetViewError);	}else{		initStreetView(false);	}}var changingPosRef = 0;var clickEvent;function changePos(ref_id){	if(changingPosRef == 0 || changingPosRef != ref_id){		if(confirm('Now click on the map and the Pin Location will be moved, click "no" to cancel if you are not ready.')){			clickEvent = GEvent.addListener(map, 'click', function(overlay, point){				map.getDragObject().setDraggableCursor('default');				$.ajax({					url: server_root+'admin/changePos.php?ref_id='+ref_id+'&posx='+point.x+'&posy='+point.y,					dataType: "json",					success: function(data) {						movePin(point, data);					},					error: function(XMLHttpRequest, textStatus, errorThrown){						alert('Server error, please try again');						changingPosRef = 0;					}				});				GEvent.removeListener(clickEvent);				changingPosRef = ref_id;			});			map.getDragObject().setDraggableCursor('crosshair')		}	}}function movePin(point, data){	if(data[0] == 0){		alert("Location changed successfully");		pins[changingPosRef].setLatLng(new GLatLng(point.y, point.x));	}else if(data[0] == 1){		alert(data[1]);	}	changingPosRef = 0;}/*function bouncePin(ref_id){	pins[ref_id].bounce(1);}*/var testError;function streetViewError(error){	if(error == 600){		initStreetView(false);	/*panoDesc = $('#other');		panoDesc.height($('#map').height() / 2);		$('#map').height($('#iceMap').height() - $('#other').height());*/	}}function goSat() {	map.setMapType(G_SATELLITE_MAP);}function initStreetView(display){	display = typeof(display) != 'undefined' ? display : true;	if((myPano == null && display) || (myPano.mf_sv_enabled == false && display)){		panoDesc = $('#pano');		panoDesc.show(0);		panoDesc.height($('#iceMap').height() / 2 );		panoDesc.width($('#iceMap').width() );		//$('#iceMap').height($(window).height() - parseInt($('#iceMap').css('padding-top'))*2 - 2 - $('#other').height());		$('#map').height($('#iceMap').height()/2);		panoDesc = document.getElementById("pano");		myPano = new GStreetviewPanorama(panoDesc);		myPano.mf_sv_enabled = true;	}else if(!display){		myPano.mf_sv_enabled = false;		panoDesc = $('#pano');		panoDesc.hide(0);		panoDesc.height(0);		myPano.remove();		previousViewChangeID = 0;		//$('#iceMap').height($(window).height() - parseInt($('#iceMap').css('padding-top'))*2 - 2 - $('#other').height());		$('#map').height($('#iceMap').height());	}}function OnStreetViewChanged(myPanoTemp){	//	alert('!'+myPanoTemp.latlng + '  - ' +myPano.origlatlng);	if(previousViewChangeID != myPano.currentViewChangeID ){		previousViewChangeID = myPano.currentViewChangeID;		var bearingChange = bearing(myPanoTemp.latlng, myPano.origlatlng);		pov = myPano.getPOV();		pov.yaw = parseInt(bearingChange);		myPano.setPOV(pov);	}	return true;}var degreesPerRadian = 180.0 / Math.PI;var radiansPerDegree = Math.PI / 180.0;// Returns the bearing in degrees between two points.// North = 0, East = 90, South = 180, West = 270.function bearing( from, to ) {	// See T. Vincenty, Survey Review, 23, No 176, p 88-93,1975.	// Convert to radians.	var lat1 = from.latRadians();	var lon1 = from.lngRadians();	var lat2 = to.latRadians();	var lon2 = to.lngRadians();	// Compute the angle.	var angle = - Math.atan2( Math.sin( lon1 - lon2 ) * Math.cos( lat2 ), Math.cos( lat1 ) * Math.sin( lat2 ) - Math.sin( lat1 ) * Math.cos( lat2 ) * Math.cos( lon1 - lon2 ) );	if ( angle < 0.0 ) angle  += Math.PI * 2.0;	// And convert result to degrees.	angle = angle * degreesPerRadian;	angle = angle.toFixed(1);	return angle;}function infoPanel(){	//alert($('#infoPanel').height());	if ($('#icePanels').height() == 0) {		$('#iceMap').width($('#iceMap').width() - $('#icePanels').outerWidth(true));		$('#map').width($('#iceMap').width());	}	$('#icePanels').height($(window).height() );	$('#icePanels').show(0);}function panelPopToggle(uri){	if($('#panelPop').attr("src") == uri){		$('#panelPop').attr("src",'about:blank') ;		var temp_panel_width = $('#icePanels').outerWidth(true);		$('#icePanels').hide(0);		$('#iceMap').width($('#iceMap').width() + temp_panel_width );		$('#map').width($('#iceMap').width());		return;	}	if ($('#panelPop').height() == 0) {		$('#iceMap').width($('#iceMap').width() - $('#icePanels').outerWidth(true));		$('#map').width($('#iceMap').width());	}	$('#icePanels').show(0);	$('#icePanels').height($(window).height() );	$('#panelPop').attr("src",uri) ;//panels.location.href=uri;}function autoSizeSearchResult(){	//alert(' icesearch '+ $('#iceSearch div.content').outerHeight(true) + '  adv '+$('#iceAdvSearch div.content').outerHeight(true));	var height_temp = $('#iceSearch div.content').outerHeight(true) + $('#iceAdvSearch div.content').outerHeight(true);	height_temp = $('#iceLeftCol').height() + $('#adminTabs').height() - $('#searchRollOut').height()- $('#iceAdminTab').height()- $('#search_again').outerHeight(true)- height_temp;	//	alert(' iceLeftCol '+ $('#iceLeftCol').outerHeight(true) + '  adv '+$('#searchRollOut').outerHeight(true) + '  iceAdminTab '+$('#iceAdminTab').outerHeight(true));	$('#searchresults').height(height_temp -10);	// alert($('#searchresults').height() + '-- '+height_temp);	$('#result').height(height_temp -12);}function showSearchDiv(div) {	document.getElementById('searchresults').style.display='none';	document.getElementById(div).style.display='';}function showOps(op) {	pmId = op + 'pm';	if (document.getElementById(op).style.display == 'none') {		document.getElementById(op).style.display='';		pm = '-';	}	else {		document.getElementById(op).style.display='none';		pm = '+';	}	document.getElementById(pmId).innerHTML= pm;}function showBal(i) {	//alert(geoArray);	var n = jQuery.inArray(i, geoArray)// geoArray.indexOf(i);	//alert(n);	//alert (geoArray[0]);	GEvent.trigger(goverlays[n], "click");}// This function picks up the click and tells GGeoXml to open the corresponding info windowfunction myclick(i) {	GEvent.trigger(goverlays[i], "click");}function prepareQ(kmlSource) {	//alert (document.criteria.ta);	a = document.criteria.com.value;	b = document.criteria.dec.value;	c = document.criteria.ta.value;	d = document.criteria.name.value;	kmlStr = kmlSource+'?o='+a+'&d='+b+'&ta='+c+'&n='+d;	//alert (kmlStr);	addLayer(kmlStr);}function getKML(layer) {	kmlFile = server_root +"kml.php"+ layer;	$('#resultPanel').show(0);	$('#getfiles').html('<a href="'+ kmlFile +'&fm=kml">View in Google Earth</a><br/>');	showResults();}function showMessage(mes) {	$('#resultPanel').show(0);	$('#simple_search_message').html(mes);	showResults();}function noResultsMes(mes){	$('#resultPanel').hide(0);	$('#simpleError').html(mes);//autoSizeSearchResult();}function showResults(){	$('#resultPanel').show(0);	$('#searchAgainButton').show();	$('#iceSearch').hide(0);	$('#iceAdvSearch').hide(0);	autoSizeSearchResult();}function showSearch(){	if(mapAdmin == true){		if($('#adminTabs').tabs('option', 'selected') == 3){			$('#searchAgainButton').hide();			$('#iceSearch').show(0);		}	}else{		if($('#iceLeftCol').tabs('option', 'selected') == 0){			$('#searchAgainButton').hide();			$('#iceSearch').show(0);		}else if($('#iceLeftCol').tabs('option', 'selected') == 1){			$('#searchAgainButton').hide();			$('#iceAdvSearch').show(0);		}	}	autoSizeSearchResult();}function prepareQS(kmlSource) {	//alert (document.criteria.ta);	c = document.criteria.ta.value;	d = escape(document.criteria.name.value);	kmlStr = kmlSource+'?ta='+c+'&n='+d;	//alert (kmlStr);	addLayer(kmlStr);	document.getElementById("searchresults").style.display='';}function handleGeoXMLLoad() {	// We have to set the zoom level after the GGeoXML object is finishedwith	// all of its work. Otherwise, we're checking the zoom level before that	// object even has a chance to set it.	var zoomLevel = map.getZoom();//map.setZoom(zoomLevel - 1);}function noResults() {	map.removeOverlay(geoxml);	zl=5;	map.setCenter(new GLatLng(-41.283281567147206,174.76953405028956),zl);}var styles = [[{	url: '../images/people35.png',	height: 35,	width: 35,	opt_anchor: [16, 0],	opt_textColor: '#FF00FF'},{	url: '../images/people45.png',	height: 45,	width: 45,	opt_anchor: [24, 0],	opt_textColor: '#FF0000'},{	url: '../images/people55.png',	height: 55,	width: 55,	opt_anchor: [32, 0]}],[{	url: 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/conv30.png',	height: 27,	width: 30,	anchor: [3, 0],	textColor: '#FF00FF'},{	url: 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/conv40.png',	height: 36,	width: 40,	opt_anchor: [6, 0],	opt_textColor: '#FF0000'},{	url: 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/conv50.png',	width: 50,	height: 45,	opt_anchor: [8, 0]}],[{	url: 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/heart30.png',	height: 26,	width: 30,	opt_anchor: [4, 0],	opt_textColor: '#FF00FF'},{	url: 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/heart40.png',	height: 35,	width: 40,	opt_anchor: [8, 0],	opt_textColor: '#FF0000'},{	url: 'http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/images/heart50.png',	width: 50,	height: 44,	opt_anchor: [12, 0]}]];function makeClusters(resAr) {	if(GBrowserIsCompatible()) {		var markers = [];		var data = resAr;		//alert (data);		//alert (data.results);		var icon = new GIcon(G_DEFAULT_ICON);		icon.image = "http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png";		for (var i = 0; i < data.count; ++i) {			var latlng = new GLatLng(data.records[i].latitude, data.records[i].longitude);			var marker = new GMarker(latlng, {				icon: icon			});			markers.push(marker);		}		refreshMap();	}}function refreshMap() {	if (markerClusterer != null) {		markerClusterer.clearMarkers();	}	var zoom = -1;	var size = 40;	var style = -1;	zoom = zoom == -1 ? null : zoom;	size = size == -1 ? null : size;	style = style == "-1" ? null: parseInt(style, 10);	markerClusterer = new MarkerClusterer(map, markers, {		maxZoom: zoom,		gridSize: size,		styles: styles[style]	});}function makeMarkers(resAr) {	if(GBrowserIsCompatible()) {		var data = resAr;		for (var i = 0; i < data.count; ++i) {			map.addOverlay(createMarker(data.records[i]));		}	}	function createMarker(result) {		var icon = new GIcon(G_DEFAULT_ICON);		var latlng = new GLatLng(result.latitude, result.longitude);		var marker = new GMarker(latlng, {			icon: icon		});		GEvent.addListener(marker, 'click', function() {			var v = unescape(result.title);			marker.openInfoWindowHtml('<h3>' +  v  + '</h3>');		});		return marker;	}}var FileEvent;var FileQueue;var FileObj;var FileResponse;var FileData;function showSuccess(event, queueID, fileObj, response, data){	if(response.indexOf('Error') >= 0){		$(descName).html('<b>'+response+'</b>');	}else{		FileEvent = event;		FileQueue = queueID;		FileObj = fileObj;		FileResponse = response;		FileData = data;		var wrapperName = '#wrapper_'+event.target.id;		var descName = '#desc_'+event.target.id;		var hiddenName = '#name_'+event.target.id;		$(wrapperName).hide(0);		$(descName).html('<b>'+fileObj.name+'</b> has been uploaded.');		$(hiddenName).val(fileObj.name);	/*alert('test' + event +' **** '+ queueID +' **** '+ fileObj +' **** '+ response +' **** '+ data);*/	}	return true;}function loadGMap(){	/*var latlng = new google.maps.LatLng(-34.397, 150.644);    var myOptions = {      zoom: 8,      mapTypeId: google.maps.MapTypeId.ROADMAP    };    map = new google.maps.Map(document.getElementById("map"), myOptions);		geoxml = [];		goverlays = [];		kmlFile = "a";		/*map = new GMap2(document.getElementById("map"));		if (mapType !='') {			map.setMapType(G_SATELLITE_MAP);		}		directionsPanel = document.getElementById("infoPanel");		directions = new GDirections(map,directionsPanel);		geoArray = [];		zl=5;* /		//map.setUIToDefault();		//alert('vom');		//map.removeControl(mapTypeControl);		for(j in startingLayer){			addLayer(startingLayer[j]['layer'], startingLayer[j]['display_type']);		}		if(startingLayer.length == 0){			map.setCenter(new LatLng(-41.283281567147206,174.76953405028956),zl);		}		GEvent.addListener(map,"addoverlay",function(overlay) {			// If this is a named overlay (e.g. not the GGeoXml itself, or the infowindow)			if (overlay.name) {				// check to see if we already know about this one				if (overlay.Known) {				// do nothing				} else {					// Add a sidebar entry					//document.getElementById("side_bar").innerHTML  += '<a href="javascript:myclick(' + goverlays.length + ')">' + overlay.name + '<\/a><br>';					geoArray[goverlays.length] = overlay.name;					//alert(goverlays.length);					// Save a reference					goverlays.push(overlay);					// remember that we know about this one					overlay.Known = true;				}			}		});		// Notify map moves for dynamic loading		if(dynamicLayer.length > 0){			GEvent.addListener(map, "moveend", function() {				var zoom = this.getZoom();				var bounds = this.getBounds();				if(zoom > 12){				}else{					addLayer('dynamic_listing='+dynamicLayer.join(',')+'&w='+bounds.getSouthWest().lat()+'&s='+bounds.getSouthWest().lng()+'&e='+bounds.getNorthEast().lat()+'&n='+bounds.getNorthEast().lng()+'&zoom='+zoom, json_kml_switch, true);				}			});		}		// The infowindow contents can be modified as it opens.		GEvent.addListener(map,"infowindowprepareopen", function(iwtabs) {			iwtabs[0].contentElem.innerHTML+="";		});		GEvent.addListener(map,"infowindowclose", function(iwtabs) {			removeShapeHighlights();		});	*/		if (GBrowserIsCompatible()) {		geoxml = [];		goverlays = [];		kmlFile = "a";		map = new GMap2(document.getElementById("map"));		/*if((typeof(mapAdmin) != 'undefined' && mapAdmin)){			map.setMapType(G_HYBRID_MAP);		}*/		if (mapType !='') {			map.setMapType(G_SATELLITE_MAP);		}		directionsPanel = document.getElementById("infoPanel");		directions = new GDirections(map,directionsPanel);		geoArray = [];		zl=5;		//map.addControl(new GLargeMapControl());		map.setUIToDefault();		//alert('vom');		//map.removeControl(mapTypeControl);		for(j in startingLayer){			addLayer(startingLayer[j]['layer'], startingLayer[j]['display_type']);		}		if(startingLayer.length == 0){			map.setCenter(new GLatLng(-41.283281567147206,174.76953405028956),zl);		}		GEvent.addListener(map,"addoverlay",function(overlay) {			// If this is a named overlay (e.g. not the GGeoXml itself, or the infowindow)			if (overlay.name) {				// check to see if we already know about this one				if (overlay.Known) {				// do nothing				} else {					// Add a sidebar entry					//document.getElementById("side_bar").innerHTML  += '<a href="javascript:myclick(' + goverlays.length + ')">' + overlay.name + '<\/a><br>';					geoArray[goverlays.length] = overlay.name;					//alert(goverlays.length);					// Save a reference					goverlays.push(overlay);					// remember that we know about this one					overlay.Known = true;				}			}		});		// Notify map moves for dynamic loading		if(dynamicLayer.length > 0){			GEvent.addListener(map, "moveend", function() {				var zoom = this.getZoom();				var bounds = this.getBounds();				if(zoom > 12){								}else{					addLayer('dynamic_listing='+dynamicLayer.join(',')+'&w='+bounds.getSouthWest().lat()+'&s='+bounds.getSouthWest().lng()+'&e='+bounds.getNorthEast().lat()+'&n='+bounds.getNorthEast().lng()+'&zoom='+zoom, json_kml_switch, true);				}			});		}		// The infowindow contents can be modified as it opens.		GEvent.addListener(map,"infowindowprepareopen", function(iwtabs) {			iwtabs[0].contentElem.innerHTML+="";		});		GEvent.addListener(map,"infowindowclose", function(iwtabs) {			removeShapeHighlights();		});	}}	//-->