Ext.onReady(function(){
Ext.util.CSS.swapStyleSheet('theme', './extjs/resources/css/xtheme-gray.css');	

});


function sendGreetings(id){

greetingForm = new Ext.FormPanel({
        	region: 'center',
        	frame: false,
        	bodyStyle:'padding:5px 5px 0;text-align:center',
        	defaultType: 'textfield',
        	//fileUpload: true,
        	el: 'greetform',
        	items:[
        		{
        			fieldLabel: 'Ihr Name',
        			invalidText: 'Bitte Name eingeben',
        			name: 'name',
        			allowBlank: false,
        			width: 500,
        			labelStyle: 'color:black;'
        		},
        		{
        			fieldLabel: 'Ihr Vorname',
        			invalidText: 'Bitte Vorname eingeben',
        			name: 'vorname',
        			allowBlank: false,
        			width: 500,
        			labelStyle: 'color:black;'
        			
        		},
        		{
        			fieldLabel: 'Ihre Email',
        			invalidText: 'Bitte Email eingeben',
        			name: 'email',
        			allowBlank: false,
        			width: 500,
        			labelStyle: 'color:black;'
        		},
        		{
        			xtype: 'htmleditor',
        			fieldLabel: 'Nachricht',
        			labelStyle: 'color:black;',
        			name: 'nachricht',
        			allowBlank: false,
        			invalidText: 'Bitte Nachricht eingeben',
        			width: 500,
        			height: 300,
        			enableLists: false,
        			enableSourceEdit: false,
        			enableFont: false,
        			enableFontSize: false,
        			enableLinks: false
        			
        		}
        		/*{
        			fieldLabel: 'Kartendatei',
        			name: 'projektkarte',
        			//allowBlank: false,
        			inputType: 'file'
        		}*/
        	],
        	buttons:[
        		{
        			text: 'Abschicken',
        			handler: function(){
        					greetingForm.getForm().submit({
        						url: './preparemessage.htm',
        						method: 'post',
        						params: {id: id},
        						waitMsg: 'Daten werden uebertragen',
        						clientValidation:true,
        						success: function(form,action){
        							var accountId=action.result.accountId;
        							var subId=action.result.subId;
        							var amount=action.result.amount;
        							var mode=action.result.mode;
        							var rdUrl=action.result.rdUrl;
        							var sessId=action.result.sessId;
        							var payUrl='https://ssl.ecs-solution.de/cgi-bin/gateway.cgi?AID='+accountId+'&SID='+
        							subId+'&AMOUNT='+amount+'&MODE='+mode+'&RDURL='+rdUrl+'&LANG=DE&mod=page&op=redirect&sessId='+sessId;
        							var iframe='<iframe src="'+payUrl+'" name="payframe" height=568 width=785>Ohne Iframe keine Zahlung</iframe>';
									mainWin.body.update(iframe);
        						},
        						failure: function(form,action){
        							Ext.MessageBox.alert("Fehler",action.result.errorText);
        						}
        					});
        					
        				}
        		},
        		{
        			text: 'Abbrechen',
        			handler: function(){mainWin.hide();}
        		}
        	]
        });

        
        //... basteln das Formular in ein Window...
        mainWin= new Ext.Window({
        	el: 'greetwin',
        	title: 'Flirtgruß',
            closable:true,
            modal: true,
            border: false,
            width: 800,
            height: 600,
            plain: false,
            layout: 'border',

            items: [greetingForm]
        });
		//... und zeigen das Window an. 
        mainWin.show();

}



