// Show and hide news on home page

jQuery.fn.delay = function(time,func){
	return this.each(function(){
		setTimeout(func,time);
	});
};
			
			

			$(document).ready(function() {
			
				// Show and hide blog post content on blog index, archives and search
				// nabbed from interlopers.net - cheers Blink :D
				
				// Insert links	
				var headlineLink = "<p class=\"hide-post\"><a href=\"#\" title=\"Collapse/Expand\">Show Headlines Only</a></p>";
				$('#content h2.blog-title').after(headlineLink);
				
				var collapseLink = "<a href=\"#\" title=\"Collapse/Expand\" class=\"collapse\"></a>";
				$('#content .post h3.non-post').after(collapseLink);
				
				//Hide and show all news
				 $('.hide-post a').toggle(function() {
				 $('.post .post-content').slideUp(400);
				 $(this).fadeOut();
				 $(this).delay(450,function(){
					$('.hide-post a').text('Show Post Content').addClass('hide');
				  });
				 $(this).fadeIn();
				 $('.post h3.non-post + a').removeClass().addClass('expand').text('');
				}, function() { 
				 $('.post .post-content').slideDown(400);
				 $(this).fadeOut();
				 $(this).delay(450,function(){
					$('.hide-post a').text('Show Headlines Only').removeClass();
				  });
				  $(this).fadeIn();
				  $('.post h3.non-post + a').removeClass().addClass('collapse').text('');
				});
				
				// Change images and text on individual links
				$('.post a.collapse').toggle(function() {
			     $(this).siblings('div').slideUp(400); 
				 $(this).removeClass().addClass('expand');
				 $(this).text('');
			    }, function() { 
			     $(this).siblings('div').slideDown(400);
				 $(this).removeClass().addClass('collapse');
				 $(this).text('');
			    });	
				
				//  Show and hide info on "About Me" page.
				
				// Insert links	
				var headlineLink = "<p class=\"hide-about\"><a href=\"#\" title=\"Collapse/Expand\">Show Titles Only</a></p>";
				$('#content h2.about-compact').after(headlineLink);
				
				var collapseLink = "<a href=\"#\" title=\"Collapse/Expand\" class=\"about-collapse\"></a>";
				$('#content .post h2.about-title').after(collapseLink);
				
				// Hide and show all news
				 $('.hide-about a').toggle(function() {
				 $('.post .about-content').slideUp(400);
				 $(this).fadeOut();
				 $(this).delay(450,function(){
					$('.hide-about a').text('Show Content').addClass('hide');
				  });
				 $(this).fadeIn();
				 $('.post h2.about-title + a').removeClass().addClass('about-expand').text('');
				}, function() { 
				 $('.post .about-content').slideDown(400);
				 $(this).fadeOut();
				 $(this).delay(450,function(){
					$('.hide-about a').text('Show Titles Only').removeClass();
				  });
				  $(this).fadeIn();
				  $('.post h2.about-title + a').removeClass().addClass('about-collapse').text('');
				});
				 
				// Change images and text on individual links
				$('.post a.about-collapse').toggle(function() {
			     $(this).siblings('div').slideUp(400); 
				 $(this).removeClass().addClass('about-expand');
				 $(this).text('');
			    }, function() { 
			     $(this).siblings('div').slideDown(400);
				 $(this).removeClass().addClass('about-collapse');
				 $(this).text('');
			    });	
				
				// Sidebar Skills
				
				var collapseLink = "<a href=\"#\" title=\"Collapse/Expand\" class=\"skills-collapse\"></a>";
				$('#sidebar h3.skills').after(collapseLink);
				
				$('#sidebar a.skills-collapse').toggle(function() {
			     $(this).siblings('div').slideUp(400); 
				 $(this).removeClass().addClass('skills-expand');
				 $(this).text('');
			    }, function() { 
			     $(this).siblings('div').slideDown(400);
				 $(this).removeClass().addClass('skills-collapse');
				 $(this).text('');
			    });	
				
			});
		
		