//
//     JQuery Text resize + Cookie recall
//     by Jonny Kamaly
//     based on script written by Faisal &amp; Homar
//
 
 
var sitefunctions = {
	textresize : function(){
		var $cookie_name = "cpc-FontSize";
		var originalFontSize = $("html").css("font-size");
		// if exists load saved value, otherwise store it
		if($.cookie($cookie_name)) {
			var $getSize = $.cookie($cookie_name);
			$("html").css({fontSize : $getSize + ($getSize.indexOf("px")!=-1 ? "" : "px")}); // IE fix for double "pxpx" error
		} else {
			$.cookie($cookie_name, originalFontSize);
		}
		// reset link
		$(".reset-font").bind("click", function() {
			$("html").css({"font-size": originalFontSize});
			$.cookie($cookie_name, originalFontSize);
			return false;
		});
		// text "+" link
		$(".go-big").bind("click", function() {
			var currentFontSize = $("html").css("font-size");
			var currentFontSizeNum = parseFloat(currentFontSize, 16);
			var newFontSize = currentFontSizeNum+2;
			if (newFontSize <= 24) {
				$("html").css({"font-size": newFontSize+"px"});
				$.cookie($cookie_name, newFontSize);
			}
			return false;	
		});
		$(".go-small").bind("click", function() {
		  var currentFontSize = $("html").css("font-size");
		  var currentFontSizeNum = parseFloat(currentFontSize, 16);
		  var newFontSize = currentFontSizeNum-2;
		  if (newFontSize >= 10) {
			$("html").css({"font-size": newFontSize+"px"});
			$.cookie($cookie_name, newFontSize);
		  }
		  return false;
		});
	}
}
