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

};

$(document).ready(function() {
	
		$("img.postimage, img.postthumb").lazyload({ placeholder : "http://www.smallpigart.se/wp-content/themes/smallpigart/images/grey.gif", threshold : 200, effect:'fadeIn' });
	
		
		$("#menu ul li.current_page_item, #menu ul li.current_page_parent").addClass("shown").find("ul li").show(0,Cufon.refresh);
		Cufon.refresh();


		$('#menu a').click(function() {
			var current_item = $(this);
			if ($(this).parent().find('ul').length < 1) { // has children?
			 	return true;
			} else if ($(this).attr('href').indexOf('/blog/') != -1) { // has '/blog/' in linkadress
				return true;
			} else if ($(this).parent().hasClass('shown')) {
				$("#menu ul li.shown").removeClass("shown").find("ul li").fadeOut("slow");
				$("#menu ul li.current_page_parent, #menu ul li.current_page_item").addClass("shown").find("ul li").fadeIn("slow");
			} else {				
				$("#menu ul li.shown").removeClass("shown").find("ul li").fadeOut("slow");
				$(this).parent().addClass("shown").find("ul li").fadeIn("slow");
			}

			Cufon.refresh();
			return false;
			
		});
		
		$("#menu li.page-item-3605 a").click(function(){
			
			$("#bymonth").fadeToggle("slow");
			return false;
		});
		
		$("#menu li.page-item-3607 a").click(function(){
			$("#bycategory").fadeToggle("slow");
			return false;
		});
		
		
        
	
});
