    
/**
 * Update the share/embed links on the page as they move the map.
 */
PEGoogleMap.prototype.stateUpdated = function(state) {
    var pemap_host = 'http://' + window.location.host;
    var pemap_path = window.location.pathname + '?' + 'll=' + state.latitude + ',' + state.longitude + '&z=' + state.zoom + '&v=' + state.version;
    
  
    if (state.pointContents && state.pointContents.place) {
        pemap_path += '&pll=' + state.pointContents.place['@lat'] + ',' + state.pointContents.place['@lng'];
        
        if (state.pointContents.place.address != '') {
            pemap_path += '&pq=' + state.pointContents.place.address;
        }
        if (state.pointContents.place.title != '') {
            pemap_path += '&pn=' + state.pointContents.place.title;
        }
        if (state.pointContents.place.description && state.pointContents.place.description['#cdata-section'] != '') {
            pemap_path += '&pd=' + state.pointContents.place.description['#cdata-section'];
        }
    } else if (state.sets && state.sets != '') {
        pemap_path += '&set=' + state.sets;
    }
    if (state.setsName && state.setsName != '') {
        //pemap_path += '&sn=' + state.setsName;
    }
    if (state.setsCurrent && state.setsCurrent != '') {
        pemap_path += '&sd=' + state.setsCurrent;
    }
    if (state.customerId && state.customerId != '' && state.customerId != '-1') {
        pemap_path += '&c=' + state.customerId;
    }
    if (state.sidebarHidden) {
        pemap_path += '&sh=true';
    }
    pemap_path += '&refcon=share';
    
    $('.share-link').val(pemap_host + pemap_path);
    $('.embed-link').val('<iframe width=\'942\' height=\'680\' frameborder=\'0\' scrolling=\'no\' marginheight=\'0\' marginwidth=\'0\' src=\'' + pemap_host + pemap_path + '&output=embed&refcon=em&refid=0\'></iframe><br/><small><a href=\'' + pemap_host + pemap_path + '\'>View Larger Map</a></small>');
    
    // save link in the info windows..
    $('.save-link').attr('href',pemap_path.replace('maps','maps/duplicate'));
}

// executed when a user clicks a link in the flyout
PEGoogleMap.prototype.mediaOpen = function(mediaId, otherId) {
//    return confirm('do you want to go to the (' + mediaId + ',' + otherId + ') media page?');
}

// executed when a user clicks a link in the flyout
PEGoogleMap.prototype.placeOpen = function(placeId, otherId) {
//    return confirm('do you want to go to the (' + placeId + ',' + otherId + ') place page?');
}

