
$( function() {
	$( '.content p img' ).each( function() {
		var img = $( this );
		var p = img.parent();
		p.before( img );
		p.remove();
	});
	
	$( '.content .text img:first-child' ).css( 'margin-top', '0' );
	
	$( '.content .amazlet-box img' ).css( 'margin', '0' );
	$( '.content .amazlet-box' ).css( 'margin', '3em 0 1.5em' );
	
	$( '.content p' ).wrapInner( $( '<span />' ) );
	
	
	$( '.nav-main' ).each( function() {
		var n = $( this ).find( '.title' );
		var t = n.text();
		n.text( '+ ' + t );
		
		var sub = $( this ).find( '.nav-sub' );
		
		var i = $( '.nav-main' ).index( $( this ) );
		
		var v = parseInt( $.cookie( "menu-" + i ) );
		if( v ) {
			n.text( '- ' + t );
		}
		else {
			sub.addClass( 'hidden' );
			n.text( '+ ' + t );
		}
		
		n.click( function() {
			sub.toggle( 300 );
			v = v ? 0 : 1;
			$.cookie( "menu-" + i, v, { expires: 7 } );
			if( v ) {
				n.text( '- ' + t );
			}
			else {
				n.text( '+ ' + t );
			}
		});
		sub.find( '.link a' ).each( function() {
			var t = $( this ).text();
			t = '> ' + t;
			$( this ).text( t );
		});
		sub.find( '.text' ).each( function() {
			var t = $( this ).text();
			t = '- ' + t;
			$( this ).text( t );
		});
		sub.find( '.sub a' ).each( function() {
			var t = $( this ).text();
			t = '/ ' + t;
			$( this ).text( t );
		});
	});
	
	var sep = [ '/', '-', '>' ];
	var sl = sep.length;
	$( 'hr' ).each( function() {
		var l = 75;
		var t = '';
		while( l -- ) {
			t += sep[ Math.floor( Math.random() * sl ) ];
		}
		var p = $( '<p class="end"/>' );
		p.text( t );
		$( this ).before( p );
		$( this ).remove();
	});
	
	$( '.content p.date').each( function() {
		var t = $( this ).text();
		t = '/ ' + t;
		$( this ).text( t );
	});
	
	/*
	$( '.content p.meta' ).each( function() {
		var t = $( this ).text();
		t = '- ' + t;
		$( this ).text( t );
	});
	*/
	
	$( '#comments .author' ).click( function() {
		var id = $( this ).attr( 'id' );
		$( '.' + id ).toggle( 200 );
	});
	/*
	$( '.content .end' ).each( function() {
		var w = $( this ).width() + 20;
		var m = $( '<marquee width="' + w + 'px" behavior="alternate"/>' );
		$( this ).wrap( m );
	});
	*/
});