
$(function(){
	$('ul.rightarow.accordion li').addClass('collapsed');
	
	$('ul.rightarow.accordion li a.exp_col').click(function(){
		var parent_li = $(this).closest('li');
		if(parent_li.hasClass('collapsed')){
			parent_li.removeClass('collapsed').addClass('expanded');
		}else{
			parent_li.removeClass('expanded').addClass('collapsed');
		}
	});
	
	$('#nivo_slider').nivoSlider({
		effect:'sliceDown', // Specify sets like: 'fold,fade,sliceDown'
		slices:3, // For slice animations
		boxCols: 3, // For box animations
		boxRows: 3, // For box animations
		animSpeed:300, // Slide transition speed
		pauseTime:5000, // How long each slide will show
		startSlide:0, // Set starting Slide (0 index)
		directionNav:false, // Next & Prev navigation
		directionNavHide:true, // Only show on hover
		controlNav:true, // 1,2,3... navigation
		controlNavThumbs:false, // Use thumbnails for Control Nav
		controlNavThumbsFromRel:false, // Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', // Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
		keyboardNav:true, // Use left & right arrows
		pauseOnHover:true, // Stop animation while hovering
		manualAdvance:false, // Force manual transitions
		captionOpacity:0.8, // Universal caption opacity
		prevText: 'Prev', // Prev directionNav text
		nextText: 'Next', // Next directionNav text
		beforeChange: function(){}, // Triggers before a slide transition
		afterChange: function(){}, // Triggers after a slide transition
		slideshowEnd: function(){}, // Triggers after all slides have been shown
		lastSlide: function(){}, // Triggers when last slide is shown
		afterLoad: function(){} // Triggers when slider has loaded
	});
})

function flipButtons () {
	var $button1 = jQuery(".header p .request_btn");
	var $button2 = jQuery(".header p .get_started_btn");
	if ($button1.css("z-index") == 2) { //button 1 is on top
		
		$button1.fadeOut('slow', function () {
			
			$button1.css("z-index", "1");
			$button2.css("z-index", "2");
			$button1.css("display", "block");
		});
	
		
	} else { //button 2
		$button2.fadeOut('slow', function () {
			
				$button2.css("z-index", "1");
				$button1.css("z-index", "2");
				$button2.css("display", "block");
			
		});
	
	}
	
}
function revealArchives(e) {

	if (jQuery(e).siblings(".extra").css('display') == "none"){
		jQuery(e).siblings(".extra").fadeIn();
		jQuery(e).html("Less");
	} else {
		jQuery(e).siblings(".extra").fadeOut();
		jQuery(e).html("More");
	}
}

function revealArchives2009(e) {

	if (jQuery(e).siblings(".extra2009").css('display') == "none"){
		jQuery(e).siblings(".extra2009").fadeIn();
		jQuery(e).html("2009");
	} else {
		jQuery(e).siblings(".extra2009").fadeOut();
		jQuery(e).html("2009");
	}
}




jQuery(document).ready(function () {
	
	//Manually set the widths of the last two columns since they are different in each browser.
	var admissions = jQuery("#admissions");
		jQuery("td.col_center", admissions).css("min-width", parseInt(jQuery(admissions).width() - 20) + "px" );
		
	var stories = jQuery("#stories");
		jQuery("td.col_center", stories).css("min-width", parseInt(jQuery(stories).width() - 20) + "px" );
		
	stories = admissions = null;
	
	
	//add class selected to leftlinks
	var leftlinks = jQuery(".leftlinks li > a");
	var docurl = jQuery(location).attr('href').split("/");docurl = docurl[docurl.length-1];
	
	jQuery.each(leftlinks, function (smee) {
		if (docurl == leftlinks[smee].getAttribute("href")) {jQuery(leftlinks[smee]).addClass("selected"); return;};		
	});
	
	leftlinks = docurl = null;
	
	
	//Scroll the top buttons

	jQuery(".header p .request_btn").css("z-index", "2");
	
	window.setInterval(function() {
		
		flipButtons();
		
	}, 5000);


    jQuery(".listnew").mouseleave(function() {
       ddaccordion.collapseone('submenuheader', 0);

    }).blur(function() {
       ddaccordion.collapseone('submenuheader', 0);

    });


		/* This is basic - uses default settings */

		$(".video_link, .video_link_sm").fancybox({
			'autoDimemensions' : false,
			  'autoScale'     	: false,
			'padding' : 0,
			'margin' : 0
		});

		/*$("a#inline").fancybox({
			'hideOnContentClick': true
		});

		$("a.group").fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	600, 
			'speedOut'		:	200, 
			'overlayShow'	:	false
		});*/

});
