function searchByKeyword() {
	var term = $('#searchfield').val();
	$.get("includes/cookbook.cfc?method=searchByKeyword&term=" + term,function(result){
		eval( 'var ' + result );
		$('#title').html(r.title);
		$('#content').html(r.content);
	});
};

function showShoppingList() {
	$.get("includes/cookbook.cfc?method=showShoppingList",function(result){
		eval( 'var ' + result );
		$('#shoppingList').html(r.thelist);
	});
};

function addRecipe(id) {
	$.get("includes/cookbook.cfc?method=addRecipe&id=" + id,function(result){
		eval( 'var ' + result );
		$('#shoppingList').html(r.content);
	});
};

function deleteRecipe(id) {
	$.get("includes/cookbook.cfc?method=deleteRecipe&id=" + id,function(result){
		eval( 'var ' + result );
		$('#shoppingList').html(r.content);
	});
};

function searchByCategory(cat) {
	$.get("includes/cookbook.cfc?method=searchByCategory&cat=" + cat,function(result){
		eval( 'var ' + result );
		$('#title').html(r.title);
		$('#content').html(r.content);
	});
};

function searchByRecipe(id,term) {
	$.get("includes/cookbook.cfc?method=searchByRecipe&id=" + id + "&term=" + term,function(result){
		eval( 'var ' + result );
		$('#title').html(r.title);
		$('#content').html(r.content);
	});
};

$(document).ready( function(){

	// category clicking (left nav)
	$('#menuBox a').click(function(){
		var $this = $(this);
		var cat = $this.attr('href').split('/').slice(-1);
		var url = "includes/cookbook.cfc?method=searchByCategory&cat=" + cat;
		$.get(url,function(result){
			eval( 'var ' + result );
			$('#title').html(r.title);
			$('#content').html(r.content);
		});
		return false;
	});

});
