$(function() {

	//external links in new window	
	$('a[href^="http://"]').attr("target", "_blank");


	//add main menu dropdown hover effect for IE6
	$('ul.nav li').hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
	
	//fix main_nav to center properly.  should be able to do this in CSS!
	var correct_width = 0;
	$('#main_nav ul.nav').children().each(function(){ 
		correct_width += $(this).width() + 2; 
		if ($.browser.msie) correct_width - 4;
	});
	//$('#main_nav ul.nav').width(correct_width + 'px');
	
	//fix dropdowns to have the parent's width.  should be able to do this in CSS!
	$('ul.nav ul.subnav').each(function(){
		$(this).width($(this).parent().width() - 2);
	});
	
	$('a#main_overview').fancybox({
		'width' : 680,
		'height' : 400
	});
	
	
	// newsletter signup
	$('#mc_embed_signup').hide();
	
	$('#newsletter_toggle').click(function(e){
		e.preventDefault();
		$('#mc_embed_signup').slideToggle();
	});
	

	/* legacy home page code
	
	//welcome banner
	$('div#welcome').addClass('closed');
	
	$('div#welcome').click(function() {
		
		if($(this).hasClass('closed')) {
			$(this).parent().css('z-index', '300');
			
			$(this).animate({
				'left' : 0
			}, 700, function() {
				$(this).removeClass('closed');
				$(this).addClass('opened');
			});
		} else {
			$(this).animate({
				'left' : -936
			}, 700, function() {
				$(this).removeClass('opened');
				$(this).addClass('closed');
				$(this).parent().css('z-index', '50');
			});
		}
	});
	
	$('div#welcome a#intro').click(function() {
		return false;
	});	
	
	$('div#welcome a#overview').click(function() {
		return false;
	});	
	
	$('div#welcome a.button_rounded').fancybox({
		'width' : 680,
		'height' : 400
	});
	
	
	$('a#main_overview').fancybox({
		'width' : 680,
		'height' : 400
	});
	
	
	//home page carousel
	$('div#carousel').roundabout({
		childSelector : 'div.moveable',
		easing : 'easeInOutExpo',
		minOpacity : 1,
		maxScale : 1,
		minScale : 0.6,
		tilt : -5.5
	});
	
	$('div#carousel div.moveable').click(function() {
		$(this).find('a').click();
	});
	
	//leah request that hover trigger rotation
	$('div.roundabout-moveable-item').hover(function(){
		if ($(this).hasClass('roundabout-in-focus')) return false; //ignore selected image
		$(this).find('a').click();
 	}, function(){
		//alert('out');
	});
	
	$('div#carousel div.moveable a').fancybox({
	 	onStart : checkFocus,
	 	'autoDimensions' : false,
		'width' : 500,
		'height' : 300
	});
	
	function checkFocus(e) {
		var clicked = e.toString().replace(location.href, '');
		var focused = $('div.roundabout-in-focus a').attr('href');
		//alert('clicked');
		return (clicked == focused);
	}*/
		
});
