document.observe("dom:loaded", function() {
	$$("ul.thumbZoom li a").each(function(element, index){
		if (((index+1) % 5 == 0) && (index > 1)){
			element.addClassName("rightCorner");
		}
		Event.observe(element, "mouseover", function(){
			$(this.parentNode).addClassName("hover")
		});
		Event.observe(element, "mouseout", function(){
			$(this.parentNode).removeClassName("hover")
		});
	});
	
	$$("ul.thumbZoom li").each(function(element, index){
		if (index < 5){
			element.addClassName("topCorner");
		}
	});
	
	$$('a.viewStudents').each(function(link, index){
		Event.observe(link, "click", function(){
			Element.extend(this);
			var container = $$("div.stLeaders")[0];
			if (!container.hasClassName("stLeadersOpen")){
				container.addClassName("stLeadersOpen");
				this.hide();
			}
		});
	});
	
	$$('a.viewGroups').each(function(link, index){
		Event.observe(link, "click", function(){
			Element.extend(this);
			var container = $$("div.userGroups")[0];
			if (!container.hasClassName("userGroupsOpen")){
				container.addClassName("userGroupsOpen");
				this.hide();
			}
		});
	});
	
	$$('a.viewDonors').each(function(link, index){
		Event.observe(link, "click", function(){
			Element.extend(this);
			var container = $$("div.donorStudent")[0];
			if (!container.hasClassName("donorStudentOpen")){
				container.addClassName("donorStudentOpen");
				this.hide();
			}
		});
	});
	
	$$("ul.navbar li").each(function(el, index){
		Event.observe(el, "mouseover", function(){
    	    this.addClassName("hover");
		});
		Event.observe(el, "mouseout", function(){
			this.removeClassName("hover");
		});
  
    });
	$$("div.expansibleGroupOption h2").each(function(el, i){
		Event.observe(el, "click", function(){
			if (!$(this).up().hasClassName("openedGroupOption")){
				$(this).up().addClassName("openedGroupOption");
			} else {
				$(this).up().removeClassName("openedGroupOption");
			}
		});
	});
    //$$("ul.navbar li ul li:has(ul)").down("a:first").append(" &raquo; ");
	
	
	$$(".filter-group-title a").each(function(el, i){
		Event.observe(el, "click", function(){
			$(this).hide();
			var target = ($(this).hasClassName("unselect") ? "select" : "unselect");
			var select = $(this).up(".filter-group-title").select("a." + target);
			select[0].style.display = "inline-block";
		});
	});
	
	if ($$("#showAllGivingHistory").length > 0){
		Event.observe("showAllGivingHistory", "click", function(){
			$($(this).up("div").select("ul")[0]).addClassName("expanded");
			$(this).hide();
		});
	}	
	
	
});