



var googlemaps_locatieselect_alle_label = 'Kies een lokatie';
/*
 * Verstuur link naar kennis. 
 */
function verstuurUrl(){

    var valid = FormRequest.newInstance('VerstuurURLForm').submit('/alliander-shared/verstuurURLJS.form');
    if(valid){
        $('#verstuurAlerts').text('Uw bericht is verstuurd.');
        
        setTimeout(function(){
            // haal popup weg
            $('#ControlPanel').remove();
        }, 3000);
    }
    return false;
}

/*
 * Meld aan voor evenement.
 */
function aanmeldenEvenement(form, styleId) {
    var success = FormRequest.newInstance(form).submit('/alliander-shared/aanmeldenEvenementJS.form');
    if(success){
        $('#successMessage_' + styleId).css("display","block");
        $('#AanmeldForm_' + styleId).remove();
        setTimeout(function(){
            // haal popup weg
            $('div#reminderEve' + styleId + ' a.closemodal').click()
            $('#successMessage_' + styleId).css("display","none");
        }, 3000);
    }
    return false;
}

/**
 * Function called by modalbox.js if
 * in overlay.
 */
function checkGmapsInOverlay() {
    
    var maps = $('div#Modalbox div.gmap:visible');
    if(maps.length === 0){
        return;
    }
    
    // kijk of er gmap(s) op de pagina staan
    maps.each(function(){
    
            //TODO Destroy previous maps
    
            var mapDiv = $(this);
            var mapId = mapDiv.attr('id');
            var singleMapUtils = new GmapsUtils({'elementId' : mapId, 'initialZoom' : 11, 'isSingle' : true});
            
            var rel = $('a#lnk_' + mapId.split('_')[1]);
            if(rel.length > 0) {
                var relId = rel.attr('rel');
                singleMapUtils.readXMLLocaties('/alliander-shared/ajaxResponse.inc?param=locatie&content-type=text/xml&tcmid=' + relId);
            }
            
            singleMapUtils.init();
            singleMapUtils.highlight();
            singleMapUtils.gotoLocation();
     });
    
}
