$.fn.ajaxSubmit = function(e) {
	/* Change a form's submission type to ajax */
	this.submit(function(){
		
		var params = {};
		$(this).find("input[@checked], input[@type='text'], input[@type='hidden'], input[@type='password'], input[@type='submit'], option[@selected], textarea").filter(":enabled").each(function() {
			params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
		});
		
		$.post(this.getAttribute("action") + "?call=ajax", params, function(xml) {
			$('div#ssMailerWarnung').hide('slow', function(){
				$(this).html('<h3>'+$(xml).find('header').text()+'</h3><p>'+$(xml).find('error').text()+'</p>').slideDown('slow');
				$('input').removeAttr('style');
				$(xml).find('fields').children().each(function(){
					$('input[name='+$(this).text()+']').show('slow',function(){
						$(this).css({border:"2px dotted #ff3100",backgroundColor:"#ff6a65",color:"#616161"}).show('slow');
					});
				});

				// Prüfen ob das Formular abgeschickt werden kann.
				var codexml = $(xml).find('codes').text();
				if(codexml == '0')
				{ 
					$('form#myform').hide('slow');
				}	
			});
		});
		
		return false;
	});
	return this;
}

$(document).ready(function(){
	$("#myform").ajaxSubmit();
});

document.write('<div id="ssMailerWarnung"></div>');
