$(document).ready(function() {

	$("#btn_email").click(function() {	
			$("#wrap_diapo").hide(); //Hide all tab content			
			$("#contact").fadeIn(); //Fade in the active content
			return false;
	});
	
	//Formular senden
	$('#submit').click( function(){
            
		$('#result').html('<img src="http://www.stadthagen-medeco.de/images/loader.gif" class="loading-img" alt="loader image">').fadeIn();  
		    var input_data = $('#contactform').serialize();		    
		        $.ajax({  
		        type: "POST",  
		        url:  "http://www.stadthagen-medeco.de/aktion_mailer.php",  
		        data: input_data,  
		        success: function(msg){  
		        	$('.loading-img').remove();
		        	if (msg == 'msg_sent') {		        		
		        		var msgText = 'Bitte überprüfen Sie ihr Postfach und bringen Sie die Teilnahmebestätigung zu Ihrem Termin mit.';
		        		$('#mailHead').html('Vielen Dank die Email wurde erfolgreich versendet.');
		        		$('<div class="message">').html(msgText).appendTo('div#result').hide().fadeIn('slow');
		        		$('#contactform').hide();
		        		$('#hint_wrapper').hide();
						$('.mailText').hide();
		        	} else {
		        		$('<div class="message">').html(msg).appendTo('div#result').hide().fadeIn('slow');  
		        	}
		        	
		        }                        
		    });   
		  
		return false;  
            
    });

});
