function mailform(){

Ext.BLANK_IMAGE_URL = 'Mailform/resources/images/default/s.gif';

var BLANKTEXT = 'Dieses Feld darf nicht leer sein!';
var d = new Date();

var date = new Ext.form.DateField({
	id: 'hiddendate',
	name: 'date',
	format : 'd.m.Y',
	value: d,
	hidden: true
});

var btn_send = new Ext.Button({
	name: 'sendmail',
	id: 'btn_send'
});

var fname = new Ext.form.TextField({
	id: 'fname',
	name: 'fname',
	blankText : BLANKTEXT,
	allowBlank : false,
	fieldLabel: 'Vorname'
	
});

var lname = new Ext.form.TextField({
	id: 'lname',
	name: 'lname',
	blankText : BLANKTEXT,
	allowBlank : false,
	fieldLabel: 'Nachname'
});

var telefon = new Ext.form.TextField({
	id: 'tel',
	name: 'tel',
	blankText : BLANKTEXT,
	allowBlank : false,
	fieldLabel: 'Telefon'
});

var fax = new Ext.form.TextField({
	id: 'fax',
	name: 'fax',
	fieldLabel: 'Fax'
});

var mail = new Ext.form.TextField({
	id: 'mail',
	name: 'mail',	
	blankText : BLANKTEXT,
	allowBlank : false,
	fieldLabel: 'E-Mail'
});

var ort = new Ext.form.TextField({
	id: 'ort',
	name: 'ort',
	blankText : BLANKTEXT,
	allowBlank : false,
	fieldLabel: 'Ort'
});

var strasse = new Ext.form.TextField({
	id: 'street',
	name: 'strasse',
	blankText : BLANKTEXT,
	allowBlank : false,
	fieldLabel: 'Strasse/Nr.'
});

var plz = new Ext.form.TextField({
	id: 'plz',
	name: 'plz',
	blankText : BLANKTEXT,
	allowBlank : false,
	fieldLabel: 'Postleitzahl'
});

var yacht1 = new Ext.form.TextField({
	id: 'yacht1',
	name: 'yacht1',
	blankText : BLANKTEXT,
	allowBlank : false,
	fieldLabel: 'Charteryacht'
});

var yacht2 = new Ext.form.TextField({
	id: 'yacht2',
	name: 'yacht2',
	fieldLabel: 'alternative Yacht'
});

var yacht3 = new Ext.form.TextField({
	id: 'yacht3',
	name: 'yacht3',
	fieldLabel: 'alternative Yacht'
});

var vonDatum = new Ext.form.DateField({
	id: 'from',
	name: 'vonDatum',
	format : 'd.m.Y',
	blankText : BLANKTEXT,
	allowBlank : false,
	fieldLabel: 'Charterzeitraum von'
});

var bisDatum = new Ext.form.DateField({
	id: 'to',
	name: 'bisDatum',
	format : 'd.m.Y',
	blankText : BLANKTEXT,
	allowBlank : false,
	fieldLabel: 'bis'
});

var text = new Ext.form.TextArea({
	id: 'text',
	name: 'text',
	width: 400,
	height: 90,
	fieldLabel: 'Freitext'
});

var revier = new Ext.form.ComboBox({
	id:'cbxRevier',
	editable: false,
	mode:'local',
	hiddenName:'revier',
	store: new Ext.data.ArrayStore({
        id: 'revierStore',
        fields: [
            'revier'
        ],
        data: [['Balearen/Spanien'], 
        		['Dänemark'],
        		['Deutschland/Nordsee'],
        		['Deutschland/Ostsee'],
        		['Finnland'],
        		['Frankreich'],
        		['Frankreich/Bretagne'],
        		['Griechenland'],
        		['Irland'], 
        		['Italien'],
        		['Kanaren'], 
        		['Karibik'],
        		['Kroatien'], 
        		['Kuba'],
        		['Malta'], 
        		['Martinique'],
        		['Norwegen'], 
        		['Portugal'],
        		['Schottland'], 
        		['Schweden'],
        		['St. Lucia'], 
        		['Südengland/Cornwall'],
        		['Türkei'], 
        		['Zypern']
        ]
    }),
    valueField: 'revier',
    displayField: 'revier',
	xtype : 'combo',
	triggerAction: 'all',
	emptyText: 'Revier wählen..',
	width: 150,
	blankText : BLANKTEXT,
	allowBlank : false,
	fieldLabel: 'Segelrevier'
});

var personPanel = new Ext.Panel({
	border: false,
	bodyBorder: false,
	layout:'column',
	defaults : {
		layout : 'form'
	},
	items : [{
			labelWidth: 100,
			columnWidth : 0.5,
			items : [fname, lname, strasse, ort]
		}, {
			labelWidth: 100,
			//labelAlign: 'right',
			columnWidth : 0.5,
			items : [plz, telefon, mail, fax]
	}]
});

var charterPanel = new Ext.Panel({
	border: false,
	bodyBorder: false,
	layout:'column',
	defaults : {
		layout : 'form'
	},
	items : [{
			labelWidth: 100,
			columnWidth : 0.5,
			items : [yacht1, yacht2, yacht3]
		}, {
			labelWidth: 130,
			labelAlign: 'right',
			columnWidth : 0.5,
			items : [vonDatum, bisDatum, revier]
	}]
});

var bemPanel = new Ext.Panel({
	border: false,
	bodyBorder: false,
	layout: 'form',
	items: [text, date]
});

var mailform = new Ext.form.FormPanel({
	frame:true,
	method: 'POST',
	url:'../mailto.php',
	border: false,
	bodyBorder: false,
	layout:'border',
	items : [{
			region: 'north',
			height: 110,
			items : [personPanel]
		}, {
			region:'center',
			height: 100,
			items : [charterPanel]
		}, {
			region: 'south',
			height: 90,
			items: [bemPanel]
		}
	]
});

var mailwindow = new Ext.Window({
	id : 'window',
	title : 'Charteranfrage an Adriacharter',
	width : 600,
	height : 360,
	layout : 'fit',
	border: false,
	bodyBorder: false,
	buttonAlign : 'center',
	resizable : true,
	closable : false,
	//constrainHeader : true,
	modal : true,
	items : mailform,
	buttons : [{
		text : 'Senden',
		handler : function() {
			if (mailform.form.isValid()) {
				mailform.form.submit({
					failure : function(form, action) {
						Ext.MessageBox.alert('Statusmeldung', 'Ihre Anfragemail wurde erfolgreich verschickt.');
						mailwindow.close();
					},
					success : function(form, action) {
						mailwindow.close();
					}
				});
			}
			else {
				Ext.MessageBox.alert('Fehler', 'Bitte füllen Sie die fehlenden Felder aus.');
			}
		}
	}, {
		text : 'Abbrechen',
		handler : function() {
			mailwindow.close();
		}
	}]
});

Ext.onReady(function(){
	mailwindow.show();
});
};