{
	xtype: "menu",
	onInitialize: function(i_owner, o_config, s_type) {

		var i_self = this;
		var i_record = o_config.records[0];
		var a_items = [];
		var s_xtype = "themedbutton";

		if (s_type == "grid") {
			s_xtype = "themedmenuitem";
		}

		var b_disabled = true;

		var o_data = i_record.getData();

		if (o_data.hasOwnProperty("USREML")) {
			b_disabled = i_record.get("USREML") ? false : true
		}

		if (o_data.hasOwnProperty("CLNEML")) {
			b_disabled = i_record.get("CLNEML") ? false : true
		}

		var i_button = Ext.widget(s_xtype, {
			itemId : "itm_greeting",
			text: ip2.i18n({
				"da": "Send velkomsthilsen",
				"en": "Send Greeting"
			}),
			iconCls : "icon-mail",
			disabled: b_disabled,
			handler: function(item) {
				Ext.Ajax.request({
					url: "/ip2-Services/wshWelcome.aspx",
					params : {
						// CLNCLNTKN is deprecated
						clienttoken : i_record.get("USRUSRTKN") || i_record.get("CLNCLNTKN")
					},
					success: function (o_response) {
						var o_result = Ext.decode(o_response.responseText, true) || {
							success: false
						};

						var s_title;
						var s_msg;

						if (o_result.success !== false) {
							s_title = ip2.i18n({
								"da" : "Success",
								"en" : "Success"
							});
							s_msg = ip2.i18n({
								"da" : "Velkomsthilsen er sendt",
								"en" : "Greeting has been sendt"
							});
						} else {
							s_title = ip2.i18n({
								"da" : "Fejl",
								"en" : "Failure"
							});
							s_msg = ip2.i18n({
								"da" : "Velkomsthilsen er IKKE sendt",
								"en" : "Greeting has NOT been sendt"
							});
						}

						Ext.Msg.show({
							title: s_title,
							msg: s_msg,
							buttons: Ext.Msg.OK,
							icon: Ext.Msg.INFO
						});
					},
					faliure: function(o_err) {

					}
				});
			}
		});

		var f_change = function(i_content) {

			var i_form = i_content.getForm();
			var i_field;

			if (o_data.hasOwnProperty("USREML")) {
				i_field = i_form.findField("USREML");
			}
			else if (o_data.hasOwnProperty("CLNEML")) {
				i_field = i_form.findField("CLNEML");
			}

			if (i_field) {

				var s_id = i_record.get(i_record.idProperty);

				i_button[s_id ? "enable" : "disable"]();

				i_field.on({
					change: {
						fn: function(i_field, value) {

							var b_valid = i_form.isValid();

							if (s_id) {
								i_button[value && b_valid ? "enable" : "disable"]();
							}
							else {
								i_button.disable();
							}
						},
						scope: "this"
					}
				});
			}
		};

		var f_save  = function(i_content) {

			var i_form = i_content.getForm();
			var i_record = i_form.getRecord();

			var value = i_record.get(i_record.idProperty);
			i_button[value ? "enable" : "disable"]();
		};



		if (s_type != "grid") {
			if (o_config.formId) {
				ip2.App.mon(i_owner, "contentReady", f_change);
				ip2.App.mon(i_owner, "contentSave", f_save);
			}

		}

		a_items.push(i_button);

		return a_items;
	}
};
