// For IE hover flicker bug
	try {
	  document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}

// L2 Headers
	function rand (n){ return (Math.floor ( Math.random() * n + 1) ); } // Set the stage for the random number
	var randNum = (rand(5)); // Limit random number to 5 and add it to section class prefix
	
	if(randNum == "1") {
		var currentSec = ("mmop_secFaculty")
		var currentSecContent = ("<a href=\"x834.xml?tab=1\"><strong>Many Minds. One Purpose.<br /></strong><span>Challenging &amp; Accessible Faculty</span></a>");
		var currentImgClass = ("mmop_faculty");
	};
	if(randNum == "2") {
		var currentSec = ("mmop_secAttention")
		var currentSecContent = ("<a href=\"x834.xml?tab=2\"><strong>Many Minds. One Purpose.<br /></strong><span>Personal Attention</span></a>");
	};
	if(randNum == "3") {
		var currentSec = ("mmop_secSuccess")
		var currentSecContent = ("<a href=\"x834.xml?tab=3\"><strong>Many Minds. One Purpose.<br /></strong><span>Your Future Success</span></a>");
	};
	if(randNum == "4") {
		var currentSec = ("mmop_secLux")
		var currentSecContent = ("<a href=\"x834.xml?tab=4\"><strong>Many Minds. One Purpose.<br /></strong><span>Lux Et Spes</span></a>");
	};
	if(randNum == "5") {
		var currentSec = ("mmop_secCampus")
		var currentSecContent = ("<a href=\"x834.xml?tab=5\"><strong>Many Minds. One Purpose.<br /></strong><span>Beautiful Campus</span></a>");
	};

// Hello jQuery!
$(document).ready(function(){

// L2 Headers part2
	$("#many_minds").addClass(currentSec).append(currentSecContent);
	$(".topimages").addClass(currentSec);

// homepage Featured Community on/off
	$(".layertoggle").mouseover(function() {
		$(this).addClass("over")
		$("#community dd p").addClass("over")
	});
	$(".layertoggle").mouseout(function() {
		$(this).removeClass("over")
		$("#community dd p").removeClass("over")
	});
	$(".layertoggle").click(function() {
		$("div#community_over").toggle()
		$("#giving p").toggleClass("hide")
	});

	$("body.home #community dt a").mouseover(function() {
		$(this).parent().parent().addClass("over");
	})
	$("body.home #community dd a").mouseover(function() {
		$(this).parent().parent().parent().addClass("over")
	});
	$("body.home #community dl").mouseout(function(){
		$(this).removeClass("over")
	})
	

// News & Events element group hovers
	$("#news_events ul a").mouseover(function() {
		$(this).parent(this).parent("#news_events ul").addClass("over");
	});
	$("#news_events ul a").mouseout(function() {
		$(this).parent(this).parent("#news_events ul").removeClass("over");
	});


	$("#news_events dl a").mouseover(function() {
		$(this).parent(this).parent("#news_events dl").addClass("over");
	});
	$("#news_events dl a").mouseout(function() {
		$(this).parent(this).parent("#news_events dl").removeClass("over");
	});

	$("#inline_news dl a").mouseover(function() {
		$(this).parent(this).parent("#inline_news dl").addClass("over");
	});
	$("#inline_news dl a").mouseout(function() {
		$(this).parent(this).parent("#inline_news dl").removeClass("over");
	});

// News & Events Hovers
	$("#news_events li[a]").mouseover(function() {
		$(this).addClass("over");
	});
	$("#news_events li[a]").mouseout(function() {
		$(this).removeClass("over");
	});

// See Also Document Link Icons
//    $(".see_also a[@href$='.pdf']").append("<span class=\"file type_pdf\">&nbsp;</span>");
//    $(".see_also a[@href$='.doc']").append("<span class=\"file type_doc\">&nbsp;</span>");

// Add arrows to the See Also links - this code must be below
// Link Icon javascript so the arrows display after the icons
	$(".see_also a").append("<span>&nbsp;&gt;</span>");

// Contact link arrow
	$(".contact_us a").append("<span>&nbsp;&gt;</span>");

// 2Col link arrows
	$(".cols_2 .col ul li a").append("<span>&nbsp;&gt;</span>");

// Upcoming Events
	$(".upcoming li a").append("<span>&nbsp;&gt;</span>");
	$(".upcoming dd:last").addClass("last");

// Module Hovers
	$(".box dd").mouseover(function() {
		$(this).parent().addClass("over");
	});
	$(".box dd").mouseout(function() {
		$(this).parent().removeClass("over");
	});

	$(".timely h2 a").mouseover(function() {
		$(this).parent(this).parent(".timely").addClass("over");
	});
	$(".timely h2 a").mouseout(function() {
		$(this).parent(this).parent(".timely").removeClass("over");
	});

	$(".timely p a").mouseover(function() {
		$(this).parent(this).parent(".timely").addClass("over");
	});
	$(".timely p a").mouseout(function() {
		$(this).parent(this).parent(".timely").removeClass("over")
	});

// Share show/hide
	$("li.option_share .share").click(function() {
		$("li.option_share").toggleClass("active");
		$("li.option_share a").toggleClass("active");
		$("li.option_share ul").toggle();
		return false;
	});

// Campus Life landing nav
	$("#landing_campus-life .button").mouseover(function() {
		$(this).next(".blurb").addClass("shown")
	});
	$("#landing_campus-life .button").mouseout(function() {
		$(this).next(".blurb").removeClass("shown")
	});

//Communities document icon hover
// News & Events element group hovers
	$(".media dt a").mouseover(function() {
		$(this).parent(this).parent("dl.media").addClass("media_over");
	});
	$(".media dt a").mouseout(function() {
		$(this).parent(this).parent("dl.media").removeClass("media_over");
	});

// Wide page margin fix
	$(".page_wide #content .col:eq(2)").addClass("col_last");

// zebra tables
$(function() {
	$("table").each(function(){
		$("tr:nth-child(odd)").addClass("odd");
	});
});

// 2-col margin fix
	$(".cols_2 .col:eq(1)").addClass("last");

// Accordion plugin
jQuery.fn.accordion = function(options) {
	// options
	var SLIDE_DOWN_SPEED = 500;
	var SLIDE_UP_SPEED = 250;
	var startClosed = options && options.start && options.start == 'closed';
	var on = options && options.on && (typeof options.on == 'number' && options.on > 0) ? options.on - 1 : 0;
	return this.each(function() {
		jQuery(this).find('dd').hide();
		jQuery(this).find('dt').click(function() {
			var current = jQuery(this.parentNode).find('dd:visible');
			var next = jQuery(this).find('+dd');
			if (current[0] != next[0]) {
				current.slideUp(SLIDE_UP_SPEED);
				$("#mmop_content dt").removeClass("active");
				$(this).addClass("active");
			}
			if (next.is(':visible')) {
				$("#mmop_content dt").removeClass("active");
				next.slideUp(SLIDE_UP_SPEED);
			} else {
				$("#mmop_content dt").removeClass("active");
				$(this).addClass("active");
				next.slideDown(SLIDE_DOWN_SPEED);
			}
		});
		if (!startClosed) {
			var active = jQuery(this).find('dd:eq(' + on + ')');
			active.slideDown(SLIDE_DOWN_SPEED);
			active.prev("dt").addClass("active");
		}
	});
};

// Accordion Hovers
	$("#mmop_content dt").mouseover(function() {
		$(this).addClass("over")
	});
	$("#mmop_content dt").mouseout(function() {
		$(this).removeClass("over")
	});

// Initiate MMOP Accordion defaults
	//$('#mmop_content').accordion();
	//$('#faq').accordion({on: 3});

// Library Dropdown
	$(".databaseList").hover(
		function() {$(this).addClass("sfhover")},
		function() {$(this).removeClass("sfhover")}
	);

	$(".libNewsEvents h3").hover(
		function() {$(this).addClass("over")},
		function() {$(this).removeClass("over")}
	);

	$(".libNewsEvents h3.neAnnouncements").click( function() {
		$(this).addClass("active")
		$("h3.neEvents").removeClass("active")
		$("ul.neAnnouncements").removeClass("hidden")
		$("ul.neEvents").addClass("hidden")	
	});

	$(".libNewsEvents h3.neEvents").click( function() {
		$(this).addClass("active")
		$("h3.neAnnouncements").removeClass("active")
		$("ul.neEvents").removeClass("hidden")
		$("ul.neAnnouncements").addClass("hidden")	
	});


//	Communities dropdown nav
	$("#nav_communities_drop").hover(
		function() {$(this).addClass("over")},
		function() {$(this).removeClass("over")}
	)


}); // Bye-bye jQuery!

//Used to place flash objects into a page, necessary to allow users of IE6 to properly view the flash file.
function writeFlash(flashSrc, flashWidth, flashHeight){
	document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" height="' + flashHeight + '" width="' + flashWidth + '" align="top" wmode="transparent"><param name="movie" value="' + flashSrc + '"><param name="wmode" value="transparent"><param name="quality" value="best"><param name="play" value="true"><embed align="top" height="' + flashHeight + '" pluginspage="http://www.macromedia.com/go/getflashplayer" src="' + flashSrc + '" type="application/x-shockwave-flash" width="' + flashWidth + '" quality="best" play="true" wmode="transparent"><\/embed><\/object>' );
}

//Used for PageOption Web 2.0
function pageOptionPopUp(site) {
    var url = self.location.href;
    var facebook = 'http://www.facebook.com/sharer.php?u=';
    var delicious = 'http://del.icio.us/post?v=4&partner=nyt&noui&jump=close&url=';
    var sharelink = 'x18235.xml?link=';
    if(site=='facebook') {
       var win = window.open(facebook + url, site, 'toolbar=0,status=0,height=436,width=646,scrollbars=yes,resizable=yes');
    }
    else if(site=='delicious')
    {
       var win = window.open(delicious + url, site, 'toolbar=0,status=0,height=436,width=646,scrollbars=yes,resizable=yes');
    }
    else if(site == 'sharelink')
    {
         var win = window.open(sharelink + url, site, 'toolbar=0,status=0,height=436,width=646,scrollbars=yes,resizable=yes');
    }
}
//Used for A - Z Listing
var ids=new Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','s','u','v','w','x','y','z');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

