/*!
 Javascript Slideshow
 */
 
$(document).ready(function() {


	// Homepage

	// rollovers on posts thumbs - homepage & archive(multiple posts for one category)
	
	$(".post").mouseover(function(e)
	{
		$(this).find('.post-title').css('display','block');
		$(this).find('.post-title').css('top','150px');
		$(this).find('.post-title').animate({top:'90px'},300);
		$(this).css('border-color','#000000');
		
		var id = $(this).find('.post-title').attr('id');
		showCategory(id);
		
	}).mouseout(function(e)
	{
		$(this).find('.post-title').css('display','none');
		if($(this).hasClass('postcats'))
		{
			$(this).css('border-color','#000000');
		}else{
			$(this).css('border-color','#242020');
		}
		
	}).click(function(e)
	{
		window.location.href = $(this).find('a').attr('href');
	});
	
	
	// button next-prev posts
	
	var postcount = $('.post-slide').attr('id');
	var rows = parseInt(postcount)%4;
	var line = 0;
	
	$(".button-post-prev").click(function(e)
	{
		if(line>0)
		{
			line--;
			$('.post-slide').animate({top:'+=156px'},500);
		}
	});

	$(".button-post-next").click(function(e)
	{
		if(line<rows-1)
		{
			line++;
			$('.post-slide').animate({top:'-=156px'},500);
		}
	});
	
	
	// show category on rollover
	
	function showCategory(id)
	{
		var pos = $('.cat-item-'+id).position();
		var width = $('.cat-item-'+id).outerWidth(false);
		$('.cat-marker').animate({left:(pos.left+152+(width/2))+'px'},500);
	}
	

	
	

});
