/* Equal Heights Plugin Version 1.0 Updated 12/10/2008 Copyright (c) 2008 Rob Glazebrook (cssnewbie.com) */
(function($) {
	$.fn.equalHeights = function(minHeight, maxHeight) {
		tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if ($(this).height() > tallest) {
				tallest = $(this).height();
			}
		});
		if ((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			$(this).height(tallest).css('overflow','auto');
		});
	}
})(jQuery);
/* Rowspan Plugin Version 1.0 Updated 01/05/2010 Copyright (c) 2010 Kate Kalcevich (clearwebstudio.ca) */
(function($) {
	$.fn.rowHeight = function() {
		rowtop = $(this).parents('div.row').offset().top;
		celltop = $(this).offset().top;
		topdiff = rowtop - celltop;
		if (topdiff != 0) {
			$(this).css('margin-top',topdiff);
			$(this).parents('div.row').css('height','auto');
		}
		cellheight = parseInt($(this).parents('div.row').height()) - 
			parseInt($(this).css('padding-top')) - 
			parseInt($(this).css('padding-bottom')) - 
			parseInt($(this).css('margin-bottom')) - 
			parseInt($(this).css('border-bottom-width')) - 
			parseInt($(this).css('border-top-width'));
		$(this).css('height',cellheight);
	}
})(jQuery);
// Functions to run when page has loaded
$(document).ready(function(){
	// set all cells with class equal(n) to equal height
	// and cells with class rowspan(n) to row height
	$('div.cell').each(function(){
		classes = $(this).attr('class');
		if (classes.indexOf('equal') >= 0 || classes.indexOf('rowspan') >= 0) {
			var classli = $(this).attr('class').split(' ');
			for (i in classli) {
				equal = classli[i].indexOf('equal');
				rowspan = classli[i].indexOf('rowspan');
				if (equal >= 0) {
					$('.equal' + classli[i].slice(equal + 5)).equalHeights();
				} else if (rowspan >= 0) {
					$('.rowspan' + classli[i].slice(rowspan + 7)).rowHeight();
				}
			}
		}
	});
	// hide email addresses from spambots
	$('a.email').each(function(){
		$(this).attr("href", "mailto:" + $(this).html().replace("(at)","@").replace("(dot)",".")); 
		$(this).html($(this).html().replace("(at)","@").replace("(dot)","."));
	});
});
// make skip link work for WebKit browsers (Safari and Chrome.)
$(document).ready(function(){
	var is_webkit = navigator.userAgent.toLowerCase().indexOf('webkit') > -1;
	var is_opera = navigator.userAgent.toLowerCase().indexOf('opera') > -1;
	if(is_webkit || is_opera) {
	 	$('a#top').attr('tabindex' , 0);
	 	$('a#skip').click(function(){ 
			$("a#top").focus(); 
		});
	}
});
