(Merkzettel = {
	requestURL: null,
	resultTemplate: null,
	resultList: null,
	buildResultList: function(){
		var container = $('#resultBox').html('');
		if (this.resultList != null)
		{
			var myres = '<hr />';
			if (this.resultList.status == 'ok'){
				myres += '<b>'+this.resultList.message+'</b>';
				
			}else{
				myres += '<b>'+this.resultList.message+'</b>';
				
			}
			myres += '<br /><a href="javascript:location.href=location.href;"><br /><b>Zurück zur Übersicht</b></a>';
			$(container).append(myres);
		}
		else{
			$(container).append('Ein unbekannter Fehler ist beim Versand des Merkzettel aufgetreten: result is NULL');
		}
	},
	commit: function(frm){
		var email = $(frm).find('input[name=mail]'),scope = this;
		var isOk = true;
		//products=cbi:///cms/2262&mandate_cbi:///cms/2327=TT.MM.JJ&mandate_cbi:///cms/2262=TT.MM.JJ&mail=abarnert@piro.net&_finish=Absenden
		if (!$(email).attr('value')||$(email).attr('value')=='Bitte E-Mail -Adresse eingeben'){
			alert('Bitte geben Sie eine gültige E-Mail an!');
			$(email).focus();
		} else {
			var val = $(email).attr('value');
			var data = {};
			$(frm).find('input').each(function(i,e){
				var name = $(e).attr('name');
				if (name){
					if ($(e).attr('type') != 'radio' || $(e).attr('checked') == true)
					{
						//alert('name:'+name +' type:'+$(e).attr('type')+' checked: '+$(e).attr('checked') + ' value: '+$(e).attr('value'));
						if (!data[name]){
							data[name] = $(e).attr('value');
						}else{
							data[name] += ';'+$(e).attr('value');
						}
					}
				}
			});
			scope.requestURL = $(frm).attr('action');
			$.post(scope.requestURL, data, function(json){
//				alert('in json callback');
				if (typeof(json)=='object') 
					scope.resultList = json;
				else scope.resultList = null;
				scope.buildResultList();
			}, 'json');
		}
	},
	initialize: function(){
		var scope = this;
		$(document).ready(function(){
			//alert('inititialize:'+scope);
		});
	}
}).initialize();
