function subscribeErrorDecorator() {};

subscribeErrorDecorator.prototype = {
    start : function() {
        var errorUl = $('div#signup-form ul.jforms-error-list');
        if (errorUl.length == 0) {
            $('div#signup-form').prepend('<ul class="jforms-error-list"></ul>');
        } else {
            $('ul.jforms-error-list').html('');
        }
        $('ul.jforms-error-list').hide();
    },
    addError : function(control, messageType) {
        var message='';
        if (messageType == 1) {
            message = control.errRequired;
        } else if(messageType == 2) {
            message = control.errInvalid;
        } else {
            message = "Error on '"+control.label+"' field";
        }
        var item = '<li>'+message+'</li>';
        $('ul.jforms-error-list').append(item);
    },
    end : function() {
        var errorUl = $('div#signup-form ul.jforms-error-list');
        if (errorUl.length == 1) {
            errorUl.show();
            if (location.href.match('#signup-form') != null) {
                location.href = location.href;
            } else {
                location.href+= '#signup-form';
            }
        }
    }
};
