//Text resize Function. URL:http://www.shopdev.co.uk/blog/text-resizing-with-jquery/
var sitefunctions = {	
	textresize : function(){
		var $cookie_name = "textsize";
		var originalFontSize = $("#content").css("font-size");
		if($.cookie($cookie_name)){
			var $getSize = $.cookie($cookie_name);
			$("#content").css({fontSize : $getSize + ($getSize.indexOf("px")!=-1 ? "" : "px")}); // IE fix for double "pxpx" error
		} else{
			$.cookie($cookie_name, originalFontSize, { path: '/' });
		}
		$(".resetFont").bind("click",function(){
				$("#content").css("font-size", originalFontSize);
				$.cookie($cookie_name, originalFontSize, { path: '/' });
		});
		$(".increaseFont").bind("click",function(){
				var currentFontSize = $("#content").css("font-size");
				var currentFontSizeNum = parseFloat(currentFontSize, 10);
				var newFontSize = currentFontSizeNum*1.2;
				if (newFontSize < 20) {
					$("#content").css("font-size", newFontSize);
					$.cookie($cookie_name, newFontSize, { path: '/' });
				}
				return false;
		});
		$(".decreaseFont").bind("click",function(){
				var currentFontSize = $("#content").css("font-size");
				var currentFontSizeNum = parseFloat(currentFontSize, 10);
				var newFontSize = currentFontSizeNum*0.8;
				if (newFontSize > 7) {
					$("#content").css("font-size", newFontSize);
					$.cookie($cookie_name, newFontSize, { path: '/' });
				}
				return false;
		});
	}
}
 
$(document).ready(function(){
	
	sitefunctions.textresize();
	
	//Smooth Scrolling
	$('#mainContent a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
			&& location.hostname == this.hostname) {
			  var $target = $(this.hash);
			  $target = $target.length && $target
			  || $('[name=' + this.hash.slice(1) +']');
			  if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body')
				.animate({scrollTop: targetOffset}, 1200);
			   return false;
			}
		}
	});

	//Clear Form Fields
	//Add the ID of each item you want to clear at the bottom of this block of code
	$.fn.clearThis = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
				this.className = "textBox1 darker";
			}
		}).blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
				this.className = "textBox1";
			}
		});
	};
	$("#searchKeywords").clearThis();
	
	//Cycle through Divs and switch content
	//Cycle Lite plugin http://www.malsup.com/jquery/cycle/lite/
	if ( $("#slideshow").length > 0 ) {
		$('#slideshow').cycle({
		    prev:   '#prev', 
		    next:   '#next',
			speed:  700,
		    timeout: 0 
		});
	}
	
});
