/*----------------------------------------------------------------------------
	After DOM is Loaded
----------------------------------------------------------------------------*/

	$(document).ready(function() {

	var root = $('#header h1 a').attr('href');

	if ($.browser.msie) {

		if($.browser.version == 6.0) {
			$('#nav li, #content-wrap input[type=submit], #share-start, #jMonthCalendar .Event, ol.event-listing li').hover(
				function() {
					$(this).addClass('hover');
				},
				function() {
					$(this).removeClass('hover');
				}
			).focus(
				function() {
					$(this).addClass('hover');
				},
				function() {
					$(this).removeClass('hover');
				}
			);

			$('.field-size-medium + .information .description','form').css("marginTop", "-10em");
		}

		$('#aside-fader div.column-header').each(function() {
			if($(this).find('a').length == 1) {
				$(this).css("cursor","pointer");
			}
		});

		$('#ctas div.column-header, #aside-fader div.column-header').click(function() {
			window.location = $(this).find('a').attr('href');
		});

		$('#ctas div.column-header:last-child').css("margin", "0 0 8px 0");
		$('#footer > li:last-child').css("margin", "0");
		$('ul.summary-list li.node:last-child,form fieldset:last-child','#content').css("borderBottom","none");

		$('ul.inline-list li:last-child,ul.tiles li:last-child,ul.tiles .public:nth-child(5n),ul.tiles .private:nth-child(3n)','#content').css("marginRight", "0");
	}

	/*----------------------------------------------------------------------------
		Open external links in a new tab/window
	----------------------------------------------------------------------------*/

	$('a[rel=external], a.external', '#container').click(function() {
		window.open($(this).attr('href'));
		return false;
	});

	$('#nav > li > a').each(function() {
		$(this).text("/ " + $(this).text());
	});
	/*	The following makes Safari 4 go bonkers, hence above.
		$('#nav > li > a').prepend("/ ");
	*/
	$('#nav ul li:not(:last-child)').after("<li class='sep'>|</li>");

	/*----------------------------------------------------------------------------
		Home Fader
	----------------------------------------------------------------------------*/

		if($('div.image-fader','#content').length == 1) {
			$("div.image-fader").imageFader(5000, 0.2);
		}

		$('#aside-fader').imageFader(5000, 0.2);

	/*----------------------------------------------------------------------------
		Lightbox:
	----------------------------------------------------------------------------*/
		var lbconfig = {
			imageLoading: root + 'workspace/images/lightbox/lightbox-ico-loading.gif',
			imageBtnClose: root + 'workspace/images/lightbox/lightbox-btn-close.gif',
			imageBtnPrev: root + 'workspace/images/lightbox/lightbox-btn-prev.gif',
			imageBtnNext: root + 'workspace/images/lightbox/lightbox-btn-next.gif'
		};

		$('div.column a.lightbox, ul.tiles a.lightbox','#content').lightBox(lbconfig);

	/*----------------------------------------------------------------------------
		Cull Important Dates Listing
	----------------------------------------------------------------------------*/
		var aside		= $('#content-wrap div.aside'),
			contentW 	= $('#content'),
			eventsList	= $('.event-listing',aside),
			exempt		= $('.social-photo-cta a',aside).height(),
			offset		= (eventsList.offset().top - contentW.offset().top);	
			
		if((eventsList.height() + offset + exempt) > contentW.height()) {
			var newHeight = contentW.height() - offset - exempt;
			var roundingHeight = $('li:eq(1)',eventsList).height();

			/* Accounts for when contentW finishes before eventsList (y-axis) */
			if(newHeight > 0) {
				newHeight = (Math.floor(newHeight / roundingHeight)) * roundingHeight;
			} else {
				newHeight = roundingHeight
			}

			eventsList.height(newHeight);
		}	
	
	});