function checkForm(form) {
	
	//Formatierung löschen
	$("input").removeClass("fehler");
	$("textarea").removeClass("fehler");
	
	$.ajax({
	   type: "POST",
	   url: "checkFormAndMail.php",
	   data: $('#'+form).serialize(),
	   error: function(){
		   //Fehler im Ajax-Auruf
		   getDialog('formContact_fehler',200,300);
		   
	   },
	   success: function(msg){
			//die ersten drei Zeichen bestimmen den Fehlercode
			var code = msg.substring(0,3);
						
			switch (Math.abs(code)) {
				case 0: //Daten wurden erfolgreich verschickt
						$("input").removeClass("fehler");
						$("textarea").removeClass("fehler");
						$('#'+form).clearForm(),
						getDialog('formContact_send',200,300);
						break;
				
				case 40: //Felder sind nicht leer
						getDialog('formContact_empty',200,300);
						var inputs = msg.split("$#$");
						for (var i = 1; i < inputs.length-1; i++) {
							$('#'+inputs[i]).addClass("fehler");
						}
						break;
				
				default:
					getDialog('formContact_fehler',200,300);
			}
	   }
	 });
}
	
function getDialog(dialogId, h, w) {
	// getModalDialog - erzeugt den User - Dialog (anahnd von "mode") 
		
	h = (typeof h == "undefined") ? 220 : h;
	w = (typeof w == "undefined") ? 380 : w;

	tb_show('', 'modalDialogs.php?height='+h+'&width='+w+'&dialogId='+dialogId, 'thickbox');
		
}

function updatePlayer(file,id) {
		
	$('#downloadItem').empty();
	
	s1.addVariable("file",file);
	s1.addVariable("autostart","true");
	s1.write("jw_player");
	
	$.ajax({
	   type: "POST",
	   url: "transactions.php",
	   data: {id: id, mode: 'getDownloadItem'},
	   success: function(html){
		
		  $('#downloadItem').append(html);
		  $('#downloadItem').slideDown("slow");
		  
	   }
 	});
}

function updateDownload(id) {
		
	$('#downloadItem').empty();
	$('#jw_player').empty();
	
	$.ajax({
	   type: "POST",
	   url: "transactions.php",
	   data: {id: id, mode: 'getDownloadItem'},
	   success: function(html){
		
		  $('#downloadItem').append(html);
		  $('#downloadItem').slideDown("slow");
		  
	   }
 	});
}