
$(document).ready(function() {
  $("a[@rel=external]").each(function(i) {this.target="_blank";});
  $('#extended-search').hide()
  $('a#toggle-search').click(function() {
      $('#extended-search').toggle();
      //$('#category').selectedIndex=0;
      document.getElementById('category').selectedIndex=0;
      document.getElementById('kitchentype').selectedIndex=0;
      document.getElementById('preptime').selectedIndex=0;
      $(this).text($(this).text() == 'uitgebreid zoeken' ? 'standaard zoeken' : 'uitgebreid zoeken');
      return false;
  });
  
  //drag and save recipe in cookie
  $("#drag-me").draggable({helper: 'clone'});
	$("#drag-target:has(a) p").css("display", "none");
  $("#drag-target").droppable({
		accept: "#drag-me",
		activeClass: 'droppable-active',
		hoverClass: 'droppable-hover',
		drop: function(ev, ui) {
      var recid = document.getElementById('recept-number').value;
			// save the recipe
			$.get("/saveRecipe.php?id=" + recid,
  				function(data){
    				$("#drag-target").html(data);
			  	}
			);
		}
	});
  
  // toggle drag en drop info
  $(".question").click(function(){
	  $("#save-explain").toggle();
	});
   
});

// unsaveRecipe
function unSaveRecipe(id) {
	$.get("/unSaveRecipe.php?id="+id,
		function(data){
			$("#drag-target").html(data);
    }
	  );
  } 