jQuery(document).ready(function() {
	//jQuery.noConflict();

	//if submit button is clicked
	jQuery('#submitNewsletter').click(function () {		
		
		//Get the data from all the fields
		var email = jQuery('input[name=email]');

		//Simple validation to make sure user entered something
		//If error found, add hightlight class to the text field

		if (email.val()=='') {
			email.addClass('hightlight');
			email.val("Bitte Email eingeben");
			return false;
		} else email.removeClass('hightlight');
		

		//organize the data properly
		var data = 'email=' + email.val();
		
		//disabled all the text fields
		//$('.text').attr('disabled','true');
		
		//show the loading sign
		//$('.loading').show();
		//start the ajax
		jQuery.ajax({
			//this is the php file that processes the data and send mail
			url: "http://www.ganzheitliche-koerperarbeit.at/fileadmin/templ/form/newsletterabo.php",	
			
			//GET method is used
			type: "GET",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {				
				//if process.php returned 1/true (send mail success)
				if (html==1) {					
					//hide the form
					jQuery('.form').slideUp('slow');					
					
					//show the success message
					jQuery('.done').fadeIn('slow');
					
				//if process.php returned 0/false (send mail failed)
				} else alert('Es ist ein Fehler aufgetreten.');				
			}		
		});
		
		//cancel the submit button default behaviours
		return false;
	});	

});	
