var FormHelpers = new Class({});
FormHelpers.shown = false;

FormHelpers.reset = function () {
    $("addMapMarker").reset();
    $$("#addMapMarker input[type=hidden]").each(function(el) { el.value = ""; })
}

FormHelpers.setLatLng = function (latlng) {
    $("lat_h").value = latlng.lat();
    $("lng_h").value = latlng.lng();
}

FormHelpers.changeIcon = function (icon) {
    maps.changeMarkerIcon(icon);
    $("icon_h").set('value', icon);
}
var sandboxx;
FormHelpers.setAddress = function (address) {
    $("address").set('text', address);
    $("address_h").set('value', address);
}

Element.implement ('show', function  () {
    if (this.slider === undefined) {
        this.slider = new Fx.Morph(this, {duration: 'short', transition: Fx.Transitions.Sine.easeOut});
    }

    if (this.style.display === 'none' || this.style.display === '') {
        this.slider.start({
            'top': [-200, -10]
        });
        this.style.display = 'inline';
    }
});

/**
 * Hides Add Marker Form. Assumes that Form was shown.
 */
FormHelpers.hide = function () {
    if (this.slider === undefined) {
        return;
    }

    if (this.shown === true) {
        this.slider.start({
            'top': [-10, -200]
        });
        this.shown = false;
    }
};

FormHelpers.hideAndRemoveMarker = function () {
    FormHelpers.hide();
    maps.removeLastMarker();
};

