// custom fadeToggle effect
jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
};
jQuery.fn.fadeOnlyToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle'}, speed, easing, callback);
};

$(document).ready(function() {
	
	// home page module hovers
	$('#modules .module').hover(function() {
		$(this).addClass('moduleHover');
	}, function() {
		$(this).removeClass('moduleHover');
	});
	
	// spread the word hover
	$('#header p#spread').hover(function() {
		$(this).addClass('hover').children('span').fadeIn('fast');
	}, function() {
		$(this).removeClass('hover').children('span').fadeOut('fast');
	});
	
	// remove right margin from the second column item in the row
	$('#menu .col:odd').css('marginRight','0');
	$('#menu .innerCol:odd').css('marginRight','0');
	
	$('#content a.menuItem').click(function() {
		$(this).parents('li').toggleClass('itemOn');
		$(this).siblings('div').fadeToggle('fast');
		return false;
	});
	
	$('#content h2 a.show').click(function() {
		$('#content #menu ul li a.menuItem').parents('li').addClass('itemOn');
		$('#content #menu ul li div').fadeIn('fast');
		$(this).hide();
		$(this).siblings('.hide').show();
		return false;
	});
	$('#content h2 a.hide').click(function() {
		$('#content #menu ul li').removeClass('itemOn');
		$('#content #menu ul li div').fadeOut('fast');
		$(this).hide();
		$(this).siblings('.show').show();
		return false;
	});
	
	$('#menu span.pairItem').hover(function() {
		$(this).css('textDecoration','underline');
	}, function() {
		$(this).css('textDecoration','none');
	});
	
	$('span.pairItem').click(function() {
		$(this).next('span.sideInfo').fadeOnlyToggle('fast');
		// var moduleHeight = $(this).parents('span').parents('p').parents('div').parents('li').height();
		// 		var imgHeight = $(this).parents('span').parents('p').siblings('img').height();
		// 		var moduleHeight = moduleHeight-120;
		// 		$(this).parents('span').parents('p').siblings('img').css('marginBottom',moduleHeight+'px');
		return false;
	});
	
	$('#content span.cluetip').cluetip({splitTitle: '|'});
	
	// Opens PDF files in a new window
	$(document).ready(function() {
		$('a[href*=.pdf]').click(function(){
		window.open(this.href);
		return false;
		});
	});
	
	// make entire home module regions clickable
	$('.module').click(function(){
  window.location=$(this).find('a').attr('href'); return false;
	});
	
	// who we are page clickable modules
	$('#comesee').click(function(){
  window.location=$(this).find('a').attr('href'); return false;
	});
	$('#sidebar #ingredients').click(function(){
  window.location='cooking.shtml'; return false;
	});
	
	// cycling for ingredients on the about page
	$('#ingredients').cycle({timeout:8300});
	
	// put labels over the contact form inputs
	$('.contact p.txtInput label, .contact p.textarea label').labelOver('over');
	
	
});


