
$(function() {
				var distance = 10;
				var time = 250;
				var hideDelay = 4000;
				var hideDelayTimer = null;
				var beingShown = false;
				var shown = false;
				var popup = $('.popup', this).css('opacity', 0);
				
				if (beingShown || shown) {
					return;
				  } else {
				    beingShown = true;
					
					$(".popup").css({
					  top: '-60px',
					  left: 20,
					  display: 'none' 
					}); 
				  }
			
			var counter=0;
			
			function addItem() {
				
 if (!$('#taf-input').val().match("^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$")) {
	  $(".popup").css({
		  display: 'block' 
	  }); 
	  $(".popup").animate({
					  //top: '-=' + distance + 'px',
					 top: '-80px',
					  opacity: 1
					}, time, 'swing', function() {

					  beingShown = false;
					  shown = true;
					  
if (hideDelayTimer) clearTimeout(hideDelayTimer);
				  
				  hideDelayTimer = setTimeout(function () {
				  hideDelayTimer = null;
			      popup.animate({
					  //top: '-=' + distance + 'px',
					  top: '-110px',
					  opacity: 0
					}, time, 'swing', function () {
					  shown = false;
					  
                      $(".popup").css({
					  top: '-60px',
					  left: 20,
					  display: 'none' // brings the popup back in to view
					  }); 
					});
				  }, hideDelay);
					  
 });
	  
 }
				
               //if($('#taf-input').val() == ""){
				//   alert('nothing put in');
			  //}
			   // Het if stukje hier is overbodig
			   else if ($('#taf-input').val().match("^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$")) { 

				$('<li style="display:none;" id="item' + counter + '" class="taf_set"><div class="holder"><span></span><input type="text" id="taf-output' + counter + '" size="10" name="taf-output' + counter + '" value="" style="visibility:hidden;" /></div><a href="#" class="remove"><img src="/_img/taf_grey_trashcan.gif" /></a><div class="clear"></div></li>').prependTo('#taf ul');
				 $("#taf-input").clone(function () {
					  var value = $("taf-input").val();
					  $("taf_set span").text(value)
					});
				 
					  var value = $("#taf-input-area input").val();
					  $('#item' + counter + ' .holder span').text(value);
					  $('#item' + counter + ' .holder input').val(value);

     		    $('#item' + counter).fadeIn();
				 $("#taf-input").val("");
      		    counter += 1;		
			}
			
			}
			
			function removeItem() {
                $(this).parent().fadeOut(800, function() {
					    $(this).remove();
				});	
			}	
				$('#right-a input').keyup(function(event){
				    if (event.keyCode == 13) {
						addItem();
				    }
				});
			$('.add').live('click', addItem);
			$('.remove').live('click', removeItem);
			
		});

       