';
                var counter = 0;
                for (i = 0; i < locations.length; i++) {
                    // grab place type for current building
                    var place_type = locations[i][4];
                    // filter
                    if ((placeTypeFilter == 0) || (placeTypeFilter == place_type)) {
                        // color code marker
                        switch(place_type) {
                            case 1:
                                image_src = '//contact/img/ui/marker-blue.png';
                                break;
                            case 2:
                                image_src = '//contact/img/ui/marker-orange.png';
                                break;
                            case 3:
                                image_src = '//contact/img/ui/marker-green.png';
                                break;
                            case 4:
                                image_src = '//contact/img/ui/marker-red.png';
                                break;
                            
                            case 5:
                                image_src = '//contact/img/ui/marker-purple.png';
                                break;
                            default:
                                image_src = '//contact/img/ui/marker-blue.png';
                        }
                        var myIcon = new google.maps.MarkerImage(image_src, null, null, null, new google.maps.Size(22,30));
                        var marker = new google.maps.Marker({
                            position: new google.maps.LatLng(locations[i][2], locations[i][3]),
                            animation: google.maps.Animation.DROP,
                            map: map,
                            icon: myIcon
                        });
                        google.maps.event.addListener(marker, 'click', (function(marker, i) {
                            return function() {
                                var nameArray = locations[i][0].split('/');
                                var name = '';
                                if (nameArray.length > 1) {
                                        name = nameArray[1];
                                }
                                infowindow.setContent('' + name + '' + locations[i][1] + '' + directionsLink(locations[i])+ '');
                                infowindow.open(map, marker);
                                map.setZoom(16);
                                $.smoothScroll({
                                    scrollTarget: '#campus-map'
                                });
                            }
                        })(marker, i));
                        markers.push(marker);
                        legend_html += '
- ';
                        legend_html += '' + locations[i][0] + '<\/a>';
                        legend_html += '
 ';
                        if (((counter+1) % 10) == 0) {
                            legend_html += '';
                            legend_html += '
 ';
                            legend_html += '';
                            legend_html += '
';
                        }
                        counter++;
                    }
                }
                legend_html += '
';
                $("#places-" + placeTypeFilter).html(legend_html);
                $(document).foundation('reflow');
            }
        }
        // When the window has finished loading create our google map below
        google.maps.event.addDomListener(window, 'load', gmaps.init(0));
        $(document).foundation({
            tab: {
                callback : function (tab) {
                    var hash = tab.context.hash;
                    var placeType = hash.split("-")[1];
                    deleteMarkers();
                    gmaps.init(placeType);
                    // setAllMap(map);
                }
            }
        });
        // Sets the map on all markers in the array.
        function setAllMap(map) {
            for (var i = 0; i < markers.length; i++) {
                markers[i].setMap(map);
            }
        }
        // Removes the markers from the map, but keeps them in the array.
        function clearMarkers() {
            setAllMap(null);
        }
        // Shows any markers currently in the array.
        function showMarkers() {
            setAllMap(map);
        }
        // Deletes all markers in the array by removing references to them.
        function deleteMarkers() {
            clearMarkers();
            markers = [];
        }
        // This function generates a link to a Larger Google Map defaulting to directions mode
        function directionsLink(loc) {
            var href = 'maps.google.com/maps?f=d&hl=en&saddr=&daddr=';
            // concatinate address
            href += encodeURIComponent(loc[1].replace('
', ','));
            // lat, long, zoom
            href += '@' + loc[2] + ',' + loc[3] + '&ie=UTF8&z=15';
            // return link
            return '';
        }
        // This function picks up the click and opens the corresponding info window
        function locate(i) {
            google.maps.event.trigger(markers[i], "click");
        }
        $(function(){
            if(window.location.hash == '#map') {
                $('a[href="#campus-map"]').click();
                window.location.hash = "#campus-map";
            }
        });