anchor.diff:  			var init = function() {
   				$( "#recipe" ).hide();
   				$( "#choice" ).show();
  -				$( "#recipe #resourceId" ).hide();
   			};
   			
   			var show = function( url ) {
  
positive.code: 			};
  		
  			var getResourceId = function() {
  				$( "#recipe #resourceId" ).text();
  			};
  			
  			var formatDate = function( number ) {
  
negative.code: 		
  		var recipeEdit = (function() {
  			
  			var recipesUrl;
  			
  			var init = function( url ) {
  				recipesUrl = url;
  				hide();
  				$( "#recipe-edit #addIngredient").click( function() { addIngredient(); })
  				recipeEdit.initCkEditor();
  			};
  			
  			var hide = function() {
  				$( "#recipeEdit" ).hide();
  			};
  			
  			var initTagEditor = function() {
  				var deferred = $.Deferred();
  		
  				$( "#recipe-edit #tags" ).tagEditor( "destroy" );
  				$( "#recipe-edit textarea[name='tags']" ).val( null );
  			
  				$.getJSON( recipesUrl + "/" + "tags" )
  					.done( function( tags ) { 
  						$allTags = tags;
  						console.log( "Tags: " + $allTags )
  						$( "#recipe-edit #tags" ).tagEditor( { 
  							autocomplete: {
  					        	source: $allTags,
  					        	delay: 0,
  				        		position: { collision: "flip" }
  					    	},
  					    	forceLowercase: true
  					    } );
  					})
  					.fail( function( xhr, status, error ) {
  		  				var err = status + ", " + error;
  		 				console.log( "Request Failed: " + err );
  		 				deferred.resolve;
  	 				})
  	 				.then( deferred.resolve );
  	 			return deferred.promise();
  			};
  			
  			var show = function( resourceId ) {
  				$( "#msg" ).hide();
  				$( "#recipe-edit #status" ).hide();
  				initTagEditor().then( processRecipe( resourceId ).then( function() { $( "#recipeEdit" ).fadeIn(); } ) );
  			};
  			
  			var processRecipe = function( resourceId ) {
  				var deferred = $.Deferred();
  				var $ingredientsUrl;
  				var $recipeObject;
  				var $recipeUrl = recipesUrl + "/" + resourceId;
  				$.getJSON( $recipeUrl )
  					.done( function( recipe ) { 
  						$.each(recipe.links, function( idx, link ) {
  							if (link.rel == "ingredients") {
  								$ingredientsUrl = link.href;
  							}
  						});
  						$recipeObject = recipe;
  						buildRecipe( recipe );
  					})
  					.fail( function( xhr, status, error ) {
  		  				var err = status + ", " + error;
  		 				console.log( "Request Failed: " + err );
  		 				deferred.resolve();
  	 				})
  	 				.then( function() {
  	 					getIngredients( $ingredientsUrl );
  	 					buildTagEditor( $recipeObject.tags )
  						deferred.resolve();
  	 				})
  	 			return deferred.promise();
  			};
  			
  			var buildTagEditor = function( tags ) {
  				$.each( tags, function( idx, tag ) {
  					$( "#recipe-edit #tags" ).tagEditor( "addTag", tag, true );
  	        	});
  			};
  					
  			var getIngredients = function( url ) {
  				$( "#recipe-edit #ingredients li" ).remove();
  				$.getJSON( url )
  					.done( function( ingredients ) {
  						$.each( ingredients, function( idx, ingredient ) {
  							buildIngredient( ingredient );	
  			        	});
  					})
  					.fail( function( xhr, status, error ) {
  	   				    var err = status + ", " + error;
  	  					console.log( "Request Failed: " + err );
  	  				})
  			};
  		
  			var buildIngredient = function( ingredient ) {
  				
  				li = $( "<li class='ingredient'>" );
  				li.attr({
  					"id": ingredient.resourceId
  				});
  				li.appendTo( $("#recipe-edit #ingredients" ) );
  				
  				rowDiv = $( "<div class='w3-row-padding'>" );
  				rowDiv.appendTo( li );
  				
  				/* ---------- Quantity */
  				colQuantity = $( "<div class='w3-col s3'>" );
  				colQuantity.appendTo( rowDiv );
  				inputQuantity = $( "<input class='w3-input' type='text' min='1' max='255' name='portion'>" );
  				if ( ingredient.portion ) {
  					inputQuantity.val( ingredient.portion );
  				}
  				inputQuantity.appendTo( colQuantity );
  				labelQuantity = $("<label class='w3-text-gray'>");
  				labelQuantity.text( "Quantity" );
  				labelQuantity.appendTo( colQuantity );
  				
  				/* ---------- Description */
  				colDescription = $( "<div class='w3-col s4'>" );
  				colDescription.appendTo( rowDiv );
  				inputDescription = $( "<input class='w3-input' type='text' min='1' max='255' required name='description'>" );
  				if ( ingredient.description ) {
  					inputDescription.val( ingredient.description );
  				}
  				inputDescription.appendTo( colDescription );
  				labelDescription = $( "<label class='w3-text-gray'>" );
  				labelDescription.text( "Description" );
  				labelDescription.appendTo( colDescription );
  				
  				/* ---------- Annotation */
  				colAnnotation = $( "<div class='w3-col s4'>" );
  				colAnnotation.appendTo( rowDiv );
  				inputAnnotation = $( "<input class='w3-input' type='text' min='1' max='255' name='comment'>" );
  				if ( ingredient.comment ) {
  					inputAnnotation.val( ingredient.comment );
  				}
  				inputAnnotation.appendTo( colAnnotation );
  				labelAnnotation = $( "<label class='w3-text-gray'>" );
  				labelAnnotation.text( "Annotation" );
  				labelAnnotation.appendTo( colAnnotation );
  				
  				/* ---------- Remove-Button */
  				colRemove = $("<div class='w3-col s1'>");
  				colRemove.appendTo( rowDiv );
  				spanRemove = $("<span class='w3-button w3-white w3-xlarge w3-right w3-light-gray'>&times;</span>")
  				spanRemove.appendTo( colRemove );
  				spanRemove.click( function() {
  					if ( ingredient.resourceId ) {
  						$( "#recipe-edit .ingredient#" + ingredient.resourceId ).fadeOut( "fast" );
  					} else {
  						$( this ).closest( $( ".ingredient" ) ).fadeOut( "fast", function() {
  							$( this ).closest( $( ".ingredient" ) ).remove();
  						});
  					}	
  				})
  			};
  		
  			var buildRecipe = function( recipe ) {
  				$( "#recipe-edit #uuid").val( recipe.uuid );
  				$( "#recipe-edit #title" ).val( recipe.title );
  				$( "#recipe-edit #editPreamble" ).val( recipe.preamble );
  				$( "#recipe-edit #noOfPerson" ).val( recipe.noOfPerson );
  				$( "#recipe-edit #editPreparation" ).val( recipe.preparation );
  	        	$( "#recipe-edit input[name='rating'][value='" + recipe.rating + "']" ).prop( "checked", true );
  	        	$( "#recipe-edit #recipeForm" ).submit( function( event ) {
  	        		save();
  	        		return false;
  	        	})
  			};
  			
  			
  			var addIngredient = function() {
  				ingredient = {};
  				buildIngredient( ingredient )
  			};
  		
  			var save = function() {
  				recipeEdit.updateRecipe().then( function() {
  					$( "#recipe-edit #status" ).fadeIn( "fast");
  	  				$( "#recipe-edit #status" ).text( "Rezept gespeichert." );
  	  				setTimeout( function() {
  	  					$( "#recipe-edit #status" ).fadeOut( "slow" );
  	  				}, 1000);
  				})
  			};
  		
  			var updateRecipe = function() {
  				var deferred = $.Deferred();
  				$recipe = {};
  				$recipe.uuid = $( "#recipe-edit input[name='uuid']" ).val();
  				if ( !$recipe.uuid ) {
  					$recipe.uuid = null;
  				}
  				$recipe.title = $( "#recipe-edit input[name='title']" ).val();
  				$recipe.preamble = CKEDITOR.instances['preamble'].getData();
  				if ( !$recipe.preamble ) {
  					$recipe.preamble = null;
  				}
  				$recipe.noOfPerson = $( "#recipe-edit input[name='noOfPerson']" ).val();
  				$recipe.preparation = CKEDITOR.instances['preparation'].getData();
  				$recipe.rating = $( "#recipe-edit input[name='rating']:checked" ).val();
  				$tags = $( "#recipe-edit textarea[name='tags']" ).val();
  				$recipe.tags = $tags.split(',');
  				$token =  $( "#recipe-edit input[name='token']" ).val();
  				
  				$json = JSON.stringify($recipe);
  				console.log( "Recipe : " + $json );
  				
  				if ( $recipe.uuid ) {
  					// bestehendes Rezept
  					$.ajax({
  						    url: $recipesUrl + "/" + $recipe.uuid,
  						    method: "PUT",
  						    contentType: "application/json; charset=UTF-8",
  						    data: $json,
  							headers: { "Authorization": "Bearer " + $token }
  					})
  					.fail( function( xhr, status, error ) {
  		   				    var err = status + ", " + error;
  		  					console.log( "Request Failed: " + err );
  		  			})
  		  			.then( function() {
  		  				updateIngredients( $recipe.uuid ).then( function() {
  		  					buildRecipeById( $recipe.uuid ); // Daten in der View aktualisieren
  		  					deferred.resolve(); 
  		  				} );
  		  				
  		  			})
  	  			} else {
  	  				// neues Rezept
  	  				$.ajax({
  						    url: $recipesUrl,
  						    method: "POST",
  						    contentType: "application/json; charset=UTF-8",
  						    data: $json,
  							headers: { "Authorization": "Bearer " + $token }
  					})
  					.fail( function( xhr, status, error ) {
  		   				    var err = status + ", " + error;
  		  					console.log( "Request Failed: " + err );
  		  			})
  		  			.then( function( data, status, xhr ) {
  		  				$location = xhr.getResponseHeader('Location');
  		  				$uuid = $location.substr( $location.lastIndexOf("/") + 1 );
  		  				updateIngredients( $uuid ).then( function() {
  		  					buildRecipeById( $uuid ); // Daten in der View aktualisieren
  		  					deferred.resolve(); 
  		  				} );
  		  			})
  	  			}
  				
  				return deferred.promise();
  			};
  		
  			var updateIngredients = function( recipeId ) {
  				var deferred = $.Deferred();
  				$( "#recipe-edit .ingredient" ).each( function( index, li ) {
  					$( "body" ).queue( function() {
  						$ingredient = {};
  						$ingredient.resourceId = $( li ).attr( "id" );
  						$ingredient.portion = $( li ).find( "input[name='portion']" ).val();
  						if ( !$ingredient.portion ) {
  							$ingredient.portion = null;
  						}
  						$ingredient.description = $( li ).find( "input[name='description']" ).val();
  						$ingredient.comment = $( li ).find( "input[name='comment']" ).val();
  						if ( !$ingredient.comment ) {
  							$ingredient.comment = null;
  						}
  					
  						updateIngredient( $( li ).is(":hidden"), $ingredient, recipeId );
  					})
  				});
  				$( "body" ).promise().done( deferred.resolve );
  				return deferred.promise();
  			};
  		
  			var updateIngredient = function( isHidden, ingredient, recipeId ) {
  				var $url = $recipesUrl + "/" + recipeId + "/ingredients/";
  				
  				if ( isHidden ) {
  					console.log( "Ingredient for delete : " + JSON.stringify( ingredient ) );
  					$.ajax({
  						type: "DELETE",
  						url: $url + ingredient.resourceId,
  						headers: { "Authorization": "Bearer " + $token },
  						success: function() { $( "body" ).dequeue(); }
  					});
  				} else {
  					if ( $ingredient.resourceId == undefined ) {
  						console.log( "new Ingredient : " + JSON.stringify( ingredient ) );
  						$.ajax({
  							type: "POST",
  							url: $url,
  							data: JSON.stringify( ingredient ),
  							contentType: "application/json; charset=UTF-8",
  							headers: { "Authorization": "Bearer " + $token },
  							success: function() { $( "body" ).dequeue(); }
  						});
  					} else {
  						console.log( "exists Ingredient : " + JSON.stringify( ingredient ) );
  						$.ajax({
  							type: "PUT",
  							url: $url + ingredient.resourceId,
  							data: JSON.stringify( $ingredient ),
  							contentType: "application/json; charset=UTF-8",
  							headers: { "Authorization": "Bearer " + $token },
  							success: function() { $( "body" ).dequeue(); }
  						});
  					}
  				}
  			};
  			
  			var initCkEditor = function() {
  				// Toolbarkonfigurator: http://ckeditor.com/latest/samples/toolbarconfigurator/index.html
  				CKEDITOR.replace( "editPreamble", {
  				    contentsCss: "resources/ckEditorContents.css",
  				    resize_enabled: true,
  				    language: "de",
  				    toolbarGroups: [
  						{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
  						{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
  						{ name: 'forms', groups: [ 'forms' ] },
  						'/',
  						{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
  						{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
  						{ name: 'document', groups: [ 'document', 'doctools', 'mode' ] },
  						{ name: 'links', groups: [ 'links' ] },
  						{ name: 'insert', groups: [ 'insert' ] },
  						'/',
  						{ name: 'styles', groups: [ 'styles' ] },
  						{ name: 'colors', groups: [ 'colors' ] },
  						{ name: 'tools', groups: [ 'tools' ] },
  						{ name: 'others', groups: [ 'others' ] },
  						{ name: 'about', groups: [ 'about' ] }
  					],	
  					removeButtons: 'Save,Templates,Cut,Undo,Copy,Paste,PasteText,PasteFromWord,Preview,NewPage,Print,Redo,Replace,Find,SelectAll,Scayt,Form,Radio,Checkbox,TextField,Textarea,Select,Button,ImageButton,HiddenField,Subscript,Superscript,CopyFormatting,RemoveFormat,Blockquote,CreateDiv,JustifyLeft,JustifyCenter,JustifyBlock,BidiLtr,BidiRtl,Language,Anchor,Unlink,Link,Image,Flash,Table,HorizontalRule,Smiley,SpecialChar,PageBreak,Iframe,FontSize,Font,Format,Styles,TextColor,BGColor,Maximize,ShowBlocks,About,JustifyRight'		
  				});
  				CKEDITOR.replace( "editPreparation", {
  				    contentsCss: "resources/ckEditorContents.css",
  				    resize_enabled: true,
  				    language: "de",
  				    toolbarGroups: [
  						{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
  						{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
  						{ name: 'forms', groups: [ 'forms' ] },
  						'/',
  						{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
  						{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
  						{ name: 'document', groups: [ 'document', 'doctools', 'mode' ] },
  						{ name: 'links', groups: [ 'links' ] },
  						{ name: 'insert', groups: [ 'insert' ] },
  						'/',
  						{ name: 'styles', groups: [ 'styles' ] },
  						{ name: 'colors', groups: [ 'colors' ] },
  						{ name: 'tools', groups: [ 'tools' ] },
  						{ name: 'others', groups: [ 'others' ] },
  						{ name: 'about', groups: [ 'about' ] }
  					],	
  					removeButtons: 'Save,Templates,Cut,Undo,Copy,Paste,PasteText,PasteFromWord,Preview,NewPage,Print,Redo,Replace,Find,SelectAll,Scayt,Form,Radio,Checkbox,TextField,Textarea,Select,Button,ImageButton,HiddenField,Subscript,Superscript,CopyFormatting,RemoveFormat,Blockquote,CreateDiv,JustifyLeft,JustifyCenter,JustifyBlock,BidiLtr,BidiRtl,Language,Anchor,Unlink,Link,Image,Flash,Table,HorizontalRule,Smiley,SpecialChar,PageBreak,Iframe,FontSize,Font,Format,Styles,TextColor,BGColor,Maximize,ShowBlocks,About,JustifyRight'		
  				});
  			};
  			
  			return {
  				show: show,
  				hide: hide, 
  				init: init,
  				initCkEditor: initCkEditor
  			}
  		
  		})();
  