//
//     $ Text resize + Cookie recall
//     by Jonny Kamaly
//     based on script written by Faisal &amp; Homar
//
 
 
var sitefunctions = {
	textresize : function(){
		// show text resizing links
		$(".FontSize").show();
		var $cookie_name = "sitename-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
		/*$(".FontSizeReset").bind("click", function() {
			$("html").css("font-size", originalFontSize);
			$.cookie($cookie_name, originalFontSize);
		});*/
		// text "+" link
		$(".FontSizeInc").bind("click", function() {
			var currentFontSize = $("body").css("font-size");
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			var newFontSize = currentFontSizeNum*1.2;
			if (newFontSize, 11) {
				$("body").css("font-size", newFontSize);
			//	$.cookie($cookie_name, newFontSize);
			}
			return false;	
		});
		$(".FontSizeDec").bind("click", function() {
		  var currentFontSize = $("body").css("font-size");
		  var currentFontSizeNum = parseFloat(currentFontSize, 10);
		  var newFontSize = currentFontSizeNum*0.8;
		  if (newFontSize, 11) {
			$("body").css("font-size", newFontSize);
		//	$.cookie($cookie_name, newFontSize);
		  }
		  return false;
		});
	}
}
 
$(document).ready(function(){
		sitefunctions.textresize();	
})

jQuery.fn.hint = function (blurClass) {
  if (!blurClass) { 
    blurClass = 'blur';
  }

  return this.each(function () {
    // get jQuery version of 'this'
    var $input = jQuery(this),

    // capture the rest of the variable to allow for reuse
      title = $input.attr('title'),
      $form = jQuery(this.form),
      $win = jQuery(window);

    function remove() {
      if ($input.val() === title && $input.hasClass(blurClass)) {
        $input.val('').removeClass(blurClass);
      }
    }

    // only apply logic if the element has the attribute
    if (title) { 
      // on blur, set value to title attr if text is blank
      $input.blur(function () {
        if (this.value === '') {
          $input.val(title).addClass(blurClass);
        }
      }).focus(remove).blur(); // now change all inputs to title

      // clear the pre-defined text when form is submitted
      $form.submit(remove);
      $win.unload(remove); // handles Firefox's autocomplete
    }
  });
};
