jQuery(document).ready(function($) {
$(document).ready(function(){

	$(".sub-menu").parent(".menu-item").addClass("has-ancestor");
	
	//Add a class for manipulating add to cart forms. Seems hacky but Opera and Safari demand it.
	$("form.wpco").addClass("addtocart");

	//Expanding content areas
	$('.hidden').hide();  
	$('div#show_hide > h2').click(function() {
		//$(this).toggleClass('openedx');
		$(this).nextUntil('h2').slideToggle('fast')
		.siblings('div:visible').slideUp('fast');
		//$(this).siblings('h4.opened').removeClass('opened');
	});

	$('.hidden_text').hide();

	$('.clicker').click(function() {
		$(this).toggleClass('opened');
		$(this).next('div').slideToggle('fast')
		.siblings('div:visible').slideUp('fast');
		$(this).siblings('p.opened').removeClass('opened');
	});

	$('<span></span>').insertAfter('.current_page_item a');

	

	$(window).load(function() {

		$('img.caption').each(function() {
		caption = $(this).attr('alt');
		width = $(this).outerWidth();
		floatvalue = $(this).hasClass('floatright') ? 'floatright' : 'floatleft';
		$(this).removeAttr('class');
		$(this).wrap('<div style="width:' + width + 'px" class="caption ' + floatvalue + '"></div>');
		$(this).after('<p>' + caption + '</p>');
		})

	});

});
});
