

$(function(){
	
if ($('#sidebar').html() != null && $('#home').hasClass('post-template-posts_generator-php') == false && $('#home').hasClass('category-poetry') == false) {
	if ($('#home').hasClass('page') || $('#home').hasClass('archive') && $('#home').hasClass('category') != true  || $('#home').hasClass('single') && $('html').height() > 1200) {
		//fixedmenu();
		
	}
}
});

function fixedmenu(){
	
	
		$('#sidebar').append('<div id="navigator" class="invisible"><div><a href="javascript:void(0);" id="press-to-top">Back to top of page</a><div><span id="simple-sound-control">Sound <a href="javascript:void(0);" class="sound-control sound-on">On</a> | <a href="javascript:void(0);" class="sound-control sound-off">Off</a></span></div>');
		
		$('#press-to-top').click(function(){
			$('html,body').stop().animate({
				scrollTop: $('html').offset().top
			}, {
				duration: 'slow',
				easing: 'swing'
			});
		})
		
				// Get a reference to the message whose position
			// we want to "fix" on window-scroll.
			var message = $( "#navigator" );
 
			// Get the origional position of the message; we will
			// need this to compare to the view scroll for
			// reverting back to the original display position.
			//alert(originalMessageTop);
			
			var originalMessageTop = message.offset().top;
 
			// Get a reference to the window object; we will use
			// this several time, so cache the jQuery wrapper.
			var view = $( window );
 
 
			// Bind to the window scroll and resize events.
			// Remember, resizing can also change the scroll
			// of the page.
			view.bind(
				"scroll resize",
				function(){
 
					// Get the current scroll of the window.
					var viewTop = view.scrollTop();
 
					// Check to see if the view had scroll down
					// past the top of the original message top
					// AND that the message is not yet fixed.
					
					
					if (
						(viewTop > originalMessageTop) &&
						!message.is( ".site-navigator-fixed" )
						){
 						
						message.stop().animate({ opacity: 1,},500);

						
						// Toggle the message classes.
						message
							.removeClass( "site-navigator-absolute" )
							.addClass( "site-navigator-fixed" )
						;
 
					// Check to see if the view has scroll back up
					// above the message AND that the message is
					// currently fixed.
					} else if (
						(viewTop <= originalMessageTop) &&
						message.is( ".site-navigator-fixed" )
						){
							
							message.stop().animate({ opacity: 0,},500);
 
						// Toggle the message classes.
						message
							.removeClass( "site-navigator-fixed" )
							.addClass( "site-navigator-absolute" )
						;
 
					}
				}
			);
}
