/*************** Window Resizing 

Written by Ty Fujimura: tyfujimura.com
Inspired by RGA: rga.com
Use this code freely!

***************/
function doResize() {
	var win = $(window).width();
	var max = 1225;
	if (win >= max) {
		$('body').removeClass('small').addClass('large')
	} else {
		$('body').removeClass('large').addClass('small')	
	}
	var ht = $(window).height();
	if (win / ht < 1280 / 801) {
		$('#slideshow').removeClass('wide').addClass('tall')
	} else {
		$('#slideshow').removeClass('tall').addClass('wide')
	} 
}

$(function() {
	doResize();
	$(window).resize(doResize);
});

/*************** Menu Functions 

Simple jQuery Hover menu by Ty Fujimura : tyfujimura.com
Using the excellent hoverIntent plugin: http://cherne.net/brian/resources/jquery.hoverIntent.html

***************/

$(function() {
	$('.menuitem ul').hide();
	$('.bottom').hide();
	$('.current').find('.bottom').show();
	$('.current').find('.top').hide();
		
	hiConfig = {
		timeout:200,
		interval:0,
		over: function() {
			$(this).find('.top').hide();
			$(this).find('.bottom').show();
			$(this).children('ul').show();
			$(this).addClass('hover');
		},
		out: function() {
			$(this).children('ul').hide();
			$(this).find('.top').show();
			$(this).find('.bottom').hide();
			$(this).removeClass('hover');
		}
	}
	
	hiConfig2 = {
		timeout:200,
		interval:150,
		over: function() {
			$(this).children('.top').hide();
			$(this).children('.bottom').show();
			$(this).children('ul').show();
		},
		out: function() {
			$(this).children('ul').hide();
			$(this).children('.top').show();
			$(this).children('.bottom').hide();
		}
	}

	hiConfig3 = {
		timeout:200,
		interval:0,
		over: function() {
			$(this).children('ul').show();
			$(this).addClass('hover');
		},
		out: function() {
			$(this).children('ul').hide();
			$(this).removeClass('hover');
		}
	}
	
	$('.menuitem').hoverIntent(hiConfig)
	
	$('.current').hoverIntent(hiConfig3)

	$('.menuitem ul li').hoverIntent(hiConfig2)
	
});

/*************** Mail Replacements 

Thanks to http://www.html-advisor.com/javascript/hide-email-with-javascript-jquery/

***************/

$(function(){
$('.mailme').each( function() {
var spt = $(this);
var at = / at /;
var dot = / dot /g;
var addr = $(spt).text().replace(at,"@").replace(dot,".");
$(spt).after('<a href="mailto:'+addr+'" title="Send an email">'+ addr +'</a>')
.hover(function(){window.status="Send a letter!";}, function(){window.status="";});
$(spt).remove();});
});