// Global Scripts
$(document).ready(function(){

	// Get the last LI in the Navigation List and assign a class of 'last'
	$('#navigation li:last, .module-right-main-menu li:last, .module-right-subbar li:last, .module-right-main p:last, .module-left p:last, .module-right-green p:last').addClass('last');

	// Show-Hide Script for all Arrows that upon click will reveal a Hidden Div and Point Downwards
	if ($('a.showhide').length > 0){
		// hide divs
		$('div.hidden').hide();
		// slide effect
		$('a.showhide').click(function(){
			$('div.hidden').slideToggle('fast');
				if($(this).hasClass('expanded')){
						$(this).removeClass('expanded');
					}
					else {
						$(this).addClass('expanded');
					}		
			return false;
		});
	}

	// Email Address Replacement
	$.getScript('/js/mailto.js',function(){ 
		$('.email').mailto();
	});					 

	// Cufon Font Replacement
	Cufon.replace('#pagetitle h1');
	
	// Press Dropdown
	if ($('#press-nav').length > 0){
		// Show first month initially, hide the rest
		var firstMonth = $('#press-nav option:selected').val();
		firstMonth = firstMonth.replace(/#/gi, "#press-");
		$('.press-items:not('+firstMonth+')').hide();
		// When someone selects a new month
		$('#press-nav').change(function(){
			var optionVal = $(this).val();
			$('.press-items').hide();
			optionVal = optionVal.replace(/#/gi, "#press-");
			$(optionVal).fadeIn();
		});
	}
	
	// Agenda Dropdown
	if ($('#agenda-nav').length > 0){
		var firstAgenda = $('.agenda-module:first').attr('id');
		firstAgenda = '#' + firstAgenda;
		if(window.console&&window.console.log) { console.log('firstAgenda: '+firstAgenda); }
		$(firstAgenda).addClass('selected');
		$('.agenda-module:not('+firstAgenda+')').hide();
		$('#agenda-nav li a').click(function(){
			$('#agenda-nav li a').removeClass('selected');
			$('.agenda-module').hide();
			$(this).addClass('selected');
			var href = $(this).attr('href');
			href = href.replace(/#/gi, "#month-");
			if(window.console&&window.console.log) { console.log('href: '+href); }
			$(href).fadeIn();
			return false;
		});
	}

	/* 
	// Dynamically clears out any text in the input fields
	if ($('.focus-blur').length > 0){
			$.getScript('jquery.valueFx.js',function(){ 
				$('.focus-blur').valueFx();
		});
	}
	*/

});
