/**
 * Brick Position
 * 
 * Calculate and place brick background.
 */
		function brick_position(){
			var Html_Height = $("html").height();
			var Body_Height = $("body").height();
			var Site_Height = $("#site").height();
			
			if(Html_Height < Site_Height){
				$("body").css({ height: Site_Height });
			} else {
				$("body").css({ height: "100%" });
			}			
		}
		
		
/**
 * Categories
 * 
 * Get location categories and build a list. Append to the categories column.
 * 
 * @param {string}	type			Menu List, Beer List
 * @param {int}	 	locationID		Location ID
 */
	function categories(type, locationID){
		//Clear all 'selected' anchor classes and add 'selected' class to current anchor.
		$("#select_city a").each(function(){
			$(this).attr("class", $(this).attr("class").replace(/selected/gi, ""));
		});
		$(this).attr("class", $(this).attr("class") + " selected");
		
		//Clear exisiting Categories and Menu Items then display loading message for Categories until content loaded.
		$("#select_category .selection_list_content").html("<div id='loading'><img src='/images/ajax-loader.gif' /> Loading</div>");
		$("#select_item .selection_list_content").html("<div class='selection_list_initial_content'><strong>&#171; Select A Menu Section</strong><br/><span>to view <em>Menu Items</em></span></div>");
		
		//Query menu categories.
		$.post("/ajax/menus.php", { Query:"Categories", Type:type, LocationID:locationID }, function(data){
			//Replace .selection_list_content with queried menu.
			$("#select_category .selection_list_content").html(data);
			
			//Position brick.
			brick_position();
		}, "html");
	}
	
	
/**
 * Products
 * 
 * Get list of all products for a given category. Append to menu items column.
 * 
 * @param {int}		categoryID		Category ID
 * @param {int}	 	locationID		Location ID
 */
	function products(categoryID, locationID){
		//Clear all 'selected' anchor classes and add 'selected' class to current anchor.
		$("#select_city a").each(function(){
			$(this).attr("class", $(this).attr("class").replace(/selected/gi, ""));
		});
		$(this).attr("class", $(this).attr("class") + " selected");

		//Clear exisiting Categories and Menu Items then display loading message for Categories until content loaded.
		$("#select_item .selection_list_content").html("<div id='loading'><img src='/images/ajax-loader.gif' /> Loading</div>");

		//Query Menu Items.
		$.post("/ajax/menus.php", { Query:"Products", CategoryID:categoryID, LocationID:locationID }, function(data){
			//Replace #select_item with queried itemms.
			$("#select_item .selection_list_content").html(data);
			
			//Position brick.
			brick_position();
		}, "html");
	}
	
	
/**
 * Product
 * 
 * Get details on a specific product and overlay onto page.
 * 
 * @param {int}		productID		Product ID
 */
	function product(productID){
		//Query Menu Items.
		$.post("/ajax/menus.php", { Query:"Product", ProductID:productID }, function(data){
			//Remove exisiting overlay if present.
			$("#menu_item_overlay").remove();

			//Add Menu Item overlay.
			$("body").append(data);
			$("#menu_item_overlay").append("<div id='menu_item_overlay_bg'><!-- --></div>");
		}, "html");
	}
	
	
	


$(document).ready(function(){
	$('a[rel*=lightbox]').lightBox();

	$("#today").parent().attr("id", "today");
	
	$(window).resize(function(){
		brick_position();
	});
	brick_position();


	//Close product overlay.
	$("#menu_item #close").live("click", function(){
		$("#menu_item_overlay").remove();
	});
	
	$("#menu_item_overlay_bg").live("click", function(){
		$("#menu_item_overlay").remove();
	});
});
