var HiddenForm = Class.create();

HiddenForm.prototype = {

    initialize: function(options) {
        this.options = Object.extend({
            name: 'hidden-form',
            id: 'hidden-form',
            method: 'post',
            action: location.href.parseUri().path
        },options);
        
        // we could probably stand to add some more sanity checks here
        
        if (!$(this.options.id)) {
            document.body.insert({
                top: '<form name="#{name}" id="#{id}" method="#{method}" action="#{action}"></form>'.interpolate(this.options)
            });

        }

        this.form = $(this.options.id);

        return this;
    },

    elements: function(hash) {
		var form = this.form;
		
		$H(hash).keys().each(
			function (key) {
		        form.insert({
		            bottom: '<input type="hidden" name="#{name}" value="#{value}" />'.interpolate({
		                'name': key,
		                'value': hash[key]
		            })
		        });			
			}
			
		);
        return this;

    },

    submit: function() {

        this.form.submit();

    }

}

