$(document).ready(function() {

	// External links
	$('a').each(function() {
		if($(this).attr('rel') == 'external') {
			$(this).click(function() {
				window.open($(this).attr('href'));
				return false;
			});
		}
	});
	
	
	// Navigation
	$('ul#navigation li').hover(function() {
		if($(this).attr('id')) $(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});


	// Buttons
	$('div.button').add('div.button-sm').hover(function() {
		var o = ($(this).hasClass('.button-sm') ? -30 : -36) + 'px';
		$(this).css('backgroundPosition', 'right ' + o);
		$(this).find('span').css('backgroundPosition', '0 ' + o);
	}, function() {
		$(this).css('backgroundPosition', 'right 0');
		$(this).find('span').css('backgroundPosition', '0 0');
	});	


	// Share menu
	$('#share-page').click(function() {
		$('#share-menu').show();
		return false;
	});
	$(document).click(function() {
		$('#share-menu').hide();
	});	


	// Image lists
	$('.image-list li a').mouseover(function() {
		var ul = $(this).parent().parent().parent();
		ul.find('li').removeClass('selected');
		$(this).parent().addClass('selected');
		var idx = 0;
		ul.find('li').each(function(i) {
			if($(this).hasClass('selected')) idx = i;							  
		});
		var m = idx * ul.find('.thumbnail div').height();
		ul.find('img:first').css({ marginTop: - m });
	});


	// Gift shop
	$('#store-item-thumbs a').click(function() {
		$('#store-item-thumbs .selected').removeClass('selected');
		$(this).parent().addClass('selected');
		$('#store-item-images img:first').attr('src', $(this).attr('href'));
		this.blur();
		return false;
	});
	$('.add-to-cart').hover(function() {
		$(this).css('backgroundPosition', '0 -30px');
	}, function() {
		$(this).css('backgroundPosition', '0 0');
	});	


	// Calendar
	$('a#set-range').click(function() {
		$('div#custom-range').slideToggle();
		return false;
	});
	
	
	// Preschool tour popups
	$('a.preschool-tour').click(function() {
		var props = 'width=616, height=482, scrollbars=0,'
		+ 'resizable=0, menubar=0, statusbar=0, directories=0';
		window.open($(this).attr('href'), 'tour', props);
		return false;									 
	});
	
	
	// Grants annual report popups
	$('a.grants-report').click(function() {
		var props = 'width=450, height=550, scrollbars=1,'
		+ 'resizable=0, menubar=0, statusbar=0, directories=0';
		window.open($(this).attr('href'), 'tour', props);
		return false;									 
	});
	
	
	// Initialize when doc is ready:
	// features.initialize();
	//schedule.initialize();
	//videos.initialize();
	//slides.initialize();
	//gallery.initialize();
	//lightbox.initialize();
	//artboard.initialize();
	//webcast.initialize();
	
});




