I must adjust a website, but I don't understand this function:

```
var geocoder;
var map;
var markersArray = [];
var bounds;
var infowindow;
var appena_entrato = true;
var mappa_attiva = "tt";

```

-- Initialize\_map

```
function initialize_map() {
    markersArray = [];

    var myLatlng = new google.maps.LatLng(45.6841895,11.4775636);
    var myOptions = {
        zoom: 14,
        maxZoom: 18,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        scrollwheel: false,
        disableDoubleClickZoom: true,
        mapTypeControl: false,
        panControl: true,
        panControlOptions: {
            position: google.maps.ControlPosition.TOP_RIGHT
        },
        zoomControl: true,
        zoomControlOptions: {
            style: google.maps.ZoomControlStyle.LARGE,
            position: google.maps.ControlPosition.RIGHT_TOP
        },
        scaleControl: false,
        streetViewControl: false
    }
    geocoder = new google.maps.Geocoder();
    map = new google.maps.Map(document.getElementById("map-canvas-"+mappa_attiva), myOptions);
    var marker = new google.maps.Marker({
        position: new google.maps.LatLng(45.6841895,11.4775636),
        map: map,
        title:"COMPANY NAME"
    });
    marker.setMap(map);
    var contentString = '<div>'+
            '<h2>COMPANY NAME</h2>'+
            '<div style="width:400px;">'+
                '<p>ADDRESS<br>' +
                'Ph. +39 0000- Fax. +39 00000</p>'+
            '</div>'+
        '</div>';
    marker.infowindow = new google.maps.InfoWindow({
        content: contentString
    });
    google.maps.event.addListener(marker, 'click', function() {
        marker.infowindow.open(map,marker);
    });
    markersArray.push(marker);
    for (i in markersArray) {
        markersArray[i].infowindow.open(map,markersArray[i]);
    }
    getLocation();
}

```

-- GetLocation 

```
function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        //console.log("Geolocation not supported!");
    }
}

```

-- ShowPosition

```
function showPosition(position) {
    var myLatlng = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
    map.setCenter(myLatlng);
    map.setZoom(9);

  coordsAddress(position.coords.latitude,position.coords.longitude,function(results){
        for (var i=0; i<results.length; i++) {
            for (var b=0; b<results[i].types.length; b++) {
                if (results[i].types[b] == "administrative_area_level_2") {
                    var indice = i;
                }
            }
        }
        for (var i=0; i<results[indice].address_components.length; i++) {
            for (var b=0; b<results[indice].address_components[i].types.length; b++) {
                if (results[indice].address_components[i].types[b] == "administrative_area_level_2") {
                    var postalCode = results[indice].address_components[i].short_name;
                }
            }
        }
        $("#provincia option:selected").removeAttr("selected");
        $("#provincia option[value="+postalCode+"]").prop("selected",true);
        mostra_coords(position.coords.latitude, position.coords.longitude, 50);
    });
}   

```

-- Code Address

```
function codeAddress(zipCode,country,callback) {
    geocoder.geocode({address: zipCode, region: country}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            if (results[0]) {
                callback(results);
            } else {
                alert('No results found');
            }
        } else {
            alert("Geocode was not successful for the following reason: " + status);
        }
    });
}

```

-- CoordsAddress

```
 function coordsAddress(latitude,longitude,callback) {
    var myLatlng = new google.maps.LatLng(latitude,longitude);
    geocoder.geocode({'latLng': myLatlng}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            if (results[0]) {
                callback(results);
            } else {
                alert('No results found');
            }
        } else {
            alert("Geocode was not successful for the following reason: " + status);
        }
    });
}

```

--Add marker

```
function add_spillo(indirizzo) {
    var id = indirizzo.attr("id");
    var geo = indirizzo.attr("rel");
    var text = indirizzo.parent().html();
    var icona = 'img/point.png';
    indirizzo = geo.split(",");
    var myLatlng = new google.maps.LatLng(indirizzo[0],indirizzo[1]);
    var marker = new google.maps.Marker({
        position: myLatlng, 
        map: map,
        icon: icona
    });
    marker.infowindow = new google.maps.InfoWindow({
        content: text
    });
    google.maps.event.addListener(marker, 'click', function () {
        marker.infowindow.open(map, marker);
    });
    markersArray.push(marker);
    bounds.extend(myLatlng);
}

```

-- Map centre

```
function centra_mappa(coords) {
    var lat = coords.lat();
    var lon = coords.lng();

    var max_lon = map.getBounds().getNorthEast().lng();
    var max_lat = map.getBounds().getNorthEast().lat();
    var min_lon = map.getBounds().getSouthWest().lng();
    var min_lat = map.getBounds().getSouthWest().lat();

    max_lon = Math.max(lon, max_lon);
    min_lon = Math.min(lon, min_lon);
    max_lat = Math.max(lat, max_lat);
    min_lat = Math.min(lat, min_lat);

    var ne = new google.maps.LatLng(max_lat, max_lon);
    var sw = new google.maps.LatLng(min_lat, min_lon);

    var nuovi_bordi = new google.maps.LatLngBounds(sw, ne);

    map.fitBounds(nuovi_bordi);
}

```

-- Delete Overlays

```
function deleteOverlays() {
    if (markersArray) {
        for (i in markersArray) {
            markersArray[i].infowindow.close();
            markersArray[i].setMap(null);
        }
        markersArray.length = 0;
    }
}

```

-- Coords Show

```
function mostra_coords(lat, lng, distance) {
    customurl = "../ajax/negozi.php";
    $("#boxNegozi-"+mappa_attiva+" ul").load(customurl, {
        lat: lat,
        lng: lng,
        distance: distance,
        brand: mappa_attiva
    }, function(data) {
        if (data == "") return alert("No shops found on your search1");
        deleteOverlays();
        bounds = new google.maps.LatLngBounds();
        $(data).find("input").each(function(index, element) {
            add_spillo($(this));
        });
        map.fitBounds(bounds);
        appena_entrato = false;
    });
}

```

-- Provincia Show

```
function mostra(provincia) {
    customurl = "../ajax/negozi.php";
    $("#boxNegozi-"+mappa_attiva+" ul").load(customurl, {
        provincia: provincia,
        brand: mappa_attiva
    }, function(data) {
        if (data == "") return alert("No shops found on your search2");
        deleteOverlays();
        bounds = new google.maps.LatLngBounds();
        $(data).find("input").each(function(index, element) {
            add_spillo($(this));
        });
        map.fitBounds(bounds);
    });
}

```

--Nazione Show

```
function mostra_nazione(nazione) {
    customurl = "../ajax/negozi.php";
    $("#boxNegozi-"+mappa_attiva+" ul").load(customurl, {
        country: nazione,
        brand: mappa_attiva
    }, function(data) {
        if (data == "") return alert("No shops found on your search3");
        deleteOverlays();
        bounds = new google.maps.LatLngBounds();
        $(data).find("input").each(function(index, element) {
            add_spillo($(this));
        });
        map.fitBounds(bounds);
    });
}

google.maps.event.addDomListener(window, 'load', initialize_map);
$(document).ready(function(){
    $("#provincia-ttt").change(function(){
        var provincia = $(this).val();
        mostra(provincia);
    });
    $("#provincia-tt").change(function(){
        var provincia = $(this).val();
        mostra(provincia);
    });

    $("#nazione-ttt").change(function(){
        console.log($(this).val());
        if ($(this).val() == "IT") $("#teen_provincia").show();
        else {
            $("#teen_provincia").hide();
            mostra_nazione($(this).val());
        }
    });

    $('#tabs a').click(function (e) {
        e.preventDefault();
        $(this).tab('show');
        if ($(this).attr('href') == "#orange") {
            mappa_attiva = "ttt";
        } else {
            mappa_attiva = "tt";
        }
        initialize_map();
        $("#provincia-"+mappa_attiva).val("");
        $("#boxNegozi-"+mappa_attiva+" ul").html("");
    });
});

```

-- I MADE THIS PHP PAGE BUT DON'T WORK, WHERE I MAKE ERROR? thanks in advance

```
    <?
$dbname            ='ltaketwd_db'; //Name of the database
$dbuser            ='ltaketwd_admin'; //Username for the db
$dbpass            ='Twork.01'; //Password for the db
$dbserver          ='localhost'; //Name of the mysql server

$dbcnx = mysql_connect ("$dbserver", "$dbuser", "$dbpass");
mysql_select_db("$dbname") or die(mysql_error());

$query = mysql_query("SELECT * FROM negozi");
while ($row = mysql_fetch_array($query)){

$lat=$row['lat'];
$lng=$row['lng'];
$distance=$row['distance'];
$name=$row['name'];
$indirizzo=$row['indirizzo'];
$provincia=$row['provincia'];
    $nazione=$row['nazione'];
}
?>

```