//     JQuery Text resize + Cookie recall
//     Ben Hayes, January 2010 | info@jackfruitdesign.com
//     Based initially on a script from http://www.shopdev.co.uk/blog/text-resizing-with-jquery/
//     This script gives a simplified binary option: normal or large text

$(document).ready(function() {
		
	     // declare a few constants:
	     var SMALL  = 11; //small font size in pixels
	     var MEDIUM = 14; //small font size in pixels
		 var LARGE  = 16; //larger size in pixels
	     var COOKIE_NAME = "Simple-Fontresizer"; //Maybe give this the name of your site.

	     //make it small by default
	     var fontsize = SMALL; 

	     // Only show text resizing links if JS is enabled
	     $(".fontresize").show();

	     // if cookie exists set font size to saved value, otherwise create cookie
	     if($.cookie(COOKIE_NAME)) {
		     fontsize = $.cookie(COOKIE_NAME);
		     //set initial font size for this page view:
		     $("#rightcol").css("font-size", fontsize + "px");
		     //set up appropriate class on font resize link:
	     } else {
		     //$("#small").addClass("current");
		     $.cookie(COOKIE_NAME, fontsize);
			 $("#small").attr("src","http://www.cyclingresourcecentre.org.au/images/home/font_decrease_hover.gif");
			 $("#medium").attr("src","http://www.cyclingresourcecentre.org.au/images/home/font_normal.gif");
			 $("#large").attr("src","http://www.cyclingresourcecentre.org.au/images/home/font_increase.gif");
	     }

	     // large font-size link:
	     $("#large").bind("click", function() {
			     if(fontsize == SMALL || fontsize == MEDIUM) {
					 fontsize = LARGE;
					 $("#rightcol").css("font-size", fontsize + "px");
					 $.cookie(COOKIE_NAME, fontsize);
					 $("#small").attr("src","http://www.cyclingresourcecentre.org.au/images/home/font_decrease.gif");
					 $("#medium").attr("src","http://www.cyclingresourcecentre.org.au/images/home/font_normal.gif");
					 $("#large").attr("src","http://www.cyclingresourcecentre.org.au/images/home/font_increase_hover.gif");
			     }
			     return false;	
			     });
		 
		 // medium font-size link:
	     $("#medium").bind("click", function() {
			     if(fontsize == SMALL || fontsize == LARGE) {
					 fontsize = MEDIUM;
					 $("#rightcol").css("font-size", fontsize + "px");
					 $.cookie(COOKIE_NAME, fontsize);
					 $("#small").attr("src","http://www.cyclingresourcecentre.org.au/images/home/font_decrease.gif");
					 $("#medium").attr("src","http://www.cyclingresourcecentre.org.au/images/home/font_normal_hover.gif");
					 $("#large").attr("src","http://www.cyclingresourcecentre.org.au/images/home/font_increase.gif");
			     }
			     return false;
			     });
	     
	     // small font-size link:
	     $("#small").bind("click", function() {
			     if(fontsize == LARGE || fontsize == MEDIUM) {
					 fontsize = SMALL;
					 $("#rightcol").css("font-size", fontsize + "px");
					 $.cookie(COOKIE_NAME, fontsize);
					 $("#small").attr("src","http://www.cyclingresourcecentre.org.au/images/home/font_decrease_hover.gif");
					 $("#medium").attr("src","http://www.cyclingresourcecentre.org.au/images/home/font_normal.gif");
					 $("#large").attr("src","http://www.cyclingresourcecentre.org.au/images/home/font_increase.gif");
			     }
			     return false;	
			     });
});

