var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";


// PRELOAD IMAGES
var preImages = new Array(
templateDirectory + "/images/subnav-rollbg.gif",
templateDirectory + "/images/sub-secNav-roll.png",
templateDirectory + "/images/gallery-controls.png",
templateDirectory + "/images/welcome.png"
);
var loader = new Asset.images(preImages);


// REPLACE FONTS
Cufon.replace('div#footer-nav a', { hover: true });
Cufon.replace('div#sub-right h2', { hover: true });
if (isIE6==false) {	
Cufon.replace('div#event-text h2');
}
// ADD HOMEPAGE STYLE

window.addEvent('domready', function(){
	if ($chk($('home-content'))) {
		$('home-content').getElement('p').set('id', 'welcome-graf');
	}
});


// FIX THE NAV SEARCHBOX

/* UNCOMMENT THIS WHEN QUICK SEARCH IS FIXED

window.addEvent('domready', function(){
	if ($chk($('head-nav-container'))) {
		$('s').setStyle('width', 137);
	}	
});
*/

window.addEvent('domready', function(){
	if ($chk($('head-nav-container'))) {
		$('searchsubmit').set('value', 'GO');
	}	
});


/* THE CALENDARS ON THE INDIVIDUAL PAGES */

/*

window.addEvent('domready', function(){

	if ($chk($('sub-calendar-wrapper'))) {
				
		$('sub-calendar-wrapper').getElements('link').destroy();
		$('sub-calendar-wrapper').getElements('script').destroy();
		$('sub-calendar-wrapper').getElements('style').destroy();
		
		if ($('sub-calendar-wrapper').getPrevious().get('tag')=='p' &&
		$('sub-calendar-wrapper').getPrevious().innerHTML.indexOf("popupEvent")) {
			//alert('delete it')
			$('sub-calendar-wrapper').getPrevious().destroy();
		}
		
		if ($chk($('overDiv'))) {
			$('overDiv').destroy();
		}
		
		if ($chk($('section-previews'))) {
			$('sub-calendar-wrapper').inject($('section-previews'), 'after');
		
		} else if
		
		(($('sub-calendar-wrapper').getParent().getElements('.galleryContainer').length > 0) && $chk($('section-previews')))
		
		{
			$('sub-calendar-wrapper').inject($('sub-calendar-wrapper').getParent().getElements('.galleryContainer')[0], 'after');

		} else if 
		
		($('sub-calendar-wrapper').getParent().getElements('.galleryContainer').length > 0) {
		$('sub-calendar-wrapper').inject($('sub-calendar-wrapper').getParent().getElements('.galleryContainer')[0], 'after');
		}				
	}
 });

*/


// FORMAT THE IMAGE GALLERIES
window.addEvent('domready', function(){

	if ($chk($('sub-right'))) {
		var theGalleryHolders = $$('.gallery');
		theGalleryHolders.each(function(el){
			
			var theLinkElements = el.getElements('a');
			var theContainerLength = 0;
			var i;
			for (i=0;i<theLinkElements.length;i++) {
			theContainerLength+=theLinkElements[i].offsetWidth;
			}
			theContainerLength+=25;
			
			var imgContainer = new Element('div', {
    		'id': el.id+'-slideContent',
    		'styles': {
        	'width': theContainerLength,
        	'height': 107
    		}
			});
			
			var galleryMask = new Element('div', {
    		'id': el.id+'-slideMask',
    		'class' : 'galleryMask',
    		'styles': {
        	'width': 525,
        	'height': 115,
        	'overflow' : 'hidden'
    		}
			});
			
			var galleryMaskContainer = new Element('div', {
    		'id': el.id+'-slideContainer',
    		'class' : 'galleryContainer',
    		'styles': {
        	'width': 520,
        	'height': 115,
        	'overflow' : 'hidden'
    		}
			});
			
			var theHeader = new Element('h3', {
    		'id': el.id+'-slideHeader',
    		'text' : 'Photo Gallery'
			});
			
			if ($chk($('section-previews'))) {
			$('section-previews').addClass('alt');
			galleryMaskContainer.inject($('section-previews'), 'after');
			} else if ($chk($('sub-calendar-wrapper'))) {
			galleryMaskContainer.inject($('sub-calendar-wrapper'), 'before');
			} else {
			galleryMaskContainer.inject(el.getParent().getParent(), 'after');
			//galleryMaskContainer.inject(el.getParent().getParent(), 'bottom');
			//alert(el.getParent().getParent().id);
			}
			
			
			//galleryMaskContainer.inject(el.getParent().getParent().getParent(), 'bottom');
			//galleryMaskContainer.inject(el, 'after');
			//galleryMaskContainer.inject($('content'), 'bottom');
			galleryMask.inject(galleryMaskContainer);
			imgContainer.inject(galleryMask);
			theLinkElements.inject(imgContainer);
			theHeader.inject(galleryMaskContainer, 'before');
			
			if (!($chk($('section-previews'))) && $chk($('sub-calendar-wrapper'))) {
			var anHR = new Element('hr');
			anHR.inject(theHeader, 'before');
			}
			
			
			el.destroy();
		
			// set up scrollers if necessary
			
			if (theContainerLength-20 > galleryMask.offsetWidth) {
			
			galleryScroll = new Fx.Scroll(el.id+'-slideMask', {
			wait: false,
			duration: 700,
			transition: Fx.Transitions.Circ.easeOut
			});
			
			
			var leftControl = new Element('div', {
    		'id': el.id+'-leftArrow',
    		'class' : 'galleryLeftArrow galleryArrow'
			});
			
			var rightControl = new Element('div', {
    		'id': el.id+'-rightArrow',
    		'class' : 'galleryRightArrow galleryArrow'
			});
			
			leftControl.inject(galleryMaskContainer);
			rightControl.inject(galleryMaskContainer);
			
			galleryMaskContainer.addEvent('mouseover', function(){
			
				if (galleryMask.getScroll().x != 0) {
				galleryMaskContainer.getElement('.galleryLeftArrow').setStyle('display', 'block');
				}
				
				if (galleryMask.getScroll().x != galleryMask.getScrollSize().x-525) {
				galleryMaskContainer.getElement('.galleryRightArrow').setStyle('display', 'block');
				}
			});
			
			galleryMaskContainer.addEvent('mouseleave', function(){
				galleryMaskContainer.getElements('.galleryArrow').setStyle('display', 'none');
			});
			
			
			/*galleryMaskContainer.getElements('.galleryArrow').each(function(el){
				
				var theX = el.getStyle('backgroundPosition').split(" ");
				theX = theX[0];
				
				el.addEvent('mouseover', function(){
				this.setStyle('backgroundPosition', theX + ' -20px');
				});
				
				el.addEvent('mouseleave', function(){
				this.setStyle('backgroundPosition', theX + ' 0');
				});
			
			});*/
			
			galleryMaskContainer.getElement('.galleryLeftArrow').addEvent('mouseover', function(){
			this.addClass('galleryLeftArrowOver');
			});
			
			galleryMaskContainer.getElement('.galleryLeftArrow').addEvent('mouseleave', function(){
			this.removeClass('galleryLeftArrowOver');
			});
			
			galleryMaskContainer.getElement('.galleryRightArrow').addEvent('mouseover', function(){
			this.addClass('galleryRightArrowOver');
			});
			
			galleryMaskContainer.getElement('.galleryRightArrow').addEvent('mouseleave', function(){
			this.removeClass('galleryRightArrowOver');
			});
			
			
			galleryMaskContainer.getElement('.galleryRightArrow').addEvent('click', function(){
			galleryScroll.start(galleryMask.getScroll().x+525, 0);
			setTimeout(function(){ 
				if (galleryMask.getScroll().x == galleryMask.getScrollSize().x-525) {
					galleryMaskContainer.getElement('.galleryRightArrow').setStyle('display', 'none');
				} else {
					galleryMaskContainer.getElement('.galleryRightArrow').setStyle('display', 'block');
				}
				if (galleryMask.getScroll().x != 0) {
					galleryMaskContainer.getElement('.galleryLeftArrow').setStyle('display', 'block');
				} else {
					galleryMaskContainer.getElement('.galleryLeftArrow').setStyle('display', 'none');
				}
			}, 800);	
			});
			
			galleryMaskContainer.getElement('.galleryLeftArrow').addEvent('click', function(){
			galleryScroll.start(galleryMask.getScroll().x-525, 0);
			setTimeout(function(){
				if (galleryMask.getScroll().x != 0) {
					galleryMaskContainer.getElement('.galleryLeftArrow').setStyle('display', 'block');
				} else {
					galleryMaskContainer.getElement('.galleryLeftArrow').setStyle('display', 'none');
				}
				if (galleryMask.getScroll().x == galleryMask.getScrollSize().x-525) {
					galleryMaskContainer.getElement('.galleryRightArrow').setStyle('display', 'none');
				} else {
					galleryMaskContainer.getElement('.galleryRightArrow').setStyle('display', 'block');
				}
			}, 800);	
			});
			
			}
			
		});	
	}
	
});


// POPOUT NAV

window.addEvent('domready', function(){
	
	if ($chk($('main-nav'))) {

	$$('.main-nav-item').addEvent('mouseover', function(){
		this.getElement('ul').setStyle('display', 'block');
		this.getElement('.main-nav-link').setStyle('backgroundPosition', '0 -36px');
	});
	
	$$('.main-nav-item').addEvent('mouseleave', function(){
		this.getElement('ul').setStyle('display', 'none');
		this.getElement('.main-nav-link').setStyle('backgroundPosition', '0 0');
	});
	
	}

});


// SUBNAV ROLLOVERS

window.addEvent('domready', function(){
	
	if ($chk($('main-nav'))) {

	$$('.main-nav-sub').each(function(el){
	var theEls = el.getElements('li');
		theEls.addEvent('mouseover', function(){
			this.addClass('over');
		});
		theEls.addEvent('mouseleave', function(){
			this.removeClass('over');
		});
	});
	
	}

});


// DO STUFF TO THE FRONT PAGE CALENDAR

window.addEvent('domready', function(){

	// determine which column is longer and make them both that length

if ($chk($('home-calendars'))) {

var theCols = $$('.homeCal-body');
var colLength = 0;

	if (theCols.length > 0) {
		
		theCols.each(function(el){
		
		// fix the weird IE6 repeating text issue
			
			/*if (isIE6) {
		
			
			var lastDiv = el.getElement('.calendar-list-item:last-child');
			var repeatDiv = lastDiv.clone();
			repeatDiv.inject(lastDiv, 'after');
			repeatDiv.setStyles({
			'height' : 0,
			'overflow' : 'hidden',
			'opacity' : 0
			});
			} */ 
					
			if (el.offsetHeight > colLength) {
				colLength = el.offsetHeight;
			}
			
		});
		
	if (isIE6==false) {	
	theCols.setStyle('height', colLength);	
	}		
		
		
		// fix more weird IE6 repeating text issue
		
		/*if (isIE6) {
			$$('.linkwrap').each(function(el){
				el.getElement('a:last-child').setStyle('display', 'none');
			});
		}*/
	
	// alternate bg colors in homepage calendar rows
	
	if ($$('.calendar-list-item').length > 0) {
	$('homeCal-left').getElements('.calendar-list-item:even').addClass('alt');
	$('homeCal-right').getElements('.calendar-list-item:odd').addClass('alt');
	}
	
	// set the background of columns to whatever color the last calendar item is	
	theCols.each(function(el){
		if ($$('.calendar-list-item').length > 0) {
		var thisBg = el.getElement('.calendar-list-item:last-child').getStyle('backgroundColor');
		el.setStyle('backgroundColor', thisBg);
		el.getElement('.calendar-list-item:last-child').setStyle('borderBottom', 'none');
		}
	});
	
	
	}
	}

});


// DO STUFF TO THE TABBED FRONT PAGE CALENDAR

window.addEvent('domready', function(){
if ($chk($('home-calendars2'))) {
	if ($$('.calendar-list-item').length > 0) {
	$('homeCal-left').getElements('.calendar-list-item:even').addClass('alt');
	$('homeCal-right').getElements('.calendar-list-item:odd').addClass('alt');
	}
}	
});


// SUB PAGE NAV ROLLOVERS

window.addEvent('domready', function(){

	if ($chk($('secondary-nav'))) {
		if ($('secondary-nav').hasClass('sub-SecNav')) {
			
			var theSpans = $('secondary-nav').getElements('span');
			theSpans.addEvent('mouseover', function(){
				this.addClass('over');
			});
			theSpans.addEvent('mouseleave', function(){
				this.removeClass('over');
			});
			
		}
	}

});

// SUB PAGE CALENDAR ROW COLORING

window.addEvent('domready', function(){

	if ($chk($('sub-calendar'))) {
		$('sub-calendar').getElements('.calendar-list-item:even').setStyle('background', '#e3e8ef');
	}	

});

// CLEAR SEARCH BOX

window.addEvent('domready', function(){

	if ($chk($('s'))) {
		$('s').value = "Search...";
		$('s').addEvent('focus', function(){
			if($('s').value == 'Search...') {
			$('s').value="";
			}
		});
		$('s').addEvent('blur', function(){
			if($('s').value == '') {
			$('s').value="Search...";
			}
		});
	}

});

// ADD ROLLOVER TO SEARCH RESULTS

window.addEvent('domready', function(){
	if ($$('.search-result').length > 0) {
		$$('.search-result').addEvent('mouseover', function(){
			this.addClass('search-result-alt');
		});
		$$('.search-result').addEvent('mouseleave', function(){
			this.removeClass('search-result-alt');
		});
	}
});


// E-COMMERCE FORMS

window.addEvent('domready', function(){

	if ($$('.tribute-form').length > 0) {
	
	if ($chk($('in_honor_of_container')) && $chk($('in_memory_of_container')))
		
		if ($('tribute_name').value == "") {
		$('in_honor_of_container').setStyle('display', 'none');
		}
		
		if ($('memory').value == "") {
		$('in_memory_of_container').setStyle('display', 'none');
		}
		
		$('in_honor_of_toggle').addEvent('click', function(e){
			e.stop();
			$('in_honor_of_container').setStyle('display', 'block');
			$('in_memory_of_container').setStyle('display', 'none');
			$('memory').value = "";
		});
		
		$('in_memory_of_toggle').addEvent('click', function(e){
			e.stop();
			$('in_memory_of_container').setStyle('display', 'block');
			/*if (Browser.Engine.trident){
			$('in_memory_of_container').setStyles({
			'paddingTop' : 20,
			'paddingBottom' : 20
			});
			}*/
			$('in_honor_of_container').setStyle('display', 'none');
			$('tribute_name').value = "";
			$('other').value = "";
			$$('.honor-request-options').each(function(el){
			el.checked = false;
			});
			
		});
	}

});


// move Donations sublinks on Giving Opps page to the top instead of bottom

window.addEvent('domready', function(){

	if ($chk($('section-previews')) && $('section-previews').hasClass('donations')) {
	
	$('section-previews').inject($$('.post')[0].getElement('h2'), 'after');
	$$('.post')[0].getElement('h2').setStyles({
	'marginBottom' : 0,
	'overflow' : 'hidden'
	});
	
	}

});


// add the smooth scrolls
window.addEvent('domready', function() {

if ($chk($('sub-right'))){

	var allLinks = $('sub-right').getElements('a');
	allLinks.each(function(el){
		if (el.name != "" && el.href == "") {
			el.id = el.name;
		}
	});
	
	//alert(allLinks.length);

	var theAnchorLinks = $$('.smoothscroll');
	if (theAnchorLinks.length > 0) {
	
	var mySmoothScroll = new SmoothScroll({
    	links: '.smoothscroll',
    	wheelStops: false
	});
	}
}	
	});

/* Trying to get dollar range to autoselect radio buttons. can't figure it out in time for launch...

window.addEvent('domready', function(){
	initSearch();
});


function initSearch() {

if ($$('.annual-giving-form').length > 0) {
	$('donation').addEvent('keyup', function(el){
		$('donation').removeEvents();
		setTimeout(function(){
		 var theAmount = $('donation').value.replace(/\,/g,'');
		 if (!(isNaN(theAmount))) {
		 
		 theRadios = $$('.contribution');
		 if (theRadios.length > 0) {
		 	theRadios.each(function(el){
		 	//alert(theAmount + ' ' + el.title);	
		 	
		 	var theRange = el.title.split('-');
		 	var theLow = theRange[0];
		 	var theHigh = theRange[1];
		 	
		 	if (theAmount > theLow && theAmount < theHigh) {
		 	alert(theAmount + ' ' + theLow + ' ' + theHigh);
		 	}
		 	
		 			 	
		 	});
		 }
		 
		 }
		 initSearch();
		}, 1000);
		//alert(el.value);
	});
	}

}
*/

// HOME PAGE SLIDESHOW


// slideshow function

function slideShow( Obj, theDuration ){
	// Version 0.2; Created by Kow, 2008; http://skyweb.hu/kow
	var pass = this;
	// initializing
	this.curImg = 0;
	this.slides = Obj;
	this.slides.each( function( img, index ){ 
		if( index > 0 ) img.fade(); 
		img.set('morph', { duration: theDuration });
	}, this);
	this.next = function(){
		pass.curImg++;
		this.slides.each( function( img, index ){ 
			img.morph({ opacity: 0 });
		}, this);
		if( pass.curImg == this.slides.length ) pass.curImg = 0;
		this.slides[ pass.curImg ].morph({ opacity: 1 });
	}
	this.prev = function(){
		pass.curImg--;
		this.slides.each( function( img, index ){ 
			img.morph({ opacity: 0 });
		}, this);
		if( pass.curImg < 0 ) pass.curImg = this.slides.length - 1;
		this.slides[ pass.curImg ].morph({ opacity: 1 });
	}
}

// set the first image to the top
window.addEvent('domready', function(){
if ($chk($('home-slideshow'))) {
$('home-slideshow').getElements('img').setStyles({
'display' : 'block',
'opacity' : 0
});
$('home-slideshow').getElement('img').setStyles({
'z-index' : 81,
'opacity' : 1

});
}
});


window.addEvent('load', function() {

if ($chk($('home-slideshow'))) {
if ($$('div#home-slideshow img').length > 1) {

$('home-slideshow').getElements('img').setStyles({
'display' : 'block',
'opacity' : 1
});

sshow = new slideShow( $$('div#home-slideshow img'), 3000 );  
sshow.next.periodical( 6000, sshow ); 
}
}

});


/* Take the bottom border and padding off of the last ".post" on all pages  */

window.addEvent('domready', function(){
	if ($$('.post').length > 0) {
		if (($$('.navigation').length == 0) && (!($chk($('section-previews'))))) {
		$$('.post')[$$('.post').length-1].setStyles({
		'borderBottom' : 0,
		'paddingBottom' : 0,
		'marginBottom' : 0,
		'borderColor' : '#ffffff'
		});
		}
	}
});



// lengthen left and right columns in IE6

window.addEvent('domready', function(){

	if (isIE6 && $('main-content-container').hasClass('sub-page')) {
		if (($('sub-left').offsetHeight + 637) < $('sub-right').offsetHeight) {
		$('sub-left').setStyle('height', $('sub-right').offsetHeight -637);
		} else {
		$('sub-left').setStyle('height', 675);
		}
	}

});

/* The Calender Reformmating */

// first figure out if this is the calendar page, and if it's calendar view or the list view


window.addEvent('domready', function(){

	if ($chk($('thecalendar'))) { // this is the calendar
	
	
	// move overDiv so that body is parent
	
	if ($chk($('overDiv'))) {
		$('overDiv').inject($(document.body), 'top');
	}
	
	if (isIE6) {
		if ($chk($('post-12'))) {
			$('sub-right').addClass('cal');
		}
	}

	//if (isIE6==false) {
	
		if (Browser.Engine.trident) {
			$('thecalendar').getElements('form').setStyles({
				'display': 'block',
				'opacity': 0
			});
			$('thecalendar').getElements('table').setStyles({
				'display': 'block',
				'opacity': 0
			});
		$('post-12').setStyle('border', 0);
		}
		else {
			$('thecalendar').setStyles({
				'display': 'block',
				'opacity': 0
			});
		}
		
		if (OSName=="Windows") {
			if (isIE6 == false) {
				$('thecalendar').getElement('table').setStyles({
					'marginLeft': -4
				});
			}
		}
		
		if ($chk($('viewButton'))) {
		
			var months = new Array(13);
			months[1] = "January";
			months[2] = "February";
			months[3] = "March";
			months[4] = "April";
			months[5] = "May";
			months[6] = "June";
			months[7] = "July";
			months[8] = "August";
			months[9] = "September";
			months[10] = "October";
			months[11] = "November";
			months[12] = "December";
			var time = new Date();
			var lmonth = months[time.getMonth() + 1];
			var date = time.getDate();
			var year = time.getYear();
			if (year < 2000) 
				year = year + 1900;
			var todayDate = lmonth + ' ' + year;
			
			/*if ($('viewButton input[type=submit]').value == "List View") { // this is the calendar view
		 alert('calendar');
		 }*/
			if ($('viewButton').getElements('input')[$('viewButton').getElements('input').length - 1].value == "List View") { // this is the calendar view
				$('thecalendar').addClass('calView');
				
				// create the header
				
				var theSelectedMonth = $$('.monthYearTextTOC')[0].innerHTML;
				
				/*var theMo = $$('.monthYearTextTOC')[0].innerHTML.substring(0, 3);
				var theYear = $$('.monthYearTextTOC')[0].innerHTML.substring($$('.monthYearTextTOC')[0].innerHTML.length - 4, $$('.monthYearTextTOC')[0].innerHTML.length);*/
				
				var newMoHeader = new Element('h3', {
					'id': 'monthHeader',
					//'text': theMo + " " + theYear,
					'text' : theSelectedMonth,
					'styles': {
						'marginTop': -20,
						'marginLeft': 5,
						'textTransform': 'uppercase',
						'color': '#000000',
						'fontWeight': 'normal'
					}
				});
				newMoHeader.inject($('thecalendar'), 'top');
				
				var currentCalNav = $('viewButton').getNext('form');
				
				var newCalNav = new Element('form', {
					'id': 'calNav',
					'name': currentCalNav.name,
					'action': currentCalNav.action,
					'method': currentCalNav.method,
					'styles': {
						'display': 'inline',
						'float': 'left'
					}
				});
				newCalNav.inject(newMoHeader, 'after');
				
				currentCalNav.getElements('input').inject(newCalNav, 'top');
				currentCalNav.getElements('select').inject('dateChange', 'before');
				$('next').inject('dateChange', 'after');
				
				currentCalNav.method = "";
				currentCalNav.action = "";
				currentCalNav.name = "";
				
				$('FilterForm').inject(newCalNav, 'after');
				$('FilterForm').setStyles({
					'display': 'inline',
					'float': 'left'
				});
				$('FilterForm').getElement('input').value = "Go";
				$('FilterForm').getElement('input').setStyles({
					'marginLeft' : -5
				});
				
				
				if (theSelectedMonth == todayDate) {
					$('awioufhaioeu').destroy();
				}
				else {
				
					$('awioufhaioeu').inject(newCalNav, 'before');
					$('awioufhaioeu').setStyles({
						'float': 'left'
					});
					
				}
				
				
				// if this is filtered by category, display in header
				var filterOptions = $('showCat').getElements('option');
				
				if (filterOptions[$('showCat').selectedIndex].innerHTML != "Show All") {
					//alert('this is not the show all page');
					newMoHeader.innerHTML += " <span>" + filterOptions[$('showCat').selectedIndex].innerHTML + " Events</span>";
				}
				else {
					newMoHeader.innerHTML += " <span>All Events</span>";
				}
			 
			 // fix mac for buttons
			 
			  if (OSName == "MacOS") {
			  	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
			  	 $('FilterForm').addClass('mac-ff');
			  	} else if (Browser.Engine.presto) {
			  		$('FilterForm').addClass('mac-opera');
			  	} else { 
			  	 $('FilterForm').addClass('mac');
			  	}
			  }
			 
			 	if (OSName == "MacOS" && Browser.Engine.presto) {
				$('epcprev').value = " < ";
				$('next').value = " > ";
				} else {
				$('epcprev').value = "<";
				$('next').value = ">";
				}
				
				$$('table')[0].setStyles({
					'clear': 'both'
				});
				
				$('viewButton').setStyles({
					'display': 'inline',
					'float': 'left'
				});
				$('viewButton').inject($('FilterForm'), 'after');
				
				
				var anHR = new Element('hr');
				anHR.inject(newMoHeader, 'after');
				
				if (Browser.Engine.trident) {
					anHR.setStyles({
						'marginBottom': 10
					});
				}
				
				
				if (!(Browser.Engine.trident)) {
					var anotherHR = new Element('hr');
					anotherHR.inject($('viewButton'), 'after');
					anotherHR.setStyles({
						'marginTop': 55
					});
					
				}
				else {
				
					$$('.mainTableTOC')[0].setStyles({
						'marginTop': 20
					});
					
				}
				
				$('dateFilter').destroy();
				$$('.monthYearRowTOC')[0].destroy();
				
				
				
			}
			
			if ($('viewButton').getElements('input')[$('viewButton').getElements('input').length - 1].value == "Calendar View") { // this is the list view
			
			/* do all of this stuff in the list view */
			
			$('thecalendar').addClass('listView');
			
			if (Browser.Engine.trident) {
			$$('.calendar-list-item')[0].setStyle('marginTop', 30);
			}
			
			if ($chk($('dateFilter'))) {
			
			
			moOptions = $('dateFilter').getElement('select').getElements('option');
			theMonth = moOptions[$('dateFilter').getElement('select').selectedIndex].innerHTML;
			yrOptions =  $('dateFilter').getElement('select').getNext().getElements('option');
			theYear = yrOptions[$('dateFilter').getElement('select').getNext().selectedIndex].innerHTML;
			
			var theSelectedMonth = theMonth + " " + theYear;
			var theShortMo = theMonth.substring(0, 3);
						
			var newMoHeader = new Element('h3', {
				'id': 'monthHeader',
					//'text': theShortMo + " " + theYear,
					'text' : theMonth + " " + theYear,
					'styles': {
						'marginTop': -20,
						'marginLeft': 5,
						'textTransform': 'uppercase',
						'color': '#000000',
						'fontWeight': 'normal'
					}
				});
				newMoHeader.inject($('thecalendar'), 'top');
				
				$$('.entry')[0].getElements('link')[0].destroy();
				$$('.entry')[0].getElements('style').each(function(el){ el.destroy(); });
				
				if (Browser.Engine.trident) {
				var negMarginTop = -10;
				} else {
				var negMarginTop = -5;
				}
				var negMarginBottom = -3;
				
				var newNavContainer = new Element('div', {
					'id': 'list-view-nav',
					'styles' : {
						'marginTop' : negMarginTop,
						'marginBottom' : negMarginBottom
						}
					});
				newNavContainer.inject($('monthHeader'), 'after');
				
				$('thecalendar').getElements('form').inject(newNavContainer, 'top');
				
				$('dateFilter').inject($('FilterForm'), 'before');
				
				$('viewButton').inject($('FilterForm'), 'after');

				
				$('FilterForm').getElement('input').value = "Go";
				
				var newPrevButton = new Element('input', {
					'type' : 'button',
					'value' : '<',
					'id': 'newPrevButton',
					'events' : {
						'click' : function(){
							window.location = $$('.navTableText')[0].href 
						}
					}
				});
				
				var newNextButton = new Element('input', {
					'type' : 'button',
					'value' : '>',
					'id': 'newNextButton',
					'events' : {
						'click' : function(){
							window.location = $$('.navTableText')[2].href 
						}
					}
				});
				
				newPrevButton.inject('dateFilter', 'top');
				newNextButton.inject('dateFilter', 'bottom');
				
				var anHR = new Element('hr');
				anHR.inject(newMoHeader, 'after');
				
				if (Browser.Engine.trident) {
					anHR.setStyles({
						'marginBottom': 20
					});
					$('viewButton').getElement('input:last-child').setStyle('marginLeft', 10);
				}
				
				
				if (!(Browser.Engine.trident)) {
					var anotherHR = new Element('hr');
					anotherHR.inject($('viewButton'), 'after');
					anotherHR.setStyles({
						'marginTop': 20
					});
					
				}
				else {
				
					/*$$('.mainTableTOC')[0].setStyles({
						'marginTop': 20
					});*/
					
				}
				
				// if this is filtered by category, display in header
				var filterOptions = $('showCat').getElements('option');
				
				if (filterOptions[$('showCat').selectedIndex].innerHTML != "Show All") {
					//alert('this is not the show all page');
					newMoHeader.innerHTML += " <span>" + filterOptions[$('showCat').selectedIndex].innerHTML + " Events</span>";
				}
				else {
					newMoHeader.innerHTML += " <span>All Events</span>";
				}
				
				
				if (theSelectedMonth != todayDate) {
					var newTodayButton = new Element('input', {
					'type' : 'button',
					'value' : 'Today',
					'id': 'newTodayButton',
					'events' : {
						'click' : function(){
							window.location = $$('.navTableText')[1].href 
						}
					},
					'styles' : {
						'marginRight' : 4
					}
				});
				newTodayButton.inject('dateFilter', 'top');
				
				$('viewButton').getElement('input:last-child').value = "Cal View";
				
				}
				
				$$('.navTable').setStyle('display', 'none');
				

			
			}
			
			
			
			}
		}
		
	//} // isIE6 is false
	}

});


window.addEvent('load', function(){
	if ($chk($('thecalendar'))) {
		if (Browser.Engine.trident) {
		$('thecalendar').getElements('table').tween('opacity', 1);
		$('thecalendar').getElements('form').tween('opacity', 1);
		} else {
		$('thecalendar').tween('opacity', 1);
		}
	} 
});

