$(document).ready(function(){
  // Reset Font Size
  var originalFontSize = $('body').css('font-size');

  // Increase Font Size
  $(".increaseFont").click(function(){
  	var currentFontSize = $('body').css('font-size');
 	var currentFontSizeNum = parseFloat(currentFontSize, 10);
    if (currentFontSizeNum < 24) {
      var newFontSize = currentFontSizeNum*1.2;
      $('body').css('font-size', newFontSize);
    }

	return false;
  });
  // Decrease Font Size
  $(".decreaseFont").click(function(){
  	var currentFontSize = $('body').css('font-size');
 	var currentFontSizeNum = parseFloat(currentFontSize, 10);
    if (currentFontSizeNum > 8) {
      var newFontSize = currentFontSizeNum*0.86;
	  $('body').css('font-size', newFontSize);
    }
	return false;
  });


  var originalWidth = $('#page').css('width');


  // Set Fluid/Fixed page width
  $(".setPageWidth").click(function(){
  	var currentWidth = $('#page').css('width');
   //	var currentFontSizeNum = parseFloat(currentFontSize, 10);
    if (currentWidth=="95%") newWidth = "960px";
    else if (currentWidth=="960px") newWidth = "95%";
    else newWidth = "960px";
	$('#page').css('width', newWidth);
	return false;
  });

});





function initTooltips(o) {
//alert($.browser.safari)

	var showTip = function() {
		var el = $('span.rss', this).css('display', 'block')[0];

		var ttHeight = $(el).height();
		var ttOffset =  el.offsetHeight;
		var ttTop = ttOffset + ttHeight;

		$('span.rss', this)
			.stop()
			.css({
				'opacity': 0,
				'top': 2 - ttOffset
			})
			.animate({
				'opacity': 1,
				'top': 18 - ttOffset
			}, 250);
	};

	var hideTip = function() {

		var self = this;
		var el = $('span.rss', this).css('display', 'block')[0];

		var ttHeight = $(el).height();
		var ttOffset =  el.offsetHeight;
		var ttTop = ttOffset + ttHeight;
	//	alert(label.height());
	//	el.hiding = true;
		$('span.rss', this)
			.stop()
			.animate({
				'opacity': 0,
				'top': 10 - ttOffset
			}, 250, function() {
				el.hiding = false;
				$(this).css('display', 'none');
			});


	};

	$('#sidebar ul.nav a span.rss').hover(
		function() { return false; },
		function() { return true; }
	);

	$('#sidebar ul.nav a').hover(
		function(){
			var self = this;
			showTip.apply(this);
			if (o.timeout) this.tttimeout = setTimeout(function() { hideTip.apply(self) } , o.timeout);
		},
		function() {
			clearTimeout(this.tttimeout);
			hideTip.apply(this);
		}
	);

}





$(function() {
// Body .safari class
	if ($.browser.safari) $('body').addClass('safari');

/* Hover effects */
	var fadeSpeed = ($.browser.safari ? 600 : 450);

    initTooltips({
		timeout: 6000
	});


});




