			var default_lat 			= -36.8484597;
			var default_lng 			= 174.76333150000005;
			var default_radius 			= 1000;
			var zoom_level 				= '15';
			var map_width 				= '100%';
			var map_height 				= '640px';
			var special_text 			= '';
			var units 					= 'km';
			var limit 					= '30';
			var plugin_url 				= 'https://www.tournament.co.nz/wp-content/plugins/simplemap';
			var visit_website_text 		= 'Details';
			var get_directions_text		= 'Get Directions';
			var location_tab_text		= 'Location';
			var description_tab_text	= 'Description';
			var phone_text				= 'Phone';
			var fax_text				= 'Fax';
			var email_text				= 'Email';

			var taxonomy_text = {};
								taxonomy_text.sm_category = 'Categories';
										taxonomy_text.sm_tag = 'Tags';
								var noresults_text			= 'No Carpark found.';
			var default_domain 			= '.co.nz';
			var address_format 			= 'town, province postalcode';
			var siteurl					= 'https://www.tournament.co.nz';
			var map;
			var geocoder;
			var autoload				= 'some';
			var auto_locate				= '';
			var markersArray = [];
			var infowindowsArray = [];

			function clearInfoWindows() {
				if (infowindowsArray) {
					for (var i=0;i<infowindowsArray.length;i++) {
						infowindowsArray[i].close();
					}
				}
			}

			function clearOverlays() {
				if (markersArray) {
					for (var i=0;i<markersArray.length;i++) {
						markersArray[i].setMap(null);
					}
				}
			}

			//function load_simplemap( lat, lng, aspid, ascid, asma ) {
			function load_simplemap( lat, lng, aspid, ascid, asma, shortcode_zoom_level, map_type, shortcode_autoload ) {
				//alert(lat + '=' + lng + '=' + aspid + '=' + ascid + '=' + asma + '=' + shortcode_zoom_level + '=' + map_type + '=' + shortcode_autoload );
				zoom_level = shortcode_zoom_level;
                autoload = shortcode_autoload;
				  
				if ( lat == 0 ) {
					lat = '-36.8484597';
				}

				if ( lng == 0 ) {
					lng = '174.76333150000005';
				}

				var latlng = new google.maps.LatLng( lat, lng );
				var myOptions = {
					zoom: parseInt(zoom_level),
					center: latlng,
					mapTypeId: google.maps.MapTypeId[map_type] 
				};
				map = new google.maps.Map( document.getElementById( "simplemap" ), myOptions );

				// Adsense for Google Maps
							}

			function codeAddress() {
				// if this is modified, modify mirror function in general-options-js php function 
				var d_address = document.getElementById("default_address").value;

				geocoder = new google.maps.Geocoder();
				geocoder.geocode( { 'address': d_address }, function( results, status ) {
					if ( status == google.maps.GeocoderStatus.OK ) {
						var latlng = results[0].geometry.location;
						document.getElementById("default_lat").value = latlng.lat();
						document.getElementById("default_lng").value = latlng.lng();
					} else {
						alert("Geocode was not successful for the following reason: " + status);
					}
				});
			}

			function codeNewAddress() {
				if (document.getElementById("store_lat").value != '' && document.getElementById("store_lng").value != '') {
					document.new_location_form.submit();
				}
				else {
					var address = '';
					var street = document.getElementById("store_address").value;
					var city = document.getElementById("store_city").value;
					var state = document.getElementById("store_state").value;
					var country = document.getElementById("store_country").value;

					if (street) { address += street + ', '; }
					if (city) { address += city + ', '; }
					if (state) { address += state + ', '; }
					address += country;

					geocoder = new google.maps.Geocoder();
					geocoder.geocode( { 'address': address }, function( results, status ) {
						if ( status == google.maps.GeocoderStatus.OK ) {
							var latlng = results[0].geometry.location;
							document.getElementById("store_lat").value = latlng.lat();
							document.getElementById("store_lng").value = latlng.lng();
							document.new_location_form.submit();
						} else {
							alert("Geocode was not successful for the following reason: " + status);
						}
					});
				}
			}

			function codeChangedAddress() {
				var address = '';
				var street = document.getElementById("store_address").value;
				var city = document.getElementById("store_city").value;
				var state = document.getElementById("store_state").value;
				var country = document.getElementById("store_country").value;

				if (street) { address += street + ', '; }
				if (city) { address += city + ', '; }
				if (state) { address += state + ', '; }
				address += country;

				geocoder = new google.maps.Geocoder();
				geocoder.geocode( { 'address': address }, function( results, status ) {
					if ( status == google.maps.GeocoderStatus.OK ) {
						var latlng = results[0].geometry.location;
						document.getElementById("store_lat").value = latlng.lat();
						document.getElementById("store_lng").value = latlng.lng();
					} else {
						alert("Geocode was not successful for the following reason: " + status);
					}
				});
			}

			function searchLocations2( is_search ) {
				// Init searchData
				var searchData = {};
				searchData.taxes = {};

				// Set defaults for search form fields
				searchData.address	= '';
				searchData.city 	= '';
				searchData.state	= '';
				searchData.zip		= '';
				searchData.country	= '';

				// Do SimpleMap Taxonomies
				
						// Do taxnonomy for checkboxes
						searchData.taxes.sm_category = '';
						var checks_found = false;
						jQuery( 'input[rel=location_search_sm_category_field]' ).each( function() {
							checks_found = true;
							if ( jQuery( this ).attr( 'checked' ) && jQuery( this ).attr( 'value' ) != null ) {
								searchData.taxes.sm_category += jQuery( this ).attr( 'value' ) + ',';
							}
						});

						// Do taxnonomy for select box if checks weren't found
						if ( false == checks_found ) {	
							jQuery( 'option[rel=location_search_sm_category_select_val]' ).each( function() {
								if ( jQuery( this ).attr( 'selected' ) && jQuery( this ).attr( 'value' ) != null ) {
									searchData.taxes.sm_category += jQuery( this ).attr( 'value' ) + ',';
								}
							});
						}

						
						// Do taxnonomy for checkboxes
						searchData.taxes.sm_tag = '';
						var checks_found = false;
						jQuery( 'input[rel=location_search_sm_tag_field]' ).each( function() {
							checks_found = true;
							if ( jQuery( this ).attr( 'checked' ) && jQuery( this ).attr( 'value' ) != null ) {
								searchData.taxes.sm_tag += jQuery( this ).attr( 'value' ) + ',';
							}
						});

						// Do taxnonomy for select box if checks weren't found
						if ( false == checks_found ) {	
							jQuery( 'option[rel=location_search_sm_tag_select_val]' ).each( function() {
								if ( jQuery( this ).attr( 'selected' ) && jQuery( this ).attr( 'value' ) != null ) {
									searchData.taxes.sm_tag += jQuery( this ).attr( 'value' ) + ',';
								}
							});
						}

						
				var query = '';
				var start = 0;
 
				if ( searchData.address && searchData.address != '' ) {
					query += searchData.address + ', ';
				}

				if ( searchData.city && searchData.city != '' ) {
					query += searchData.city + ', ';
				}

				if ( searchData.state && searchData.state != '' ) {
					query += searchData.state + ', ';
				}

				if ( searchData.zip && searchData.zip != '' ) {
					query += searchData.zip + ', ';
				}

				if ( searchData.country && searchData.country != '' ) {
					query += searchData.country + ', ';
				}
				

				// Query
				if ( query != null ) {
					query = query.slice(0, -2);
				}
				if ( searchData.limit == '' || searchData.limit == null ) {
					searchData.limit = 0;
				}

				if ( searchData.radius == '' || searchData.radius == null ) {
					searchData.radius = 0;
				}

				
				// Load default location if query is empty
				if ( query == '' || query == null ) {

					if ( searchData.lat != 0 && searchData.lng != 0 )
						query = searchData.lat + ', ' + searchData.lng;
					else
						query = '-36.8484597, 174.76333150000005';

				}

				// Searching
				if ( 1 == searchData.searching || 1 == is_search ) {
					is_search = 1;
					searchData.source = 'search';
				} else {
					is_search = 0;
					searchData.source = 'initial_load';
				}
			}

			function searchLocations( is_search ) {
				// Init searchData
				var searchData = {};
				searchData.taxes = {};

				// Set defaults for search form fields
				searchData.address	= '';
				searchData.city 	= '';
				searchData.state	= '';
				searchData.zip		= '';
				searchData.country	= '';

				if ( null != document.getElementById('location_search_address_field') ) {
					searchData.address = document.getElementById('location_search_address_field').value;
				}

				if ( null != document.getElementById('location_search_city_field') ) {
					searchData.city = document.getElementById('location_search_city_field').value;
				}

				if ( null != document.getElementById('location_search_country_field') ) {
					searchData.country = document.getElementById('location_search_country_field').value;;
				}

				if ( null != document.getElementById('location_search_state_field') ) {
					searchData.state = document.getElementById('location_search_state_field').value;
				}

				if ( null != document.getElementById('location_search_zip_field') ) {
					searchData.zip = document.getElementById('location_search_zip_field').value;
				}

				if ( null != document.getElementById('location_search_distance_field') ) {
					searchData.radius = document.getElementById('location_search_distance_field').value;
				}
				
				if ( null != document.getElementById('location_search_distance_field') ) {
					searchData.filters = document.getElementById('simplemap_result_filters').value;
				}
				
				searchData.lat			= document.getElementById('location_search_default_lat').value;
				searchData.lng			= document.getElementById('location_search_default_lng').value;
				searchData.limit		= document.getElementById('location_search_limit').value; 
				searchData.searching	= document.getElementById('location_is_search_results').value;
				
				
				
				// Do SimpleMap Taxonomies
				
						// Do taxnonomy for checkboxes
						searchData.taxes.sm_category = '';
						var checks_found = false;
						jQuery( 'input[rel=location_search_sm_category_field]' ).each( function() {
							checks_found = true;
							if ( jQuery( this ).attr( 'checked' ) && jQuery( this ).attr( 'value' ) != null ) {
								searchData.taxes.sm_category += jQuery( this ).attr( 'value' ) + ',';
							}
						});

						// Do taxnonomy for select box if checks weren't found
						if ( false == checks_found ) {	
							jQuery( 'option[rel=location_search_sm_category_select_val]' ).each( function() {
								if ( jQuery( this ).attr( 'selected' ) && jQuery( this ).attr( 'value' ) != null ) {
									searchData.taxes.sm_category += jQuery( this ).attr( 'value' ) + ',';
								}
							});
						}

						
						// Do taxnonomy for checkboxes
						searchData.taxes.sm_tag = '';
						var checks_found = false;
						jQuery( 'input[rel=location_search_sm_tag_field]' ).each( function() {
							checks_found = true;
							if ( jQuery( this ).attr( 'checked' ) && jQuery( this ).attr( 'value' ) != null ) {
								searchData.taxes.sm_tag += jQuery( this ).attr( 'value' ) + ',';
							}
						});

						// Do taxnonomy for select box if checks weren't found
						if ( false == checks_found ) {	
							jQuery( 'option[rel=location_search_sm_tag_select_val]' ).each( function() {
								if ( jQuery( this ).attr( 'selected' ) && jQuery( this ).attr( 'value' ) != null ) {
									searchData.taxes.sm_tag += jQuery( this ).attr( 'value' ) + ',';
								}
							});
						}

						
				var query = '';
				var start = 0;
 
				if ( searchData.address && searchData.address != '' ) {
					query += searchData.address + ', ';
				}

				if ( searchData.city && searchData.city != '' ) {
					query += searchData.city + ', ';
				}

				if ( searchData.state && searchData.state != '' ) {
					query += searchData.state + ', ';
				}

				if ( searchData.zip && searchData.zip != '' ) {
					query += searchData.zip + ', ';
				}

				if ( searchData.country && searchData.country != '' ) {
					query += searchData.country + ', ';
				}
				

				// Query
				if ( query != null ) {
					query = query.slice(0, -2);
				}
				if ( searchData.limit == '' || searchData.limit == null ) {
					searchData.limit = 0;
				}

				if ( searchData.radius == '' || searchData.radius == null ) {
					searchData.radius = 0;
				}

				// Taxonomies
				
						if ( searchData.taxes.sm_category != null ) {
							var _sm_category = searchData.taxes.sm_category.slice(0, -1);
						} else {
							var _sm_category = '';
						}

						// Append available taxes logic if no taxes are selected but limited taxes were passed through shortcode as available
						if ( '' != document.getElementById('avail_sm_category').value && '' == _sm_category ) {
							_sm_category = 'OR,' + document.getElementById('avail_sm_category').value;
						}

						searchData.taxes.sm_category = _sm_category;

						
						if ( searchData.taxes.sm_tag != null ) {
							var _sm_tag = searchData.taxes.sm_tag.slice(0, -1);
						} else {
							var _sm_tag = '';
						}

						// Append available taxes logic if no taxes are selected but limited taxes were passed through shortcode as available
						if ( '' != document.getElementById('avail_sm_tag').value && '' == _sm_tag ) {
							_sm_tag = 'OR,' + document.getElementById('avail_sm_tag').value;
						}

						searchData.taxes.sm_tag = _sm_tag;

						
				// Load default location if query is empty
				if ( query == '' || query == null ) {

					if ( searchData.lat != 0 && searchData.lng != 0 )
						query = searchData.lat + ', ' + searchData.lng;
					else
						query = '-36.8484597, 174.76333150000005';

				}

				// Searching
				if ( 1 == searchData.searching || 1 == is_search ) {
					is_search = 1;
					searchData.source = 'search';
				} else {
					is_search = 0;
					searchData.source = 'initial_load';
				}
				geocoder.geocode( { 'address': query }, function( results, status ) {
					if ( status == google.maps.GeocoderStatus.OK ) {
						searchData.center = results[0].geometry.location;
						if ( 'none' != autoload || is_search ) {
							if ( 'all' == autoload && is_search != 1 ) {
								searchData.radius = 0;
								searchData.limit = 0;
							}

							if (! searchData.center) {
								searchData.center = new GLatLng( 44.9799654, -93.2638361 );
							}
							searchData.query_type = 'all';
							searchData.mapLock = 'unlock';
							searchData.homeAddress = query;

							searchLocationsNear(searchData); 
						}
					}
				});
			}

			function searchLocationsNear(searchData) {
				// Radius
				if ( searchData.radius != null && searchData.radius != '' ) {
					searchData.radius = parseInt( searchData.radius );

					if ( units == 'km' ) {
						searchData.radius = parseInt( searchData.radius ) / 1.609344;
					}
				} else if ( autoload == 'all' ) {
					searchData.radius = 0;
				} else {
					if ( units == 'mi' ) {
						searchData.radius = parseInt( default_radius );
					} else if ( units == 'km' ) {
						searchData.radius = parseInt( default_radius ) / 1.609344;
					}
				}

				// Build search URL
				
				var searchUrl = siteurl + '/?sm-xml-search=1&lat=' + searchData.center.lat() + '&lng=' + searchData.center.lng() + '&radius=' + searchData.radius + '&namequery=' + searchData.homeAddress + '&query_type=' + searchData.query_type  + '&limit=' + searchData.limit + '&sm_category=' + searchData.taxes.sm_category + '&sm_tag=' + searchData.taxes.sm_tag + '&address=' + searchData.address + '&city=' + searchData.city + '&state=' + searchData.state + '&zip=' + searchData.zip + '&filters=' + searchData.filters;
				//alert(searchUrl);
								// Display Updating Message and hide search results
				jQuery( "#simplemap" ).hide();
				jQuery( "#simplemap-updating" ).show();
								jQuery( "#results" ).html( '' );
				jQuery.get( searchUrl, {}, function(data) {
										// Hide Updating Message
					jQuery( "#simplemap-updating" ).hide();
					jQuery( "#simplemap" ).show();
					
					clearOverlays();

					var results = document.getElementById('results');
					results.innerHTML = '';
					
					//Samuel Data
					var markers = jQuery( data );
					if (markers.length == 0) {
						results.innerHTML = '<div class="locations_txt">' + noresults_text + '</div>';
						map.setCenter( searchData.center );
						return;
					}
					

					var bounds = new google.maps.LatLngBounds();
					var resultNum = 0;
					markers.each( function () {
						var locationData = this;
						locationData.distance = parseFloat(locationData.distance);
						locationData.point = new google.maps.LatLng(parseFloat(locationData.lat), parseFloat(locationData.lng));
						
						locationData.homeAddress = searchData.homeAddress;
                                                            if(resultNum==0){
                                                            var marker = createMarker_big(locationData);
                                                            }else {
                                                            						
						var marker = createMarker(locationData);
                                                            }
						var sidebarEntry = createSidebarEntry(marker, locationData, searchData);
						resultNum = 1 + resultNum;
						if(resultNum > 5)
						{ return; }
						results.appendChild(sidebarEntry);
						bounds.extend(locationData.point);			
						
					});

					// Make centeral marker on search
					if ( 'search' == searchData.source && true) {
						var searchMarkerOptions = {};
						searchMarkerOptions.map = map;
						searchMarkerOptions.position = searchData.center;

						//echo esc_js( apply_filters( 'sm-search-marker-image-url', SIMPLEMAP_URL . "/inc/images/blue-dot1.png" ) );
						searchMarkerOptions.icon = new google.maps.MarkerImage( 

							'https://www.tournament.co.nz/wp-content/plugins/simplemap',
							new google.maps.Size(30, 51),
							new google.maps.Point(0,0),
							new google.maps.Point(6,51)
						);

						var searchMarkerTitle = '';
						if ( '' != searchData.address ) {
								searchMarkerTitle += searchData.address + ' ';
						}
						if ( '' != searchData.city ) {
								searchMarkerTitle += searchData.city + ' ';
						}
						if ( '' != searchData.state ) {
								searchMarkerTitle += searchData.state + ' ';
						}
						if ( '' != searchData.zip ) {
								searchMarkerTitle += searchData.zip + ' ';
						}

						var searchMarker = new google.maps.Marker( searchMarkerOptions );
						searchMarker.title = searchMarkerTitle;
						markersArray.push(searchMarker);
						bounds.extend(searchMarkerOptions.position);
					}

					// If the search button was clicked, limit to a 15px zoom
					if ( 'search' == searchData.source ) {
						map.fitBounds( bounds );
						if ( map.getZoom() > 15 ) {
							map.setZoom( 15 );
						}
					} else {
						// If initial load of map, zoom to default settings
						map.setZoom(parseInt(zoom_level));
					}

				});
			}

			function stringFilter(s) {
				filteredValues = "emnpxt%";     // Characters stripped out
				var i;
				var returnString = "";
				for (i = 0; i < s.length; i++) {  // Search through string and append to unfiltered values to returnString.
					var c = s.charAt(i);
					if (filteredValues.indexOf(c) == -1) returnString += c;
				}
				return returnString;
			}

			function createMarker( locationData ) {

				// Init tax heights
				locationData.taxonomyheights = [];

				// Allow plugin users to define Maker Options (including custom images)
				var markerOptions = {};
				if ( 'function' == typeof window.simplemapCustomMarkers ) {
					markerOptions = simplemapCustomMarkers( locationData );
				}

				// Allow developers to turn of description in bubble. (Return true to hide)
				
				markerOptions.map = map;
				markerOptions.position = locationData.point;
				var marker = new google.maps.Marker( markerOptions );
				var str11 = locationData.name; // get the text from the text box here

				str11 = str11.replace(/(&#8220;)|(&#8221;)|[""\u8220\u8221]/g, "& quot;");
				str11= str11.replace(/(&#8216;)|(&#8217;)|[''\u8216\u8217]/g, "'");
				str11 = str11.replace("&#8211;","-"); 
				marker.title = str11;
				markersArray.push(marker);

				var mapwidth = Number(stringFilter(map_width));
				var mapheight = Number(stringFilter(map_height));

				var maxbubblewidth = Math.round(mapwidth / 1.5);
				var maxbubbleheight = Math.round(mapheight / 2.2);

				var fontsize = 12;
				var lineheight = 12;

				if (locationData.taxes.sm_category && locationData.taxes.sm_category != '' ) {
					var titleheight = 3 + Math.floor((locationData.name.length + locationData.taxes.sm_category.length) * fontsize / (maxbubblewidth * 1.5));
				} else {
					var titleheight = 3 + Math.floor((locationData.name.length) * fontsize / (maxbubblewidth * 1.5));
				}

				var addressheight = 2;
				if (locationData.address2 != '') {
					addressheight += 1;
				}
				if (locationData.phone != '' || locationData.fax != '') {
					addressheight += 1;
					if (locationData.phone != '') {
						addressheight += 1;
					}
					if (locationData.fax != '') {
						addressheight += 1;
					}
				}

				for (jstax in locationData.taxes) {
					if ( locationData.taxes[jstax] !== '' ) {
						locationData.taxonomyheights[jstax] = 3 + Math.floor((locationData.taxes[jstax][length]) * fontsize / (maxbubblewidth * 1.5));
					}
				}
				var linksheight = 2;

				var totalheight = titleheight + addressheight;
				for (jstax in locationData.taxes) {
					if ( 'sm_category' != jstax ) {
						totalheight += locationData.taxonomyheights[jstax];
					}
				}
				totalheight = (totalheight + 1) * fontsize;

				if (totalheight > maxbubbleheight) {
					totalheight = maxbubbleheight;
				}

				var html = '<div class="markertext" style="height: ' + 230 + 'px; overflow-y: auto; overflow-x: hidden;">';
				html += '<font color="orange"><h3 style="margin-top: 0; padding-top: 0; border-top: none;">';

				if ( '' != locationData.permalink ) {
					html += '<a href="/?page_id=765&meta_id=' + locationData.postid + '">';
				}
				html += locationData.name;

				if ( '' != locationData.permalink ) {
					html += '</a>';
				}

				if (locationData.taxes.sm_category && locationData.taxes.sm_category != null && locationData.taxes.sm_category != '' ) {
					html += '<br /><span class="bubble_category">' + locationData.taxes.sm_category + '</span>';
				}

				html += '</h3></font> ';

				html += '<p class="buble_address">' + locationData.address;
				if (locationData.address2 != '') {
					html += '<br />' + locationData.address2;
				}
				
				// Address Data
				if (address_format == 'town, province postalcode') {
					html += '<br />' + locationData.city + ', ' + locationData.state + ' ' + locationData.zip + '</p>';
				} else if (address_format == 'town province postalcode') {
					html += '<br />' + locationData.city + ' ' + locationData.state + ' ' + locationData.zip + '</p>';
				} else if (address_format == 'town-province postalcode') {
					html += '<br />' + locationData.city + '-' + locationData.state + ' ' + locationData.zip + '</p>';
				} else if (address_format == 'postalcode town-province') {
					html += '<br />' + locationData.zip + ' ' + locationData.city + '-' + locationData.state + '</p>';
				} else if (address_format == 'postalcode town, province') {
					html += '<br />' + locationData.zip + ' ' + locationData.city + ', ' + locationData.state + '</p>';
				} else if (address_format == 'postalcode town') {
					html += '<br />' + locationData.zip + ' ' + locationData.city + '</p>';
				} else if (address_format == 'town postalcode') {
					html += '<br />' + locationData.city + ' ' + locationData.zip + '</p>';
				}

				// Phone and Fax Data
				if (locationData.phone != null && locationData.phone != '') {
					html += '<p class="bubble_contact"><span class="bubble_phone">' + phone_text + ': ' + locationData.phone + '</span>';
					if (locationData.email != null && locationData.email != '') {
						html += '<br />' + email_text + ': <a class="bubble_email" href="mailto:' + locationData.email + '">' + locationData.email + '</a>';
					}
					if (locationData.fax != null && locationData.fax != '') {
						html += '<br /><span class="bubble_fax">' + fax_text + ': ' + locationData.fax + '</span>';
					}
					html += '</p>';
				} else if (locationData.fax != null && locationData.fax != '') {
					html += '<p>' + fax_text + ': ' + locationData.fax + '</p>';
				}
								
				html += '<p class="bubble_tags">';
				
				for (jstax in locationData.taxes) {
					if ( 'sm_category' == jstax ) {
						continue;
					}
					if ( locationData.taxes[jstax] != null && locationData.taxes[jstax] != '' ) {
						html += taxonomy_text[jstax] + ': ' + locationData.taxes[jstax] + '<br />';
					}
				}
				html += '</p>';

					var dir_address = locationData.point.toUrlValue(10);
					var dir_address2 = '';
					if (locationData.address) { dir_address2 += locationData.address; }
					if (locationData.city) { if ( '' != dir_address2 ) { dir_address2 += ' '; } dir_address2 += locationData.city; };
					if (locationData.state) { if ( '' != dir_address2 ) { dir_address2 += ' '; } dir_address2 += locationData.state; };
					if (locationData.zip) { if ( '' != dir_address2 ) { dir_address2 += ' '; } dir_address2 += locationData.zip; };
					if (locationData.country) { if ( '' != dir_address2 ) { dir_address2 += ' '; } dir_address2 += locationData.country; };

					if ( '' != dir_address2 ) { dir_address = locationData.point.toUrlValue(10) + '(' + escape( dir_address2 ) + ')'; };
								
				html += '		<p class="bubble_links"><a class="bubble_directions" href="http://google' + default_domain + '/maps?saddr=' + locationData.homeAddress + '&daddr=' + dir_address + '" target="_blank">' + get_directions_text + '</a>';
								if (locationData.url != '') {
				html += '			<span class="bubble_website">&nbsp;|&nbsp;<a href="' + locationData.permalink + '" title="' + locationData.name + '" target="_blank">' + visit_website_text + '</a></span>';
								}
				html += '		</p>';

				if (locationData.description != '' && locationData.description != null) {
					var numlines = Math.ceil(locationData.description.length / 40);
					var newlines = locationData.description.split('<br />').length - 1;
					var totalheight2 = 0;

					if ( locationData.description.indexOf('<img') == -1) {
						totalheight2 = (numlines + newlines + 1) * fontsize;
					}
					else {
						var numberindex = locationData.description.indexOf('height=') + 8;
						var numberend = locationData.description.indexOf('"', numberindex);
						var imageheight = Number(locationData.description.substring(numberindex, numberend));

						totalheight2 = ((numlines + newlines - 2) * fontsize) + imageheight;
					}

					if (totalheight2 > maxbubbleheight) {
						totalheight2 = maxbubbleheight;
					}

					//marker.openInfoWindowTabsHtml([new GInfoWindowTab(location_tab_text, html), new GInfoWindowTab(description_tab_text, html2)], {maxWidth: maxbubblewidth});
					// tabs aren't possible with the Google Maps api v3
					html += '<hr /><p>' + locationData.description + '</p>';
				}

				html += '	</div>';

				google.maps.event.addListener(marker, 'click', function() {
					clearInfoWindows();
					var infowindow = new google.maps.InfoWindow({
						maxWidth: 250,
						content: html
					});
					infowindow.open(map, marker);
					infowindowsArray.push(infowindow);
					window.location = '#map_top';
				});

				return marker;
			}
function createMarker_big( locationData ) {

				// Init tax heights
				locationData.taxonomyheights = [];

				// Allow plugin users to define Maker Options (including custom images)
				var markerOptions = {};
				if ( 'function' == typeof window.simplemapCustomMarkers ) {
					//markerOptions = simplemapCustomMarkers( locationData );
                                                  markerOptions.icon = new google.maps.MarkerImage( 
							'https://www.tournament.co.nz/wp-content/plugins/simplemap/inc/images/blue-dot.png',
							new google.maps.Size(30, 51),
							new google.maps.Point(0,0),
							new google.maps.Point(6,51)
						);
				}

				// Allow developers to turn of description in bubble. (Return true to hide)
				
				markerOptions.map = map;
				markerOptions.position = locationData.point;
				var marker = new google.maps.Marker( markerOptions );
				
				var str1 = locationData.name; // get the text from the text box here
str1 = str1.replace(/(&#8220;)|(&#8221;)|[""\u8220\u8221]/g, "& quot;");
str1 = str1.replace(/(&#8216;)|(&#8217;)|[''\u8216\u8217]/g, "'");
				marker.title = str1;
				markersArray.push(marker);

				var mapwidth = Number(stringFilter(map_width));
				var mapheight = Number(stringFilter(map_height));

				var maxbubblewidth = Math.round(mapwidth / 1.5);
				var maxbubbleheight = Math.round(mapheight / 2.2);

				var fontsize = 12;
				var lineheight = 12;

				if (locationData.taxes.sm_category && locationData.taxes.sm_category != '' ) {
					var titleheight = 3 + Math.floor((locationData.name.length + locationData.taxes.sm_category.length) * fontsize / (maxbubblewidth * 1.5));
				} else {
					var titleheight = 3 + Math.floor((locationData.name.length) * fontsize / (maxbubblewidth * 1.5));
				}

				var addressheight = 2;
				if (locationData.address2 != '') {
					addressheight += 1;
				}
				if (locationData.phone != '' || locationData.fax != '') {
					addressheight += 1;
					if (locationData.phone != '') {
						addressheight += 1;
					}
					if (locationData.fax != '') {
						addressheight += 1;
					}
				}

				for (jstax in locationData.taxes) {
					if ( locationData.taxes[jstax] !== '' ) {
						locationData.taxonomyheights[jstax] = 3 + Math.floor((locationData.taxes[jstax][length]) * fontsize / (maxbubblewidth * 1.5));
					}
				}
				var linksheight = 2;

				var totalheight = titleheight + addressheight;
				for (jstax in locationData.taxes) {
					if ( 'sm_category' != jstax ) {
						totalheight += locationData.taxonomyheights[jstax];
					}
				}
				totalheight = (totalheight + 1) * fontsize;

				if (totalheight > maxbubbleheight) {
					totalheight = maxbubbleheight;
				}

				var html = '<div class="markertext" style="height: ' + 230 + 'px; overflow-y: auto; overflow-x: hidden;">';
				html += '<font color="orange"><h3 style="margin-top: 0; padding-top: 0; border-top: none;">';

				if ( '' != locationData.permalink ) {
					html += '<a href="/?page_id=765&meta_id=' + locationData.postid + '">';
				}
				html += locationData.name;

				if ( '' != locationData.permalink ) {
					html += '</a>';
				}

				if (locationData.taxes.sm_category && locationData.taxes.sm_category != null && locationData.taxes.sm_category != '' ) {
					html += '<br /><span class="bubble_category">' + locationData.taxes.sm_category + '</span>';
				}

				html += '</h3></font> ';

				html += '<p class="buble_address">' + locationData.address;
				if (locationData.address2 != '') {
					html += '<br />' + locationData.address2;
				}
				
				// Address Data
				if (address_format == 'town, province postalcode') {
					html += '<br />' + locationData.city + ', ' + locationData.state + ' ' + locationData.zip + '</p>';
				} else if (address_format == 'town province postalcode') {
					html += '<br />' + locationData.city + ' ' + locationData.state + ' ' + locationData.zip + '</p>';
				} else if (address_format == 'town-province postalcode') {
					html += '<br />' + locationData.city + '-' + locationData.state + ' ' + locationData.zip + '</p>';
				} else if (address_format == 'postalcode town-province') {
					html += '<br />' + locationData.zip + ' ' + locationData.city + '-' + locationData.state + '</p>';
				} else if (address_format == 'postalcode town, province') {
					html += '<br />' + locationData.zip + ' ' + locationData.city + ', ' + locationData.state + '</p>';
				} else if (address_format == 'postalcode town') {
					html += '<br />' + locationData.zip + ' ' + locationData.city + '</p>';
				} else if (address_format == 'town postalcode') {
					html += '<br />' + locationData.city + ' ' + locationData.zip + '</p>';
				}

				// Phone and Fax Data
				if (locationData.phone != null && locationData.phone != '') {
					html += '<p class="bubble_contact"><span class="bubble_phone">' + phone_text + ': ' + locationData.phone + '</span>';
					if (locationData.email != null && locationData.email != '') {
						html += '<br />' + email_text + ': <a class="bubble_email" href="mailto:' + locationData.email + '">' + locationData.email + '</a>';
					}
					if (locationData.fax != null && locationData.fax != '') {
						html += '<br /><span class="bubble_fax">' + fax_text + ': ' + locationData.fax + '</span>';
					}
					html += '</p>';
				} else if (locationData.fax != null && locationData.fax != '') {
					html += '<p>' + fax_text + ': ' + locationData.fax + '</p>';
				}
								
				html += '<p class="bubble_tags">';
				
				for (jstax in locationData.taxes) {
					if ( 'sm_category' == jstax ) {
						continue;
					}
					if ( locationData.taxes[jstax] != null && locationData.taxes[jstax] != '' ) {
						html += taxonomy_text[jstax] + ': ' + locationData.taxes[jstax] + '<br />';
					}
				}
				html += '</p>';

					var dir_address = locationData.point.toUrlValue(10);
					var dir_address2 = '';
					if (locationData.address) { dir_address2 += locationData.address; }
					if (locationData.city) { if ( '' != dir_address2 ) { dir_address2 += ' '; } dir_address2 += locationData.city; };
					if (locationData.state) { if ( '' != dir_address2 ) { dir_address2 += ' '; } dir_address2 += locationData.state; };
					if (locationData.zip) { if ( '' != dir_address2 ) { dir_address2 += ' '; } dir_address2 += locationData.zip; };
					if (locationData.country) { if ( '' != dir_address2 ) { dir_address2 += ' '; } dir_address2 += locationData.country; };

					if ( '' != dir_address2 ) { dir_address = locationData.point.toUrlValue(10) + '(' + escape( dir_address2 ) + ')'; };
								
				html += '		<p class="bubble_links"><a class="bubble_directions" href="http://google' + default_domain + '/maps?saddr=' + locationData.homeAddress + '&daddr=' + dir_address + '" target="_blank">' + get_directions_text + '</a>';
								if (locationData.url != '') {
				html += '			<span class="bubble_website">&nbsp;|&nbsp;<a href="' + locationData.url + '" title="' + locationData.name + '" target="_blank">' + visit_website_text + '</a></span>';
								}
				html += '		</p>';

				if (locationData.description != '' && locationData.description != null) {
					var numlines = Math.ceil(locationData.description.length / 40);
					var newlines = locationData.description.split('<br />').length - 1;
					var totalheight2 = 0;

					if ( locationData.description.indexOf('<img') == -1) {
						totalheight2 = (numlines + newlines + 1) * fontsize;
					}
					else {
						var numberindex = locationData.description.indexOf('height=') + 8;
						var numberend = locationData.description.indexOf('"', numberindex);
						var imageheight = Number(locationData.description.substring(numberindex, numberend));

						totalheight2 = ((numlines + newlines - 2) * fontsize) + imageheight;
					}

					if (totalheight2 > maxbubbleheight) {
						totalheight2 = maxbubbleheight;
					}

					//marker.openInfoWindowTabsHtml([new GInfoWindowTab(location_tab_text, html), new GInfoWindowTab(description_tab_text, html2)], {maxWidth: maxbubblewidth});
					// tabs aren't possible with the Google Maps api v3
					html += '<hr /><p>' + locationData.description + '</p>';
				}

				html += '	</div>';

				google.maps.event.addListener(marker, 'click', function() {
					clearInfoWindows();
					var infowindow = new google.maps.InfoWindow({
						maxWidth: 250,
						content: html
					});
					infowindow.open(map, marker);
					infowindowsArray.push(infowindow);
					window.location = '#map_top';
				});

				return marker;
			}

			
			function createSidebarEntry(marker, locationData, searchData) {
				
				
				
				var div = document.createElement('div');
				
				// Beginning of result
				
				var html = '<div id="location_' + locationData.postid + '" class="result">';
				
				html += '<div class="location_txt_main">';
				html += '<div class="location_img"><img width="18" height="30" alt="" src="https://www.tournament.co.nz/wp-content/themes/Tournament2/images/p_img.png"></div>';
				
				html += '<div class="locations_txt">';
				
				
				
					html += locationData.name;
					html += '<br/>';
					html += locationData.address;
					if (locationData.address2 != '') {
						html += ', ' + locationData.address2;
					}
					html += ', ' + locationData.city + ', ' + locationData.state + ' ' + locationData.zip;
					
				html += '<br><span class="number_txt">';
					
					if (locationData.distance.toFixed(1) != 'NaN') {
						if (units == 'mi') {
							html+= locationData.distance.toFixed(1) + ' miles';
						}
						else if (units == 'km') {
							html+= (locationData.distance * 1.609344).toFixed(1) + ' km';
						}
					}
				
					
				html += '</span></div>';
				
				////////////////////locationData.postid//////////////////
				html += '<div class="more_img">';
				html += '<a href="' + locationData.permalink + '"><img width="46" height="19" title="Learn More" alt="Learn More" src="https://www.tournament.co.nz/wp-content/themes/Tournament2/images/more_button.png"></a>';
				//html += '<a href="/?page_id=765&meta_id=' + locationData.postid + '&/'+locationData.name +'"><img width="46" height="19" title="Learn More" alt="Learn More" src="https://www.tournament.co.nz/wp-content/themes/Tournament2/images/more_button.png"></a>';
html += '</div>';
				html += '<br/>';
				html += '</div>';
				html += '</div>';
				
				div.innerHTML = html;
				div.style.cursor = 'pointer'; 
				div.style.margin = 0;

				var icon1 = "https://www.tournament.co.nz/wp-content/plugins/simplemap/inc/images/red-dot.png ";
		        var icon2 = "https://www.tournament.co.nz/wp-content/plugins/simplemap/inc/images/blue-dot.png ";
		        
		        
		        google.maps.event.addDomListener(div,  'mouseover', function() {
		          
		            marker.setIcon(icon2);
		        });
		        google.maps.event.addDomListener(div,  'mouseout', function() {
		          
		            marker.setIcon(icon1);
		        });


				google.maps.event.addDomListener(div, 'click', function() {
					google.maps.event.trigger(marker, 'click');
				});
				return div;
			}
			