
jQuery(function($){

	$('.dropdown li.current').parents('li').addClass('current');

	/*$('ul.faq-qa-set a.question').toggle(
		function()
		{
			var set = $(this).parent().parent();
			window.location.hash = '#'+set.attr('id').replace('_set', '');
			$(this).siblings().filter('ul.answer').css('display', 'block');
		},
		function()
		{
			window.location.hash = '';
			$(this).siblings().filter('ul.answer').css('display', 'none');
		}
	);

	if (window.location.hash && window.location.hash.indexOf('#faq_') === 0)
	{
		var hash = window.location.hash;
		window.location.hash = hash+'_position';
		window.location.hash = hash;
		$(window.location.hash+'_set').find('ul.answer').css('display', 'block');
	}*/
	
	$('a.star-vote').click(function(e)
	{
		e.preventDefault();

		if (window.location.toString().match(/recipes\//))
		{
			alert('Please visit the recipe page to vote.');
			return;
		}

		var link = $(this);

		if (link.hasClass('voted'))
		{
			alert('You already voted.');
			return false;
		}

		$.get(link.attr('href'), function(data, textStatus)
		{
			link.addClass('voted');

			if(data.match(/^\s*1\s*$/))
			{
				alert('Your vote has been counted.');
			}
			else
			{
				alert('You already voted.');
			}
		});
	});
});

