$(document).ready(function(){

		var printStyle;
		var printSize;

	// Resize

		$(".post-body-resize").click(function () { 
			$(".post-content .body").toggleClass('large');
		});

	// Print styles 
	
		$.extend({
		  getUrlVars: function(){
		    var vars = [], hash;
		    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		    for(var i = 0; i < hashes.length; i++)
		    {
		      hash = hashes[i].split('=');
		      vars.push(hash[0]);
		      vars[hash[0]] = hash[1];
		    }
		    return vars;
		  },
		  getUrlVar: function(name){
		    return $.getUrlVars()[name];
		  }
		});
		
		printStyle = $.getUrlVar('print');
		printSize = $.getUrlVar('size');
		
		if (printStyle == "true") {
			$('body').addClass('print');
			if (printSize == "3x5") {
				$('.post').columnize({
					width : 500,
					height : 350
				});
			}
		}
		
	
	// Cufon
	
		Cufon.set("fontFamily", "Marketing Script");
		Cufon.replace("h1");
		
		if (printStyle !== "true") {
			$("h1").show();
		}
	
	// Set view type
		
		if ($.cookie("view") == "thumbnails") {
			$("#posts").addClass('thumbnails');
			$("#sidebar-view-descriptions").removeClass('selected');
			$("#sidebar-view-thumbnails").addClass('selected');
			$('#posts').masonry({ singleMode: true, itemSelector: '.post' });
		}
			
		$("#sidebar-view-descriptions").click(function(e) {
			e.preventDefault();
			if (!$("#sidebar-view-descriptions").hasClass("selected")) {
				// disable window-resize trigger
			    $("#posts").masonry({resizeable: false})
			    // set container back to its default height
			    .css({height: 'auto'})
			        // set arranged items back to normal floats
			        .find('.post').css({
			            position: 'relative',
			            top: 'auto',
			            left: 'auto',
			            float: 'auto'
			        });
				$("#posts").removeClass('thumbnails');
				$("#sidebar-view-thumbnails").removeClass('selected');
				$("#sidebar-view-descriptions").addClass('selected');
				$.cookie("view", "descriptions");
			}
		});
		$("#sidebar-view-thumbnails").click(function(e) {
			e.preventDefault();
			if (!$("#sidebar-view-thumbnails").hasClass("selected")) {
				$("#posts").addClass('thumbnails');
				$("#sidebar-view-descriptions").removeClass('selected');
				$("#sidebar-view-thumbnails").addClass('selected');
				$('#posts').masonry({ singleMode: true, itemSelector: '.post' });
				$.cookie("view", "thumbnails");
			}
		});

		
	
});