var inputName = 'IHR NAME';
var inputNummer = 'IHRE TELEFONNUMMER';
var inputEmail = 'IHRE E-MAIL ADRESSE';
var inputMessage = '';

$(document).ready(function() {

	$('a[href*=#]').click(function() {
	 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
	 && location.hostname == this.hostname) {
	   var $target = $(this.hash);
	   $target = $target.length && $target
	   || $('[id=' + this.hash.slice(1) +']');
	   if ($target.length) {
	  var targetOffset = $target.offset().top;
	  $('html,body')
	  .animate({scrollTop: targetOffset}, 500);
	    return false;
	   }
	  }
	  });

	
	$('#name').val(inputName);
	$('#name').click(function() { if (this.value == inputName) { this.value = '' } } );
	$('#name').blur(function() { if (this.value == '') { this.value = inputName; } });
	
	$('#nummer').val(inputNummer);
	$('#nummer').click(function() { if (this.value == inputNummer) { this.value = '' } } );
	$('#nummer').blur(function() { if (this.value == '') { this.value = inputNummer; } });
	
	$('#email').val(inputEmail);
	$('#email').click(function() { if (this.value == inputEmail) { this.value = '' } } );
	$('#email').blur(function() { if (this.value == '') { this.value = inputEmail; } });
	
	$('#emailBig').val(inputEmail);
	$('#emailBig').click(function() { if (this.value == inputEmail) { this.value = '' } } );
	$('#emailBig').blur(function() { if (this.value == '') { this.value = inputEmail; } });
	

	var formOptions = { 
		target: '#success',
		success: function() { 
			$("#form").fadeOut(500);
			setTimeout("$('#success').fadeIn(500);", 500);
			//setTimeout("$('#success').fadeOut(500);", 7000);
			//setTimeout("$('#form').slideToggle(500);", 8000);
			setTimeout("$('#name').val(inputName);", 2000);
			setTimeout("$('#nummer').val(inputNummer);", 2000);
			setTimeout("$('#email').val(inputEmail);", 2000);
			setTimeout("$('#emailBig').val(inputEmail);", 2000);
			setTimeout("$('#message').val(inputMessage);", 2000);
		}
	};

	$.validator.addMethod('checkInput', function(value, element, param) {
	        return this.optional(element) || value!=param;
	    });
	
	$("#callback").validate({
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit(formOptions);
		},
		rules: { 
			name: { required: true, checkInput: inputName },
			nummer:{ required: true, checkInput: inputNummer },
			email:{ required: true, checkInput: inputEmail }
	        }, 
		messages: { 
			name: "Fehler!", 
			nummer: "Fehler!",
			email: "Fehler!"
	        }
	});
	
});

