var map;
var infowindow=new Array;
/*******************/
function empty (mixed_var) {

    var key;

    if (mixed_var === "" ||
        mixed_var === 0 ||
        mixed_var === "0" ||
        mixed_var === null ||
        mixed_var === false ||
        mixed_var === undefined
        ){
        return true;
    }

    if (typeof mixed_var == 'object') {
        for (key in mixed_var) {
            return false;
        }
        return true;
    }

    return false;
}
/*******************/
function ucwords (str) {
       return (str+'').replace(/^(.)|\s(.)/g, function ( $1 ) {
        return $1.toUpperCase( );
    } );
}

/*******************/
function initialize(latcenter,loncenter) {

    //geocoder = new google.maps.Geocoder()

    var latlng = new google.maps.LatLng(latcenter,loncenter)
    var myOptions = {
        zoom: 5,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        mapTypeControl:true,
        mapTypeControlOptions: {
            style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
        }
    };
    map = new google.maps.Map(document.getElementById("googlemap"), myOptions);

    //searchLocationsNear(latcenter,loncenter)
}

/**********************/
function createInfoMarker(map,point,name,address,cp,ville,url) {
    if (empty(url)===false)
        name="<a href='"+url+"'>" + name + "</a>"

   // var chdis=""
    //if (parseInt(distance)>0)
        //chdis='(à ' + distance.toFixed(0) + ' km)'
    var html = "<b>" + name + "</b><br /> " + address + "<br />"+cp+" "+ville;

    var i=infowindow.length++
    infowindow[i] = new google.maps.InfoWindow({
        content: html
    })

    var marker = new google.maps.Marker({
        position: point,
        map: map,
        title:name
    });

    google.maps.event.addListener(marker, 'click', function() {
        for(var j=0;j<infowindow.length;j++)
            infowindow[j].close();

        infowindow[i].open(map,marker);
    });

    return marker;

}



