function toggleElement(id, callbacks) {
    if(callbacks != undefined && callbacks['before'] != undefined) {
        callbacks['before']();
    }

    if($(id).style.display == 'none') {
        new Effect.Appear(id);
    } else {
        new Effect.Fade(id);
    }
    return false;
}

function gIcon() {

    this.image = window.location.protocol + '//' + window.location.host + '/img/ggsa_marker.png';
    this.lat   = -34.07256864540124;
    this.lng   = 18.431196212768555;

    this.getIcon = function () {
        var icon = new google.maps.Icon();
        icon.image = this.image;
        icon.iconSize = new google.maps.Size(27, 30);
        icon.iconAnchor = new google.maps.Point(6, 20);
        icon.infoWindowAnchor = new google.maps.Point(5, 1);
        return icon;
    }

    this.getMarker = function() {
        var marker = new google.maps.Marker(new google.maps.LatLng(this.lat, this.lng), { icon: this.getIcon() });
        google.maps.Event.addListener(marker, 'click', function() {
            marker.openInfoWindowHtml('<strong>GreaterGood South Africa Trust</strong>');
        });
        return marker;
    }

    return this.getMarker();
}

// disable the first submit button for given form element on submit
function disableOnSubmit(form) {
    Event.observe(form, 'submit', function() {
        $$('input[type=submit]')[0].disable().value = 'Please wait...';
    });
}

// use as an event handler to empty a form field on focus
function emptyOnFocus(event) {
    if(event.target.value != '') event.target.value = '';
}

// use as an event handler to populate a form field with value on blur
function populateOnBlur(value) {
    return function(event) {
        if(event.target.value == '') event.target.value = value;
    }
}