$(document).ready(pageInit);
function pageInit() {
	mainNav();
	$("#footer #sitemap > ul > li:last-child").addClass('last');
}

function mainNav() {
	//find the main nav
	mainNav = "#navigation #main";
	$("ul li:last-child", mainNav).addClass("last");
	//for the last 3 nav items - add a class
	l = $(mainNav + " ul:first-child > li").length;
	$(mainNav + " ul > li").hover(function() { $(this).addClass("hover") }, function() { $(this).removeClass("hover"); });
	l = Math.ceil(l / 2);
	$(mainNav + " ul:first-child > li:gt(" + l + ") > ul").addClass("subNavRightHalf");
}

var mediaGallery = {
	/*
	#mediaPlayer
	#largeFormat
	#mpImage
	#mpVideo
	#mpMap
	#thumbsGallery
	.thumb
	.window
	.mpImage|.mpVideo|.mpMap
	rel="source"
	*/

	type: { image: 'mpImage', video: 'mpVideo', map: 'mpMap' },

	init: function() {
		// check to see this page has a media gallery:
		if ($('#mediaPlayer').is('#mediaPlayer')) {
			//see what the first item in the list is...
			list = $('#thumbsGallery .thumb .window img');
			if (list.length > 0) {
				largeIdName = list[0].className;
				el = document.getElementById(largeIdName);
				//set it active
				$(el).show();
				this.addClickHandlers();
			}
		}
	},

	addClickHandlers: function() {
		els = $('#thumbsGallery .thumb .window img');
		for (var i = 0; i < els.length; i++) {
			link = els[i].parentNode;
			$(link).wrap("<div class=\"mediaGalleryThumb\"></div>");
			switch (els[i].className) {
				case this.type.image:
					$(link).click(function() { mediaGallery.clickedImage(this) });
					$(link).after("<div class=\"mgImageIcon\"></div>");
					break;
				case this.type.video:
					$(link).click(function() { mediaGallery.clickedVideo(this) });
					$(link).after("<div class=\"mgVideoIcon\"></div>");
					break;
				case this.type.map:
					$(link).click(function() { mediaGallery.clickedMap(this) });
					$(link).after("<div class=\"mgMapIcon\"></div>");
					break;
				default:
					break;
			}

		}
	},

	clickedImage: function(t) {
		newSrc = t.rel;
	},

	clickedVideo: function(t) {
		newSrc = t.rel;
	},

	clickedMap: function(t) {
		newCoords = t.rel;
	}
}