// jQuery/ Javascript Document
//show speech bubble when hover on menu items
function speech(menuItem){
	$('#speech-bubble').show();	
	switch(menuItem){
		case 'home-nav-menu-item':
			$('#speech-bubble').html("Mi Casa es Su Casa!");
			break;
		case 'menu-nav-menu-item':
			$('#speech-bubble').html("Get some grub!");
			break;
		case 'location-nav-menu-item':
			$('#speech-bubble').html("Real men don't ask directions");
			break;
		case 'merch-nav-menu-item':
			//$('#speech-bubble').html("Drop some dough!");
			$('#speech-bubble').html("Coming Soon!");
			break;
		case 'baby-nav-menu-item':
			$('#speech-bubble').html("Who you callin' baby?");
			break;
		case 'contact-nav-menu-item':
			//$('#speech-bubble').html("Talk to me!");
			$('#speech-bubble').html("Coming Soon!");
			break;
	}
}

$(document).ready(function() {
	var file_name = document.location.href;
	var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
	var pathname = file_name.substring(file_name.lastIndexOf("/")+1, end);
	var toggle = function(direction, display) {
		return function() {
			var self = this;
			var ul = $("ul", this);
			if( ul.css("display") == display && !self["block" + direction] ) {
				self["block" + direction] = true;
				ul["slide" + direction]("slow", function() {
					self["block" + direction] = false;
				});
			}
		};
  	}
 	$("li.menu").hover(toggle("Down", "none"), toggle("Up", "block"));
	$("li.menu ul").hide("fast");

	
	//function for slowly fading in and out the navigation menu
	$("#nav-menu-list li").hover(function(){
		var menuOption = $(this).find('.background .nav-menu-item');
		$(menuOption).css("opacity","1").stop().animate({
			opacity: 0
		}, "slow");
		$('#speech-bubble2').hide();
		speech($(menuOption).attr('id'));
	},function () {
		$(this).find('.background .nav-menu-item').stop().animate({
			opacity: 1
		}, "fast");
		$('#speech-bubble').hide();
		if(pathname=="/badassburrito/menu.php")
			$('#speech-bubble2').show();	
	});
	
	//function for slowly fading in and out the menu filters
	$("#menu-item-list li").hover(function(){
		var menuOption = $(this).find('.background .menu-item');
		$(menuOption).css("opacity","1").stop().animate({
			opacity: 0
		}, "slow");
	},function(){
		$(this).find('.background .menu-item').stop().animate({
			opacity: 1
		}, "fast");
	});
	$("#menu-item-list .background .menu-item").click(function(){
		$("#menu-item-list .background .menu-item").removeClass('selected');
		$(this).addClass('selected');
	});	  
  
  	$("#menu div").hover(function(){
		//hover over menu item
		$(this).find('img').css("opacity","1").stop().animate({
			opacity: 0
		}, "slow");
	},function () {
		//hover out menu item
		$(this).find('img').stop().animate({
			opacity: 1
		}, "fast");
	});
	
	//Menu speech bubble
	if(pathname=="menu.php") {
		$('#speech-bubble2').show();	
		$('#speech-bubble2').html("Click on a menu section to check it out!");
	}
});

function menu(sec){
	if(sec=="sec-all"){
		$('.menu-sec').show();
	}else{
		$('.menu-sec').hide();
		$('#'+sec).show();
	}
}


