/**
 * Common script to be executed after any website page is loaded
 */

function rebuildShadowHeight() {
	$('#shadow-top-wrapper').height($('#wrapper').height());
}

$(document).ready(function() {
	// Resizes shadow wrapper's height to match content height
	rebuildShadowHeight();
	
	$('#slideshow').cycle({
		delay:  -1000,
		before: function(){
			$('#slideshow div.slide').css('visibility','visible');
		}
	});
	
	$('li.page-item-5 a').click(function(event) {
		event.preventDefault();
		$('.submenu').hide('fast', function(){
			rebuildShadowHeight();
		});
		$('#programs-submenu').show('fast', function(){
			rebuildShadowHeight();
		});
	});
	$('#programs-submenu .close-submenu').click(function(event) {
		event.preventDefault();
		$('#programs-submenu').hide('fast', function(){
			rebuildShadowHeight();
		});
	});
	
	$('li.page-item-7 a').click(function(event) {
		event.preventDefault();
		$('.submenu').hide('fast', function(){
			rebuildShadowHeight();
		});
		$('#departments-submenu').show('fast', function(){
			rebuildShadowHeight();
		});
	});
	$('#departments-submenu .close-submenu').click(function(event) {
		event.preventDefault();
		$('#departments-submenu').hide('fast', function(){
			rebuildShadowHeight();
		});
	});
	
	$('a.question').click(function(event){
		event.preventDefault();
		if($(this).parent().find('.answer').css('display') == 'none') {
			$(this).parent().find('.answer').show('fast', function(){
				rebuildShadowHeight();
			});
			$(this).parent().find('.arrow').attr('src', $('#arrow-opened').attr('src'));
		} else {
			$(this).parent().find('.answer').hide('fast', function(){
				rebuildShadowHeight();
			});
			$(this).parent().find('.arrow').attr('src', $('#arrow-closed').attr('src'));
		}
	});
});

