
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
$(document).ready(function() {
  // Clear input function
  function autoFill(id, v){
  	$(id).attr({ value: v }).focus(function(){
  		if($(this).val()==v){
  			$(this).val("");
  		}
  	}).blur(function(){
  		if($(this).val()==""){
  			$(this).val(v);
  		}
  	});
  }
  autoFill($("#search-form .text"), "Search site");
	equalHeight($(".column"));
  
  		
	/* Text resize
	................................................... */
	var options = { min: -2, max: 3}; // define number of steps
	$.FontSizer.Init(options); //Initialize the font sizer.		
	//$(this).fontSizer();
	
	// Assign buttons
	$('.controls li.decrease-size a').click(function(){
		$.FontSizer.DecreaseSize();
		return false;
	});
	$('.controls li.increase-size a').click(function(){
		$.FontSizer.IncreaseSize();
		return false;
	});

	
	//print
	$(".controls li.print-page a").click(function(){
		window.print();
		return false;
	});
	
	$('#scamAlert #scamAlertRollover').hover(function(){
		$(this).find('#scamAlertMsg').show();//fadeIn(100);
	}, function(){
		$(this).find('#scamAlertMsg').hide();//fadeOut(100);
	});

});

/* ...................................................
	
	Cookie functions
	Credit: Quirksmode (http://www.quirksmode.org/js/cookies.html)
	
................................................... */
function setCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	setCookie(name,"",-1);
}

/* ...................................................
	
	Fontsizer
	
................................................... */
$.FontSizer = {
	level:0,
	options:{
		min:-2,
		max:3
	},
	Init : function(options){
		if(options){ $.FontSizer.options = $.extend($.FontSizer.options, options);	}
		var level = (readCookie('font_level') != null ? readCookie('font_level') : 0)
		$.FontSizer.SetSize(level);
	},
	IncreaseSize : function(){
		if(($.FontSizer.level) + 1 <= $.FontSizer.options.max){
			var next = parseFloat($.FontSizer.level) + 1;
			$.FontSizer.SetSize(next);
		}
	},
	DecreaseSize : function(){
		if(($.FontSizer.level - 1) >= $.FontSizer.options.min){
			var next = parseFloat($.FontSizer.level) - 1;
			$.FontSizer.SetSize(next);
		}
	},
	SetSize : function(level){
		$.FontSizer.level = parseFloat(level);
		setCookie('font_level', parseFloat(level));
		var level = (level/10) + 1;
		$('#contentBox-2, #footer').css('fontSize', level+'em');
	}
}