/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
  jQuery.fn.scrollerBaby = function() {
	var pageHeight = jQuery(this).height();
	jQuery(this).css({'overflow': 'visible', 'height': 'auto'});
	var pageScroll = jQuery(this).find('#scroll').outerHeight();
	jQuery(this).css({'overflow': 'hidden', 'height' : pageHeight + 'px'});

	//Sidebar Offset, Top value
	var divTop = parseInt(jQuery(this).offset().top);

	//Sidebar Offset, Bottom value
	var divBottom = parseInt(jQuery(this).height() + divTop);
	var divSize = divBottom - divTop;
	var endScroll = -(pageScroll - divSize);
	
	if (pageScroll > divSize){
		jQuery(this).mousemove(function(e) {
			// Try with a Hover
			var locateMouse = (e.pageY - divTop)/ divSize;
			var currentScroll = endScroll * locateMouse;
			jQuery(this).find('#scroll').css({top: currentScroll});
		});
	}
 }


jQuery(document).ready(function($) {

// Fit navigation menu padding to div
	var menuWidth = $('#main').outerWidth() - ( $('#content').outerWidth() + $('#sidebar').outerWidth() );
	$('#menu').css({width : menuWidth});
	$('#menu a').each(
		function(){
			var rightPad = $('#menu').width() - $(this).outerWidth();

			if( $(this).outerWidth(true) < $('#menu').width() ){
				$(this).css({"padding-right" : rightPad});
			}
		}
	);

	// Hide the front page graphic
	$('#home .hover').click(function(){
		$(this).fadeOut('slow');
//		location.href = "/about";
	});
//
//	alert(window.location);

	// Set up Front Page Buttons

	$('#home .hover').hover(function(){
		$(this).css({opacity: 1});
	}, function(){
		$(this).css({opacity: 0});
	});

	// Add Block-quotes
	$('blockquote p').prepend('&#8220;');
	$('blockquote p').append('&#8221;');
	
	$('#content').scrollerBaby();
});