$(document).ready(function() {
	//$('<a href="#"><span>Jetzt gratulieren</span></a>').insertAfter('#greetingsText');
	 
		$("#greetingsForm").validate({
					
		  submitHandler: function() { 
			var name = $('#name').val();
			var greeting = $('#greeting').val();
			var judas = $('#judas').val();
			
			$.ajax({
			  type: "post",
			  url: "/send-greeting",
			  data: {name: name, greeting: greeting, judas: judas},
			  success: function(msg){
				$('#greetings p').remove();
				$('#greetings input').remove();
				$('<p>Vielen Dank f&uuml;r Ihr Feedback.</p><p>Klicken Sie zum Schlie&szlig;en dieses Fensters oben rechts auf das Kreuz.</p>').insertAfter('#greetings legend');
			  }
			}); 
			
			 
		  }
		});
		
/*
		jQuery.fn.fadeTo = function(speed,to,callback) { 
			return this.animate({opacity: to}, speed, function() { 
				if (to == 1 && jQuery.browser.msie)  
					this.style.removeAttribute('filter');  
				if (jQuery.isFunction(callback)) 
					callback();  
			}); 
		};
*/		
		
		/* Greetings Ani */	
		function slideWelcomeTeaser() {
			slideTimer = setTimeout(function() {
/*			
			$('.boxFixed p.active').fadeOut(750,function(){
				
				$('.boxFixed p.inactive').fadeIn(750, function(){
					$(this).removeClass('inactive');			
					$(this).addClass('active');	
				}); 

				$(this).removeClass('active');			
				$(this).addClass('inactive');							
				
				return false;
			}); 
*/			


			var inActPosition = $('.boxFixed li.inactive').position();
			var actPosition = $('.boxFixed li.active').position();			

			
			$('.boxFixed #animContainer ul').fadeTo( 750, 0.01 );

			
			$('.boxFixed #animContainer ul').animate({
				left: '-'+inActPosition.left+'px'			
				}, 0, 'swing');

			$('.boxFixed #animContainer ul').fadeTo( 750, 0.99 , function(){
				$(this).children('li').toggleClass('active inactive');			
			});				
/*				
			$('.boxFixed #animContainer ul').animate({
				left: '-'+inActPosition.left+'px'			
				}, 750, 'swing', function(){
					$(this).children('li').toggleClass('active inactive');
			}); 
*/			
			

			slideWelcomeTeaser();
			
			}, 10000);			

		};
		
		slideWelcomeTeaser();
		
		
		function test(id) {
			slideTimer = setTimeout(function() {
				$('ul#navTeaser li.'+id+' a').click();
				var nextID = 'teaser-01';
			}, 8000);
		}	
		/* Greetings Ani */	
			
});
