$().ready(function() {
	//console.log($.browser);
	// deal with the scenario of IE 8 stuck in compatibility mode (even though we try to force 
	// standards mode.)  The fix is to go to the Page menu -> Compatibility View Settings and remove
	// marlboro.edu
	if($.browser.msie) {
		if(parseInt($.browser.version) >= '8' || navigator.userAgent.search(/Trident/i)) {
			$('.nav ol').mc_menu();	
		}
	}
	else {
		$('.nav ol').mc_menu();	
	}
	// Homepage slideshows
	$('.features').gallery({
		'class': 'features-gallery',
		'width': '19em',
		'height': '30em',
		'pauseHover': true,
		//'interval': 5000,
		'visibleSlides': 5,
		'title': 'Features',
		'next': '/graphics/assets/arrows/next.png',
		'prev': '/graphics/assets/arrows/prev.png'
	});
	$('.profiles').gallery({
		'class': 'profiles-gallery',
		'width': '33em',
		'height': '10em',
		'pauseHover': true,
		'autoRotate': false,
		'interval': 8000,
		'visibleSlides': 6,
		'title': 'Features',
		'next': '/graphics/assets/arrows/next.png',
		'prev': '/graphics/assets/arrows/prev.png',
		'speed': 800
	});
	
	$('.features-gallery').prepend($('.features-head'));
	$('.profiles-gallery').prepend($('.profiles-head'));
	
	// we hide nav/features/profiles in css if javascript is available to hide ugly load
	// $('.js .container').fadeIn();
	// If we don't have local navigation
	if(! $('.local').length) {
		$('.content').addClass('noLocal');
	}
	// SSO
	setTimeout(function(){
		$('.sso .message').fadeOut();
	}, 5000);
	
	// Colored Lists 
	$('.content li').not(function() {
		// ignore all with the ignore-color on the parent
		return $(this).parent().hasClass('ignore-color');
	}).wrapInner('<span />');
	
	// Alternate Tables 
	$(".tableWithColor tr:even, .striped tr:even").addClass("alternate");
	 
	// unobfuscate email Addresses
	$(".obfuscated").each(function () {
		var unobfuscated = this.href.replace(/.*\/contact\/mail\/(.+)\/(.+)\/?/i, 'mailto:'+'$1' + '@' + '$2');
		this.href = unobfuscated.replace(/\//i, '');
	});
	
	// Fix labels on login pages
	$('input[placeholder]').placeHeld();

	// add fancy zoom
	$('.zoom').imageZoom();
	
	// Thank you Error and Success messages 
	$('.thank-you.success').dialog({ 
		dialogClass:'success', 
		width: 500,
		buttons: {
			Ok: function() {
				$(this).dialog('close');
			}
		}
	});
	$('.thank-you.error').dialog({
		dialogClass:'error',
		width: 500,
		buttons: {
			Ok: function() {
				$(this).dialog('close');
			}
		}
	});
	
	// add calendar pickers
	$("input.date" ).datepicker({
			changeMonth: true,
			changeYear: true
	});
	
	// Info boxes for the campus maps
	$('body').append('<div class="map-info"></div>');
	$('.map-info').css('position', 'absolute').hide();
	$('area').hover(function(e) {
		var text = $(this).attr('alt');
		if(text != '') {
			var top = Math.round((e.pageX + 10)/10) * 10;
			var left = Math.round((e.pageY + 10)/10) * 10;
			$('.map-info').text(text).css('top', left).css('left', top).show();
		}
	},
	function(e) {
		$('.map-info').fadeOut();
	});
	
	// notification of cookie expiration
	
});

