$(document).ready(function() {

	// Cufon.replace('h1, h2, #nav li a, .post h2 a');
	
	// Add post_image div around all image in a post
	$(".entry img, p img").wrap("<div class='post_image'></div>");

	//$(".post").slideDown("slow");
	
	var ch = $('#page-content').height();
	var sb = $('#sidebar').height();
	
	if((navigator.userAgent.match(/iPad/i) ) || (navigator.userAgent.match(/iPhone/i)) ) {
		switch(window.orientation)
		{
		
			case 0:
				$('#page-content p').css({'font-size': 19 });
				$('#sidebar').css({ 'height': 370 });
				$('body.single #sidebar').css({ 'height': 370 });
					break;	
					
			case 90:
				$('#page-content p').css({'font-size': 13 });
				$('#sidebar').css({ 'height': ch-10 });
				$('body.single #sidebar').css({ 'height': ch });
					break;
			
			case -90:
				$('#page-content p').css({'font-size': 13 });
				$('#sidebar').css({ 'height': ch-10 });
				$('body.single #sidebar').css({ 'height': ch });
					break;
		}
	} else {
		if( ch > sb ) {
			$('#sidebar').css({ 'height': ch-85 });
			$('body.single #sidebar').css({ 'height': ch });
		}
	}
	
	function updateOrientation()
	{
		var orientation=window.orientation;
		switch(orientation)
		{
		
			case 0:
				$('#page-content p').css({'font-size': 19 });
				$('#sidebar').css({ 'height': 370 });
				$('body.single #sidebar').css({ 'height': 370 });
					break;	
					
			case 90:
				$('#page-content p').css({'font-size': 13 });
				$('#sidebar').css({ 'height': ch-10 });
				$('body.single #sidebar').css({ 'height': ch });
					break;
			
			case -90:
				$('#page-content p').css({'font-size': 13 });
				$('#sidebar').css({ 'height': ch-10 });
				$('body.single #sidebar').css({ 'height': ch });
					break;
		}
	
	}
	
	window.onorientationchange=updateOrientation;

});

