s.invite = function(selector){
	this.form = $(selector);
}

s.invite.prototype.append = function(){
	y.util.Event.addListener(this.form, "submit", function(event){
		y.util.Event.preventDefault(event);
		this.send();
	},this,true);
}

s.invite.prototype.send = function(){
	y.util.Connect.setForm(this.form);
	y.util.Connect.asyncRequest('POST', this.form.action, this.callback(this.form));
}

s.invite.prototype.callback = function(form){
	return {
		'customevents':{
			'onStart': function(eventType, args) {
				s.notifications.show(dict['sending_invitation'] ,'wait');
			},
			'onSuccess': function(eventType, args) {
				try {
					response = y.lang.JSON.parse(args[0].responseText);
					if (response.status==1){
						form.email.value = '';
					}
					s.notifications.show(response.message,'info');
				}
				catch (error) {
					s.notifications.show(dict['ajax_error']+ ': '+error,'error');
				}
			},
			'onFailure': function(eventType, args) {
				s.notifications.show(dict['ajax_error'] + ': '+error,'error');
			}
		}
	}
}