/*******************************************
* Font Replacement						   *
*******************************************/
Cufon.replace('#navigation', { fontFamily: 'Ayumi Bold', hover: true });
Cufon.replace('h2', { fontFamily: 'Ayumi Bold', hover: true });
Cufon.replace('#menu-selection', { fontFamily: 'Ayumi Bold', hover: true });
Cufon.replace('#download-full', { fontFamily: 'Ayumi Bold', hover: true });
Cufon.replace('#menu-items h3', { fontFamily: 'Ayumi Bold', hover: true });
Cufon.replace('.brand', { fontFamily: 'Ayumi Bold', hover: true });

/*******************************************
* Vars									   *
*******************************************/
var Philly = new Array();
var ChickenWing = new Array();
var Beverages = new Array();
var Breakfast = new Array();
var Burgers = new Array();
var Chicken = new Array();
var Dessert = new Array();
var Subs = new Array();
var HotDogs = new Array();
var Pitas = new Array();
var Platters = new Array();
var Salads = new Array();
var Seafood = new Array();
var Sides = new Array();


$(document).ready(function() {

	// Healthy Menu Grid
	$(function(){
	  $('#healthyItems').masonry({
	    // options
	    itemSelector : '.healthy-menu',
	    columnWidth : 4
	  });
	});
	
		
	$('.features a').contents().unwrap();
	$('#navigation, h2, #menu-selection, #download-full, #menu-items h3, .brand, #menu-items ').css('visibility','visible');
	
	/*******************************************
	* Store all menu items in arrays 		   *
	*******************************************/
	$('#menu-items .category-philly-cheesesteaks').each(function(index) {
		Philly.push(this);
	});
	
	$('#menu-items .category-hot-dogs').each(function(index) {
		HotDogs.push(this);
	});
	
	$('#menu-items .category-chicken-wings').each(function(index) {
		ChickenWing.push(this);
	});
	
	$('#menu-items .category-beverages').each(function(index) {
		Beverages.push(this);
	});
	
	$('#menu-items .category-breakfast').each(function(index) {
		Breakfast.push(this);
	});
	
	$('#menu-items .category-burgers').each(function(index) {
		Burgers.push(this);
	});
	
	$('#menu-items .category-chicken').each(function(index) {
		Chicken.push(this);
	});
	
	$('#menu-items .category-dessert').each(function(index) {
		Dessert.push(this);
	});
	
	$('#menu-items .category-subs').each(function(index) {
		Subs.push(this);
	});
	
	$('#menu-items .category-pitas').each(function(index) {
		Pitas.push(this);
	});
	
	$('#menu-items .category-platters').each(function(index) {
		Platters.push(this);
	});
	
	$('#menu-items .category-salads').each(function(index) {
		Salads.push(this);
	});
	
	$('#menu-items .category-seafood').each(function(index) {
		Seafood.push(this);
	});
	
	$('#menu-items .category-sides').each(function(index) {
		Sides.push(this);
	});
	
	/*******************************************
	* Removes all items from the page 		   *
	*******************************************/
	$('#menu-items div').remove();
	addContent(Philly);
	$('.category-philly-cheesesteaks').show();
	setGrid();
	
	
	/*******************************************
	* Submenu Buttons	 					   *
	*******************************************/
	$('#menu-selection .PhillyCheesesteaks').click(function() {
		addContent(Philly);
		$('.category-philly-cheesesteaks').show();
		setGrid();
	});
	
	$('#menu-selection .ChickenWings').click(function() {
		addContent(ChickenWing);	
		$('.category-chicken-wings').show();
		setGrid();
	});
	
	$('#menu-selection .Beverages').click(function() {
		addContent(Beverages);	
		$('.category-beverages').show();
		setGrid();
	});
	
	$('#menu-selection .Breakfast').click(function() {
		addContent(Breakfast);	
		$('.category-breakfast').show();
		setGrid();
	});
	
	$('#menu-selection .Burger').click(function() {
		addContent(Burgers);	
		$('.category-burgers').show();
		setGrid();
	});
	
	$('#menu-selection .Chicken').click(function() {
		addContent(Chicken);	
		$('.category-chicken').show();
		setGrid();
	});
	
	$('#menu-selection .Dessert').click(function() {
		addContent(Dessert);	
		$('.category-dessert').show();
		setGrid();
	});
	
	$('#menu-selection .Subs').click(function() {
		addContent(Subs);	
		$('.category-subs').show();
		setGrid();
	});
	
	$('#menu-selection .HotDogs').click(function() {
		addContent(HotDogs);	
		$('.category-hot-dogs').show();
		setGrid();
	});
	
	$('#menu-selection .Pitas').click(function() {
		addContent(Pitas);	
		$('.category-pitas').show();
		setGrid();
	});
	
	$('#menu-selection .Platters').click(function() {
		addContent(Platters);	
		$('.category-platters').show();
		setGrid();
	});
	
	$('#menu-selection .Salads').click(function() {
		addContent(Salads);	
		$('.category-salads').show();
		setGrid();
	});
	
	$('#menu-selection .Seafood').click(function() {
		addContent(Seafood);	
		$('.category-seafood').show();
		setGrid();
	});
	
	$('#menu-selection .Sides').click(function() {
		addContent(Sides);	
		$('.category-sides').show();
		setGrid();
	});
	
});



function addContent(THEARRAY){
	$('#menu-items,#featured div').animate({ opacity: 0 }, 0);
	$('#extras div').hide();
	
	$('#featured div').hide();
	$('#extras div').hide();
	$('#menu-items .category-philly-cheesesteaks').remove();
	$('#menu-items .category-chicken-wings').remove();
	$('#menu-items .category-pitas').remove();
	$('#menu-items .category-burgers').remove();
	$('#menu-items .category-platters').remove();
	$('#menu-items .category-salads').remove();
	$('#menu-items .category-chicken').remove();
	$('#menu-items .category-subs').remove();
	$('#menu-items .category-seafood').remove();
	$('#menu-items .category-hot-dogs').remove();
	$('#menu-items .category-breakfast').remove();
	$('#menu-items .category-sides').remove();
	$('#menu-items .category-dessert').remove();
	$('#menu-items .category-beverages').remove();
	
	$.each(
		THEARRAY,
		function( intIndex, objValue ){
			$('#menu-items').append(THEARRAY[intIndex]);
		}
	);
};


function setGrid(){
	$('#menu-items').masonry( 'destroy' );
	var $container = $('#menu-items');	
	$container.imagesLoaded(function(){
		$container.masonry(
			{
				itemSelector : '.category-menu',
				columnWidth : 4
			},
			FadeIn()
		);
	});
};



function FadeIn(){
	$('#menu-items, #featured div').animate({ opacity: 1 }, 0);
	//$('#extras div').show();
};
