$(document).ready(
	function()
	{

		//Fun Stuff for Weekly Section
		$('#postbody.weekly').parent('div.blogpost').addClass('printabletip');
		$('#postbody.weekly ul[class] li strong:not(:empty)').prepend('<input type="checkbox">');
		$('#postbody.weekly #sharethis').before('<div class="createlist"><h4>Create a Printable Shopping List</h4><p>Just check the items you plan to buy &amp; click the &ldquo;Create List&rdquo; button below.</p><form id="sendlist" action="/static/shoppinglist/" method="post" target="_blank"><input type="button" value="Create List" id="createlist" /> <input type="checkbox" name="showcoupons" id="showcoupons" checked="checked" /><label for="nocoupons">Include Coupon Matchups?</label><fieldset id="checkeditems"></fieldset></form><p><strong>Note:</strong> Every page of this site is printer friendly. So, if you want a copy of this entire page, just click <code>File-&gt;Print</code> from your browser.</p></div');
		$('#postbody.weekly #createlist').click(function(){
			var showcoupons = true;
			$('#checkeditems').empty();
			
			if($('#showcoupons').not(':checked')){showcoupons = false;}

			$('#postbody.weekly ul').each(function(){
				var allchecked = "";
				var itemcat = $(this).attr("class");
				if (itemcat){
					$('#checkeditems').append('<input type="hidden" name="' + itemcat + '" id="' + itemcat + '" value="" />');
					$('#postbody.weekly ul.' + itemcat + ' input:checked').each(function(){
						allchecked += '<li>' + $(this).parent('strong').parent('li').html() + '</li>';
					});
					if (allchecked != ""){
						$('input#' + itemcat).attr('value',allchecked);
					}
				}
			});
			$('form#sendlist').submit();
		});
		
		// Create SkipTo Links and Back ToTop anchors for Weekly Section
		var skipto = "";
		var h2count = $('#postbody.weekly h2').length;
		$('#postbody.weekly h2').each(function(i){
			var aname = $(this).next('ul').attr('class');
			$(this).addClass(aname);
			var atext = $(this).text().replace(':','');
			if (aname){
				$(this).before('<a name="'+aname+'"></a>');
				skipto += '<li class="'+aname+'"><a href="#'+aname+'">'+atext+'</a></li>';
			}
			$(this).next('ul').after('<a href="#header" class="totop">Return to Top</a>');
		});
		if(skipto != ""){
			skipto = 'Skip down to: <ul id="skipto">' + skipto + '</ul>';
			$('#postbody.weekly h2:first').before(skipto);
		}
	

		// Smooth scroll to anchor links using ScrollTo Plugin.
		$.localScroll();
		
		// Makes the flyout nav work in IE6
		$('#navigation_bar ul li').hover(
			function () {$(this).addClass("over");},
			function () {$(this).removeClass("over");}
		);
		

		// Zebra-stripe data tables
		$("table.data tbody").each(function(){
			 $("tr:odd", this).not(".even").addClass("odd");
			 $("tr:even", this).not(".odd").addClass("even");
		 });

	}
);
