jQuery(document).ready(function(){
	//Add pdflink class to all links ending with a .pdf extension
	jQuery('a[href$=.pdf]').before('Download a PDF of ').addClass('pdflink');
	
	//Alternate tweet colors
	jQuery("#twitter-5 li:odd").css("background-color", "#FFFFFF");
  	jQuery("#twitter-5 li:even").css("background-color", "#F0F0F0");
	
	//Swap Image for the Bio Page
	jQuery(function() {
		jQuery('.rollover').hover(function() {
		var currentImg = jQuery(this).attr('src');
		jQuery(this).attr('src', jQuery(this).attr('hover'));
		jQuery(this).attr('hover', currentImg);
	}, function() {
		var currentImg = jQuery(this).attr('src');
		jQuery(this).attr('src', jQuery(this).attr('hover'));
		jQuery(this).attr('hover', currentImg);
		});
	});
	
	//Add line breaks to the Volunteer form
	var path = window.location.pathname;
	if(path == '/volunteer/'){ jQuery('.cf-group-after').append('<br />'); }
	
	//Coda Slider Settings
	var numRand = Math.floor(Math.random()*5);
	jQuery('#coda-slider-1').codaSlider({
		autoHeight: false,
		autoSlide: true,
		autoSlideInterval: 5500,
		autoSlideStopWhenClicked: true,
		firstPanelToLoad: numRand,
		dynamicArrows: true,
		dynamicTabs: true,
		dynamicArrowLeftText: "",
		dynamicArrowRightText: "",
		dynamicTabsPosition: 'bottom'
	});
	
	//select all the a tag with name equal to modal
		jQuery('a[name=modal]').click(function(e) {
		//Jump to the top of the page	
		scroll(0,0); 
			
		//Cancel the link behavior
		e.preventDefault();

		//Get the A tag
		var id = jQuery(this).attr('href');

		//Get the screen height and width
		var maskHeight = jQuery(document).height();
		var maskWidth = jQuery(window).width();

		//Set heigth and width to mask to fill up the whole screen
		jQuery('#mask').css({'width':maskWidth,'height':maskHeight});

		//transition effect		
		jQuery('#mask').fadeIn(1000);	
		jQuery('#mask').fadeTo("slow",0.8);	

		//Get the window height and width
		var winH = jQuery(window).height();
		var winW = jQuery(window).width();

		//Set the popup window to center
		jQuery(id).css('top',  winH/2-jQuery(id).height()/2);
		jQuery(id).css('left', winW/2-jQuery(id).width()/2);

		//transition effect
		jQuery(id).fadeIn(2000); 

	});

	//if close button is clicked
	jQuery('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();

		jQuery('#mask').hide();
		jQuery('.window').hide();
	});		

	//if mask is clicked
	jQuery('#mask').click(function () {
		jQuery(this).hide();
		jQuery('.window').hide();
	});
	
});