function fadeSite() {
	$("h1").css({opacity: 0, visibility: "visible"}).animate({opacity: 100}, 500,function(){
		$("#nav").css({opacity: 0, visibility: "visible"}).animate({opacity: 100},1000,function(){
			$("#entries").css({opacity: 0, visibility: "visible"}).animate({opacity: 100},3000);
		});
	});
}
function fadeEntries() {
	$("#entries").css({opacity: 0, visibility: "visible"}).animate({opacity: 100},3000);
}
$(document).ready(function() {	
	var entriesWidth = 0;
	var entryWidth = 0;
	var hideReadMore = false;
	$(".columns").each(function(){
		var pHeight = 0;
		if($(".slides img:first", this).length != 0) {
			$(this).parent(".entry").addClass("img");
			var imgWidth = $(".slides img:first", this).width();
			if(imgWidth < 300) {
				imgWidth = 300;
			}
			$(this).width(imgWidth+200);
			var pHeight = $(this).parent(".entry").find("p:first").height();
			if(($(this).parent(".entry").find("p").length <= 1) && pHeight <= 64) {
				hideReadMore = true;
			}
		} else {
			$(this).parent(".entry").addClass("text");
			$(this).children("p").each(function(){
				pHeight += $(this).height();
			});
			if(pHeight < 300) {
				$(this).width("300px");
				hideReadMore = true;
			} else {
				$(this).width("500px");
				hideReadMore = false;
			}
		}
		if(hideReadMore) {
			$(this).parent(".entry").find(".read-more").remove();
			$(this).parent(".entry").find(".read-less").remove();
		}
		hideReadMore = false;
	});
	
	$('.columns').columnize({ width: 300, height: 410 });

	$(".entry").each(function(){
		entryWidth = $(".columns .column:first",this).width();
		$(this).width(entryWidth);
		entriesWidth += entryWidth+50;
	});

	$("#wrapper,#entries").width(entriesWidth);
	
	$(".read-more").click(function(){
		var $this = $(this);
		var numColumns = 0;
		entryWidth = 0;
		entriesWidth = $("#entries").width();
		
		entryWidth = $(this).parents(".entry").children(".columns").width()+25;
		entriesWidth = (entriesWidth - $(this).parents(".entry").find(".column:first").width()) + entryWidth;
		$(this).parents("#entries").width(entriesWidth+25);
		
		$(this).hide();
		
		$(this).parents(".entry").animate({width: entryWidth},500);

		return false;
	});
	
	$(".read-less").click(function(){
		var $this = $(this);
		currentWidth =  $(this).parents(".entry").width();
		entriesWidth = $("#entries").width();
		entryWidth = $(this).parents(".entry").find(".column:first").outerWidth();
		
		entriesWidth = (entriesWidth - currentWidth) + entryWidth;
		$("#entries").animate({width: entriesWidth},600);
		
		$(this).parents(".entry").animate({width: entryWidth},500, function(){
			$this.parents(".entry").find(".read-more").show();
		});
		
		return false;
	});
	
	$(".entry .slides").each(function(){
		$(this).cycle({
			timeout:0,
			speed: 0,
			height: '300',
			slideExpr: 'img',
			next: $(".next",this),
			prev: $(".prev",this),
			pager:  $(this).parents(".entry").find(".img-nav"), 
		    pagerAnchorBuilder: function(idx) { 
		        return '<li><a href="#">' + (idx+1) + '</a></li>'; 
		    }
		});
	});
	$(document).bind('mwheelIntent', function(e, d){
		e.preventDefault();
		//tweenMenu('30px')
		/* Mousewheel UP */
		if (d > 0) {
			window.scrollBy(-100,0);
		} 
		/* Mousewheel DOWN*/
		else if (d < 0) {
			window.scrollBy(100,0);			
		}
	});
});