$(document).ready(function() {
	function moveLight(object, speed) {
		var left = 262;
		if (!speed && speed != 0) speed = 300;
		if ($('#primarynav ul a.active').length > 0) left = $('#primarynav ul a.active').offset().left + $('#primarynav ul a.active').width() / 2 - $('#header').offset().left;
		$('#light').clearQueue();
		if (object && object != $('#logo img')) left = $(object).offset().left + $(object).width() / 2 - $('#header').offset().left;
		$('#light').animate({ left: left }, speed);
	}
	function changeSelected(object) {
		var selected = false;
		$('#primarynav a').each(function() { $('#highlighter').removeClass($(this).attr('class')); });
		if ($('#primarynav a.active')) $('#header .separator').addClass($('#primarynav a.active').attr('class'));
		if ($('#primarynav ul a.active').length > 0) selected = $('#primarynav ul a.active');
		if (object && !$(object).hasClass('member')) selected = object;
		if (selected) {
			$('#highlighter').addClass($(selected).attr('class'));
			$('#highlighter').css('left', $(selected).parent().position().left + 'px');
			$('#highlighter').css('width', $(selected).width() + 6 + 'px');
			$('#highlighter').show();
		}
		else
			$('#highlighter').hide();
	}
	
	$('#primarynav a').mouseenter(function() { changeSelected(this); });
	$('#primarynav ul').mouseleave(function() { changeSelected(); });
	// $('#logo img').mouseenter(function() { moveLight(this); changeSelected(); });
	// $('#logo img').mouseleave(function() { moveLight(); changeSelected(); });
	
	// moveLight(false, 0);
	if ($('#primarynav ul a.active').length > 0) changeSelected($('#primarynav a.active'));
	
	Cufon.replace('h1', { fontFamily: 'Avant Garde Book' });
	Cufon.replace('#banner.whatwedo h1', { fontFamily: 'Avant Garde Book', color: '-linear-gradient(#f5781b, #f5781b)', textShadow: '#ffffff 1px 1px' });
	Cufon.replace('#banner.aboutus h1', { fontFamily: 'Avant Garde Book', color: '-linear-gradient(#40aa09, #65bb39)', textShadow: '#ffffff 1px 1px' });
	Cufon.replace('#banner.blog h1', { fontFamily: 'Avant Garde Book', color: '-linear-gradient(#1796d5, #1796d5)', textShadow: '#ffffff 1px 1px' });
	Cufon.replace('#banner.contactus h1', { fontFamily: 'Avant Garde Book', color: '-linear-gradient(#e94b88, #e94b88)', textShadow: '#ffffff 1px 1px' });
	Cufon.replace('h2', { fontFamily: 'Avant Garde Demi' });
	Cufon.replace('h3', { fontFamily: 'Avant Garde Demi' });
	Cufon.replace('h4', { fontFamily: 'Avant Garde Demi' });
	Cufon.now();
	
	$('#homearrows-what').mouseenter(function() {
		$('#homearrows').attr('src', '/images/homearrows-what.jpg');
	});
	$('#homearrows-how').mouseenter(function() {
		$('#homearrows').attr('src', '/images/homearrows-how.jpg');
	});
	$('#homearrows-why').mouseenter(function() {
		$('#homearrows').attr('src', '/images/homearrows-why.jpg');
	});
	$('#homearrows-what').mouseleave(function() {
		$('#homearrows').attr('src', '/images/homearrows.jpg');
	});
	$('#homearrows-how').mouseleave(function() {
		$('#homearrows').attr('src', '/images/homearrows.jpg');
	});
	$('#homearrows-why').mouseleave(function() {
		$('#homearrows').attr('src', '/images/homearrows.jpg');
	});
});